]> jspc29.x-matter.uni-frankfurt.de Git - coral.git/commitdiff
more functionality, yet lacking help message
authorMichael Wiebusch <antiquark@gmx.net>
Wed, 25 Jun 2014 15:46:57 +0000 (17:46 +0200)
committerMichael Wiebusch <antiquark@gmx.net>
Wed, 25 Jun 2014 15:46:57 +0000 (17:46 +0200)
.analyzer.pl.swp [new file with mode: 0644]
user_interface/analyzer.pl
user_interface/out.dat
user_interface/plot.png [new file with mode: 0644]
user_interface/plot.sh [new file with mode: 0755]
user_interface/pmt_100k_div60.dat [new file with mode: 0644]
user_interface/pmt_10k_div10.dat [new file with mode: 0644]
user_interface/pmt_10k_div10_hicnt.dat [new file with mode: 0644]

diff --git a/.analyzer.pl.swp b/.analyzer.pl.swp
new file mode 100644 (file)
index 0000000..a3dd929
Binary files /dev/null and b/.analyzer.pl.swp differ
index 819b28f77e38940bc6e339693bb5585c1d60d73c..3a8e19a354223ffd6989855848bab23405e443b5 100755 (executable)
@@ -5,6 +5,7 @@ use Device::SerialPort;
 use Time::HiRes;
 use Getopt::Long;
 use POSIX qw/strftime/;
+use POSIX;
 
 # plot destination
 # check for tools
@@ -15,24 +16,97 @@ use POSIX qw/strftime/;
 # defaults
 my $baudrate=115200;
 my $port;
+my $opt_command;
+my $read;
+my $opt_help;
+my $write;
+my $clear;
+my $clkdiv;
+my $window;
 
 
 my $ser_dev = "/dev/ttyUSB0";
 
 
 
+GetOptions (  'h|help'      => \$opt_help,
+              'c|cmd=s'   => \$opt_command,
+              'tty=s'     => \$ser_dev,
+              'baud=s'    => \$baudrate,
+              'r|read=s'  => \$read,
+              'w|write=s'  => \$write,
+              'c|clear'   => \$clear,
+              'd|divider=s' => \$clkdiv,
+              'window=s'  => \$window
+            );
+
+
 init_port();
 
-for (my $i=0;$i<128;$i++){
-  my $rstring = communicate("R".chr($i));
-#   printf ("length of response: %d \n",length($rstring));
 
+if (defined ($read)) {
+  
+  my $val = communicate("R".chr($read));
+  printf("response: %d\n",$val);
 
-  my $byte3 = ord(substr($rstring,0,1));
-  my $byte2 = ord(substr($rstring,1,1));
-  my $byte1 = ord(substr($rstring,2,1));
-  my $byte0 = ord(substr($rstring,3,1));
-  my $val = (($byte3<<24)|($byte2<<16)|($byte1<<8)|$byte0);
+  exit;
+}
+
+if (defined($clear)){
+  $write = '129_1';
+}
+
+
+if (defined($window)){
+  my $tunit=1e-3;
+  if($window =~ m/ms/){
+    $tunit=1e-3;
+  } elsif($window =~ m/us/){
+    $tunit=1e-6;
+  } elsif($window =~ m/ns/){
+    $tunit=1e-9;
+  } elsif($window =~ m/s/){
+    $tunit=1;
+  }
+  
+  $window =~ m/([\d\.]+)/;
+  my $number = $1;
+  printf("requested window width: %e s\n",$number*$tunit);
+  my $FPGAclk=133000000;
+  my $analyzerBins=128;
+  $clkdiv = floor(($number*$tunit)/$analyzerBins/(1/$FPGAclk)); 
+
+}
+
+if (defined($clkdiv)){
+  $write = "128_$clkdiv";
+}
+
+if (defined ($write)) {
+  
+  unless( $write =~ m/(\d+)_(\d+)/ ) {
+    die "input parameter: analyzer -w 127_1234\n";
+  } 
+  
+  my $addr = $1;
+  my $value = $2;
+  print "addr:$addr value:$value\n";
+  
+  my $byte3 = chr(int($value)>>24);
+  my $byte2 = chr((int($value)>>16)&0xFF);
+  my $byte1 = chr((int($value)>>8)&0xFF);
+  my $byte0 = chr(int($value)&0xFF);
+  
+  my $val = communicate("W".chr($addr).$byte3.$byte2.$byte1.$byte0);
+  printf("response: %d\n",$val);
+
+  exit;
+}
+
+
+for (my $i=0;$i<128;$i++){
+  my $val = communicate("R".chr($i));
+#   printf ("length of response: %d \n",length($rstring));
   printf("%d\t%d\n",$i,$val);
 #   printf("addr %d:\t%d.%d.%d.%d\n",$i,$byte3,$byte2,$byte1,$byte0);
 #       Time::HiRes::sleep(.01);
@@ -47,39 +121,43 @@ sub communicate {
 
   my $command = $_[0];
 #   print "sending command $command\n";
-  my $cmd_echo;
+  my $rstring;
 
 
-  $port->are_match(chr(10));
+  $port->are_match("");
+  $port->read_char_time(1);
+  $port->read_const_time(0);
   $port->lookclear; 
+  #Time::HiRes::sleep(.004);
   $port->write("$command\n");
   
   my $ack = 0;
+  
+  
 
+  #Time::HiRes::sleep(.004);
 
-
-
-ACK_POLLING:  for (my $i = 0; ($i<$ack_timeout*100) ;$i++) {
-#     print $i."\n";
-    while(my $a = $port->lookfor) {
-        if($a=~ m/R(....)/) {
-          $cmd_echo = $1;
+  my ($count, $a) = $port->read(12);
+  
+  if($a=~ m/R(.{4})/s) {
+    $rstring= $1;
 #           print "padiwa sent: $cmd_echo\n\n";
-          $ack=1;
-          last ACK_POLLING;
-        }
-
-    } 
-      Time::HiRes::sleep(.01);
-
+    $ack=1;
   }
   
+  
+  
   unless($ack) {
     print "no answer\n";
-    return "0";
+    return 0; 
   }
+  my $byte3 = ord(substr($rstring,0,1));
+  my $byte2 = ord(substr($rstring,1,1));
+  my $byte1 = ord(substr($rstring,2,1));
+  my $byte0 = ord(substr($rstring,3,1));
+  my $val = (($byte3<<24)|($byte2<<16)|($byte1<<8)|$byte0);
   
-  return $cmd_echo;
+  return $val;
   
   
 
index ec215d969b376ef21274cf63cdf53a02421efcba..07a558ab7360ffc5dab4479a2f103d13a1ea35e6 100644 (file)
-0      59
-1      0
-2      0
-3      0
-4      0
-5      0
-6      0
-7      0
-8      0
-9      0
-10     742
-11     0
-12     0
-13     0
-14     0
-15     0
-16     0
-17     0
-18     0
-19     0
-20     0
-21     377
-22     0
-23     0
-24     0
-25     0
-26     0
-27     0
-28     0
-29     0
-30     0
-31     0
-32     170
-33     0
-34     0
-35     0
-36     0
-37     0
-38     0
-39     0
-40     0
-41     0
-42     0
-43     95
-44     0
-45     0
-46     0
-47     0
-48     0
-49     0
-50     0
-51     0
-52     0
-53     0
-54     49
-55     0
-56     0
-57     0
-58     0
-59     0
-60     0
-61     0
-62     0
-63     0
-64     23
-65     6
-66     0
-67     0
-68     0
-69     0
-70     0
-71     0
-72     0
+0      0
+1      2
+2      1
+3      1
+4      1
+5      4
+6      3
+7      4
+8      9
+9      3
+10     5
+11     5
+12     10
+13     10
+14     9
+15     12
+16     14
+17     21
+18     23
+19     24
+20     24
+21     10
+22     23
+23     10
+24     31
+25     35
+26     23
+27     33
+28     43
+29     32
+30     53
+31     45
+32     51
+33     42
+34     53
+35     43
+36     47
+37     60
+38     55
+39     63
+40     82
+41     67
+42     83
+43     86
+44     84
+45     80
+46     83
+47     90
+48     95
+49     104
+50     101
+51     110
+52     106
+53     100
+54     131
+55     121
+56     92
+57     114
+58     111
+59     121
+60     119
+61     140
+62     124
+63     155
+64     149
+65     128
+66     131
+67     139
+68     144
+69     149
+70     131
+71     133
+72     173
+no answer
 73     0
-74     0
-76     0
-77     0
-78     0
-79     0
-80     0
-81     0
-82     0
-83     0
-84     0
-85     0
-86     6
-87     0
-88     0
-89     0
-90     0
-91     0
-92     0
-93     0
-94     0
-95     0
-96     0
-97     3
-98     0
-99     0
-100    0
-101    0
-102    0
-103    0
-104    0
-105    0
-106    0
-107    0
-108    1
-109    0
-110    0
-111    0
-112    0
-113    0
-114    0
-115    0
-116    0
-117    0
-118    0
-119    2
-120    0
-121    0
-122    0
-123    0
-124    0
-125    0
-126    0
-127    3
+74     180
+75     161
+76     209
+77     209
+78     271
+79     285
+80     348
+81     340
+82     385
+83     448
+84     428
+85     406
+86     432
+87     413
+88     487
+89     434
+90     417
+91     400
+92     325
+93     412
+94     365
+95     352
+96     266
+97     291
+98     288
+99     242
+100    229
+101    225
+102    222
+103    195
+104    161
+105    148
+106    139
+107    135
+108    136
+109    117
+110    124
+111    91
+112    89
+113    82
+114    61
+115    68
+116    47
+117    32
+118    37
+119    30
+120    20
+121    16
+122    10
+123    8
+124    6
+125    9
+126    3
+127    1022
diff --git a/user_interface/plot.png b/user_interface/plot.png
new file mode 100644 (file)
index 0000000..396bf9d
Binary files /dev/null and b/user_interface/plot.png differ
diff --git a/user_interface/plot.sh b/user_interface/plot.sh
new file mode 100755 (executable)
index 0000000..0755f5b
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+./analyzer.pl > out.dat
+cat <<EOF | gnuplot
+set terminal png
+set output "plot.png"
+plot "out.dat" using 1:2
+EOF
+display plot.png
diff --git a/user_interface/pmt_100k_div60.dat b/user_interface/pmt_100k_div60.dat
new file mode 100644 (file)
index 0000000..1c7c5c8
--- /dev/null
@@ -0,0 +1,128 @@
+0      2
+1      2
+2      3
+3      3
+4      11
+5      13
+6      15
+7      10
+8      23
+9      28
+10     26
+11     26
+12     22
+13     40
+14     30
+15     36
+16     45
+17     46
+18     41
+19     42
+20     58
+21     48
+22     63
+23     56
+24     88
+25     117
+26     131
+27     163
+28     142
+29     210
+30     211
+31     225
+32     260
+33     292
+34     355
+35     356
+36     392
+37     419
+38     459
+39     439
+40     545
+41     536
+42     581
+43     589
+44     582
+45     652
+46     661
+47     620
+48     680
+49     677
+50     720
+51     703
+52     763
+53     697
+54     791
+55     766
+56     846
+57     776
+58     778
+59     820
+60     816
+61     786
+62     838
+63     779
+64     806
+65     853
+66     834
+67     858
+68     870
+69     900
+70     919
+71     958
+72     1007
+73     1119
+74     1148
+75     1185
+76     1205
+77     1190
+78     1278
+79     1191
+80     1231
+81     1182
+82     1171
+83     1167
+84     1117
+85     1046
+86     947
+87     922
+88     870
+89     896
+90     831
+91     746
+92     705
+93     681
+94     623
+95     597
+96     542
+97     487
+98     427
+99     376
+100    373
+101    325
+102    286
+103    228
+104    180
+105    169
+106    133
+107    106
+108    81
+109    54
+110    48
+111    41
+112    23
+113    26
+114    20
+115    16
+116    12
+117    12
+118    9
+119    13
+120    10
+121    8
+122    7
+123    8
+124    11
+125    6
+126    10
+127    303
diff --git a/user_interface/pmt_10k_div10.dat b/user_interface/pmt_10k_div10.dat
new file mode 100644 (file)
index 0000000..6c5cd11
--- /dev/null
@@ -0,0 +1,128 @@
+0      0
+1      3
+2      9
+3      18
+4      20
+5      20
+6      18
+7      27
+8      45
+9      42
+10     45
+11     45
+12     50
+13     54
+14     62
+15     77
+16     91
+17     111
+18     110
+19     144
+20     161
+21     168
+22     135
+23     181
+24     180
+25     163
+26     224
+27     217
+28     242
+29     264
+30     252
+31     276
+32     294
+33     288
+34     335
+35     360
+36     366
+37     376
+38     382
+39     421
+40     430
+41     448
+42     481
+43     477
+44     506
+45     516
+46     551
+47     573
+48     591
+49     594
+50     624
+51     682
+52     662
+53     647
+54     681
+55     688
+56     708
+57     742
+58     744
+59     733
+60     763
+61     771
+62     782
+63     846
+64     810
+65     789
+66     773
+67     797
+68     797
+69     794
+70     867
+71     842
+72     801
+73     879
+74     881
+75     903
+76     992
+77     1256
+78     1511
+79     1692
+80     1984
+81     2294
+82     2464
+83     2616
+84     2683
+85     2769
+86     2761
+87     2622
+88     2636
+89     2584
+90     2461
+91     2303
+92     2085
+93     1959
+94     1800
+95     1601
+96     1376
+97     1249
+98     1098
+99     951
+100    764
+101    619
+102    474
+103    397
+104    202
+105    167
+106    115
+107    47
+108    36
+109    10
+110    14
+111    9
+112    4
+113    3
+114    3
+115    7
+116    2
+117    10
+118    7
+119    5
+120    5
+121    5
+122    4
+123    9
+124    5
+125    2
+126    2
+127    132
diff --git a/user_interface/pmt_10k_div10_hicnt.dat b/user_interface/pmt_10k_div10_hicnt.dat
new file mode 100644 (file)
index 0000000..8e9715e
--- /dev/null
@@ -0,0 +1,128 @@
+0      0
+1      8
+2      31
+3      51
+4      63
+5      66
+6      71
+7      87
+8      125
+9      124
+10     123
+11     138
+12     172
+13     192
+14     194
+15     282
+16     297
+17     355
+18     416
+19     459
+20     483
+21     510
+22     511
+23     593
+24     591
+25     602
+26     701
+27     697
+28     771
+29     854
+30     842
+31     904
+32     991
+33     988
+34     1084
+35     1133
+36     1231
+37     1233
+38     1313
+39     1364
+40     1429
+41     1501
+42     1561
+43     1587
+44     1641
+45     1757
+46     1761
+47     1810
+48     1912
+49     1918
+50     2007
+51     2107
+52     2161
+53     2121
+54     2223
+55     2317
+56     2296
+57     2392
+58     2335
+59     2470
+60     2474
+61     2472
+62     2545
+63     2633
+64     2549
+65     2536
+66     2534
+67     2670
+68     2681
+69     2610
+70     2786
+71     2791
+72     2762
+73     2816
+74     2899
+75     2913
+76     3275
+77     4138
+78     4854
+79     5687
+80     6640
+81     7652
+82     8238
+83     8544
+84     8831
+85     9032
+86     9146
+87     9054
+88     8872
+89     8437
+90     8081
+91     7537
+92     7095
+93     6617
+94     6012
+95     5291
+96     4714
+97     4101
+98     3527
+99     2962
+100    2495
+101    1944
+102    1427
+103    1105
+104    714
+105    520
+106    356
+107    202
+108    124
+109    66
+110    35
+111    25
+112    10
+113    20
+114    18
+115    24
+116    8
+117    10
+118    15
+119    15
+120    16
+121    20
+122    9
+123    10
+124    12
+125    11
+126    9
+127    510