]> jspc29.x-matter.uni-frankfurt.de Git - hades_mdc_settings.git/commitdiff
update scripts for setting power boards
authorJan Michel <mail@janmichel.eu>
Sat, 7 Jan 2023 15:52:48 +0000 (16:52 +0100)
committerJan Michel <mail@janmichel.eu>
Sat, 7 Jan 2023 15:52:48 +0000 (16:52 +0100)
scripts/MDCPower.pm
scripts/README.md
scripts/mdc_voltage.pl
scripts/merge_and_flash_settings.pl
settings_power/settings_voltage_orig.db [new file with mode: 0644]

index 4bf4478ff4bcd1db20cc3624020dfbfa073d126b..17335c3f00738a15155665c2f222656ae9367c01 100644 (file)
@@ -31,6 +31,29 @@ sub set_voltage {
   return 1;
   }
 
+###############################################################################  
+#set the voltage for a all boards and channels.
+###############################################################################
+sub set_all_voltages {
+  my $ret;
+  my $filename = "../settings_power/settings_voltage.db";
+  open FILE, $filename or die $!."\nsettings_voltage.db not found.";
+  while (my $a = <FILE>) {
+    if(my @values = $a =~ /^\s*0x(\w\w\w\w)\s+(\d)\s+(\d)(.*)$/) {
+      my $addr  = hex($values[0]);
+      
+      $ret = set_voltage($addr,0,$values[1],0);
+      print "Unmatched entry found\n" unless $ret == 1;
+
+      $ret = set_voltage($addr,1,$values[2],0);
+      print "Unmatched entry found\n" unless $ret == 1;
+      
+      }
+    }
+  
+  return 1;
+  }  
+  
 
 ###############################################################################  
 #saves the voltage for a given board and channel
index 42d320f83fc577bc09800e0b4caaf0e944c32dfa..0b6cfc94a528de3b0d900eb8f4318a0c916c4ade 100644 (file)
@@ -1,4 +1,4 @@
-#Scripts#
+#Scripts
 
 * `generate_address_list.pl` takes the list of installed MBO serial numbers and generates the address.db file for DAQ
 * `generate_address_settings.pl` makes the files needed to automatically set the board addresses from Flash ROM
@@ -8,13 +8,18 @@
   * settings are written for boards currently in the system (otherwise serial number / uid can't be matched to addresses)
   * default PASTTREC registers are currently hardcoded (!)
 * `merge_and_flash_settings.pl` generates and loads settings from the 'settings' directory to the FPGAs flashes
+
+##Pasttrec Settings
 * `pasttrec_set_threshold.pl` sets an identical threshold to all Pasttrec (temporarily)
 * `pasttrec_baseline_finder.pl` basic baseline finder script
 
-#Packages#
+##Voltages
+* `mdc_voltage.pl` set voltages and update voltage database file
+* `mdc_powerboard.pl` send commands to MDC power board
 
+#Packages
 * `MDC.pm` Library with common functions, like address lookup
 * `MDCPower.pm` Library with common functions related to power setting and switching
 
-#Notes#
+#Notes
 All scripts assume that the daqtools repository is available next to this repository.
index e6f1b2085cab26e174b064756002a6fd37b9b50c..bf9dd67ed1acd990ae7391756c9064db872bcafc 100755 (executable)
@@ -13,29 +13,48 @@ my $board;
 my $channel;
 my $setting;
 my $write;
+my $load;
 
 Getopt::Long::Configure(qw(gnu_getopt));
 GetOptions(
-           'help|h' => \$help,
-           'board|b=s' => \$board,
+           'help|h'      => \$help,
+           'board|b=s'   => \$board,
            'channel|c=i' => \$channel,
-           'value|v=i'  => \$setting,
-           'write|w'    => \$write,
+           'value|v=i'   => \$setting,
+           'write|w'     => \$write,
+           'load|l'      => \$load,
           ) ;
 
 
 if($help) {
 print <<HELP;
-mdc_voltage.pl (-board|-b) 0x8nnn [(-channel|c) (0|1)] [(-value|-v) (0-7)] [(-write|-w)]
+mdc_voltage.pl (-board|-b) 0xnnnn 
+        display settings from file
 
+mdc_voltage.pl (-board|-b) 0x8nnn (-load|-l)
+        load settings from file to board
+
+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)]
+        change setting on board only
+
+mdc_voltage.pl (-board|-b) 0x8nnn [(-channel|c) (0|1)] [(-value|-v) (0-7)] (-write|-w)
+        change setting on board and store in file
+       
 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
+
+exit;
 }
 
 
-$board = hex($board);
-if($board < 0x8e00 || $board > 0x8fff) {
+$board = hex($board) if defined $board;
+if(defined $board && ($board < 0x8e00 || $board > 0x8fff)) {
   die "Wrong board address (8e00 - 8fff)\n";
   }
 
@@ -46,15 +65,23 @@ if(defined $channel && ($channel < 0 || $channel > 1)) {
 if(defined $setting && ($setting < 0 || $setting > 7)) {
   die "Wrong setting number (0-7)\n";
   }
-  
-if(!defined $setting || !defined $channel) {
+
+#Load all settings  
+if(defined $load) {
+  my $ret = MDCPower::set_all_voltages();
+  }
+
+#Read settings from file  
+elsif(!defined $setting || !defined $channel) {
   my ($v1,$v2) = MDCPower::get_voltage($board);
   die "Settings not found\n" if $v1 == -1 && $v2 == -1;
   
   print ("Board\tV0\tV1\n");
   printf("%04x\t%u\t%u\n\n",$board,$v1,$v2)
   }
-else {
+
+#Update settings on board and file  
+elsif(defined $board) {
   print("Change Settings\n");
   my $ret = MDCPower::set_voltage($board,$channel,$setting,0);
   die "Invalid Settings\n" if $ret == -1;
@@ -66,4 +93,8 @@ else {
     print "ERROR: Board not found in database.\n" unless $found;
     }
   }
-
+  
+#Don't understand  
+else {
+  die "Invalid command\n";
+  }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..dc45ebf37862635adcd527201c75a5e2f0eb1267 100755 (executable)
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+use warnings;
+no warnings "portable";
+use FileHandle;
+use Getopt::Long;
+use Data::Dumper;
+use HADES::TrbNet;
+
+
diff --git a/settings_power/settings_voltage_orig.db b/settings_power/settings_voltage_orig.db
new file mode 100644 (file)
index 0000000..649d87d
--- /dev/null
@@ -0,0 +1,380 @@
+#Board address used here is the TrbNet address of OEP (the same as for ADC readings)
+#Position in the detector and channel on power board can be calculated from this
+#using MDC::get_power_channel()
+#Voltages are set between 0 and 7
+#This file can be edited, but is changed by scripts as well.
+
+#  Address   #  Voltage 1  #  Voltage 2
+########################################
+  0x8e00          2              2
+  0x8e01          2              2
+  0x8e02          2              2
+  0x8e03          2              2
+  0x8e04          2              2
+  0x8e05          2              2
+  0x8e06          2              2
+  0x8e07          2              2
+  0x8e08          2              2
+  0x8e09          2              2
+  0x8e0a          2              2
+  0x8e0b          2              2
+  0x8e0c          2              2
+  0x8e0d          2              2
+  0x8e10          2              2
+  0x8e11          2              2
+  0x8e12          2              2
+  0x8e13          2              2
+  0x8e14          2              2
+  0x8e15          2              2
+  0x8e16          2              2
+  0x8e17          2              2
+  0x8e18          2              2
+  0x8e19          2              2
+  0x8e1a          2              2
+  0x8e1b          2              2
+  0x8e1c          2              2
+  0x8e1d          2              2
+  0x8e20          2              2
+  0x8e21          2              2
+  0x8e22          2              2
+  0x8e23          2              2
+  0x8e24          2              2
+  0x8e25          2              2
+  0x8e26          2              2
+  0x8e27          2              2
+  0x8e28          2              2
+  0x8e29          2              2
+  0x8e2a          2              2
+  0x8e2b          2              2
+  0x8e2c          2              2
+  0x8e2d          2              2
+  0x8e30          2              2
+  0x8e31          2              2
+  0x8e32          2              2
+  0x8e33          2              2
+  0x8e34          2              2
+  0x8e35          2              2
+  0x8e36          2              2
+  0x8e37          2              2
+  0x8e38          2              2
+  0x8e39          2              2
+  0x8e3a          2              2
+  0x8e3b          2              2
+  0x8e3c          2              2
+  0x8e3d          2              2
+  0x8e40          2              2
+  0x8e41          2              2
+  0x8e42          2              2
+  0x8e43          2              2
+  0x8e44          2              2
+  0x8e45          2              2
+  0x8e46          2              2
+  0x8e47          2              2
+  0x8e48          2              2
+  0x8e49          2              2
+  0x8e4a          2              2
+  0x8e4b          2              2
+  0x8e4c          2              2
+  0x8e4d          2              2
+  0x8e50          2              2
+  0x8e51          2              2
+  0x8e52          2              2
+  0x8e53          2              2
+  0x8e54          2              2
+  0x8e55          2              2
+  0x8e56          2              2
+  0x8e57          2              2
+  0x8e58          2              2
+  0x8e59          2              2
+  0x8e5a          2              2
+  0x8e5b          2              2
+  0x8e5c          2              2
+  0x8e5d          2              2
+  0x8e60          2              2
+  0x8e61          2              2
+  0x8e62          2              2
+  0x8e63          2              2
+  0x8e64          2              2
+  0x8e65          2              2
+  0x8e66          2              2
+  0x8e67          2              2
+  0x8e68          2              2
+  0x8e69          2              2
+  0x8e6a          2              2
+  0x8e6b          2              2
+  0x8e6c          2              2
+  0x8e6d          2              2
+  0x8e6e          2              2
+  0x8e6f          2              2
+  0x8e70          2              2
+  0x8e71          2              2
+  0x8e72          2              2
+  0x8e73          2              2
+  0x8e74          2              2
+  0x8e75          2              2
+  0x8e76          2              2
+  0x8e77          2              2
+  0x8e78          2              2
+  0x8e79          2              2
+  0x8e7a          2              2
+  0x8e7b          2              2
+  0x8e7c          2              2
+  0x8e7d          2              2
+  0x8e7e          2              2
+  0x8e7f          2              2
+  0x8e80          2              2
+  0x8e81          2              2
+  0x8e82          2              2
+  0x8e83          2              2
+  0x8e84          2              2
+  0x8e85          2              2
+  0x8e86          2              2
+  0x8e87          2              2
+  0x8e88          2              2
+  0x8e89          2              2
+  0x8e8a          2              2
+  0x8e8b          2              2
+  0x8e8c          2              2
+  0x8e8d          2              2
+  0x8e8e          2              2
+  0x8e8f          2              2
+  0x8e90          2              2
+  0x8e91          2              2
+  0x8e92          2              2
+  0x8e93          2              2
+  0x8e94          2              2
+  0x8e95          2              2
+  0x8e96          2              2
+  0x8e97          2              2
+  0x8e98          2              2
+  0x8e99          2              2
+  0x8e9a          2              2
+  0x8e9b          2              2
+  0x8e9c          2              2
+  0x8e9d          2              2
+  0x8e9e          2              2
+  0x8e9f          2              2
+  0x8ea0          2              2
+  0x8ea1          2              2
+  0x8ea2          2              2
+  0x8ea3          2              2
+  0x8ea4          2              2
+  0x8ea5          2              2
+  0x8ea6          2              2
+  0x8ea7          2              2
+  0x8ea8          2              2
+  0x8ea9          2              2
+  0x8eaa          2              2
+  0x8eab          2              2
+  0x8eac          2              2
+  0x8ead          2              2
+  0x8eae          2              2
+  0x8eaf          2              2
+  0x8eb0          2              2
+  0x8eb1          2              2
+  0x8eb2          2              2
+  0x8eb3          2              2
+  0x8eb4          2              2
+  0x8eb5          2              2
+  0x8eb6          2              2
+  0x8eb7          2              2
+  0x8eb8          2              2
+  0x8eb9          2              2
+  0x8eba          2              2
+  0x8ebb          2              2
+  0x8ebc          2              2
+  0x8ebd          2              2
+  0x8ebe          2              2
+  0x8ebf          2              2
+  0x8f00          2              2
+  0x8f01          2              2
+  0x8f02          2              2
+  0x8f03          2              2
+  0x8f04          2              2
+  0x8f05          2              2
+  0x8f06          2              2
+  0x8f07          2              2
+  0x8f08          2              2
+  0x8f09          2              2
+  0x8f0a          2              2
+  0x8f0b          2              2
+  0x8f0c          2              2
+  0x8f0d          2              2
+  0x8f0e          2              2
+  0x8f0f          2              2
+  0x8f10          2              2
+  0x8f11          2              2
+  0x8f12          2              2
+  0x8f13          2              2
+  0x8f14          2              2
+  0x8f15          2              2
+  0x8f16          2              2
+  0x8f17          2              2
+  0x8f18          2              2
+  0x8f19          2              2
+  0x8f1a          2              2
+  0x8f1b          2              2
+  0x8f1c          2              2
+  0x8f1d          2              2
+  0x8f1e          2              2
+  0x8f1f          2              2
+  0x8f20          2              2
+  0x8f21          2              2
+  0x8f22          2              2
+  0x8f23          2              2
+  0x8f24          2              2
+  0x8f25          2              2
+  0x8f26          2              2
+  0x8f27          2              2
+  0x8f28          2              2
+  0x8f29          2              2
+  0x8f2a          2              2
+  0x8f2b          2              2
+  0x8f2c          2              2
+  0x8f2d          2              2
+  0x8f2e          2              2
+  0x8f2f          2              2
+  0x8f30          2              2
+  0x8f31          2              2
+  0x8f32          2              2
+  0x8f33          2              2
+  0x8f34          2              2
+  0x8f35          2              2
+  0x8f36          2              2
+  0x8f37          2              2
+  0x8f38          2              2
+  0x8f39          2              2
+  0x8f3a          2              2
+  0x8f3b          2              2
+  0x8f3c          2              2
+  0x8f3d          2              2
+  0x8f3e          2              2
+  0x8f3f          2              2
+  0x8f40          2              2
+  0x8f41          2              2
+  0x8f42          2              2
+  0x8f43          2              2
+  0x8f44          2              2
+  0x8f45          2              2
+  0x8f46          2              2
+  0x8f47          2              2
+  0x8f48          2              2
+  0x8f49          2              2
+  0x8f4a          2              2
+  0x8f4b          2              2
+  0x8f4c          2              2
+  0x8f4d          2              2
+  0x8f4e          2              2
+  0x8f4f          2              2
+  0x8f50          2              2
+  0x8f51          2              2
+  0x8f52          2              2
+  0x8f53          2              2
+  0x8f54          2              2
+  0x8f55          2              2
+  0x8f56          2              2
+  0x8f57          2              2
+  0x8f58          2              2
+  0x8f59          2              2
+  0x8f5a          2              2
+  0x8f5b          2              2
+  0x8f5c          2              2
+  0x8f5d          2              2
+  0x8f5e          2              2
+  0x8f5f          2              2
+  0x8f60          2              2
+  0x8f61          2              2
+  0x8f62          2              2
+  0x8f63          2              2
+  0x8f64          2              2
+  0x8f65          2              2
+  0x8f66          2              2
+  0x8f67          2              2
+  0x8f68          2              2
+  0x8f69          2              2
+  0x8f6a          2              2
+  0x8f6b          2              2
+  0x8f6c          2              2
+  0x8f6d          2              2
+  0x8f6e          2              2
+  0x8f6f          2              2
+  0x8f70          2              2
+  0x8f71          2              2
+  0x8f72          2              2
+  0x8f73          2              2
+  0x8f74          2              2
+  0x8f75          2              2
+  0x8f76          2              2
+  0x8f77          2              2
+  0x8f78          2              2
+  0x8f79          2              2
+  0x8f7a          2              2
+  0x8f7b          2              2
+  0x8f7c          2              2
+  0x8f7d          2              2
+  0x8f7e          2              2
+  0x8f7f          2              2
+  0x8f80          2              2
+  0x8f81          2              2
+  0x8f82          2              2
+  0x8f83          2              2
+  0x8f84          2              2
+  0x8f85          2              2
+  0x8f86          2              2
+  0x8f87          2              2
+  0x8f88          2              2
+  0x8f89          2              2
+  0x8f8a          2              2
+  0x8f8b          2              2
+  0x8f8c          2              2
+  0x8f8d          2              2
+  0x8f8e          2              2
+  0x8f8f          2              2
+  0x8f90          2              2
+  0x8f91          2              2
+  0x8f92          2              2
+  0x8f93          2              2
+  0x8f94          2              2
+  0x8f95          2              2
+  0x8f96          2              2
+  0x8f97          2              2
+  0x8f98          2              2
+  0x8f99          2              2
+  0x8f9a          2              2
+  0x8f9b          2              2
+  0x8f9c          2              2
+  0x8f9d          2              2
+  0x8f9e          2              2
+  0x8f9f          2              2
+  0x8fa0          2              2
+  0x8fa1          2              2
+  0x8fa2          2              2
+  0x8fa3          2              2
+  0x8fa4          2              2
+  0x8fa5          2              2
+  0x8fa6          2              2
+  0x8fa7          2              2
+  0x8fa8          2              2
+  0x8fa9          2              2
+  0x8faa          2              2
+  0x8fab          2              2
+  0x8fac          2              2
+  0x8fad          2              2
+  0x8fae          2              2
+  0x8faf          2              2
+  0x8fb0          2              2
+  0x8fb1          2              2
+  0x8fb2          2              2
+  0x8fb3          2              2
+  0x8fb4          2              2
+  0x8fb5          2              2
+  0x8fb6          2              2
+  0x8fb7          2              2
+  0x8fb8          2              2
+  0x8fb9          2              2
+  0x8fba          2              2
+  0x8fbb          2              2
+  0x8fbc          2              2
+  0x8fbd          2              2
+  0x8fbe          2              2
+  0x8fbf          2              2