From: hadeshyp Date: Tue, 5 Jun 2012 14:20:26 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=c394fcc979431c96b35eec83337042886cb4bf89;p=daqtools.git *** empty log message *** --- c394fcc979431c96b35eec83337042886cb4bf89 diff --git a/dac_configuration.txt b/dac_configuration.txt new file mode 100644 index 0000000..fada851 --- /dev/null +++ b/dac_configuration.txt @@ -0,0 +1,5 @@ +# Board DAC Channel Command Value + f333 0 0 3 0x3450 + f333 0 1 3 0x1230 + f333 1 0 3 0x6780 + f333 2 0 3 0x345 diff --git a/dac_program.pl b/dac_program.pl new file mode 100755 index 0000000..aaf8f69 --- /dev/null +++ b/dac_program.pl @@ -0,0 +1,70 @@ +#!/usr/bin/perl -w +use warnings; + +use FileHandle; +use Time::HiRes qw( usleep ); +use Data::Dumper; +use HADES::TrbNet; + + +if (!defined &trb_init_ports()) { + die("can not connect to trbnet-daemon on the $ENV{'DAQOPSERVER'}"); +} + + + +my $config = {}; + +my $fh; + +if(!$ARGV[0]) { + print "usage: dac_program.pl \n\n"; + print "Example config file:\n"; + print "# Board DAC Channel Command Value\n"; + print " f301 0 0 3 0x3450\n"; + print " f301 0 1 3 0x1230\n"; + print " f301 1 0 3 0x6780\n"; + print " f301 2 0 3 0x345\n"; + + + exit; +} + + +open $fh, "$ARGV[0]" or die $!."\nFile '$ARGV[0]' not found."; + +while (my $a = <$fh>) { + next if($a=~/^\s*#/); + next if($a=~/^\s*\!/); + + $a=~s/#.*//; + + + if(my ($board,$dac,$chan,$cmd,$val) = $a =~ /^\s*(\w\w\w\w)\s+(\d+)\s+(\d)\s+(\w)\s+(\w+)/) { + if (substr($val,0,2) eq "0x") { + $val = hex(substr($val,2)); + } + $cmd = hex($cmd); + $board = hex($board); + + $o = $cmd << 20; + $o |= $chan << 16; + $o |= $val; + + my @values; + foreach my $i (0..15) { + $values[$i] = 0x00F00000; + } + $values[16] = $dac+1; + $values[$dac] = $o; + + + #Write memory address $board registers 0xd400 - 0xd410 with @values... + foreach my $i (0..15) { + trb_register_write($board,0xd100+$i,$values[$i]); + } + trb_register_write($board,0xd110,16); #"16" workaround until length of chain is known + } + usleep(100); + + } \ No newline at end of file