]> jspc29.x-matter.uni-frankfurt.de Git - hades_mdc_settings.git/commitdiff
few updates to power scripts
authorJan Michel <michel@physik.uni-frankfurt.de>
Thu, 1 Jun 2023 12:01:37 +0000 (14:01 +0200)
committerJan Michel <michel@physik.uni-frankfurt.de>
Thu, 1 Jun 2023 12:02:06 +0000 (14:02 +0200)
scripts/MDCPower.pm
scripts/README.md
scripts/mdc_voltage.pl
scripts/testpb.pl [new file with mode: 0644]

index 823fb603e4255ec10c2494ee3ea4bd1f9054bd42..8b4ab65d234c363dc0f4c75624808a6775808906 100644 (file)
@@ -37,7 +37,9 @@ sub set_voltage {
   my ($host,$board,$outp) = MDC::get_power_output($addr);
   return -2 unless defined $host && $board >= 0 && $outp >= 0;
 
-  system("./mdc_powerboard.pl -d $host -b $board  -o $outp -c $channel -r adjust -v $setting");
+  #system("./mdc_powerboard.pl -d $host -b $board  -o $outp -c $channel -r adjust -v $setting");
+  $ret = powerboard_command($host,$board,$outp,$channel,'adjust',$setting);
+  print("Errorcode $ret\n") unless $ret == 1;
   
   store_voltage($addr,$channel,$setting) if $save;
   return 1;
@@ -173,7 +175,7 @@ sub powerboard_command {
   if($rw eq 'W' && $answ == 0x00d1) {
     return 1;
     }
-  elsif($rw == 1) {
+  elsif($rw eq 'W') {
     return -10;
     }
   else {  
@@ -187,7 +189,7 @@ sub powerboard_command {
       $ret = ($answ&0xFFFF)*417/27*2.5/1000;
       }
     if($command == 3) { #Current
-      $ret = ($answ&0xFFF)/800.*2.5; # 800mV/A
+      $ret = ($answ&0xFFF)/500.*2.5; # 500mV/A
       }
     if($command == 4 && $board == -1) { #Temperature PD
       $ret = ($answ/100.);
index 6aad49b655f59656ee8b4d94736b9729b188221f..951bee4c277faf674f93f651e80f21eaf7a5d72f 100644 (file)
@@ -16,8 +16,8 @@
 * `pasttrec_baseline_finder.pl` basic baseline finder script
 
 ## Voltages
-* `mdc_voltage.pl` set voltages and update voltage database file
-* `mdc_powerboard.pl` send commands to MDC power board
+* `mdc_voltage.pl` set voltages and update voltage database file, switches boards on/off, based on addresses
+* `mdc_powerboard.pl` send commands to a MDC power board, based on raw device and channel numbers
 * `check_voltages.pl` reads voltages and suggests changes
 
 # Packages
index f2e60a8523cfdcdcdc46523862083737acd27577..46c30c2a86b7b39d1e7c89ca389fe40fc988c5ef 100755 (executable)
@@ -34,6 +34,25 @@ GetOptions(
 
 if($help) {
 print <<HELP;
+Reads the current voltage setting from configuration file.
+Sets the current voltage, optionally changes configuration file.
+Board needs to be a valid OEP address.
+
+Options
+=======
+  -b 0xnnnn    Board address
+  -c (0|1)     Channel number
+  -r (-7..7)   relative change of setting
+  -v (0-7)     absolute change of setting
+  -w           write to configuration file
+  --on/--off   switch power (power cycle if both are specified)
+  -l           load settings from file
+
+
+
+Examples
+========
+
 mdc_voltage.pl (-board|-b) 0xnnnn 
         display settings from file
 
@@ -43,21 +62,18 @@ mdc_voltage.pl (-board|-b) 0x8nnn (-load|-l)
 mdc_voltage.pl (-load|-l)
         load all settings from file to boards
             
-mdc_voltage.pl (-board|-b) 0x8nnn (-channel|c) (0|1) (-value|-v) (0-7)
+mdc_voltage.pl (-board|-b) 0x8nnn (-channel|-c) (0|1) (-value|-v) (0-7)
         change setting on board only
 
-mdc_voltage.pl (-board|-b) 0x8nnn (-channel|c) (0|1) (-value|-v) (0-7) (-write|-w)
+mdc_voltage.pl (-board|-b) 0x8nnn (-channel|-c) (0|1) (-value|-v) (0-7) (-write|-w)
         change setting on board and store in file
 
-mdc_voltage.pl (-board|-b) 0x8nnn (-channel|c) (0|1) (-relative|-r) (-7..7) [(-write|-w)]
+mdc_voltage.pl (-board|-b) 0x8nnn (-channel|-c) (0|1) (-relative|-r) (-7..7) [(-write|-w)]
         change setting relative to the setting in file
         
 mdc_voltage.pl (-board|-b) 0xnnnn (--on|--off)
         switches board on/off
         
-Reads the current voltage setting from configuration file.
-Sets the current voltage (optionally changes configuration file if -w is set).
-Board needs to be a valid OEP address, or FFFF to show/load all channels.
 
 HELP
 
diff --git a/scripts/testpb.pl b/scripts/testpb.pl
new file mode 100644 (file)
index 0000000..3017eb8
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -w
+use warnings;
+no warnings "portable";
+use Getopt::Long;
+use Data::Dumper;
+use Time::HiRes qw(usleep);
+use lib '.';
+use MDC;
+use MDCPower;
+
+
+#   my($host,$board,$output,$channel,$command,$value)
+print(MDCPower::powerboard_command("192.168.0.12",-1,0,0,"temp")."\n");
+print(MDCPower::powerboard_command("192.168.0.12",0,0,0,"temp")."\n");
+print(MDCPower::powerboard_command("192.168.0.12",0,0,0,"curr")."\n");
+print(MDCPower::powerboard_command("192.168.0.12",0,0,0,"vin")."\n");