From: hadeshyp Date: Mon, 18 Jun 2012 10:58:37 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=48f4d6ab7401876f815d816a184af6eaba54a391;p=daqtools.git *** empty log message *** --- diff --git a/dac_configuration.txt b/dac_configuration.txt index f1b780b..fdc3abe 100644 --- a/dac_configuration.txt +++ b/dac_configuration.txt @@ -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 diff --git a/dac_program.pl b/dac_program.pl index 6898391..fa31999 100755 --- a/dac_program.pl +++ b/dac_program.pl @@ -14,21 +14,27 @@ if(!$ARGV[0]) { print "usage: dac_program.pl \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) {