]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
*** empty log message ***
authorhadeshyp <hadeshyp>
Mon, 18 Jun 2012 10:58:37 +0000 (10:58 +0000)
committerhadeshyp <hadeshyp>
Mon, 18 Jun 2012 10:58:37 +0000 (10:58 +0000)
dac_configuration.txt
dac_program.pl

index f1b780b45e33613d11861c7188e6ae4325808756..fdc3abee5546f7f3639532d50793794521835ccd 100644 (file)
@@ -1,5 +1,6 @@
 # Board   Chain     ChainLen   DAC     Channel       Command       Value
-  f333    1         4          0       0             3             0x3450
-  f333    1         4          0       1             3             0x1230
-  f333    1         4          1       0             3             0x6780
-  f333    1         4          2       0             3             0x3450
\ No newline at end of file
+!Reference 2500
+  f333    1         4          0       0             3             3450
+  f333    1         4          0       1             3             1230
+  f333    1         4          1       0             3              780
+  f333    1         4          2       0             3             1450
\ No newline at end of file
index 68983912242b059ed3933b35a84cdb6532866b43..fa3199989fd6bc09ec8b9c39e2b3e325e53a22a5 100755 (executable)
@@ -14,21 +14,27 @@ if(!$ARGV[0]) {
   print "usage: dac_program.pl <filename of configuration file>\n\n";
   print "Example config file:\n";
   print "# Board   Chain     ChainLen    DAC     Channel       Command       Value\n";
-  print "  f300    1         1           0       0             3             0x3450\n";
-  print "  f300    1         1           0       1             3             0x1230\n";
-  print "  f300    1         1           0       2             3             0x6780\n";
-  print "  f300    1         1           0       3             3             0x0345\n";
+  print "!Reference 2500\n";
+  print "  f300    1         1           0       0             3             1450\n";
+  print "  f300    1         1           0       1             3             1230\n";
+  print "  f300    1         1           0       2             3             2280\n";
+  print "  f300    1         1           0       3             3             345\n";
   exit;
   }
 
 open $fh, "$ARGV[0]" or die $!."\nFile '$ARGV[0]' not found.";
 
+my $reference = 2**16;
+
 while (my $a = <$fh>) {
   next if($a=~/^\s*#/);
-  next if($a=~/^\s*\!/);
 
   $a=~s/#.*//;
-  
+  if(my ($ref) = $a =~ /^\s*!Reference\s+(\w+)/i) {
+    $ref = hex(substr($ref,2)) if (substr($ref,0,2) eq "0x");
+    $reference = $ref * 1.;
+    print $reference."\n";
+    }
  
   if(my ($board,$chain,$chainlen,$dac,$chan,$cmd,$val) = $a =~ /^\s*(\w\w\w\w)\s+(\w+)\s+(\d+)\s+(\d+)\s+(\d)\s+(\w)\s+(\w+)/) {
     $val = hex(substr($val,2)) if (substr($val,0,2) eq "0x");
@@ -36,9 +42,14 @@ while (my $a = <$fh>) {
     $cmd = hex($cmd);
     $board = hex($board);
     
+    if ($val > $reference) {
+      printf("Error, value %i is higher than reference %i\n",$val,$reference);
+      next;
+      }
+    
     $o = $cmd << 20;
     $o |= $chan << 16;
-    $o |= $val;
+    $o |= (($val*1.)/$reference*65536.) & 0xFFFF;
     
     my @values;
     foreach my $i (0..15) {