]> jspc29.x-matter.uni-frankfurt.de Git - mimosis_chain.git/commitdiff
we need to commit more here...
authorMaps <maps@ikf>
Tue, 21 May 2024 16:59:54 +0000 (18:59 +0200)
committerMaps <maps@ikf>
Tue, 21 May 2024 16:59:54 +0000 (18:59 +0200)
72 files changed:
scripts/Mimosis.pm
scripts/cli/mimosis
scripts/conf/CONF_1out.pl [deleted file]
scripts/conf/CONF_M2-ikf-settings.pl [new file with mode: 0644]
scripts/conf/CONF_VCAS_2.pl [deleted file]
scripts/conf/CONF_VCAS_high.pl [deleted file]
scripts/conf/CONF_allregisters_1Link.pl [deleted file]
scripts/conf/CONF_dac.pl [deleted file]
scripts/conf/CONF_dac_M47.pl [deleted file]
scripts/conf/CONF_dacsonly.pl
scripts/conf/CONF_linktest.pl [deleted file]
scripts/conf/CONF_seq.pl [deleted file]
scripts/conf/CONF_testmode_enable.pl
scripts/legacy/adc_i2c_cmd.pl_ [new file with mode: 0755]
scripts/legacy/dacscan/dac_scan.pl [moved from scripts/dacscan/dac_scan.pl with 100% similarity]
scripts/legacy/dacscan/plotdac.gp [moved from scripts/dacscan/plotdac.gp with 100% similarity]
scripts/legacy/dacscan/plotdacpng.gp [moved from scripts/dacscan/plotdacpng.gp with 100% similarity]
scripts/legacy/gbtsc/adc-i2c-test.sh [moved from scripts/gbtsc/adc-i2c-test.sh with 100% similarity]
scripts/legacy/gbtsc/dac-results.dat [moved from scripts/gbtsc/dac-results.dat with 100% similarity]
scripts/legacy/gbtsc/mimosis-dacscan.sh [moved from scripts/gbtsc/mimosis-dacscan.sh with 100% similarity]
scripts/legacy/gbtsc/sca-main.pl [moved from scripts/gbtsc/sca-main.pl with 100% similarity]
scripts/legacy/gbtsc/set_reg.sh [moved from scripts/gbtsc/set_reg.sh with 100% similarity]
scripts/legacy/qa/DACscan.py [moved from scripts/qa/FFM2/DACscan.py with 87% similarity]
scripts/legacy/qa/QAScript_abandonedOct27.sh [moved from scripts/qa/QAScript_abandonedOct27.sh with 100% similarity]
scripts/legacy/qa/QAScript_old.pl [new file with mode: 0755]
scripts/legacy/qa/analogue.pl [moved from scripts/qa/analogue.pl with 100% similarity]
scripts/legacy/qa/curves [moved from scripts/qa/curves with 100% similarity]
scripts/legacy/qa/fpn [moved from scripts/qa/fpn with 100% similarity]
scripts/pulse/fit-raw.py [changed mode: 0644->0755]
scripts/qa/11/results.db [new file with mode: 0644]
scripts/qa/323/results.db [new file with mode: 0644]
scripts/qa/33/results.db [new file with mode: 0644]
scripts/qa/333/results.db [new file with mode: 0644]
scripts/qa/89899/CONF_scurves.pl [new file with mode: 0644]
scripts/qa/89899/MATRIX-A/2024-5-17-17-18/METADATA [new file with mode: 0644]
scripts/qa/89899/MATRIX-A/lastdir [new symlink]
scripts/qa/CONF_scurves.pl [new file with mode: 0644]
scripts/qa/DACscan.py [deleted file]
scripts/qa/FFM2/results.db [deleted file]
scripts/qa/Fasdfrab/results.db [deleted file]
scripts/qa/FranzMegaSensor/results.db [deleted file]
scripts/qa/FranzMegaSensor2/results.db [deleted file]
scripts/qa/QAScript.pl
scripts/qa/dac.pl [deleted file]
scripts/qa/k/results.db [deleted file]
scripts/qa/kj/CONF_scurves.pl [new file with mode: 0644]
scripts/qa/kj/MATRIX-A/2024-5-17-16-47/METADATA [new file with mode: 0644]
scripts/qa/kj/MATRIX-A/lastdir [new symlink]
scripts/qa/kk/CONF_scurves.pl [new file with mode: 0644]
scripts/qa/kk/MATRIX-A/2024-5-17-17-7/METADATA [new file with mode: 0644]
scripts/qa/kk/MATRIX-A/lastdir [new symlink]
scripts/qa/lastdir [new symlink]
scripts/qa/powering.pl [deleted file]
scripts/qa/s123/CONF_scurves.pl [new file with mode: 0644]
scripts/qa/s123/DACscan.py [deleted file]
scripts/qa/s123/MATRIX-A/2024-5-21-10-44/METADATA [new file with mode: 0644]
scripts/qa/s123/MATRIX-A/lastdir [new symlink]
scripts/qa/s123/results.db [deleted file]
scripts/qa/s1234/DACscan.py [deleted file]
scripts/qa/s1234/results.db [deleted file]
scripts/qa/s12345/results.db [deleted file]
scripts/qa/s1234543/results.db [deleted file]
scripts/qa/s123456/results.db [deleted file]
scripts/qa/s2222/results.db [new file with mode: 0644]
scripts/qa/s2345/results.db [deleted file]
scripts/qa/uu/CONF_scurves.pl [new file with mode: 0644]
scripts/qa/uu/MATRIX-A/2024-5-17-17-1/METADATA [new file with mode: 0644]
scripts/qa/uu/MATRIX-A/lastdir [new symlink]
scripts/qa/yyy/CONF_scurves.pl [new file with mode: 0644]
scripts/qa/yyy/MATRIX-A/2024-5-17-17-46/METADATA [new file with mode: 0644]
scripts/qa/yyy/MATRIX-A/lastdir [new symlink]
scripts/start.sh

index 78b378ed05ff22d58c01f00469a085f84d04204f..2a75c46b6d321cdb32fead3bea8800bb65488f69 100755 (executable)
@@ -1,6 +1,7 @@
 package Mimosis;
 
 use warnings;
+use strict;
 no warnings "portable";
 use HADES::TrbNet;
 use Time::HiRes qw(usleep);
@@ -17,22 +18,56 @@ my $adc_cmdI = 0x9380;
 my $adc_rreg = 0x0;
 my $adcConv = ( 2 * 4096 ) / 2**16;
 
+my $chipid = 0x1;
+
+
+
+sub set_chipid {
+
+    my ($cid) = @_;
+
+    if ( $cid >= 0 &&
+         $cid <= 3 ) {
+        $chipid = $cid;
+
+    } else {
+
+        print "Mimosis::set_chipid(): input not between 0 and 7. Exiting.\n";
+        exit 1;
+    }
+}
+
+
+
+sub get_chipid {
+
+    return $chipid;
+}
+
 
 sub adc_i2c_command
 {
     my ( $fpga, $addr, $cmd, $data, $readwrite, $skipcmd, $wordbyte ) = @_;
 
-    $reg_data = ( $data << 16 ) + ( $cmd << 8 ) + 0x80 + $addr;
-    $reg_flag = ( $readwrite << 8 ) + ( $skipcmd << 4 ) + $wordbyte;
+    my $reg_data = ( $data << 16 ) + ( $cmd << 8 ) + 0x80 + $addr;
+    my $reg_flag = ( $readwrite << 8 ) + ( $skipcmd << 4 ) + $wordbyte;
+
+    if ( $readwrite == 0 ) {
+
+        trb_register_write_mem( $fpga,
+                                0xd681,
+                                0,
+                                [ $reg_flag, $reg_data ],
+                                2 );
+
+    } elsif ( $readwrite == 1 ) {
+
+        trb_register_write_mem( $fpga,
+                                0xd681,
+                                0,
+                                [ $reg_flag, $reg_data ],
+                                2 ); usleep(1000);
 
-    if ( $readwrite == 0 )
-    {
-        trb_register_write_mem( $fpga, 0xd681, 0, [ $reg_flag, $reg_data ], 2 );
-    }
-    elsif ( $readwrite == 1 )
-    {
-        trb_register_write_mem( $fpga, 0xd681, 0, [ $reg_flag, $reg_data ], 2 );
-        usleep(1000);
         my $reg_return = trb_register_read( $fpga, 0xd684 );
         return $reg_return->{$fpga} & 0xffff;
     }
@@ -44,10 +79,8 @@ sub mimosis_i2c_command
 {
     my ( $fpga, $addr, $cmd, $data, $readwrite, $skipcmd, $wordbyte ) = @_;
 
-    # printf("%x %x %x %x %x %x %x\n",$fpga,$addr, $cmd, $data, $readwrite, $skipcmd, $wordbyte);
-
-    $reg_data = ( $data << 16 ) + ( $cmd << 8 ) + ( $addr << 1 );
-    $reg_flag = ( $readwrite << 8 ) + ( $skipcmd << 4 ) + $wordbyte;
+    my $reg_data = ( $data << 16 ) + ( $cmd << 8 ) + ( $addr << 1 );
+    my $reg_flag = ( $readwrite << 8 ) + ( $skipcmd << 4 ) + $wordbyte;
 
     if ( $readwrite == 0 )
     {
@@ -57,8 +90,6 @@ sub mimosis_i2c_command
     }
     elsif ( $readwrite == 1 )
     {
-        # printf( "%x %x %x %x\n", $fpga, $addr, $cmd, $data );
-        # printf( "%x %x\n", $reg_flag, $reg_data );
         trb_register_write_mem( $fpga, 0xde01, 0, [ $reg_flag, $reg_data, 0x1 ], 3 );
         usleep(1000);
         my $reg_return = trb_register_read( $fpga, 0xde04 );
@@ -71,11 +102,10 @@ sub mimosis_i2c_command
 sub mimosis_register_write{
 
     my ( $fpga, $mimosis_reg, $mimosis_data, $singleaccess ) = @_;
-    my ( $addr, $cmd, $data );
 
-    $addr = 0x12;
-    $cmd  = ( $mimosis_reg >> 8 );
-    $data = ( ( $mimosis_reg & 0xff ) << 8 ) + $mimosis_data;
+    my $addr = ($chipid << 4) +  0x2;
+    my $cmd  = ( $mimosis_reg >> 8 );
+    my $data = ( ( $mimosis_reg & 0xff ) << 8 ) + $mimosis_data;
 
     # printf( "%x %x\n", $cmd, $data );
     if ($singleaccess)
@@ -98,11 +128,10 @@ sub mimosis_register_write{
 sub mimosis_register_write_indirect
 {
     my ( $fpga, $mimosis_reg, $mimosis_data, $singleaccess ) = @_;
-    my ( $addr, $cmd, $data );
 
-    $addr = 0x12;
-    $cmd  = ( $mimosis_reg >> 8 );
-    $data = ( ( $mimosis_reg & 0xff ) << 8 ) + $mimosis_data;
+    my $addr = ($chipid << 4) +  0x2;
+    my $cmd  = ( $mimosis_reg >> 8 );
+    my $data = ( ( $mimosis_reg & 0xff ) << 8 ) + $mimosis_data;
 
     # printf( "%x %x\n", $cmd, $data );
     if ($singleaccess)
@@ -126,12 +155,11 @@ sub mimosis_register_write_indirect
 sub mimosis_register_read
 {
     my ( $fpga, $mimosis_reg, $singleaccess) = @_;
-    my ( $addr, $cmd, $data );
 
     # printf("%x %x\n",$fpga,$mimosis_reg);
-    $addr = 0x12;
-    $cmd  = ( $mimosis_reg >> 8 );
-    $data = ( $mimosis_reg & 0xff );
+    my $addr = ($chipid << 4) +  0x2;
+    my $cmd  = ( $mimosis_reg >> 8 );
+    my $data = ( $mimosis_reg & 0xff );
 
     if ($singleaccess)
     {
@@ -146,8 +174,8 @@ sub mimosis_register_read
     }
 
     usleep(1000);
-    $addr = 0x15;
-    $val  = mimosis_i2c_command( $fpga, $addr, 0, 0, 1, 1, 0 );
+    $addr = ($chipid << 4) +  0x5;
+    my $val  = mimosis_i2c_command( $fpga, $addr, 0, 0, 1, 1, 0 );
 
     # printf( "%x\n", $val );
     return $val & 0xff;
@@ -181,7 +209,7 @@ sub mimosis_load_file {
     $printall = defined $printall ? 1 : 0;
     $printwrong = defined $printwrong ? 1 : 0;
 
-    @config = do $file;
+    my @config = do $file;
 
     foreach my $i (@config)
     {
@@ -202,14 +230,21 @@ sub mimosis_load_file {
                 unless(($val & 0xff) == @$i[1])
                 {
                     my $reg_return = trb_register_read $fpga, 0xde04 ;
-                    my $status = (($reg_return->{$fpga}//0) >> 16 ) & 0xff;
-                    printf "%x %x    Status: %x\n", @$i[0], $val, $status;
+
+                   foreach my $k (keys %{$reg_return}) {
+                       my $status = (($reg_return->{$k}//0) >> 16 ) & 0xff;
+                       printf "%x %x %x    Status: %x\n", $k, @$i[0], $val, $status;
+                   }
+                   # my $status = (($reg_return->{$fpga}//0) >> 16 ) & 0xff;
+                   # printf "%x %x    Status: %x\n", @$i[0], $val, $status;
                 }
             }
         }
     }
 }
 
+
+
 sub mimosis_dacscan_initial_test {
 
     my %odac = (
@@ -242,7 +277,7 @@ sub mimosis_dacscan_initial_test {
     $slow = defined $slow ? $slow : 10000;
     $printall = defined $printall ? 1 : 0;
 
-    my $other_file_n = "other_data.csv";
+    my $other_file_n = $name . "/other_data.csv";
 
     trb_register_write( $fpga, 0xd680, 0x1e );    #write speed 30 to adc
 
@@ -264,15 +299,12 @@ sub mimosis_dacscan_initial_test {
         Mimosis::mimosis_register_write( $fpga, 0x0026, $dac, $a ); usleep($slow);
 
         #loop over settings
-        for ( my $set = 0; $set <= 2**8 - 1; $set += 10 )
+        for ( my $set = 0; $set <= 0xff; $set += 10 )
         {
             #set dac to $set
             Mimosis::mimosis_register_write( $fpga, $odac{$dac}, $set, $a ); usleep($slow);
-            #issue one shot measurement of ADC
             Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_wreg, $adc_cmdV, 0, 0, 1 ); usleep($slow);
-            #read measured value
             my $rawV = Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_rreg, 0x0, 1, 0, 1 );
-            #print to file
             printf( FH "%x\t%i\t%i\n", $odac{$dac}, $set, $rawV * $adcConv );
         }
 
@@ -281,11 +313,9 @@ sub mimosis_dacscan_initial_test {
         printf( FH "\n\n" );
     }
 
-
     #VPHF Scan
     Mimosis::mimosis_register_write( $fpga, 0x0026, 1, $a ); usleep($slow);
 
-    #loop over settings
     for ( my $set = 0; $set <= 2**8 - 1; $set += 10 )
     {
 
@@ -296,16 +326,9 @@ sub mimosis_dacscan_initial_test {
     }
 
     Mimosis::mimosis_register_write( $fpga, 0x0046, 0, $a ); usleep($slow);
-    close(FH);
 
+    close(FH);
 
-    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-    $year = sprintf("%02d", $year % 100);
-    $mon = sprintf("%02d", $mon + 1);
-    $mday = sprintf("%02d", $mday);
-    $min = sprintf("%02d", $min);
-    $hour = sprintf("%02d", $hour);
-    my $timestamp = $hour . ":" . $min . "-" . $mday . "-" . $mon . "-" . $year;
     my $img_n = $name . "/" . $name . ".png";
 
     my $message_png = <<"END_MESSAGE";
@@ -315,9 +338,11 @@ set key Left left top box;
 set xlabel \\"set.\\";
 set ylabel \\"[mV]\\";
 array names2[4] = [\\"VRESET\\", \\"VPH\\", \\"VPL\\", \\"VPHF\\"];
-plot \\"good_range_vphf.txt\\" using 1:2:3 ls 4 w filledcu fc \\"grey\\", \\"good_range_odac.txt\\" using 1:2:3 ls 4 w filledcu fc \\"grey\\", for [i=0:3] \\"other_data.csv\\" using 2:3 index i with l title names2[i+1]";
+plot \\"good_range_vphf.txt\\" using 1:2:3 ls 4 w filledcu fc \\"grey\\", \\"good_range_odac.txt\\" using 1:2:3 ls 4 w filledcu fc \\"grey\\", for [i=0:3] \\"$other_file_n\\" using 2:3 index i with l title names2[i+1]";
 END_MESSAGE
     system $message_png;
+
+    system "display $name/$name.png &";
 }
 
 
@@ -413,37 +438,35 @@ sub mimosis_dacscan
     #generate adc addresses
     if ( $ikf )
     {
-        $adc_cmdV = 0xe380;
-        $adc_cmdI = 0xd380;
+           $adc_cmdV = 0xe380;
+           $adc_cmdI = 0xd380;
     }
 
     #MONVOLT
     open( FH, '>', $vmon_file_n ) or die $!;
-
+    
     #loop over dacs
     for my $dac ( sort keys %vdac )
     {
         if( $printall ) { printf "Scan: %x\n", $vdac{$dac}; }
-
+    
         Mimosis::mimosis_register_write( $fpga, 0x0026, $dac, $a ); usleep($slow);
-
+    
         #loop over settings
-        for my $set ( 0 .. 2**8 - 1 )
+        for my $set ( 0 .. 0x8f )
         {
-            #set dac to $set
             Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $set, $a ); usleep($slow);
-            #issue one shot measurement of ADC
             Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_wreg, $adc_cmdV, 0, 0, 1 ); usleep($slow);
-            #read measured value
             my $rawV = Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_rreg, 0x0, 1, 0, 1 );
-            #print to file
             printf( FH "%x\t%f\t%i\n", $vdac{$dac}, $set, $rawV * $adcConv );
         }
-
+    
         #set DAC to reset value
         Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $vdac_reset{$dac}, $a  ); usleep($slow);
         printf( FH "\n\n" );
+       # last;
     }
+    
     close(FH);
 
 
@@ -453,13 +476,10 @@ sub mimosis_dacscan
     #loop over dacs
     for my $dac ( sort keys %idac )
     {
-        #if on ikf proxy, skip current dacs. BUG
-        if ( $ikf ) { last; }
-
-        if( $printal ){ printf "Scan: %x\n", $idac{$dac}; }
+        if( $printall ){ printf "Scan: %x\n", $idac{$dac}; }
 
         #set MONCURR to $dac
-        Mimosis::mimosis_register_write( $fpga, 0x0025, $dac, $a  ); usleep($slow);
+      # Mimosis::mimosis_register_write( $fpga, 0x0025, $dac, $a  ); usleep($slow);
 
         #loop over settings
         for my $set ( 0 .. 2**8 - 1 )
@@ -543,8 +563,8 @@ END_MESSAGE
 }
 
 
-sub mimosis_dacscan_sf
-{
+sub mimosis_dacscan_sf {
+
     my %vdac = (
         1  => 0x0045,
         2  => 0x0044,
@@ -625,55 +645,79 @@ sub mimosis_dacscan_sf
         $adc_cmdI = 0xd380;
     }
 
+
+    my %results = (
+                0x0040 => [],
+                0x0041 => [],
+                0x0042 => [],
+                0x0043 => [],
+                0x0044 => [],
+                0x0045 => [],
+                0x0046 => [],
+                0x0047 => [],
+                0x0048 => [],
+                0x0049 => [],
+                0x004a => [],
+                0x004b => [],
+                0x004c => [],
+                0x004d => [],
+                0x004e => [],
+               );
+
     #MONVOLT
-    for my $dac ( sort keys %vdac )
-    {
-        my $fname = $names{$vdac{$dac}} . '.csv';
+    while( my ($key, $dac) = each(%vdac) ) {
+
+        my $fname = $names{$dac} . '.csv';
         open( FH, '>', $fname ) or die $!;
 
-        if( $printall ) { printf "Scan: %x\n", $vdac{$dac}; }
+        if( $printall ) { printf "Scan: %x\n", $dac; }
 
-        Mimosis::mimosis_register_write( $fpga, 0x0026, $dac, $a ); usleep($slow);
+        # Set MONVOLT
+        Mimosis::mimosis_register_write( $fpga, 0x0026, $key, $a ); usleep($slow);
 
-        for my $set ( 0 .. 2**8 - 1 )
-        {
-            Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $set, $a ); usleep($slow);
+        for my $set ( 0 .. 0xff ) {
+
+            Mimosis::mimosis_register_write( $fpga, $dac, $set, $a ); usleep($slow);
             Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_wreg, $adc_cmdV, 0, 0, 1 ); usleep($slow);
+
             my $rawV = Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_rreg, 0x0, 1, 0, 1 );
-            printf( FH "%x\t%i\t%f\n", $vdac{$dac}, $set, $rawV * $adcConv );
+            printf( FH "%x\t%i\t%f\n", $dac, $set, $rawV * $adcConv );
+            push ( @{$results{$dac}}, $rawV*$adcConv );
         }
 
-        Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $vdac_reset{$dac}, $a  ); usleep($slow);
         close(FH);
+
+        Mimosis::mimosis_register_write( $fpga, $dac, $vdac_reset{$key}, $a ); usleep($slow);
     }
 
 
+
     #MONCURR
-    for my $dac ( sort keys %idac )
-    {
-        #if on ikf proxy, skip current dacs. BUG
-        if ( $ikf ) { last; }
+    while( my ($key, $dac) = each(%idac) ) {
 
-        my $fname = $names{$idac{$dac}} . '.csv';
+        my $fname = $names{$dac} . '.csv';
         open( FH, '>', $fname ) or die $!;
 
-        if( $printall ){ printf "Scan: %x\n", $idac{$dac}; }
+        if( $printall ){ printf "Scan: %x\n", $dac; }
 
-        Mimosis::mimosis_register_write( $fpga, 0x0025, $dac, $a  ); usleep($slow);
+        Mimosis::mimosis_register_write( $fpga, 0x0025, $key, $a  ); usleep($slow);
 
-        for my $set ( 0 .. 2**8 - 1 )
-        {
-            Mimosis::mimosis_register_write( $fpga, $idac{$dac}, $set, $a ); usleep($slow);
+        for my $set ( 0 .. 0xff) {
+
+            Mimosis::mimosis_register_write( $fpga, $dac, $set, $a ); usleep($slow);
             Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_wreg, $adc_cmdI, 0, 0, 1 ); usleep($slow);
             my $rawV = Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_rreg, 0x0, 1, 0, 1 );
-            printf( FH "%x\t%i\t%f\n", $idac{$dac}, $set, $rawV * $adcConv );
+            printf( FH "%x\t%i\t%f\n", $dac, $set, $rawV * $adcConv );
+            push ( @{$results{$dac}}, $rawV*$adcConv );
         }
 
-        Mimosis::mimosis_register_write( $fpga, $idac{$dac}, $idac_reset{$dac}, $a ); usleep($slow);
         close(FH);
+
+        Mimosis::mimosis_register_write( $fpga, $dac, $idac_reset{$key}, $a ); usleep($slow);
     }
 
 
+
     #VPH_FINE
     my $fname = $names{0x0046 } . '.csv';
     open( FH, '>', $fname ) or die $!;
@@ -681,21 +725,27 @@ sub mimosis_dacscan_sf
     if( $printall ){ printf "Scan: %x\n", 0x0046; }
 
     Mimosis::mimosis_register_write( $fpga, 0x0045, 0, $a ); usleep($slow);
+
     Mimosis::mimosis_register_write( $fpga, 0x0026, 1, $a  ); usleep($slow);
 
-    for my $set ( 0 .. 2**8 - 1 )
-    {
+    for my $set ( 0 .. 0xff ) {
+
         Mimosis::mimosis_register_write( $fpga, 0x0046, $set, $a ); usleep($slow);
         Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_wreg, $adc_cmdV, 0, 0, 1 ); usleep($slow);
         my $rawV = Mimosis::adc_i2c_command( $fpga, $adc_addr, $adc_rreg, 0x0, 1, 0, 1 );
         printf( FH "%x\t%i\t%f\n", 0x0046, $set, $rawV * $adcConv );
+        push ( @{$results{0x0046}}, $rawV*$adcConv );
     }
 
-    Mimosis::mimosis_register_write( $fpga, 0x0046, 0x0, $a ); usleep($slow);
     close(FH);
+
+    Mimosis::mimosis_register_write( $fpga, 0x0046, 0x0, $a ); usleep($slow);
+
+    return %results;
 }
 
 
+
 sub send_params_scurve
 {
     my %params = @_;
@@ -713,6 +763,7 @@ sub send_params_scurve
     my $region = $params{'region'};
     my $vcasn= $params{'vcasn'};
     my $singleAccess = $params{'singleAccess'};
+    my $fpga = $params{'fpga'};
 
     $state = defined $state ? $state : "DONE";
     $ySta = defined $ySta ? $ySta : 0;
@@ -725,9 +776,10 @@ sub send_params_scurve
     $setTra = defined $setTra ? $setTra : 1;
     $setCnt = defined $setCnt ? $setCnt : 0;
     $mod = defined $mod ? $mod : 3;
-    $region = defined $region ? $region : A;
+    $region = defined $region ? $region : 'A';
     $vcasn= defined $vcasn ? $vcasn : 0;
     $singleAccess= defined $singleAccess ? $singleAccess : 0;
+    $fpga = defined $fpga ? $fpga : 0xa000;
 
     my $frameWr = "START-" .
       $state . "-" .
@@ -743,7 +795,8 @@ sub send_params_scurve
       $mod . "-" .
       $region . "-" .
       $vcasn . "-" .
-      $singleAccess . "-END";
+      $singleAccess . "-" .
+      $fpga . "-END";
 
     my $pipeNameWr = "/tmp/scurveipipe";
     my $fdPipeWr = POSIX::open($pipeNameWr, &POSIX::O_WRONLY);
@@ -757,15 +810,14 @@ sub kill_proc_by_pid_file
 {
     my ($pidName) = @_;
 
-    my $pidFile = POSIX::open($pidName, &POSIX::O_RDONLY)
-      or die "hldprint already killed probably\n";
+    my $pidFile = POSIX::open($pidName, &POSIX::O_RDONLY) or return;
     my $buf;
     my $bytes = POSIX::read($pidFile,$buf,10);
     POSIX::close($pidFile);
 
     kill 15, $buf;
 
-    unlink($pidName) or die "Can't delete $pidName: $!\n";
+    unlink($pidName);
 }
 
 
@@ -821,7 +873,7 @@ sub mimosis_scan_region
         'D' => [ 896, 1023 ]
         );
 
-    %rowadd     = ( 'A' => 4, 'B' => 2, 'C' => 2, 'D' => 4 );
+    my %rowadd     = ( 'A' => 4, 'B' => 2, 'C' => 2, 'D' => 4 );
 
     $slow = defined $slow ? $slow : 10000;
     $a = defined $a ? $a : 0;
@@ -834,10 +886,10 @@ sub mimosis_scan_region
     $setEnd = defined $setEnd ? $setEnd : 0xff;
     $setTra = defined $setTra ? $setTra : 1;
     $setCnt = defined $setCnt ? $setCnt : 4000;
-    $pixpulsea_a = defined $pixpulsea_a ? $pixpulsea_a : 25;
-    $pixpulsea_b = defined $pixpulsea_b ? $pixpulsea_b : 75;
-    $pixpulsed_a = defined $pixpulsed_a ? $pixpulsed_a : 0;
-    $pixpulsed_b = defined $pixpulsed_b ? $pixpulsed_b : 0;
+    my $pixpulsea_a = defined $params{'pixpulsea_a'} ? $params{'pixpulsea_a'} : 25;
+    my $pixpulsea_b = defined $params{'pixpulsea_b'} ? $params{'pixpulsea_b'} : 75;
+    my $pixpulsed_a = defined $params{'pixpulsed_a'} ? $params{'pixpulsed_a'} : 0;
+    my $pixpulsed_b = defined $params{'pixpulsed_b'} ? $params{'pixpulsed_b'} : 0;
     $mod = defined $mod ? $mod : 3;
 
     Mimosis::mimosis_register_write( $fpga, 0x0020, 0x40, $a ); usleep($slow); #en_pixelmask to 0 for pulse
@@ -868,12 +920,120 @@ sub mimosis_scan_region
                        mod    => $mod,
                        region => $region,
                        vcasn  => 0,
-                       singleAccess => $a
+                       singleAccess => $a,
+                       fpga => $fpga
                       );
     await_ack();
 }
 
 
+
+sub mimosis_scan_region_loop
+{
+    my %params = @_;
+    my $fpga = $params{'fpga'};
+    my $slow = $params{'slow'};
+    my $a = $params{'a'};
+    my $region = $params{'region'};
+    my $vcasnSta = $params{'vcasnSta'};
+    my $vcasnEnd = $params{'vcasnEnd'};
+    my $vcasnStep = $params{'vcasnStep'};
+    my $ySta = $params{'ySta'};
+    my $yEnd = $params{'yEnd'};
+    my $yTra = $params{'yTra'};
+    my $xSta = $params{'xSta'};
+    my $xEnd = $params{'xEnd'};
+    my $setSta = $params{'setSta'};
+    my $setEnd = $params{'setEnd'};
+    my $setTra = $params{'setTra'};
+    my $setCnt = $params{'setCnt'};
+    my $analogAlimA = $params{'analogalima'};
+    my $analogAlimB = $params{'analogalimb'};
+    my $analogDlimA = $params{'analogdlima'};
+    my $analogDlimB = $params{'analogdlimb'};
+    my $printall = $params{'printall'};
+    my $mod = $params{'mod'};
+
+    defined $fpga or die "Mimosis::mimosis_scan_region_loop: must provide $fpga.";
+    defined $region or die "Mimosis::mimosis_scan_region_loop: must provide $region.";
+
+
+    my %regCharToStr = (
+        A => 'VCASNA',
+        B => 'VCASNB',
+        C => 'VCASNC',
+        D => 'VCASND'
+        );
+
+    my %dacs = (
+        IBIAS => 0x0040,
+        ITHR  => 0x0041,
+        IDB   => 0x0042,
+        VRESET => 0x0043,
+        VPL    => 0x0044,
+        VPH    => 0x0045,
+        VPH_FINE => 0x0046,
+        VCASP    => 0x0047,
+        VCASNA   => 0x0048,
+        VCASNB   => 0x0049,
+        VCASNC   => 0x004a,
+        VCASND   => 0x004b,
+        VCASN2   => 0x004c,
+        VCLIP    => 0x004d,
+        IBUFBIAS => 0x004e
+        );
+
+    my $vcasnStr = $regCharToStr{$region};
+    my $vcasnVal = mimosis_register_read( $fpga, $dacs{$vcasnStr}, $a );
+    $vcasnSta = defined $vcasnSta ? $vcasnSta : $vcasnVal;
+    $vcasnEnd = defined $vcasnEnd ? $vcasnEnd : $vcasnSta;
+    $vcasnStep = defined $vcasnStep ? $vcasnStep : 1;
+
+    system("/d/jspc37/mimosis/cpp/build/scurve-scan mbss://localhost:36789 &");
+
+    for ( my $vcasnSet = $vcasnSta;
+          $vcasnSet <= $vcasnEnd;
+          $vcasnSet += $vcasnStep ) {
+        #set vcasn
+        mimosis_register_write( $fpga, $dacs{$vcasnStr}, $vcasnSet, $a ); usleep($slow);
+
+        if( $printall ) { printf("dac: $vcasnSet\n"); }
+
+        mimosis_scan_region(
+            fpga        => $fpga,
+            slow        => $slow,
+            a           => $a,
+            region      => $region,
+            ySta        => $ySta,
+            yEnd        => $yEnd,
+            yTra        => $yTra,
+            xSta        => $xSta,
+            xEnd        => $xEnd,
+            setSta      => $setSta,
+            setEnd      => $setEnd,
+            setTra      => $setTra,
+            setCnt      => $setCnt,
+            analogAlimA => $analogAlimA,
+            analogAlimB => $analogAlimB,
+            analogDlimA => $analogDlimA,
+            analogDlimB => $analogDlimB,
+            mod         => $mod,
+        );
+
+        send_params_scurve(
+            state => "FIT",
+            region => $regCharToStr{$region},
+            vcasn => $vcasnSet
+            );
+
+        await_ack();
+    }
+
+    send_params_scurve( state => "DONE" );
+    await_ack();
+    kill_proc_by_pid_file("/tmp/hldprint-pid");
+}
+
 sub mimosis_pulse_region
 {
     my %params = @_;
@@ -893,17 +1053,17 @@ sub mimosis_pulse_region
     defined $fpga or die "Mimosis::mimosis_scan_region: Must provide --fpga.";
     defined $region or die "mimosis::mimosis_scan_region: must provide --region.";
 
-    %rowadd     = ( 'A' => 4, 'B' => 2, 'C' => 2, 'D' => 4 );
+    my %rowadd     = ( 'A' => 4, 'B' => 2, 'C' => 2, 'D' => 4 );
 
     $slow = defined $slow ? $slow : 10000;
     $a = defined $a ? $a : 0;
     $ySta = defined $ySta ? $ySta : 0;
     $yEnd = defined $yEnd ? $yEnd : 503;
     $yTra = defined $yTra ? $yTra : $rowadd{$region};
-    $pixpulseA_A = defined $pixpulseA_A ? $pixpulseA_A : 25;
-    $pixpulseA_B = defined $pixpulseA_B ? $pixpulseA_B : 75;
-    $pixpulseD_A = defined $pixpulseD_A ? $pixpulseD_A : 0;
-    $pixpulseD_B = defined $pixpulseD_B ? $pixpulseD_B : 0;
+    my $pixpulseA_A = defined $params{'pixpulsea_a'} ? $params{'pixpulsea_a'} : 25;
+    my $pixpulseA_B = defined $params{'pixpulsea_b'} ? $params{'pixpulsea_b'} : 75;
+    my $pixpulseD_A = defined $params{'pixpulsed_a'} ? $params{'pixpulsed_a'} : 0;
+    my $pixpulseD_B = defined $params{'pixpulsed_b'} ? $params{'pixpulsed_b'} : 0;
     $modpulse = defined $modpulse ? $modpulse : 3;
 
     Mimosis::mimosis_register_write( $fpga, 0x0020, 0x40, $a ); usleep($slow); #EN_PIXELMASK to 0 for pulse
@@ -1168,8 +1328,6 @@ sub mimosis_mask
     }
     else
     {
-        print colored ( "Either specified column values doesn't match INT,INT or values are unlogic. Using all columns now. You have 10 seconds to abort with Ctrl-C.", 'red' ), "\n";
-        sleep 10;
         $cl = 0;
         $ch = 1023;
     }
@@ -1194,8 +1352,6 @@ sub mimosis_mask
     }
     else
     {
-        print colored ( "Either specified row values doesn't match INT,INT or values are unlogic. Using all rows now. You have 10 seconds to abort with Ctrl-C.", 'red' ), "\n";
-        sleep 10;
         $rl = 0;
         $rh = 503;
     }
index 5d2fffc010b056ebae7208a538c19d8e9add7c74..931b87ec19a39ba8906ab12cc1b66def0c415a04 100755 (executable)
@@ -38,7 +38,7 @@ my %dacs = (
 
 
 #global
-my ( $fpga, $a, $slow );
+my ( $fpga, $a, $slow, $chipid);
 
 #load
 my ( $printall_load, $printwrong_load );
@@ -66,12 +66,12 @@ my ( $vcasnAn, $threadsAn );
 
 my @ARGV_bak = @ARGV;
 
-
 my $res = GetOptions (
     options => {
         'fpga|f=s'        => \$fpga,
         'singleaccess|a'  => \$a,
         'slow|s=s'        => \$slow,
+        'chipid=s'        => \$chipid,
     },
     default_subcommand => 'default',
     subcommands => {
@@ -230,6 +230,9 @@ trb_init_ports() or die trb_strerror();
 
 $fpga = defined($fpga) ? hex $fpga : 0xa000;
 $slow = defined($slow) ? $slow : 10000;
+$chipid = defined($chipid) ? hex $chipid: 0x1;
+
+Mimosis::set_chipid($chipid);
 
 
 if( $res->{subcommand}[0] eq 'load' )
@@ -301,56 +304,82 @@ elsif( $res->{subcommand}[0] eq 'scurves' )
 
     if( defined $regionSc )
     {
-        my $vcasnStr = $regCharToStr{$regionSc};
-        my $vcasnVal = Mimosis::mimosis_register_read( $fpga, $dacs{$vcasnStr}, $a );
-        $vcasnStaSc = defined $vcasnStaSc ? $vcasnStaSc : $vcasnVal;
-        $vcasnEndSc = defined $vcasnEndSc ? $vcasnEndSc : $vcasnStaSc;
-        $vcasnStepSc = defined $vcasnStepSc ? $vcasnStepSc : 1;
-
-        system("/d/jspc37/mimosis/cpp/build/scurve-scan mbss://localhost:36789 &");
-
-        for ( my $vcasnSet = $vcasnStaSc;
-              $vcasnSet <= $vcasnEndSc;
-              $vcasnSet += $vcasnStepSc ) {
-            #set vcasn
-            Mimosis::mimosis_register_write( $fpga, $dacs{$vcasnStr}, $vcasnSet, $a ); usleep($slow);
-
-            if( $printDacSc || $printAllSc ) { printf("dac: $vcasnSet\n"); }
-
-            Mimosis::mimosis_scan_region(
-                fpga        => $fpga,
-                slow        => $slow,
-                a           => $a,
-                region      => $regionSc,
-                ySta        => $yStaSc,
-                yEnd        => $yEndSc,
-                yTra        => $yTraSc,
-                xSta        => $xStaSc,
-                xEnd        => $xEndSc,
-                setSta      => $setStaSc,
-                setEnd      => $setEndSc,
-                setTra      => $setStepSc,
-                setCnt      => $setCntSc,
-                analogAlimA => $analogAlimASc,
-                analogAlimB => $analogAlimBSc,
-                analogDlimA => $analogDlimASc,
-                analogDlimB => $analogDlimBSc,
-                mod         => $modpulseSc,
+        Mimosis::mimosis_scan_region_loop(
+            fpga        => $fpga,
+            slow        => $slow,
+            a           => $a,
+            region      => $regionSc,
+            vcasnSta    => $vcasnStaSc,
+            vcasnEnd    => $vcasnEndSc,
+            vcasnStep   => $vcasnStepSc,
+            ySta        => $yStaSc,
+            yEnd        => $yEndSc,
+            yTra        => $yTraSc,
+            xSta        => $xStaSc,
+            xEnd        => $xEndSc,
+            setSta      => $setStaSc,
+            setEnd      => $setEndSc,
+            setTra      => $setStepSc,
+            setCnt      => $setCntSc,
+            analogAlimA => $analogAlimASc,
+            analogAlimB => $analogAlimBSc,
+            analogDlimA => $analogDlimASc,
+            analogDlimB => $analogDlimBSc,
+            mod         => $modpulseSc,
             );
 
-            Mimosis::send_params_scurve(
-                                        state => "FIT",
-                                        region => $regCharToStr{$regionSc},
-                                        vcasn => $vcasnSet
-                                       );
-            Mimosis::await_ack();
-        }
-
-        Mimosis::send_params_scurve( state => "DONE" );
-        Mimosis::await_ack();
-        Mimosis::kill_proc_by_pid_file("/tmp/hldprint-pid");
         exit 0;
 
+        # my $vcasnStr = $regCharToStr{$regionSc};
+        # my $vcasnVal = Mimosis::mimosis_register_read( $fpga, $dacs{$vcasnStr}, $a );
+        # $vcasnStaSc = defined $vcasnStaSc ? $vcasnStaSc : $vcasnVal;
+        # $vcasnEndSc = defined $vcasnEndSc ? $vcasnEndSc : $vcasnStaSc;
+        # $vcasnStepSc = defined $vcasnStepSc ? $vcasnStepSc : 1;
+
+        # system("/d/jspc37/mimosis/cpp/build/scurve-scan mbss://localhost:36789 &");
+
+        # for ( my $vcasnSet = $vcasnStaSc;
+        #       $vcasnSet <= $vcasnEndSc;
+        #       $vcasnSet += $vcasnStepSc ) {
+        #     #set vcasn
+        #     Mimosis::mimosis_register_write( $fpga, $dacs{$vcasnStr}, $vcasnSet, $a ); usleep($slow);
+
+        #     if( $printDacSc || $printAllSc ) { printf("dac: $vcasnSet\n"); }
+
+        #     Mimosis::mimosis_scan_region(
+        #         fpga        => $fpga,
+        #         slow        => $slow,
+        #         a           => $a,
+        #         region      => $regionSc,
+        #         ySta        => $yStaSc,
+        #         yEnd        => $yEndSc,
+        #         yTra        => $yTraSc,
+        #         xSta        => $xStaSc,
+        #         xEnd        => $xEndSc,
+        #         setSta      => $setStaSc,
+        #         setEnd      => $setEndSc,
+        #         setTra      => $setStepSc,
+        #         setCnt      => $setCntSc,
+        #         analogAlimA => $analogAlimASc,
+        #         analogAlimB => $analogAlimBSc,
+        #         analogDlimA => $analogDlimASc,
+        #         analogDlimB => $analogDlimBSc,
+        #         mod         => $modpulseSc,
+        #     );
+
+        #     Mimosis::send_params_scurve(
+        #                                 state => "FIT",
+        #                                 region => $regCharToStr{$regionSc},
+        #                                 vcasn => $vcasnSet
+        #                                );
+        #     Mimosis::await_ack();
+        # }
+
+        # Mimosis::send_params_scurve( state => "DONE" );
+        # Mimosis::await_ack();
+        # Mimosis::kill_proc_by_pid_file("/tmp/hldprint-pid");
+        # exit 0;
+
     } elsif (defined $xSc && defined $ySc && defined $vcasnSc) {
 
         # my $vcasnVal = Mimosis::mimosis_register_read( $fpga, $dacs{$vcasnSc}, $a );
@@ -416,17 +445,13 @@ elsif( $res->{subcommand}[0] eq 'scurves' )
 
 elsif( $res->{subcommand}[0] eq 'analyse' )
 {
-    my %regCharToStr = (
-        A => 'VCASNA',
-        B => 'VCASNB',
-        C => 'VCASNC',
-        D => 'VCASND'
-        );
-
     open(FH, '<', 'METADATA') or die print "Cannot open METADATA. Is this a vild run dir?\n";
 
-    # system("/d/jspc37/mimosis/scripts/pulse/plot-raw.py");
+    while(<FH>){
+        print $_;
+    }
 
+    # system("/d/jspc37/mimosis/scripts/pulse/plot-raw.py");
 
     exit 0;
 }
diff --git a/scripts/conf/CONF_1out.pl b/scripts/conf/CONF_1out.pl
deleted file mode 100644 (file)
index f768196..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#read files like my @config = do "CONF_allregisters.pl";
-
-  #General Control
-  [0x0020,   0x40  ], #RUNMODE  -> table 8
-  [0x0021,   0x6E  ], #TRIMDAC  -> table 9
-  [0x0022,   0x00  ], #INJCURR  -> table 10
-  [0x0023,   0x00  ], #INJVOLT1 -> table 11
-  [0x0024,   0x00  ], #INJVOLT2 -> table 12
-  [0x0025,   0x00  ], #MONCURR  -> table 13
-  [0x0026,   0x00  ], #MONVOLT  -> table 14
-  [0x0027,   0x01  ], #CLKGEN1  -> table 15
-  [0x0028,   0x01  ], #CLKGEN2  -> table 16
-  [0x0029,   0x16  ], #PLL      -> table 17  
-  [0x002a,   0x00  ], #PLLLOCK  -> table 18
-  [0x002b,   0x00  ], #MONTEMP  -> table 19
-  [0x002c,   0x15  ], #SLVSTX   -> table 20
-  [0x002d,   0x00  ], #SLVSRX   -> table 21
-  [0x002e,   0x74  ], #OUTPUT   -> table 22
-  [0x002f,   0x00  ], #MONPWR   -> table 23
-  
-  #DACs
-  [0x0040,   0x40  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
-  [0x0041,   0x34  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
-  [0x0042,   0x1c  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
-  [0x0043,   0xab  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
-  [0x0044,   0x46  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
-  [0x0045,   0x55  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
-  [0x0046,   0x00  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
-  [0x0047,   0x43  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x0048,   0x78  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
-  [0x0049,   0x78  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
-  [0x004a,   0x78  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
-  [0x004b,   0x60  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
-  [0x004c,   0x3c  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x004d,   0x37  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
-  [0x004e,   0x7d  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
-  
-  #Sequencer - 0x0100 registers are upper byte of the word
-  [0x0060,         ], # PIXLOAD_A     0x00
-  [0x0160,         ], #               0x00
-  [0x0070,         ], # PIXLOAD_B     0x01
-  [0x0170,         ], #               0x00
-  [0x0061,         ], # PIXREAD_A     0x00
-  [0x0161,         ], #               0x00
-  [0x0071,         ], # PIXREAD_B     0x97
-  [0x0171,         ], #               0x00
-  [0x0062,         ], # PIXRSTB_A     0x98
-  [0x0162,         ], #               0x00
-  [0x0072,         ], # PIXRSTB_B     0x99
-  [0x0172,         ], #               0x00
-  [0x0063,         ], # DPSTART_A     0x00
-  [0x0163,         ], #               0x00
-  [0x0073,         ], # DPSTART_B     0x01
-  [0x0173,         ], #               0x00
-  [0x0064,         ], # DPTOKEN_A     0x01
-  [0x0164,         ], #               0x00
-  [0x0074,         ], # DPTOKEN_B     0x02
-  [0x0174,         ], #               0x00
-  [0x0065,         ], # DPEND_A       0x98
-  [0x0165,         ], #               0x00
-  [0x0075,         ], # DPEND_B       0x99
-  [0x0175,         ], #               0x00
-  [0x0066,         ], # PIXPULSEA_A   0x00
-  [0x0166,         ], #               0x00
-  [0x0076,         ], # PIXPULSEA_B   0x00
-  [0x0176,         ], #               0x00
-  [0x0067,         ], # PIXPULSED_A   0x00
-  [0x0167,         ], #               0x00
-  [0x0077,         ], # PIXPULSED_B   0x00
-  [0x0177,         ], #               0x00
-  [0x0068,         ], # MKSEQ1_A      0x00
-  [0x0168,         ], #               0x00
-  [0x0078,         ], # MKSEQ1_B      0x02                        
-  [0x0178,         ], #               0x00
-  [0x0069,         ], # MKSEQ2_A      0x00
-  [0x0169,         ], #               0x00
-  [0x0079,         ], # MKSEQ2_B      0x02
-  [0x0179,         ], #               0x00
-  [0x007A,         ], # POLARITY      0x05
-  [0x017A,         ], #               0x00
-  [0x007B,         ], # FRAMELENGTH    100
-  [0x017B,         ], #               0x00
-  [0x007C,         ], # MAXFRAME      0x00
-  [0x017C,         ], #               0x00
-  [0x007D,         ], # MODPULSE      0x00
-  [0x007E,         ], # MODPIXRSTB    0x00
-  [0x007F,         ], # MODMKSEQ1     0x00
-                      
-  #Monitoring (read only)
-  [0x00E0,         ], # MON_POR_LOCK       Power On Rest and PLL lock
-  [0x00E1,         ], # MON_PAD            PADs
-  [0x00E2,         ], # MON_FR_CPT_0       Frame counter bits 7-0
-  [0x00E3,         ], # MON_FR_CPT_1       Frame counter bits 15-8
-  [0x00E4,         ], # MON_FR_CPT_2       Frame counter bits 23-16
-  [0x00E5,         ], # MON_FR_CPT_3       Frame counter bits 31-24
-  [0x00E6,         ], # EV_TMR_SEQ         Triple Modular Redundancy Error in sequencer
-  [0x00E7,         ], # EV_LOCK            PLL lock
-  [0x00E8,         ], # EV_LOCKFILTER      PLL lock after filtering
-  [0x00E9,         ], # EV_POR1            Power On Reset 1
-  [0x00EA,         ], # EV_POR2            Power On Reset 2
-  [0x00EB,         ], # EV_POR3            Power On Reset 3
-  [0x00EC,         ], # EV_RSTB            RSTB pad
-  [0x00ED,         ], # EV_START           START all types (auto, pad, and soft)
-  [0x00EE,         ], # EV_DPSTART         Digital Periphery Start
-  
-  #Analog pixel selection
-  [0x8020,         ], # SEL_ANAPIX0        Analogue Pixel Selection LSB
-  [0x8021,         ], # SEL_ANAPIX1        Analogue Pixel Selection MSB
-  
-  #Readout test configuration
-  [0x8040,   0xaa  ], # PATTERN0
-  [0x8041,   0xfc  ], # PATTERN1
-  [0x8042,   0xaa  ], # PATTERN2
-  [0x8043,   0xfc  ], # PATTERN3
-  [0x8044,   0xaa  ], # PATTERN4
-  [0x8045,   0xfc  ], # PATTERN5
-  [0x8046,   0xaa  ], # PATTERN6
-  [0x8047,   0xfc  ], # PATTERN7
-  [0x8048,   0xaa  ], # PATTERN8
-  [0x8049,   0xfc  ], # PATTERN9
-  [0x804A,   0xaa  ], # PATTERN10
-  [0x804B,   0xfc  ], # PATTERN11
-  [0x804C,   0xaa  ], # PATTERN12
-  [0x804D,   0xfc  ], # PATTERN13
-  [0x804E,   0xaa  ], # PATTERN14
-  [0x804F,   0xfc  ], # PATTERN15
-  [0x8050,         ], # BANDWIDTH0
-  [0x8051,         ], # BANDWIDTH1
-  [0x8052,   0x00  ], # FILLLEVEL0 #custom level at 1536
-  [0x8053,   0x06  ], # FILLLEVEL1
-                     
-  #Pixel control registers TBD
-  
-  #Multi frame emulation memories TBD
-                            
diff --git a/scripts/conf/CONF_M2-ikf-settings.pl b/scripts/conf/CONF_M2-ikf-settings.pl
new file mode 100644 (file)
index 0000000..5f738e8
--- /dev/null
@@ -0,0 +1,15 @@
+[0x0040,   7], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current                                   
+[0x0041,  15], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current                                   
+[0x0042,  15], #IDB         0 - 40 nA      ,  157 pA     Pixel current                                   
+[0x0043, 171], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage             
+[0x0044,  78], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value) 
+[0x0045, 135], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high        
+[0x0046, 255], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE                         
+[0x0047,  87], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage                                   
+[0x0048, 104], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A         
+[0x0049, 255], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B         
+[0x004a, 255], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C         
+[0x004b, 255], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D         
+[0x004c, 122], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage                                   
+[0x004d,  12], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage                
+[0x004e,  56], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)             
diff --git a/scripts/conf/CONF_VCAS_2.pl b/scripts/conf/CONF_VCAS_2.pl
deleted file mode 100644 (file)
index 8f95fa2..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#read files like my @config = do "CONF_allregisters.pl";
-
-  #General Control
-  [0x0020,         ], #RUNMODE  -> table 8
-  [0x0021,         ], #TRIMDAC  -> table 9
-  [0x0022,         ], #INJCURR  -> table 10
-  [0x0023,         ], #INJVOLT1 -> table 11
-  [0x0024,         ], #INJVOLT2 -> table 12
-  [0x0025,         ], #MONCURR  -> table 13
-  [0x0026,         ], #MONVOLT  -> table 14
-  [0x0027,         ], #CLKGEN1  -> table 15
-  [0x0028,         ], #CLKGEN2  -> table 16
-  [0x0029,         ], #PLL      -> table 17  
-  [0x002a,         ], #PLLLOCK  -> table 18
-  [0x002b,         ], #MONTEMP  -> table 19
-  [0x002c,         ], #SLVSTX   -> table 20
-  [0x002d,         ], #SLVSRX   -> table 21
-  [0x002e,         ], #OUTPUT   -> table 22
-  [0x002f,         ], #MONPWR   -> table 23
-  
-  #DACs
-  [0x0040,         ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
-  [0x0041,         ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
-  [0x0042,         ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
-  [0x0043,         ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
-  [0x0044,         ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
-  [0x0045,         ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
-  [0x0046,         ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
-  [0x0047,         ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x0048,   0x78  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
-  [0x0049,   0x78  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
-  [0x004a,   200   ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
-  [0x004b,   200   ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
-  [0x004c,   175   ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x004d,         ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
-  [0x004e,         ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
-  
-  #Sequencer - 0x0100 registers are upper byte of the word
-  [0x0060,         ], # PIXLOAD_A     0x00
-  [0x0160,         ], #               0x00
-  [0x0070,         ], # PIXLOAD_B     0x01
-  [0x0170,         ], #               0x00
-  [0x0061,         ], # PIXREAD_A     0x00
-  [0x0161,         ], #               0x00
-  [0x0071,         ], # PIXREAD_B     0x97
-  [0x0171,         ], #               0x00
-  [0x0062,         ], # PIXRSTB_A     0x98
-  [0x0162,         ], #               0x00
-  [0x0072,         ], # PIXRSTB_B     0x99
-  [0x0172,         ], #               0x00
-  [0x0063,         ], # DPSTART_A     0x00
-  [0x0163,         ], #               0x00
-  [0x0073,         ], # DPSTART_B     0x01
-  [0x0173,         ], #               0x00
-  [0x0064,         ], # DPTOKEN_A     0x01
-  [0x0164,         ], #               0x00
-  [0x0074,         ], # DPTOKEN_B     0x02
-  [0x0174,         ], #               0x00
-  [0x0065,         ], # DPEND_A       0x98
-  [0x0165,         ], #               0x00
-  [0x0075,         ], # DPEND_B       0x99
-  [0x0175,         ], #               0x00
-  [0x0066,         ], # PIXPULSEA_A   0x00
-  [0x0166,         ], #               0x00
-  [0x0076,         ], # PIXPULSEA_B   0x00
-  [0x0176,         ], #               0x00
-  [0x0067,         ], # PIXPULSED_A   0x00
-  [0x0167,         ], #               0x00
-  [0x0077,         ], # PIXPULSED_B   0x00
-  [0x0177,         ], #               0x00
-  [0x0068,         ], # MKSEQ1_A      0x00
-  [0x0168,         ], #               0x00
-  [0x0078,         ], # MKSEQ1_B      0x02                        
-  [0x0178,         ], #               0x00
-  [0x0069,         ], # MKSEQ2_A      0x00
-  [0x0169,         ], #               0x00
-  [0x0079,         ], # MKSEQ2_B      0x02
-  [0x0179,         ], #               0x00
-  [0x007A,         ], # POLARITY      0x05
-  [0x017A,         ], #               0x00
-  [0x007B,         ], # FRAMELENGTH    100
-  [0x017B,         ], #               0x00
-  [0x007C,         ], # MAXFRAME      0x00
-  [0x017C,         ], #               0x00
-  [0x007D,         ], # MODPULSE      0x00
-  [0x007E,         ], # MODPIXRSTB    0x00
-  [0x007F,         ], # MODMKSEQ1     0x00
-                      
-  #Monitoring (read only)
-  [0x00E0,         ], # MON_POR_LOCK       Power On Rest and PLL lock
-  [0x00E1,         ], # MON_PAD            PADs
-  [0x00E2,         ], # MON_FR_CPT_0       Frame counter bits 7-0
-  [0x00E3,         ], # MON_FR_CPT_1       Frame counter bits 15-8
-  [0x00E4,         ], # MON_FR_CPT_2       Frame counter bits 23-16
-  [0x00E5,         ], # MON_FR_CPT_3       Frame counter bits 31-24
-  [0x00E6,         ], # EV_TMR_SEQ         Triple Modular Redundancy Error in sequencer
-  [0x00E7,         ], # EV_LOCK            PLL lock
-  [0x00E8,         ], # EV_LOCKFILTER      PLL lock after filtering
-  [0x00E9,         ], # EV_POR1            Power On Reset 1
-  [0x00EA,         ], # EV_POR2            Power On Reset 2
-  [0x00EB,         ], # EV_POR3            Power On Reset 3
-  [0x00EC,         ], # EV_RSTB            RSTB pad
-  [0x00ED,         ], # EV_START           START all types (auto, pad, and soft)
-  [0x00EE,         ], # EV_DPSTART         Digital Periphery Start
-  
-  #Analog pixel selection
-  [0x8020,         ], # SEL_ANAPIX0        Analogue Pixel Selection LSB
-  [0x8021,         ], # SEL_ANAPIX1        Analogue Pixel Selection MSB
-  
-  #Readout test configuration
-  [0x8040,         ], # PATTERN0
-  [0x8041,         ], # PATTERN1
-  [0x8042,         ], # PATTERN2
-  [0x8043,         ], # PATTERN3
-  [0x8044,         ], # PATTERN4
-  [0x8045,         ], # PATTERN5
-  [0x8046,         ], # PATTERN6
-  [0x8047,         ], # PATTERN7
-  [0x8048,         ], # PATTERN8
-  [0x8049,         ], # PATTERN9
-  [0x804A,         ], # PATTERN10
-  [0x804B,         ], # PATTERN11
-  [0x804C,         ], # PATTERN12
-  [0x804D,         ], # PATTERN13
-  [0x804E,         ], # PATTERN14
-  [0x804F,         ], # PATTERN15
-  [0x8050,         ], # BANDWIDTH0
-  [0x8051,         ], # BANDWIDTH1
-  [0x8052,         ], # FILLLEVEL0 #custom level at 1536
-  [0x8053,         ], # FILLLEVEL1
-                     
-  #Pixel control registers TBD
-  
-  #Multi frame emulation memories TBD
-                            
diff --git a/scripts/conf/CONF_VCAS_high.pl b/scripts/conf/CONF_VCAS_high.pl
deleted file mode 100644 (file)
index afd6baf..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#read files like my @config = do "CONF_allregisters.pl";
-
-  #General Control
-  [0x0020,         ], #RUNMODE  -> table 8
-  [0x0021,         ], #TRIMDAC  -> table 9
-  [0x0022,         ], #INJCURR  -> table 10
-  [0x0023,         ], #INJVOLT1 -> table 11
-  [0x0024,         ], #INJVOLT2 -> table 12
-  [0x0025,         ], #MONCURR  -> table 13
-  [0x0026,         ], #MONVOLT  -> table 14
-  [0x0027,         ], #CLKGEN1  -> table 15
-  [0x0028,         ], #CLKGEN2  -> table 16
-  [0x0029,         ], #PLL      -> table 17  
-  [0x002a,         ], #PLLLOCK  -> table 18
-  [0x002b,         ], #MONTEMP  -> table 19
-  [0x002c,         ], #SLVSTX   -> table 20
-  [0x002d,         ], #SLVSRX   -> table 21
-  [0x002e,         ], #OUTPUT   -> table 22
-  [0x002f,         ], #MONPWR   -> table 23
-  
-  #DACs
-  [0x0040,         ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
-  [0x0041,         ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
-  [0x0042,         ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
-  [0x0043,         ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
-  [0x0044,         ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
-  [0x0045,         ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
-  [0x0046,         ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
-  [0x0047,         ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x0048,   00   ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
-  [0x0049,   00   ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
-  [0x004a,   00   ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
-  [0x004b,   00   ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
-  [0x004c,   5   ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x004d,         ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
-  [0x004e,         ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
-  
-  #Sequencer - 0x0100 registers are upper byte of the word
-  [0x0060,         ], # PIXLOAD_A     0x00
-  [0x0160,         ], #               0x00
-  [0x0070,         ], # PIXLOAD_B     0x01
-  [0x0170,         ], #               0x00
-  [0x0061,         ], # PIXREAD_A     0x00
-  [0x0161,         ], #               0x00
-  [0x0071,         ], # PIXREAD_B     0x97
-  [0x0171,         ], #               0x00
-  [0x0062,         ], # PIXRSTB_A     0x98
-  [0x0162,         ], #               0x00
-  [0x0072,         ], # PIXRSTB_B     0x99
-  [0x0172,         ], #               0x00
-  [0x0063,         ], # DPSTART_A     0x00
-  [0x0163,         ], #               0x00
-  [0x0073,         ], # DPSTART_B     0x01
-  [0x0173,         ], #               0x00
-  [0x0064,         ], # DPTOKEN_A     0x01
-  [0x0164,         ], #               0x00
-  [0x0074,         ], # DPTOKEN_B     0x02
-  [0x0174,         ], #               0x00
-  [0x0065,         ], # DPEND_A       0x98
-  [0x0165,         ], #               0x00
-  [0x0075,         ], # DPEND_B       0x99
-  [0x0175,         ], #               0x00
-  [0x0066,         ], # PIXPULSEA_A   0x00
-  [0x0166,         ], #               0x00
-  [0x0076,         ], # PIXPULSEA_B   0x00
-  [0x0176,         ], #               0x00
-  [0x0067,         ], # PIXPULSED_A   0x00
-  [0x0167,         ], #               0x00
-  [0x0077,         ], # PIXPULSED_B   0x00
-  [0x0177,         ], #               0x00
-  [0x0068,         ], # MKSEQ1_A      0x00
-  [0x0168,         ], #               0x00
-  [0x0078,         ], # MKSEQ1_B      0x02                        
-  [0x0178,         ], #               0x00
-  [0x0069,         ], # MKSEQ2_A      0x00
-  [0x0169,         ], #               0x00
-  [0x0079,         ], # MKSEQ2_B      0x02
-  [0x0179,         ], #               0x00
-  [0x007A,         ], # POLARITY      0x05
-  [0x017A,         ], #               0x00
-  [0x007B,         ], # FRAMELENGTH    100
-  [0x017B,         ], #               0x00
-  [0x007C,         ], # MAXFRAME      0x00
-  [0x017C,         ], #               0x00
-  [0x007D,         ], # MODPULSE      0x00
-  [0x007E,         ], # MODPIXRSTB    0x00
-  [0x007F,         ], # MODMKSEQ1     0x00
-                      
-  #Monitoring (read only)
-  [0x00E0,         ], # MON_POR_LOCK       Power On Rest and PLL lock
-  [0x00E1,         ], # MON_PAD            PADs
-  [0x00E2,         ], # MON_FR_CPT_0       Frame counter bits 7-0
-  [0x00E3,         ], # MON_FR_CPT_1       Frame counter bits 15-8
-  [0x00E4,         ], # MON_FR_CPT_2       Frame counter bits 23-16
-  [0x00E5,         ], # MON_FR_CPT_3       Frame counter bits 31-24
-  [0x00E6,         ], # EV_TMR_SEQ         Triple Modular Redundancy Error in sequencer
-  [0x00E7,         ], # EV_LOCK            PLL lock
-  [0x00E8,         ], # EV_LOCKFILTER      PLL lock after filtering
-  [0x00E9,         ], # EV_POR1            Power On Reset 1
-  [0x00EA,         ], # EV_POR2            Power On Reset 2
-  [0x00EB,         ], # EV_POR3            Power On Reset 3
-  [0x00EC,         ], # EV_RSTB            RSTB pad
-  [0x00ED,         ], # EV_START           START all types (auto, pad, and soft)
-  [0x00EE,         ], # EV_DPSTART         Digital Periphery Start
-  
-  #Analog pixel selection
-  [0x8020,         ], # SEL_ANAPIX0        Analogue Pixel Selection LSB
-  [0x8021,         ], # SEL_ANAPIX1        Analogue Pixel Selection MSB
-  
-  #Readout test configuration
-  [0x8040,         ], # PATTERN0
-  [0x8041,         ], # PATTERN1
-  [0x8042,         ], # PATTERN2
-  [0x8043,         ], # PATTERN3
-  [0x8044,         ], # PATTERN4
-  [0x8045,         ], # PATTERN5
-  [0x8046,         ], # PATTERN6
-  [0x8047,         ], # PATTERN7
-  [0x8048,         ], # PATTERN8
-  [0x8049,         ], # PATTERN9
-  [0x804A,         ], # PATTERN10
-  [0x804B,         ], # PATTERN11
-  [0x804C,         ], # PATTERN12
-  [0x804D,         ], # PATTERN13
-  [0x804E,         ], # PATTERN14
-  [0x804F,         ], # PATTERN15
-  [0x8050,         ], # BANDWIDTH0
-  [0x8051,         ], # BANDWIDTH1
-  [0x8052,         ], # FILLLEVEL0 #custom level at 1536
-  [0x8053,         ], # FILLLEVEL1
-                     
-  #Pixel control registers TBD
-  
-  #Multi frame emulation memories TBD
-                            
diff --git a/scripts/conf/CONF_allregisters_1Link.pl b/scripts/conf/CONF_allregisters_1Link.pl
deleted file mode 100644 (file)
index 3f84647..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#read files like my @config = do "CONF_allregisters.pl";
-
-  #General Control
-  [0x0020,   0x40  ], #RUNMODE  -> table 8
-  [0x0021,   0x6E  ], #TRIMDAC  -> table 9
-  [0x0022,   0x00  ], #INJCURR  -> table 10
-  [0x0023,   0x00  ], #INJVOLT1 -> table 11
-  [0x0024,   0x00  ], #INJVOLT2 -> table 12
-  [0x0025,   0x00  ], #MONCURR  -> table 13
-  [0x0026,   0x00  ], #MONVOLT  -> table 14
-  [0x0027,   0x01  ], #CLKGEN1  -> table 15
-  [0x0028,   0x01  ], #CLKGEN2  -> table 16
-  [0x0029,   0x16  ], #PLL      -> table 17  
-  [0x002a,   0x00  ], #PLLLOCK  -> table 18
-  [0x002b,   0x00  ], #MONTEMP  -> table 19
-  [0x002c,   0x15  ], #SLVSTX   -> table 20
-  [0x002d,   0x00  ], #SLVSRX   -> table 21
-  [0x002e,   0x14  ], #OUTPUT   -> table 22
-  [0x002f,   0x00  ], #MONPWR   -> table 23
-  
-  #DACs
-  [0x0040,   0x40  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
-  [0x0041,   0x34  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
-  [0x0042,   0x1c  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
-  [0x0043,   0xab  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
-  [0x0044,   0x46  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
-  [0x0045,   0x55  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
-  [0x0046,   0x00  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
-  [0x0047,   0x43  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x0048,   0x78  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
-  [0x0049,   0x78  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
-  [0x004a,   0x78  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
-  [0x004b,   0x60  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
-  [0x004c,   0x3c  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x004d,   0x37  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
-  [0x004e,   0x7d  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
-  
-  #Sequencer - 0x0100 registers are upper byte of the word
-  [0x0060,         ], # PIXLOAD_A     0x00
-  [0x0160,         ], #               0x00
-  [0x0070,         ], # PIXLOAD_B     0x01
-  [0x0170,         ], #               0x00
-  [0x0061,         ], # PIXREAD_A     0x00
-  [0x0161,         ], #               0x00
-  [0x0071,         ], # PIXREAD_B     0x97
-  [0x0171,         ], #               0x00
-  [0x0062,         ], # PIXRSTB_A     0x98
-  [0x0162,         ], #               0x00
-  [0x0072,         ], # PIXRSTB_B     0x99
-  [0x0172,         ], #               0x00
-  [0x0063,         ], # DPSTART_A     0x00
-  [0x0163,         ], #               0x00
-  [0x0073,         ], # DPSTART_B     0x01
-  [0x0173,         ], #               0x00
-  [0x0064,         ], # DPTOKEN_A     0x01
-  [0x0164,         ], #               0x00
-  [0x0074,         ], # DPTOKEN_B     0x02
-  [0x0174,         ], #               0x00
-  [0x0065,         ], # DPEND_A       0x98
-  [0x0165,         ], #               0x00
-  [0x0075,         ], # DPEND_B       0x99
-  [0x0175,         ], #               0x00
-  [0x0066,         ], # PIXPULSEA_A   0x00
-  [0x0166,         ], #               0x00
-  [0x0076,         ], # PIXPULSEA_B   0x00
-  [0x0176,         ], #               0x00
-  [0x0067,         ], # PIXPULSED_A   0x00
-  [0x0167,         ], #               0x00
-  [0x0077,         ], # PIXPULSED_B   0x00
-  [0x0177,         ], #               0x00
-  [0x0068,         ], # MKSEQ1_A      0x00
-  [0x0168,         ], #               0x00
-  [0x0078,         ], # MKSEQ1_B      0x02                        
-  [0x0178,         ], #               0x00
-  [0x0069,         ], # MKSEQ2_A      0x00
-  [0x0169,         ], #               0x00
-  [0x0079,         ], # MKSEQ2_B      0x02
-  [0x0179,         ], #               0x00
-  [0x007A,         ], # POLARITY      0x05
-  [0x017A,         ], #               0x00
-  [0x007B,         ], # FRAMELENGTH    100
-  [0x017B,         ], #               0x00
-  [0x007C,         ], # MAXFRAME      0x00
-  [0x017C,         ], #               0x00
-  [0x007D,         ], # MODPULSE      0x00
-  [0x007E,         ], # MODPIXRSTB    0x00
-  [0x007F,         ], # MODMKSEQ1     0x00
-                      
-  #Monitoring (read only)
-  [0x00E0,         ], # MON_POR_LOCK       Power On Rest and PLL lock
-  [0x00E1,         ], # MON_PAD            PADs
-  [0x00E2,         ], # MON_FR_CPT_0       Frame counter bits 7-0
-  [0x00E3,         ], # MON_FR_CPT_1       Frame counter bits 15-8
-  [0x00E4,         ], # MON_FR_CPT_2       Frame counter bits 23-16
-  [0x00E5,         ], # MON_FR_CPT_3       Frame counter bits 31-24
-  [0x00E6,         ], # EV_TMR_SEQ         Triple Modular Redundancy Error in sequencer
-  [0x00E7,         ], # EV_LOCK            PLL lock
-  [0x00E8,         ], # EV_LOCKFILTER      PLL lock after filtering
-  [0x00E9,         ], # EV_POR1            Power On Reset 1
-  [0x00EA,         ], # EV_POR2            Power On Reset 2
-  [0x00EB,         ], # EV_POR3            Power On Reset 3
-  [0x00EC,         ], # EV_RSTB            RSTB pad
-  [0x00ED,         ], # EV_START           START all types (auto, pad, and soft)
-  [0x00EE,         ], # EV_DPSTART         Digital Periphery Start
-  
-  #Analog pixel selection
-  [0x8020,         ], # SEL_ANAPIX0        Analogue Pixel Selection LSB
-  [0x8021,         ], # SEL_ANAPIX1        Analogue Pixel Selection MSB
-  
-  #Readout test configuration
-  [0x8040,   0xaa  ], # PATTERN0
-  [0x8041,   0xfc  ], # PATTERN1
-  [0x8042,   0xaa  ], # PATTERN2
-  [0x8043,   0xfc  ], # PATTERN3
-  [0x8044,   0xaa  ], # PATTERN4
-  [0x8045,   0xfc  ], # PATTERN5
-  [0x8046,   0xaa  ], # PATTERN6
-  [0x8047,   0xfc  ], # PATTERN7
-  [0x8048,   0xaa  ], # PATTERN8
-  [0x8049,   0xfc  ], # PATTERN9
-  [0x804A,   0xaa  ], # PATTERN10
-  [0x804B,   0xfc  ], # PATTERN11
-  [0x804C,   0xaa  ], # PATTERN12
-  [0x804D,   0xfc  ], # PATTERN13
-  [0x804E,   0xaa  ], # PATTERN14
-  [0x804F,   0xfc  ], # PATTERN15
-  [0x8050,         ], # BANDWIDTH0
-  [0x8051,         ], # BANDWIDTH1
-  [0x8052,   0x00  ], # FILLLEVEL0 #custom level at 1536
-  [0x8053,   0x06  ], # FILLLEVEL1
-                     
-  #Pixel control registers TBD
-  
-  #Multi frame emulation memories TBD
-                            
diff --git a/scripts/conf/CONF_dac.pl b/scripts/conf/CONF_dac.pl
deleted file mode 100644 (file)
index b384337..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-[0x0040,  64], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current                                   
-[0x0041,  52], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current                                   
-[0x0042,  28], #IDB         0 - 40 nA      ,  157 pA     Pixel current                                   
-[0x0043, 171], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage             
-[0x0044,  70], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value) 
-[0x0045, 188], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high        
-[0x0046, 254], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE                         
-[0x0047, 144], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage                                   
-[0x0048, 131], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A         
-[0x0049,   0], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B         
-[0x004a,   0], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C         
-[0x004b,   0], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D         
-[0x004c, 127], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage                                   
-[0x004d,  55], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage                
-[0x004e, 125], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)             
diff --git a/scripts/conf/CONF_dac_M47.pl b/scripts/conf/CONF_dac_M47.pl
deleted file mode 100644 (file)
index b384337..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-[0x0040,  64], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current                                   
-[0x0041,  52], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current                                   
-[0x0042,  28], #IDB         0 - 40 nA      ,  157 pA     Pixel current                                   
-[0x0043, 171], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage             
-[0x0044,  70], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value) 
-[0x0045, 188], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high        
-[0x0046, 254], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE                         
-[0x0047, 144], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage                                   
-[0x0048, 131], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A         
-[0x0049,   0], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B         
-[0x004a,   0], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C         
-[0x004b,   0], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D         
-[0x004c, 127], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage                                   
-[0x004d,  55], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage                
-[0x004e, 125], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)             
index 275ac27fc73609bb032e2f21b8855ca292cd641b..8e160186e9742d9304143ae6abc59682f88d4244 100644 (file)
@@ -1,23 +1,3 @@
-#read files like my @config = do "CONF_allregisters.pl";
-
-  #General Control
-  [0x0020,     ], #RUNMODE  -> table 8
-  [0x0021,     ], #TRIMDAC  -> table 9
-  [0x0022,     ], #INJCURR  -> table 10
-  [0x0023,     ], #INJVOLT1 -> table 11
-  [0x0024,     ], #INJVOLT2 -> table 12
-  [0x0025,     ], #MONCURR  -> table 13
-  [0x0026,     ], #MONVOLT  -> table 14
-  [0x0027,     ], #CLKGEN1  -> table 15
-  [0x0028,     ], #CLKGEN2  -> table 16
-  [0x0029,     ], #PLL      -> table 17  
-  [0x002a,     ], #PLLLOCK  -> table 18
-  [0x002b,     ], #MONTEMP  -> table 19
-  [0x002c,     ], #SLVSTX   -> table 20
-  [0x002d,     ], #SLVSRX   -> table 21
-  [0x002e,     ], #OUTPUT   -> table 22
-  [0x002f,     ], #MONPWR   -> table 23
-  
   #DACs
   [0x0040,   0x40  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
   [0x0041,   0x34  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
   [0x004c,   0x3c  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
   [0x004d,   0x37  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
   [0x004e,   0x7d  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
-  
-  #Sequencer - 0x0100 registers are upper byte of the word
-  [0x0060,         ], # PIXLOAD_A     0x00
-  [0x0160,         ], #               0x00
-  [0x0070,         ], # PIXLOAD_B     0x01
-  [0x0170,         ], #               0x00
-  [0x0061,         ], # PIXREAD_A     0x00
-  [0x0161,         ], #               0x00
-  [0x0071,         ], # PIXREAD_B     0x97
-  [0x0171,         ], #               0x00
-  [0x0062,         ], # PIXRSTB_A     0x98
-  [0x0162,         ], #               0x00
-  [0x0072,         ], # PIXRSTB_B     0x99
-  [0x0172,         ], #               0x00
-  [0x0063,         ], # DPSTART_A     0x00
-  [0x0163,         ], #               0x00
-  [0x0073,         ], # DPSTART_B     0x01
-  [0x0173,         ], #               0x00
-  [0x0064,         ], # DPTOKEN_A     0x01
-  [0x0164,         ], #               0x00
-  [0x0074,         ], # DPTOKEN_B     0x02
-  [0x0174,         ], #               0x00
-  [0x0065,         ], # DPEND_A       0x98
-  [0x0165,         ], #               0x00
-  [0x0075,         ], # DPEND_B       0x99
-  [0x0175,         ], #               0x00
-  [0x0066,         ], # PIXPULSEA_A   0x00
-  [0x0166,         ], #               0x00
-  [0x0076,         ], # PIXPULSEA_B   0x00
-  [0x0176,         ], #               0x00
-  [0x0067,         ], # PIXPULSED_A   0x00
-  [0x0167,         ], #               0x00
-  [0x0077,         ], # PIXPULSED_B   0x00
-  [0x0177,         ], #               0x00
-  [0x0068,         ], # MKSEQ1_A      0x00
-  [0x0168,         ], #               0x00
-  [0x0078,         ], # MKSEQ1_B      0x02                        
-  [0x0178,         ], #               0x00
-  [0x0069,         ], # MKSEQ2_A      0x00
-  [0x0169,         ], #               0x00
-  [0x0079,         ], # MKSEQ2_B      0x02
-  [0x0179,         ], #               0x00
-  [0x007A,         ], # POLARITY      0x05
-  [0x017A,         ], #               0x00
-  [0x007B,         ], # FRAMELENGTH    100
-  [0x017B,         ], #               0x00
-  [0x007C,         ], # MAXFRAME      0x00
-  [0x017C,         ], #               0x00
-  [0x007D,         ], # MODPULSE      0x00
-  [0x007E,         ], # MODPIXRSTB    0x00
-  [0x007F,         ], # MODMKSEQ1     0x00
-                      
-  #Monitoring (read only)
-  [0x00E0,         ], # MON_POR_LOCK       Power On Rest and PLL lock
-  [0x00E1,         ], # MON_PAD            PADs
-  [0x00E2,         ], # MON_FR_CPT_0       Frame counter bits 7-0
-  [0x00E3,         ], # MON_FR_CPT_1       Frame counter bits 15-8
-  [0x00E4,         ], # MON_FR_CPT_2       Frame counter bits 23-16
-  [0x00E5,         ], # MON_FR_CPT_3       Frame counter bits 31-24
-  [0x00E6,         ], # EV_TMR_SEQ         Triple Modular Redundancy Error in sequencer
-  [0x00E7,         ], # EV_LOCK            PLL lock
-  [0x00E8,         ], # EV_LOCKFILTER      PLL lock after filtering
-  [0x00E9,         ], # EV_POR1            Power On Reset 1
-  [0x00EA,         ], # EV_POR2            Power On Reset 2
-  [0x00EB,         ], # EV_POR3            Power On Reset 3
-  [0x00EC,         ], # EV_RSTB            RSTB pad
-  [0x00ED,         ], # EV_START           START all types (auto, pad, and soft)
-  [0x00EE,         ], # EV_DPSTART         Digital Periphery Start
-  
-  #Analog pixel selection
-  [0x8020,         ], # SEL_ANAPIX0        Analogue Pixel Selection LSB
-  [0x8021,         ], # SEL_ANAPIX1        Analogue Pixel Selection MSB
-  
-  #Readout test configuration
-  [0x8040,     ], # PATTERN0
-  [0x8041,     ], # PATTERN1
-  [0x8042,     ], # PATTERN2
-  [0x8043,     ], # PATTERN3
-  [0x8044,     ], # PATTERN4
-  [0x8045,     ], # PATTERN5
-  [0x8046,     ], # PATTERN6
-  [0x8047,     ], # PATTERN7
-  [0x8048,     ], # PATTERN8
-  [0x8049,     ], # PATTERN9
-  [0x804A,     ], # PATTERN10
-  [0x804B,     ], # PATTERN11
-  [0x804C,     ], # PATTERN12
-  [0x804D,     ], # PATTERN13
-  [0x804E,     ], # PATTERN14
-  [0x804F,     ], # PATTERN15
-  [0x8050,     ], # BANDWIDTH0
-  [0x8051,     ], # BANDWIDTH1
-  [0x8052,     ], # FILLLEVEL0 #custom level at 1536
-  [0x8053,     ], # FILLLEVEL1
-                     
-  #Pixel control registers TBD
-  
-  #Multi frame emulation memories TBD
-                            
diff --git a/scripts/conf/CONF_linktest.pl b/scripts/conf/CONF_linktest.pl
deleted file mode 100644 (file)
index f500df6..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#read files like my @config = do "CONF_allregisters.pl";
-
-  #General Control
-  [0x002e,   0x05  ], #OUTPUT   -> table 22
-  
-                            
diff --git a/scripts/conf/CONF_seq.pl b/scripts/conf/CONF_seq.pl
deleted file mode 100644 (file)
index 2a26802..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#read files like my @config = do "CONF_allregisters.pl";
-
-  #General Control
-  [0x0020,         ], #RUNMODE  -> table 8
-  [0x0021,         ], #TRIMDAC  -> table 9
-  [0x0022,         ], #INJCURR  -> table 10
-  [0x0023,         ], #INJVOLT1 -> table 11
-  [0x0024,         ], #INJVOLT2 -> table 12
-  [0x0025,         ], #MONCURR  -> table 13
-  [0x0026,         ], #MONVOLT  -> table 14
-  [0x0027,         ], #CLKGEN1  -> table 15
-  [0x0028,         ], #CLKGEN2  -> table 16
-  [0x0029,         ], #PLL      -> table 17
-  [0x002a,         ], #PLLLOCK  -> table 18
-  [0x002b,         ], #MONTEMP  -> table 19
-  [0x002c,         ], #SLVSTX   -> table 20
-  [0x002d,         ], #SLVSRX   -> table 21
-  [0x002e,  0x77   ], #OUTPUT   -> table 22
-  [0x002f,         ], #MONPWR   -> table 23
-  
-  #DACs
-  [0x0040,         ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
-  [0x0041,         ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
-  [0x0042,         ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
-  [0x0043,         ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
-  [0x0044,         ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
-  [0x0045,         ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
-  [0x0046,         ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
-  [0x0047,         ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x0048,         ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
-  [0x0049,         ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
-  [0x004a,         ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
-  [0x004b,         ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
-  [0x004c,         ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
-  [0x004d,         ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
-  [0x004e,         ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
-  
-  #Sequencer - 0x0100 registers are upper byte of the word
-  [0x0060,         ], # PIXLOAD_A     0x00
-  [0x0160,         ], #               0x00
-  [0x0070,         ], # PIXLOAD_B     0x01
-  [0x0170,         ], #               0x00
-  [0x0061,         ], # PIXREAD_A     0x00
-  [0x0161,         ], #               0x00
-  [0x0071,         ], # PIXREAD_B     0x97
-  [0x0171,         ], #               0x00
-  [0x0062,         ], # PIXRSTB_A     0x98
-  [0x0162,         ], #               0x00
-  [0x0072,         ], # PIXRSTB_B     0x99
-  [0x0172,         ], #               0x00
-  [0x0063,         ], # DPSTART_A     0x00
-  [0x0163,         ], #               0x00
-  [0x0073,         ], # DPSTART_B     0x01
-  [0x0173,         ], #               0x00
-  [0x0064,         ], # DPTOKEN_A     0x01
-  [0x0164,         ], #               0x00
-  [0x0074,         ], # DPTOKEN_B     0x02
-  [0x0174,         ], #               0x00
-  [0x0065,         ], # DPEND_A       0x98
-  [0x0165,         ], #               0x00
-  [0x0075,         ], # DPEND_B       0x99
-  [0x0175,         ], #               0x00
-  [0x0066,         ], # PIXPULSEA_A   0x00
-  [0x0166,         ], #               0x00
-  [0x0076,         ], # PIXPULSEA_B   0x00
-  [0x0176,         ], #               0x00
-  [0x0067,         ], # PIXPULSED_A   0x00
-  [0x0167,         ], #               0x00
-  [0x0077,         ], # PIXPULSED_B   0x00
-  [0x0177,         ], #               0x00
-  [0x0068, 0x01    ], # MKSEQ1_A      0x00
-  [0x0168, 0x00    ], #               0x00
-  [0x0078, 0x02    ], # MKSEQ1_B      0x02                        
-  [0x0178, 0x00    ], #               0x00
-  [0x0069, 0x01    ], # MKSEQ2_A      0x00
-  [0x0169, 0x00    ], #               0x00
-  [0x0079, 0x02    ], # MKSEQ2_B      0x02
-  [0x0179, 0x00    ], #               0x00
-  [0x007A,    0    ], # POLARITY      0x05
-  [0x017A,    0    ], #               0x00
-  [0x007B,    2    ], # FRAMELENGTH    100
-  [0x017B,         ], #               0x00
-  [0x007C,    0    ], # MAXFRAME      0x00
-  [0x017C,         ], #               0x00
-  [0x007D,         ], # MODPULSE      0x00
-  [0x007E,         ], # MODPIXRSTB    0x00
-  [0x007F, 0x02    ], # MODMKSEQ1     0x00
-                      
-  #Monitoring (read only)
-  [0x00E0,         ], # MON_POR_LOCK       Power On Rest and PLL lock
-  [0x00E1,         ], # MON_PAD            PADs
-  [0x00E2,         ], # MON_FR_CPT_0       Frame counter bits 7-0
-  [0x00E3,         ], # MON_FR_CPT_1       Frame counter bits 15-8
-  [0x00E4,         ], # MON_FR_CPT_2       Frame counter bits 23-16
-  [0x00E5,         ], # MON_FR_CPT_3       Frame counter bits 31-24
-  [0x00E6,         ], # EV_TMR_SEQ         Triple Modular Redundancy Error in sequencer
-  [0x00E7,         ], # EV_LOCK            PLL lock
-  [0x00E8,         ], # EV_LOCKFILTER      PLL lock after filtering
-  [0x00E9,         ], # EV_POR1            Power On Reset 1
-  [0x00EA,         ], # EV_POR2            Power On Reset 2
-  [0x00EB,         ], # EV_POR3            Power On Reset 3
-  [0x00EC,         ], # EV_RSTB            RSTB pad
-  [0x00ED,         ], # EV_START           START all types (auto, pad, and soft)
-  [0x00EE,         ], # EV_DPSTART         Digital Periphery Start
-  
-  #Analog pixel selection
-  [0x8020,         ], # SEL_ANAPIX0        Analogue Pixel Selection LSB
-  [0x8021,         ], # SEL_ANAPIX1        Analogue Pixel Selection MSB
-  
-  #Readout test configuration
-  [0x8040,         ], # PATTERN0
-  [0x8041,         ], # PATTERN1
-  [0x8042,         ], # PATTERN2
-  [0x8043,         ], # PATTERN3
-  [0x8044,         ], # PATTERN4
-  [0x8045,         ], # PATTERN5
-  [0x8046,         ], # PATTERN6
-  [0x8047,         ], # PATTERN7
-  [0x8048,         ], # PATTERN8
-  [0x8049,         ], # PATTERN9
-  [0x804A,         ], # PATTERN10
-  [0x804B,         ], # PATTERN11
-  [0x804C,         ], # PATTERN12
-  [0x804D,         ], # PATTERN13
-  [0x804E,         ], # PATTERN14
-  [0x804F,         ], # PATTERN15
-  [0x8050,         ], # BANDWIDTH0
-  [0x8051,         ], # BANDWIDTH1
-  [0x8052,         ], # FILLLEVEL0 #custom level at 1536
-  [0x8053,         ], # FILLLEVEL1
-                     
-  #Pixel control registers TBD
-  
-  #Multi frame emulation memories TBD
-                            
index 9831f7e62b9791e04b833edd1fe417b6bf8e67a7..e1a408bfd3c825e7d05cb8594cf6e9947b3b5f53 100644 (file)
@@ -16,4 +16,5 @@
   [0x804D,   0xfc  ], # PATTERN13
   [0x804E,   0xaa  ], # PATTERN14
   [0x804F,   0xfc  ], # PATTERN15
-  [0x0020,   0x48  ], #
+
+  [0x0020,   0x48  ],
diff --git a/scripts/legacy/adc_i2c_cmd.pl_ b/scripts/legacy/adc_i2c_cmd.pl_
new file mode 100755 (executable)
index 0000000..d8cfaef
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -I.
+
+use warnings;
+use Getopt::Long;
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+use lib ".";
+use Mimosis;
+
+my ( $fpga, $addr, $cmd, $cmd_t, $data, $data_t, $word );
+
+Getopt::Long::Configure(qw(gnu_getopt));
+GetOptions(
+    "fpga|f=s" => \$fpga,
+    "addr|a=s" => \$addr,
+    "cmd|c=s"  => \$cmd_t,
+    "data|d=s" => \$data_t,
+    "word|w"   => \$word,
+);
+
+trb_init_ports() or die trb_strerror();
+
+defined($fpga) ? $fpga = hex($fpga) : die print("Must provide FPGA address.\n");
+defined($addr) ? $addr = hex($addr) : die print("Must provide I2C address.\n");
+$cmd  = defined($cmd_t)  ? hex($cmd_t)  : 0x0;
+$data = defined($data_t) ? hex($data_t) : 0x0;
+
+$val =
+  Mimosis::adc_i2c_command( $fpga, $addr, $cmd, $data, !defined($data_t),
+    !defined($cmd_t), defined($word) );
+if ( not defined($data_t) ) {
+    printf( "%x\n", $val );
+}
similarity index 87%
rename from scripts/qa/FFM2/DACscan.py
rename to scripts/legacy/qa/DACscan.py
index f0de24758b3510e5f45db7d6e0d0d626d76de70a..166772067145c5fd24fe20a80463ccf4d276fab8 100644 (file)
@@ -33,8 +33,8 @@ class DACScan():
     vResetList = readFile('dacscan_data/VRESET.csv')
     vPhfList = readFile('dacscan_data/VPH_FINE.csv')
     
-    for elements in range(1,256):
-        vPhfList[elements - 1] = vPhfList[elements-1] - vPhList[0]
+    for elements in range(len(vPhfList)):
+        vPhfList[elements] = vPhfList[elements] - vPhList[0]
     
     vCasnaList = readFile('dacscan_data/VCASNA.csv')
     vCasnbList = readFile('dacscan_data/VCASNB.csv')
@@ -96,8 +96,26 @@ class DACScan():
             if (goodDNL and goodINL):
                 sensorQuality = 1
                 
+    VPhfSlope = (vPhfList[255] - vPhfList[0]) / 255.
+    
+    print(vPhfList[255])
+    print(vPhfList[0])
+    SixtyElectronVPHSetting = 0
+    Offset = 0
+    
+    for i in range(len(vPhList)):
+        if (55. <= (vPhList[i] - vPlList[70]) <= 65.):
+            SixtyElectronVPHSetting = i
+            Offset = vPhList[i] - vPlList[70]
+            break
+            
+    
+    
+    
     print("Sensor Quality for DACs is: " + str(sensorQuality))
     f = open("results.db", "a")
-    f.write("DAC quality\t" + str(sensorQuality))
+    f.write("DAC quality\t" + str(sensorQuality) + "\n")
+    f.write("VPHFSlope\t" + str(VPhfSlope) + "\n")
+    f.write("VPHSetting60Electrons\t" + str(SixtyElectronVPHSetting) + "\t" + str(Offset) + "\n")
     f.close()
     
diff --git a/scripts/legacy/qa/QAScript_old.pl b/scripts/legacy/qa/QAScript_old.pl
new file mode 100755 (executable)
index 0000000..6aecc60
--- /dev/null
@@ -0,0 +1,617 @@
+#!/usr/bin/perl
+use HADES::TrbNet;
+use lib "/d/jspc37/mimosis/scripts/";
+use Mimosis;
+use Time::HiRes qw(usleep);
+use POSIX;
+
+
+
+
+$fpgalink = 0xa001;
+$singleaccessmode = 1;
+$slow = 1000;
+
+trb_init_ports() or die trb_strerror();
+
+my %reglist = (
+    3  => 0x004c,       # default value right of =>. Left of =>: Register number, for example in hex.
+    4  => 0x0047,
+    5  => 0x004d,
+    7  => 0x0048,
+    8  => 0x0049,
+    9  => 0x004a,
+    10 => 0x004b,
+);
+
+my %testwordlist = (
+    3  => 0x004c,       # default value right of =>. Left of =>: Register number, for example in hex.
+    4  => 0x0047,
+    5  => 0x004d,
+    7  => 0x0048,
+    8  => 0x0049,
+    9  => 0x004a,
+    10 => 0x004b,
+);
+
+
+for my $regs ( keys %reglist ) {
+
+    for my $testwords ( keys %testwordlist ) {
+        Mimosis::mimosis_register_write( $fpgalink, $regs, $testwords, $singleaccessmode ); usleep($slow); # write value into register
+        my $val = Mimosis::mimosis_register_read( $fpgalink, $regs, $singleaccessmode ); usleep($slow); # 
+        if ( $val != $testwords ) {
+            print("$testwords != $val\n");
+        }
+        Mimosis::mimosis_register_write( $fpgalink, $regs, $reglist{$regs}, $singleaccessmode ); usleep($slow);
+    }
+}
+
+print "Welcome to the MIMOSIS QA Script.\n";
+print "Please enter your name: ";
+my $operatorname = <STDIN>;
+chomp $operatorname;
+
+print "Please enter a sensor name.\n";
+print "This will be used as a directory to save the acumulated data.\n";
+print "\n";
+
+my $sensnamecheck = 1;
+my $sensorname = "aaa";
+
+while ($sensnamecheck) {                        # Perform loop until a good name is found, i.e. it has never been assigned or is not empty
+    print "Enter the sensor name: ";
+    $sensorname = <STDIN>;
+    chomp $sensorname;
+
+    if (-d $sensorname or $sensorname eq "") {  # Check for bad names.
+        print "Sensor name already chosen. Choose new one...\n";
+    }
+
+    else {
+    my $message_makedir = <<"END_MESSAGE";
+mkdir $sensorname;
+END_MESSAGE
+    system $message_makedir;                    # Make folder for data
+    $sensnamecheck = 0;                         # Quit loop
+    my $message_changedir_and_makefile = <<"END_MESSAGE";
+cd $sensorname;
+touch results.db;
+echo \"Operatorname\t$operatorname\" >> results.db;
+echo \"Sensorname\t$sensorname\" >> results.db;
+END_MESSAGE
+    system $message_changedir_and_makefile;
+    }
+}
+
+my $irradtest = 1;
+my $irraddeg = 10000;
+
+do {
+    print "Please enter sensor $sensorname TID dose in kRad: ";
+    $irraddeg = <STDIN>;
+    chomp $irraddeg;
+    
+    if ($irraddeg =~ /^\d{1,4}$/ ) # Check if numeric and within good current range, all ok
+    {
+        print "You have entered a TID dose of $digitalcur kRad.\n";
+        print "This was accepted.\n";
+        $irradtest = 0;
+    }
+    
+    else 
+    {
+        print "You have entered an invalid value (letters, out of range dose, ...)\n";
+        print "Please try again.\n";
+    }
+    
+    
+} while ($irradtest eq 1);
+
+my $bbtest = 1;
+my $backbias = 10000;
+
+do {
+    print "Please enter sensor $sensorname backbias in mV: ";
+    $backbias = <STDIN>;
+    chomp $backbias;
+    
+    if ($backbias =~ /^\d{1,4}$/  && $backbias <= 6000 && $backbias >= 0) # Check if numeric and within good range, all ok
+    {
+        print "You have entered a backbias of $digitalcur mV.\n";
+        print "This was accepted.\n";
+        $bbtest = 0;
+    }
+    
+    else 
+    {
+        print "You have entered an invalid value (letters, out of range voltage, ...)\n";
+        print "It should be between 0 and 6000 mV.\n";
+        print "Please try again.\n";
+    }
+    
+    
+} while ($bbtest eq 1);
+
+#Program sensor and find how many good links
+
+my $message_program_and_link = <<"END_MESSAGE";
+/d/jspc37/mimosis/scripts/start.sh;
+END_MESSAGE
+    system $message_program_and_link;
+
+trb_init_ports() or die trb_strerror();
+my $reg0 = trb_register_read( $fpgalink, 0xa000 );
+$reg0 = ( $reg0->{$fpgalink} & 0x7f00 ) >> 8;
+
+my $reg1 = trb_register_read( $fpgalink, 0xa001 );
+$reg1 = ( $reg1->{$fpgalink} & 0x7f00 ) >> 8;
+
+my $reg2 = trb_register_read( $fpgalink, 0xa002 );
+$reg2 = ( $reg2->{$fpgalink} & 0x7f00 ) >> 8;
+
+my $reg3 = trb_register_read( $fpgalink, 0xa003 );
+$reg3 = ( $reg3->{$fpgalink} & 0x7f00 ) >> 8;
+
+my $reg4 = trb_register_read( $fpgalink, 0xa004 );
+$reg4 = ( $reg4->{$fpgalink} & 0x7f00 ) >> 8;
+
+my $reg5 = trb_register_read( $fpgalink, 0xa005 );
+$reg5 = ( $reg5->{$fpgalink} & 0x7f00 ) >> 8;
+
+my $reg6 = trb_register_read( $fpgalink, 0xa006 );
+$reg6 = ( $reg6->{$fpgalink} & 0x7f00 ) >> 8;
+
+my $reg7 = trb_register_read( $fpgalink, 0xa007 );
+$reg7 = ( $reg7->{$fpgalink} & 0x7f00 ) >> 8;
+
+if ($reg0 >= 70) { 
+    print("All sensor links broken. Sensor rated faulty.\n");
+    my $message_all_links_broken = <<"END_MESSAGE";
+cd $sensorname;
+touch results.db;
+echo \"LinksWorking\tF\t0\" >> results.db;
+END_MESSAGE
+    system $message_all_links_broken;
+    exit 0;
+}
+#
+#elsif ($reg4 >= 30) { 
+#    print("One sensor link working. Sensor rated faulty.\n");
+#    print("Can be set aside for education purposes.\n");
+#    my $message_first_link_broken = <<"END_MESSAGE";
+#cd $sensorname;
+#touch results.db;
+#echo \"LinksWorking\tF\t1\" >> results.db;
+#END_MESSAGE
+#    system $message_first_link_broken;
+#    exit 0;
+#}
+#
+#elsif ($reg2 >= 30 or $reg6 >= 30) { 
+#    print("Two sensors link working. Sensor rated bronze.\n");
+#    my $message_second_links_broken = <<"END_MESSAGE";
+#cd $sensorname;
+#touch results.db;
+#echo \"LinksWorking\tB\t2\" >> results.db;
+#END_MESSAGE
+#    system $message_second_links_broken;
+#}
+#
+#elsif ($reg1 >= 30 or $reg3 >= 30 or $reg5 >= 30 or $reg7 >= 30) { 
+#    print("Four sensor links working. Sensor rated silver.\n");
+#    my $message_third_links_broken = <<"END_MESSAGE";
+#cd $sensorname;
+#touch results.db;
+#echo \"LinksWorking\tS\t4\" >> results.db;
+#END_MESSAGE
+#    system $message_third_links_broken;
+#}
+#
+#else {
+#    print("All sensor links working. Sensor rated gold.\n");
+#    my $message_no_links_broken = <<"END_MESSAGE";
+#cd $sensorname;
+#touch results.db;
+#echo \"LinksWorking\tG\t8\" >> results.db;
+#END_MESSAGE
+#    system $message_no_links_broken;
+#}
+
+#Find out current drawn by sensor on digital and perform data checks.
+my $lowleveldig = 100;                          # Minimum digital current for passing as ok
+my $highleveldig = 200;                         # Maximum digital current for passing as ok
+my $digicurcheck = 0;
+print "Please enter sensor $sensorname digital current in mA.\n";
+print "Round to the closest full number.\n";
+my $digitalcur = 0;
+my $digicounter = 1;
+
+do {
+    if ($digitalcur eq 0) {
+        print "Enter sensor $sensorname digital current in mA now: ";   
+        $digitalcur = <STDIN>;
+        chomp $digitalcur;
+    }
+    
+    if ($digitalcur =~ /^\d{1,4}$/ && $digitalcur <= $highleveldig && $digitalcur >= $lowleveldig) # Check if numeric and within good current range, all ok
+    {
+        $digicurcheck = 1;
+        print "You have entered a digital current of $digitalcur mA.\n";
+        print "This was accepted.\n";
+    }
+
+
+    elsif ($digitalcur =~ /^\d{1,4}$/ && ($digitalcur >= $highleveldig || $digitalcur <= $lowleveldig)) # Check if numeric and outside good current range, not ok, retry up to 4 further times
+    {
+        print "You have entered a digital current of $digitalcur mA.\n"; 
+        print "This is outside of the sensors specifications: $lowleveldig - $highleveldig mA.\n"; 
+        print "Make sure your connection is proper now.\n";
+        print "If you find a better connection, enter new current now.\n";
+        print "If not, confirm by pressing F. The sensor will be instantly rated faulty.\n";
+        print "You can redo the test later, but you have to delete the subfolder $sensorname first.\n";
+        print "Enter your choice now (current (mA)/F): ";
+        my $digicurcorr = <STDIN>;
+        chomp $digicurcorr;
+        
+        if ($digicurcorr =~ /^\d{1,4}$/)
+        {
+            $digitalcur = $digicurcorr;
+            $digicounter += 1;
+            break;
+        }
+        elsif ($digicurcorr eq 'F' || $digicurcorr eq 'f') { # Wilfull termination of program as sensor has bad digital current consumption.
+            $digicurcheck = 1;
+            my $message_write_digicur = <<"END_MESSAGE";
+cd $sensorname;
+echo \"Digitalcurrent\tF\t$digitalcur\" >> results.db;
+END_MESSAGE
+    system $message_write_digicur;
+            exit 0;                     # End because set as F
+        }
+        else {                          # When something entered is not F or numeric
+        $digicurcheck = 0;
+        $digitalcur = $digicurcorr;
+        print "Not a valid number, try again.\n"; 
+        print "Make sure that it is between 1 and 9999 mA.\n";
+        }
+           
+    }
+    
+    else                                # All other cases not considered.
+    {
+        $digicurcheck = 0;
+        $digitalcur = 0;
+        print "Not a valid number, try again.\n"; 
+        print "Make sure that it is between 1 and 9999 mA.\n";
+    }
+    
+
+} while ($digicurcheck == 0 && $digicounter lt 5);
+
+
+
+if ($digicounter eq 5) {                # Terminate program because too many tries gone wrong on entering digital current
+    print "You have reached the maximum tries of entering a digital current for sensor $sensorname.\n";
+    print "Try to clean the probe setup (Needles, etc?). If you get a current between $lowleveldig - $highleveldig mA, try again.\n";
+    print "To do this, you will have to delete the folder $sensorname, as the sensor is currently rated FAULTY.\n";
+    print "END OF PROGRAM, SENSOR STATUS F due to DIGITAL CURRENT.\n";
+    my $message_write_digicur = <<"END_MESSAGE";
+cd $sensorname;
+echo \"Digitalcurrent\tF\t$digitalcur\" >> results.db;
+END_MESSAGE
+    system $message_write_digicur;
+    
+    exit 0;                             # End because too many attempts to enter digital current.
+}
+
+my $message_write_digicur = <<"END_MESSAGE";
+cd $sensorname;
+echo \"Digitalcurrent\tS\t$digitalcur\" >> results.db;
+END_MESSAGE
+    system $message_write_digicur;
+
+#Find out current drawn by sensor on analog and perform data checks.
+my $lowlevelana = 10;                          # Minimum analog current for passing as ok
+my $highlevelana = 80;                         # Maximum analog current for passing as ok
+my $anacurcheck = 0;
+print "Please enter sensor $sensorname analog current in mA.\n";
+print "Round to the closest full number.\n";
+my $analogcur = 0;
+
+my $anacounter = 1;
+
+do {
+
+    if ($analogcur eq 0) {
+        print "Enter sensor $sensorname analog current in mA now: ";   
+        $analogcur = <STDIN>;
+        chomp $analogcur;
+    }
+    
+    
+    if ($analogcur =~ /^\d{1,3}$/ && $analogcur <= $highlevelana && $analogcur >= $lowlevelana) # Check if numeric and within good current range, all ok
+    {
+        $anacurcheck = 1;
+        print "You have entered a analog current of $analogcur mA.\n";
+        print "This was accepted.\n";
+    }
+
+
+    elsif ($analogcur =~ /^\d{1,3}$/ && ($analogcur >= $highlevelana || $analogcur <= $lowlevelana)) # Check if numeric and outside good current range, not ok, retry up to 4 further times
+    {
+        print "You have entered a analog current of $analogcur mA.\n"; 
+        print "This is outside of the sensors specifications: $lowlevelana - $highlevelana mA.\n"; 
+        print "Make sure your connection is proper now.\n";
+        print "If you find a better connection, enter new current now.\n";
+        print "If not, confirm by pressing F. The sensor will be instantly rated faulty.\n";
+        print "You can redo the test later, but you have to delete the subfolder $sensorname first.\n";
+        print "Enter your choice now (current (mA)/F): ";
+        my $anacurcorr = <STDIN>;
+        chomp $anacurcorr;
+        
+        if ($anacurcorr =~ /^\d{1,3}$/)
+        {
+            $analogcur = $anacurcorr;
+            $anacounter += 1;
+            break;
+        }
+        elsif ($anacurcorr eq 'F' || $anacurcorr eq 'f') { # Wilfull termination of program as sensor has bad analog current consumption.
+            $anacurcheck = 1;
+            my $message_write_anacur = <<"END_MESSAGE";
+cd $sensorname;
+echo \"Analogcurrent\tF\t$anacur\" >> results.db;
+END_MESSAGE
+    system $message_write_anacur;
+            exit 0;                     # End because set as F
+        }
+        else {                          # When something entered is not F or numeric
+        $anacurcheck = 0;
+        $analogcur = $anacurcorr;
+        print "Not a valid number, try again.\n"; 
+        print "Make sure that it is between 1 and 999 mA.\n";
+        }
+           
+    }
+    
+    else                                # All other cases not considered.
+    {
+        $anacurcheck = 0;
+        print "Not a valid number, try again.\n"; 
+        print "Make sure that it is between 1 and 999 mA.\n";
+    }
+    
+
+} while ($anacurcheck == 0 && $anacounter lt 5);
+
+if ($anacounter eq 5) {                 # Terminate program because too many tries gone wrong on entering analog current
+    print "You have reached the maximum tries of entering an analog current for sensor $sensorname.\n";
+    print "Try to clean the probe setup (Needles, etc?). If you get a current between $lowlevelana - $highlevelana mA, try again.\n";
+    print "To do this, you will have to delete the folder $sensorname, as the sensor is currently rated FAULTY.\n";
+    print "END OF PROGRAM, SENSOR STATUS F due to ANALOG CURRENT.\n";
+    my $message_write_anacur = <<"END_MESSAGE";
+cd $sensorname;
+echo \"Analogcurrent\tF\t$anacur\" >> results.db;
+END_MESSAGE
+    system $message_write_anacur;
+    
+    exit 0;                             # End because too many attempts to enter analog current.
+}
+
+my $message_write_anacur = <<"END_MESSAGE";
+cd $sensorname;
+echo \"Analogcurrent\tS\t$anacur\" >> results.db;
+END_MESSAGE
+    system $message_write_anacur;
+
+print "\n";
+print "Proceeding to preliminary DAC scans...\n";
+print "Validate that results from VPulseHigh, VPulseLow and VReset are in the steep grey area.\n";
+print "Validate that result from VPulseHighFine is in the gently inclined grey area.\n";
+
+
+my $message_quickdacscan = <<"END_MESSAGE";
+./dac.pl --p $sensorname
+cd $sensorname/
+display $sensorname.png &
+END_MESSAGE
+system $message_quickdacscan;
+
+print "Please enter rapid DAC scan result classification.\n";
+print "S = satisfactory if in grey areas, otherwise F = unsatisfactory.\n";
+print "A classification of F will instantly rate sensor $sensorname FAULTY.\n";
+my $rapiddacclassvar = 1;
+
+do {
+print "Enter rapid DAC scan result classification now: ";
+my $rapiddacclass = <STDIN>;
+chomp $rapiddacclass;
+
+    if ($rapiddacclass eq "S" || $rapiddacclass eq "s") {
+        my $message_rapiddac = <<"END_MESSAGE";
+cd $sensorname;
+echo \"RapidDACTest\tS\" >> results.db;
+END_MESSAGE
+    system $message_rapiddac;
+        $rapiddacclassvar = 0;
+    }
+    elsif ($rapiddacclass eq "F" || $rapiddacclass eq "f") {
+    my $message_rapiddac = <<"END_MESSAGE";
+cd $sensorname;
+echo \"RapidDACTest\tF\" >> results.db
+END_MESSAGE
+    system $message_rapiddac;
+        exit 0;
+    }
+    else {
+    print "Invalid classification.\n";
+    }
+} while ($rapiddacclassvar);
+
+
+# Next step, acquire all DAC data and judge accordingly
+#POSIX::cp("/d/jspc37/mimosis/scripts/qa/DACscan.py");
+#mkdir("dacscan_data");
+#Mimosis::mimosis_dacscan_sf(fpga => $fpgalink, printall => 1);
+
+my $message_slowdac = <<"END_MESSAGE";
+cd $sensorname;
+cp /d/jspc37/mimosis/scripts/qa/DACscan.py . ;
+mkdir dacscan_data;
+cd dacscan_data;
+perl -I/d/jspc37/mimosis/scripts -mMimosis -MHADES::TrbNet -e"trb_init_ports(); Mimosis::mimosis_dacscan_sf(fpga => $fpgalink, printall => 1);";
+cd .. ;
+python3 DACscan.py;
+END_MESSAGE
+system $message_slowdac;
+
+#get Offset and slope
+
+my $VPHOffsetLSB = 0;
+my $VPHOffsetElectron = 0;
+my $VPHFSlopeParam = 0.5;
+
+my $logfile = $sensorname . '/results.db';
+
+open(FH, '<', $logfile) or die $!;
+
+while(<FH>){
+
+    if(/$_ ~= VPHSetting60Electrons/)
+    {
+        ($VPHOffsetLSB, $VPHOffsetElectron) = (split /\t/, $_)[1, 2];
+        print $_;
+    }
+    
+    if(/$_ ~= VPHFSlope/)
+    {
+        $VPHFSlopeParam = (split /\t/, $_)[1];
+        print $_;
+    }
+    
+}
+
+close(FH);
+
+
+
+
+# S curve scan tests
+
+if ($backbias == 3000 && $irraddeg >= 1000) 
+{
+        $lowerlimitA = 100;
+        $upperlimitA = 180;
+        
+        $lowerlimitB = 100;
+        $upperlimitB = 180;
+        
+        $lowerlimitC = 100;
+        $upperlimitC = 180;
+        
+        $lowerlimitD = 100;
+        $upperlimitD = 180;
+}
+
+elsif ($backbias == 1000 && $irraddeg >= 1000) 
+{
+        $lowerlimitA = 60;
+        $upperlimitA = 85;
+        
+        $lowerlimitB = 88;
+        $upperlimitB = 88;
+        
+        $lowerlimitC = 88;
+        $upperlimitC = 88;
+        
+        $lowerlimitD = 88;
+        $upperlimitD = 88;
+}
+
+else 
+{
+        $lowerlimitA = 100;
+        $upperlimitA = 180;
+        
+        $lowerlimitB = 80;
+        $upperlimitB = 180;
+        
+        $lowerlimitC = 80;
+        $upperlimitC = 180;
+        
+        $lowerlimitD = 60;
+        $upperlimitD = 180;
+}
+
+print("Now starting rapid S curve scans.\n");
+$durRapidScurves = (($upperlimitA - $lowerlimitA) / 5. + ($upperlimitD - $lowerlimitD) / 5. + 2.) * (6. / 25.); 
+print("This will take approximately $durRapidScurves minutes.\n");
+
+#Mimosis::mimosis_register_write( $fpgalink, 0x45, $VPHOffsetLSB, $singleaccessmode );
+
+my $message_QuickSCScan = <<"END_MESSAGE";
+cd $sensorname;
+mkdir RapidSCurves;
+cd RapidSCurves;
+mkdir Matrix_A;
+cd Matrix_A;
+mimosis -f $fpgalink reg 0x45 $VPHOffsetLSB, $singleaccessmode
+mimosis -f $fpgalink scurves --region A --firstrow 250 --lastrow 260 --printrow --firstvcasn $lowerlimitA --lastvcasn $upperlimitA --vcasndiv 5;
+for i in *; do python3 ../../pulse/fit-raw.py $i.csv $VPHOffsetElectron $VPHFSlopeParam; done
+cd .. ;
+END_MESSAGE
+system $message_QuickSCScan;
+
+print("\n");
+print("RAPID S CURVE SCANS COMPLETED.");
+print("Navigate to the sensor $sensorname / RapidSCurves subfolder.\n");
+print("Note down the VCASN for each submatrix, where the GMDT is closest to 150 e!\n");
+print("\n");
+print("IMPORTANT: If at a submatrix does not produce good S curve scans, enter \'F\' for it.\n");
+print("This will cause the sensor to be rated faulty IMMEDIATELY.\n");
+print("If you want to restart, you will have to delete folder $sensorname and rerun the script.\n");
+print("\n");
+print("Enter the appropriate VCASNA values or \'F\' if bad:");
+
+# FIXME implement checker for values. Just not in the mood now.
+
+$ScurveVCASNA = <STDIN>;
+chomp $ScurveVCASNA;
+
+print("Enter the appropriate VCASNB values or \'F\' if bad:");
+
+$ScurveVCASNB = <STDIN>;
+chomp $ScurveVCASNB;
+
+print("Enter the appropriate VCASNC values or \'F\' if bad:");
+
+$ScurveVCASNC = <STDIN>;
+chomp $ScurveVCASNC;
+
+print("Enter the appropriate VCASND values or \'F\' if bad:");
+
+$ScurveVCASND = <STDIN>;
+chomp $ScurveVCASND;
+
+if ($ScurveVCASNA eq "F" or $ScurveVCASNA eq "f" or $ScurveVCASNB eq "F" or $ScurveVCASNB eq "f" or $ScurveVCASNC eq "F" or $ScurveVCASNC eq "f" or $ScurveVCASND eq "F" or $ScurveVCASND eq "f") {
+    my $message_write_BadScurves = <<"END_MESSAGE";
+cd $sensorname;
+echo \"RapidSCurves,MatrixA\t$ScurveVCASNA\tSubA\" >> results.db;
+echo \"RapidSCurves,MatrixB\t$ScurveVCASNB\tSubB\" >> results.db;
+echo \"RapidSCurves,MatrixC\t$ScurveVCASNC\tSubC\" >> results.db;
+echo \"RapidSCurves,MatrixD\t$ScurveVCASND\tSubC\" >> results.db;
+END_MESSAGE
+    system $message_write_BadScurves;
+            exit 0;
+}
+
+else{
+    die();
+}
+
+#Ziel: Schreibe 3 mal 0x00 und 0xFF und 0xAA in register 0x21 und 0x26 und schaue jeweils, welches register falsch zurück liest.
+#Schreibe das Register raus, sowie was sein soll und was zurück gelesen wird.
+
+$iter = 3;
+
+
similarity index 100%
rename from scripts/qa/curves
rename to scripts/legacy/qa/curves
similarity index 100%
rename from scripts/qa/fpn
rename to scripts/legacy/qa/fpn
old mode 100644 (file)
new mode 100755 (executable)
index 0a9636d..9f90baf
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
 import numpy as np
 import matplotlib.pyplot as plt
 import pandas as pd
@@ -6,16 +8,16 @@ from scipy import special
 import sys
 
 
-
 def error_func(x, mean, sig, ampl):
-    return ampl*(1 + special.erf((x-mean)/(np.sqrt(2*sig))))
+        return ampl*(1 + special.erf((x-mean)/(np.sqrt(2*sig))))
 
 
 
 def gauss_func(x, mean, sig, ampl):
     return ampl*np.exp(-1*(((x-mean)**2)/(2*sig**2)))
 
-
+offset = float(sys.argv[2])
+slopex = float(sys.argv[3])
 
 f =  sys.argv[1]
 df = pd.read_csv(f, delimiter='\t',header=None)
@@ -24,6 +26,10 @@ x = np.linspace(0, 255, num=255)
 
 fpn = np.zeros(255)
 
+calcmeansum = 0
+calcmeanheight = 0
+errorcounter = 0
+
 for i in range(len(df.loc[:])):
 
     xS = []
@@ -31,8 +37,6 @@ for i in range(len(df.loc[:])):
         if df.loc[i][j] != 0:
             xS.append(j)
 
-#    print(xS)
-
     if sum(df.loc[i][0:255]) != 0:
 
         hist = df.loc[i][0:255]
@@ -40,35 +44,65 @@ for i in range(len(df.loc[:])):
         guess = [130, 25, 400]
         params = []
         try:
-            params, tmp  = curve_fit(error_func, x, hist)
-            print(params)
+            params, tmp  = curve_fit(error_func, x, hist, guess) # guess before hist
+            print(params)
         except RuntimeError:
             continue
+            errorcounter += 1
+        except RuntimeWarning:
+            pass
 
         mean = int(round(params[0]))
+
         if mean < 255 and mean >= 0:
             fpn[mean] += 1
 
-        plt.bar(x,hist,width=1)
-        plt.plot(x,error_func(x,params[0],params[1],params[2]),color="red")
+        # plt.bar(x,hist,width=1)
+        # plt.plot(x,error_func(x,params[0],params[1],params[2]),color="red")
+        # plt.savefig("raw-fit-" + str(i) + ".png")
+        # plt.clf()
+        # plt.cla()
+        # plt.close()
+
+
+fpnMeanAndSigma = np.zeros(255)
+
+
+for i in range(0,255):
 
-        plt.savefig("raw-fit-" + str(i) + ".png")
-        plt.clf()
-        plt.cla()
-        plt.close()
+    fpnMeanAndSigma[i] = i * fpn[i]
+    calcmeansum += i * fpn[i]
+    calcmeanheight += fpn[i]
 
 
-# plot fpn
+stddev = 0
+means = calcmeansum / calcmeanheight
+
+
+for i in range(0,255):
+    stddev += (i - means)**2 * (fpn[i] / calcmeanheight)
+
+
+means = offset + slopex * (calcmeansum / calcmeanheight)
+stddev = slopex * np.sqrt(stddev)
+
+# print(means)
+# print(stddev)
+
+guess = [fpn.argmax(), 10, max(fpn)]
 params = []
-#guess = [75, 25, 10]
-guess = [10, 10, 10]
-params, tmp = curve_fit(gauss_func, x, fpn,guess)
-print("\n\nFPN: " + str(params[1]) + "\n\n")
-print(params)
-print()
-print()
+params, tmp = curve_fit(gauss_func, x, fpn, guess)
 
-plt.bar(x,fpn,width=1)
-plt.plot(x,gauss_func(x,params[0],params[1],params[2]),color="red")
-plt.savefig("fpn.png")
+# print("\n\nFPNFIT: " + str(params[1]) + "\n\n")
+# print("FIT:" + params + "\n\n")
 
+# print("\n\nFPNCALC: " + str(np.std(fpn)) + "\n\n")
+# print("CALC:" + str(np.mean(fpn)) + " " + str(np.std(fpn)) + "\n\n")
+# print()
+# print()
+
+stringPlot = "GMDT: " + str(means) + "\nFPN:  " + str(stddev) + "\nERRS: " + str(errorcounter)
+plt.bar(x,fpn,width=1)
+plt.plot(x,gauss_func(x,means/slopex - offset,stddev/slopex,max(fpn)),color="red") # plt.plot(x,gauss_func(x,params[0],params[1],params[2]),color="red")
+plt.text(120,50,stringPlot)
+plt.savefig("fpn-" + f + ".png")
diff --git a/scripts/qa/11/results.db b/scripts/qa/11/results.db
new file mode 100644 (file)
index 0000000..d2e3b06
--- /dev/null
@@ -0,0 +1,3 @@
+SensorName     11
+CHIP-ID_0      S
+CHIP-ID_1      S
diff --git a/scripts/qa/323/results.db b/scripts/qa/323/results.db
new file mode 100644 (file)
index 0000000..9e86eb6
--- /dev/null
@@ -0,0 +1,13 @@
+Link_1 44      GOOD
+SensorName     323
+Link_7 41      GOOD
+Link_3 35      GOOD
+Link_0 45      GOOD
+Link_2 42      GOOD
+CHIP-ID_0      S
+Digitalcurrent 142.575
+Analogcurrent  F
+Link_6 42      GOOD
+CHIP-ID_1      S
+Link_4 38      GOOD
+Link_5 42      GOOD
diff --git a/scripts/qa/33/results.db b/scripts/qa/33/results.db
new file mode 100644 (file)
index 0000000..6c23d3e
--- /dev/null
@@ -0,0 +1,14 @@
+Link_7 38      GOOD
+Link_1 42      GOOD
+CHIP-ID_1      S
+Link_0 0       GOOD
+CHIP-ID_0      S
+Link_3 33      GOOD
+Link_4 35      GOOD
+SensorName     33
+RapidDACTest   S
+Analogcurrent  F
+Link_2 0       GOOD
+Digitalcurrent 142.575
+Link_6 40      GOOD
+Link_5 0       GOOD
diff --git a/scripts/qa/333/results.db b/scripts/qa/333/results.db
new file mode 100644 (file)
index 0000000..fd57a16
--- /dev/null
@@ -0,0 +1,13 @@
+Link_2 43      GOOD
+Analogcurrent  F
+Link_4 41      GOOD
+CHIP-ID_1      S
+Link_6 42      GOOD
+Link_1 45      GOOD
+Digitalcurrent 142.6625
+Link_5 43      GOOD
+Link_7 44      GOOD
+Link_0 47      GOOD
+Link_3 39      GOOD
+SensorName     333
+CHIP-ID_0      S
diff --git a/scripts/qa/89899/CONF_scurves.pl b/scripts/qa/89899/CONF_scurves.pl
new file mode 100644 (file)
index 0000000..0d1d4c9
--- /dev/null
@@ -0,0 +1,18 @@
+#read files like my @config = do "CONF_allregisters.pl";
+
+  #DACs
+  [0x0040,     64  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
+  [0x0041,     52  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
+  [0x0042,     28  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
+  [0x0043,    171  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
+  [0x0044,     70  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
+  [0x0045,     90  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
+  [0x0046,      0  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
+  [0x0047,     67  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x0048,      0  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
+  [0x0049,      0  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
+  [0x004a,      0  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
+  [0x004b,      0  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
+  [0x004c,    150  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x004d,     50  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
+  [0x004e,    125  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
diff --git a/scripts/qa/89899/MATRIX-A/2024-5-17-17-18/METADATA b/scripts/qa/89899/MATRIX-A/2024-5-17-17-18/METADATA
new file mode 100644 (file)
index 0000000..126fc61
--- /dev/null
@@ -0,0 +1,9 @@
+START: 2024-5-17-17-18
+VCASN:
+YMIN:  250
+YMAX:  253
+XMIN:  0
+XMAX:  127
+EXITSTATE:     TAKEDATA
+TIME(s):       190
+COMMENT:       <insert comment here>
diff --git a/scripts/qa/89899/MATRIX-A/lastdir b/scripts/qa/89899/MATRIX-A/lastdir
new file mode 120000 (symlink)
index 0000000..1224d75
--- /dev/null
@@ -0,0 +1 @@
+2024-5-17-17-18
\ No newline at end of file
diff --git a/scripts/qa/CONF_scurves.pl b/scripts/qa/CONF_scurves.pl
new file mode 100644 (file)
index 0000000..0d1d4c9
--- /dev/null
@@ -0,0 +1,18 @@
+#read files like my @config = do "CONF_allregisters.pl";
+
+  #DACs
+  [0x0040,     64  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
+  [0x0041,     52  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
+  [0x0042,     28  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
+  [0x0043,    171  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
+  [0x0044,     70  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
+  [0x0045,     90  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
+  [0x0046,      0  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
+  [0x0047,     67  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x0048,      0  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
+  [0x0049,      0  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
+  [0x004a,      0  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
+  [0x004b,      0  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
+  [0x004c,    150  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x004d,     50  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
+  [0x004e,    125  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
diff --git a/scripts/qa/DACscan.py b/scripts/qa/DACscan.py
deleted file mode 100644 (file)
index 351fbde..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-import numpy as np
-import matplotlib.pyplot as plt
-
-class DACScan():
-    def readFile(filepath = 'abc.txt'):
-        dac = []
-        file = open(filepath, 'r')
-        for line in file:
-            dac.append( float((line.split('\t'))[2]) )
-        return dac
-        
-
-    def calcGain(dac = []):
-        return ((dac[199] - dac[24]) / 175.)
-        
-    def calcOffset(dac = []):
-        return dac[0]
-
-    def calcDNLAndINL(dac = [], gain = 6.):
-        dnl = [0]
-        inl = [0]
-        for element in range(1, 256):
-            currentDNL = ((dac[element] - dac[element - 1]) / gain) - 1
-            dnl.append(currentDNL)
-            inl.append(inl[element - 1] + currentDNL)
-        return dnl, inl
-            
-    iBiasList = readFile('IBIAS.csv')
-    iDbList = readFile('IDB.csv')
-    iThrList = readFile('ITHR.csv')
-    
-    vPhList = readFile('VPH.csv')
-    vPlList = readFile('VPL.csv')
-    vResetList = readFile('VRESET.csv')
-    vPhfList = readFile('VPH_FINE.csv')
-    
-    for count in range(0, 256):
-            vPhfList[count] = vPhfList[count] - vPhList[0]
-    
-    vCasnaList = readFile('VCASNA.csv')
-    vCasnbList = readFile('VCASNB.csv')
-    vCasncList = readFile('VCASNC.csv')
-    vCasndList = readFile('VCASND.csv')
-    vCasn2List = readFile('VCASN2.csv')
-    vCaspList = readFile('VCASP.csv')
-
-    VPHOffset = vPhList[0]
-    VPLOffset = vPlList[0]
-    VResetOffset = vResetList[0]
-    VPH210 = vPhList[211]
-    VPL210 = vPlList[211]
-    VReset210 = vResetList[211]
-    VPHFOffset = vPhfList[0]
-    VPHF210 = vPhfList[211] - VPHFOffset
-    
-    xaxis = []
-    
-    print(iBiasList)
-    
-    for i in range(0,256):
-        xaxis.append(i)
-        
-    #iBiasINL, iBiasDNL = calcDNLAndINL(iBiasList, calcGain(iBiasList))
-    #iThrINL, iThrDNL = calcDNLAndINL(iThrList, calcGain(iThrList))
-    #iDbINL, iDbDNL = calcDNLAndINL(iDbList, calcGain(iDbList))
-            
-    vPhDNL, vPhINL = calcDNLAndINL(vPhList, calcGain(vPhList))
-    vPlDNL, vPlINL = calcDNLAndINL(vPlList, calcGain(vPlList))
-    vResetDNL, vResetINL = calcDNLAndINL(vResetList, calcGain(vResetList))
-    #vPhfDNL, vPhfINL = calcDNLAndINL(vPhfList, calcGain(vPhfList))
-            
-    vCasnaDNL, vCasnaINL = calcDNLAndINL(vCasnaList, calcGain(vCasnaList))
-    vCasnbDNL, vCasnbINL = calcDNLAndINL(vCasnbList, calcGain(vCasnbList))
-    vCasncDNL, vCasncINL = calcDNLAndINL(vCasncList, calcGain(vCasncList))
-    vCasndDNL, vCasndINL = calcDNLAndINL(vCasndList, calcGain(vCasndList))
-    vCasn2DNL, vCasn2INL = calcDNLAndINL(vCasn2List, calcGain(vCasn2List))
-    vCaspDNL, vCaspINL = calcDNLAndINL(vCaspList, calcGain(vCaspList))
-    
-    sensorQuality = 4
-    
-    if ( (250 <= VPHOffset <= 350) and (250 <= VPLOffset <= 350) and (250 <= VResetOffset <= 350) and VPH210 >= 1410 and VPL210 >= 1410 and VReset210 >= 1410 and VPHFOffset <= 20 and VPHF210 >= 190):
-        sensorQuality = 3
-        if ( max(vCasnaList) > 1100 and max(vCasnbList) > 1100 and max(vCasnbList) > 1100 and max(vCasncList) > 1100 and max(vCasndList) > 1100 and max(vCasn2List) > 1100 and max(vCasn2List) > 1100 and max(vClipList) > 550 and max(vCaspList) > 550 and max(iBiasList) >= 260 and max(iThrList) >= 260 and max(iDbList) >= 260):
-            sensorQuality = 2
-            
-            if (max(iBiasINL[:200]) <= 5 and max(iThrINL[:200]) <= 5 and max(iDbINL[:200]) <= 5 and max(vPhINL[:200]) <= 5 and max(vPlINL[:200]) <= 5 and  max(vResetINL[:200]) <= 5 and max(vPhfINL[:200]) <= 5 and max(vCasnaINL[:200]) <= 5 and max(vCasnbINL[:200]) <= 5 and max(vCasncINL[:200]) <= 5 and max(vCasndINL[:200]) <= 5 and max(vCasn2INL[:200]) <= 5 and max(vCaspINL[:200]) <= 5):
-                sensorQuality = 1
-        
-    plt.plot(np.array(xaxis), np.array(vPlINL))
-    plt.show()
-                
-    print(sensorQuality)
-
-
-    
-    
-    
-    
-    
diff --git a/scripts/qa/FFM2/results.db b/scripts/qa/FFM2/results.db
deleted file mode 100644 (file)
index 48a9d4b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-Operatorname   Ben
-Sensorname     FFM2
-LinksWorking   G       8
-Digitalcurrent S       123
-Analogcurrent  S       
-RapidDACTest   S
-DAC quality    2RapidSCurves,MatrixA   F       SubA
-RapidSCurves,MatrixB   F       SubB
-RapidSCurves,MatrixC   F       SubC
-RapidSCurves,MatrixD   F       SubC
diff --git a/scripts/qa/Fasdfrab/results.db b/scripts/qa/Fasdfrab/results.db
deleted file mode 100644 (file)
index ce912d4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Operatorname   asdf
-Sensorname     Fasdfrab
-Digitalcurrent S       123
-Analogcurrent  S       
diff --git a/scripts/qa/FranzMegaSensor/results.db b/scripts/qa/FranzMegaSensor/results.db
deleted file mode 100644 (file)
index c9e8cae..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Operatorname   Ben
-Sensorname     FranzMegaSensor
-LinksWorking   F       0
diff --git a/scripts/qa/FranzMegaSensor2/results.db b/scripts/qa/FranzMegaSensor2/results.db
deleted file mode 100644 (file)
index 8260582..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Operatorname   Ben
-Sensorname     FranzMegaSensor2
-LinksWorking   F       1
index 2be3634ef1864152c15f24cb601e4e8598b0ff95..5271a2ca7d1566b123fd4ae5d5c9da812e10016f 100755 (executable)
 #!/usr/bin/perl
+use strict;
+use warnings;
 use HADES::TrbNet;
 use lib "/d/jspc37/mimosis/scripts/";
 use Mimosis;
-use Time::HiRes qw(usleep);
+use Time::HiRes qw( usleep );
+use POSIX;
+use Data::Dump qw( dump );
+use List::Util qw( min max );
+use threads;
+use IO::Handle;
+use IO::Socket;
+use File::Temp qw( tempfile );
+use File::Copy qw( cp );
+use Cwd qw();
 
 
-$fpgalink = 0xa001;
-$singleaccessmode = 1;
-$slow = 1000;
 
-trb_init_ports() or die trb_strerror();
 
-my %reglist = (
-    3  => 0x004c,       # default value right of =>. Left of =>: Register number, for example in hex.
-    4  => 0x0047,
-    5  => 0x004d,
-    7  => 0x0048,
-    8  => 0x0049,
-    9  => 0x004a,
-    10 => 0x004b,
-);
+sub ask_continue
+{
+    print "Repeat test? [y/N]: ";
+    my $answer = <STDIN>;
+    chomp $answer;
 
-my %testwordlist = (
-    3  => 0x004c,       # default value right of =>. Left of =>: Register number, for example in hex.
-    4  => 0x0047,
-    5  => 0x004d,
-    7  => 0x0048,
-    8  => 0x0049,
-    9  => 0x004a,
-    10 => 0x004b,
-);
+    return 0 if $answer eq "" || $answer eq "n" || $answer eq "N";
+    return 1;
+}
 
 
-for my $regs ( keys %reglist ) {
 
-    for my $testwords ( keys %testwordlist ) {
-        Mimosis::mimosis_register_write( $fpgalink, $regs, $testwords, $singleaccessmode ); usleep($slow); # write value into register
-        my $val = Mimosis::mimosis_register_read( $fpgalink, $regs, $singleaccessmode ); usleep($slow); # 
-        if ( $val != $testwords ) {
-            print("$testwords != $val\n");
-        }
-        Mimosis::mimosis_register_write( $fpgalink, $regs, $reglist{$regs}, $singleaccessmode ); usleep($slow);
-    }
-}
+my $fpgalink = 0xa001;
+my $singleaccessmode = 1;
+my $slow = 100;
+my $slow2 = 100000;
+my $adcSlow = 100000;
+
+my $peer = "192.168.0.61";
+my $port = "5025";
+my $bbCh = 2;
+
+trb_init_ports() or die trb_strerror();
+
+
 
-print "Welcome to the MIMOSIS QA Script.\n";
-print "Please enter your name: ";
-my $operatorname = <STDIN>;
-chomp $operatorname;
 
-print "Please enter a sensor name.\n";
-print "This will be used as a directory to save the acumulated data.\n";
 print "\n";
+print "############################################################################\n";
+print "###                                INIT                                  ###\n";
+print "############################################################################\n";
+print "\n";
+
+my $sensorname;
 
-my $sensnamecheck = 1;
-my $sensorname = "aaa";
+# Perform loop until a good name is found,
+# i.e. it has never been assigned or is not empty
+while ( 1 ) {
 
-while ($sensnamecheck) {                        # Perform loop until a good name is found, i.e. it has never been assigned or is not empty
     print "Enter the sensor name: ";
     $sensorname = <STDIN>;
     chomp $sensorname;
 
-    if (-d $sensorname or $sensorname eq "") {  # Check for bad names.
-        print "Sensor name already chosen. Choose new one...\n";
-    }
+    # Check for bad names
+    if (-d $sensorname or $sensorname eq "") {
+
+        print "Sensor name already chosen or illegal. Choose new one...\n";
 
-    else {
-    my $message_makedir = <<"END_MESSAGE";
-mkdir $sensorname;
-END_MESSAGE
-    system $message_makedir;                    # Make folder for data
-    $sensnamecheck = 0;                         # Quit loop
-    my $message_changedir_and_makefile = <<"END_MESSAGE";
-cd $sensorname;
-touch results.db;
-echo \"Operatorname\t$operatorname\" >> results.db;
-echo \"Sensorname\t$sensorname\" >> results.db;
-END_MESSAGE
-    system $message_changedir_and_makefile;
+    } else {
+
+        mkdir($sensorname);
+        last;
     }
 }
 
-my $irradtest = 1;
-my $irraddeg = 10000;
 
-do {
-    print "Please enter sensor $sensorname TID dose in kRad: ";
+# Hash where everything gets stored before written to file
+my %file;
+
+# Trap sig int
+$SIG{INT} = sub {
+
+    open(RESULTS_FH, '>', $sensorname . "/results.db") or die $!;
+    print RESULTS_FH "$_\t$file{$_}\n" foreach (keys %file);
+    close RESULTS_FH;
+    die "\nAbort.\n"
+};
+
+
+$file{"SensorName"} = $sensorname;
+
+
+
+
+my $irraddeg;
+
+while ( 1 ) {
+
+    print "TID dose [kRad]: ";
     $irraddeg = <STDIN>;
     chomp $irraddeg;
-    
-    if ($irraddeg =~ /^\d{1,4}$/ ) # Check if numeric and within good current range, all ok
-    {
-        print "You have entered a TID dose of $digitalcur kRad.\n";
-        print "This was accepted.\n";
-        $irradtest = 0;
-    }
-    
-    else 
-    {
-        print "You have entered an invalid value (letters, out of range dose, ...)\n";
-        print "Please try again.\n";
+
+    # Check if numeric and within good current range
+    if ($irraddeg =~ /^\d{1,4}$/ ) {
+        last;
+    } elsif ($irraddeg eq "") {
+        $irraddeg = 1000;
+        last;
+    } else {
+        print "Invalid value (letters).\n";
     }
-    
-    
-} while ($irradtest eq 1);
+}
+
 
-my $bbtest = 1;
-my $backbias = 10000;
+
+
+
+my $backbias;
 
 do {
-    print "Please enter sensor $sensorname backbias in mV: ";
-    $backbias = <STDIN>;
+    my $socket = IO::Socket::INET->new(PeerAddr => $peer, PeerPort => $port, Proto => "tcp", Type => SOCK_STREAM)
+      or die "ERROR: Cannot connect: $@";
+
+    usleep 1e5; print $socket "INST OUT$bbCh\n";
+    usleep 1e5; print $socket "MEAS:VOLT?\n";
+    $backbias = <$socket>;
     chomp $backbias;
-    
-    if ($backbias =~ /^\d{1,4}$/  && $backbias <= 6000 && $backbias >= 0) # Check if numeric and within good range, all ok
-    {
-        print "You have entered a backbias of $digitalcur mV.\n";
-        print "This was accepted.\n";
-        $bbtest = 0;
-    }
-    
-    else 
-    {
-        print "You have entered an invalid value (letters, out of range voltage, ...)\n";
-        print "It should be between 0 and 6000 mV.\n";
-        print "Please try again.\n";
-    }
-    
-    
-} while ($bbtest eq 1);
+    $backbias = 1000 * $backbias;
+    print "Back bias: $backbias mV\n";
 
-#Program sensor and find how many good links
+} while ask_continue();
 
-my $message_program_and_link = <<"END_MESSAGE";
-/d/jspc37/mimosis/scripts/start.sh;
-END_MESSAGE
-    system $message_program_and_link;
 
-trb_init_ports() or die trb_strerror();
-my $reg0 = trb_register_read( $fpgalink, 0xa000 );
-$reg0 = ( $reg0->{$fpgalink} & 0x7f00 ) >> 8;
 
-my $reg1 = trb_register_read( $fpgalink, 0xa001 );
-$reg1 = ( $reg1->{$fpgalink} & 0x7f00 ) >> 8;
 
-my $reg2 = trb_register_read( $fpgalink, 0xa002 );
-$reg2 = ( $reg2->{$fpgalink} & 0x7f00 ) >> 8;
 
-my $reg3 = trb_register_read( $fpgalink, 0xa003 );
-$reg3 = ( $reg3->{$fpgalink} & 0x7f00 ) >> 8;
+print "\n";
+print "#############################################################################\n";
+print "###                             CHIPID TEST                               ###\n";
+print "#############################################################################\n";
+print "\n";
+
+my @chipids = ( 0x0, 0x1 );
+
+my $gpioReg = 0xd580;
+my $testreg = 0x0020; # Pixel control register for testing
+my $testval = 0x1;
+my $shouldKill = 0;
+
+do {
+    foreach my $id (@chipids) {
 
-my $reg4 = trb_register_read( $fpgalink, 0xa004 );
-$reg4 = ( $reg4->{$fpgalink} & 0x7f00 ) >> 8;
+        # Reset all
+        my $bitmaskClear = 0x1 << 30;
 
-my $reg5 = trb_register_read( $fpgalink, 0xa005 );
-$reg5 = ( $reg5->{$fpgalink} & 0x7f00 ) >> 8;
+        trb_register_clearbit(
+                              $fpgalink,
+                              $gpioReg,
+                              $bitmaskClear
+                             ); usleep($slow2);
 
-my $reg6 = trb_register_read( $fpgalink, 0xa006 );
-$reg6 = ( $reg6->{$fpgalink} & 0x7f00 ) >> 8;
+        # Set desired bits
+        my $bitmaskSet = $id << 30;
 
-my $reg7 = trb_register_read( $fpgalink, 0xa007 );
-$reg7 = ( $reg7->{$fpgalink} & 0x7f00 ) >> 8;
+        trb_register_setbit(
+                            $fpgalink,
+                            $gpioReg,
+                            $bitmaskSet
+                           ); usleep($slow2);
 
-if ($reg0 >= 70) { 
-    print("All sensor links broken. Sensor rated faulty.\n");
-    my $message_all_links_broken = <<"END_MESSAGE";
-cd $sensorname;
-touch results.db;
-echo \"LinksWorking\tF\t0\" >> results.db;
-END_MESSAGE
-    system $message_all_links_broken;
-    exit 0;
-}
-#
-#elsif ($reg4 >= 30) { 
-#    print("One sensor link working. Sensor rated faulty.\n");
-#    print("Can be set aside for education purposes.\n");
-#    my $message_first_link_broken = <<"END_MESSAGE";
-#cd $sensorname;
-#touch results.db;
-#echo \"LinksWorking\tF\t1\" >> results.db;
-#END_MESSAGE
-#    system $message_first_link_broken;
-#    exit 0;
-#}
-#
-#elsif ($reg2 >= 30 or $reg6 >= 30) { 
-#    print("Two sensors link working. Sensor rated bronze.\n");
-#    my $message_second_links_broken = <<"END_MESSAGE";
-#cd $sensorname;
-#touch results.db;
-#echo \"LinksWorking\tB\t2\" >> results.db;
-#END_MESSAGE
-#    system $message_second_links_broken;
-#}
-#
-#elsif ($reg1 >= 30 or $reg3 >= 30 or $reg5 >= 30 or $reg7 >= 30) { 
-#    print("Four sensor links working. Sensor rated silver.\n");
-#    my $message_third_links_broken = <<"END_MESSAGE";
-#cd $sensorname;
-#touch results.db;
-#echo \"LinksWorking\tS\t4\" >> results.db;
-#END_MESSAGE
-#    system $message_third_links_broken;
-#}
-#
-#else {
-#    print("All sensor links working. Sensor rated gold.\n");
-#    my $message_no_links_broken = <<"END_MESSAGE";
-#cd $sensorname;
-#touch results.db;
-#echo \"LinksWorking\tG\t8\" >> results.db;
-#END_MESSAGE
-#    system $message_no_links_broken;
-#}
+        Mimosis::set_chipid($id);
+
+        my $tmp = Mimosis::mimosis_register_read(
+                                                 $fpgalink,
+                                                 $testreg,
+                                                 $singleaccessmode
+                                                ); usleep($slow2);
+
+        Mimosis::mimosis_register_write(
+                                        $fpgalink,
+                                        $testreg,
+                                        $testval,
+                                        $singleaccessmode
+                                       ); usleep(100000);
+
+        my $testTmp = Mimosis::mimosis_register_read(
+                                                     $fpgalink,
+                                                     $testreg,
+                                                     $singleaccessmode
+                                                    ); usleep($slow2);
+
+        if ( ( $testTmp&0xff ) != $testval ) {
+
+            print "Chip-ID $id not working.\n";
+            $file{"CHIP-ID_$id"} = "F";
+            $shouldKill += 1;
+
+        } else {
+
+            $file{"CHIP-ID_$id"} = "S";
+        }
+    }
+} while ask_continue();
+
+# die "Found broken chip ids. Exiting.\n" if $shouldKill;
+
+# Reset chipid to 0x1
+Mimosis::set_chipid(0x1); usleep($slow2);
+
+trb_register_setbit(
+                    $fpgalink,
+                    $gpioReg,
+                    0x1 << 30
+                   ); usleep($slow2);
+
+
+
+
+
+print "\n";
+print "############################################################################\n";
+print "###                          REGISTER TEST                               ###\n";
+print "############################################################################\n";
+print "\n";
+
+my %reglist = (
+    0x0020 => 0x1,
+    0x0021 => 0x1,
+    0x0022 => 0x1,
+);
 
-#Find out current drawn by sensor on digital and perform data checks.
-my $lowleveldig = 100;                          # Minimum digital current for passing as ok
-my $highleveldig = 200;                         # Maximum digital current for passing as ok
-my $digicurcheck = 0;
-print "Please enter sensor $sensorname digital current in mA.\n";
-print "Round to the closest full number.\n";
-my $digitalcur = 0;
-my $digicounter = 1;
 
 do {
-    if ($digitalcur eq 0) {
-        print "Enter sensor $sensorname digital current in mA now: ";   
-        $digitalcur = <STDIN>;
-        chomp $digitalcur;
+    while( my ($reg, $val) = each(%reglist) ) {
+
+        # Save original value into register
+        my $tmp = Mimosis::mimosis_register_read(
+                                                 $fpgalink,
+                                                 $reg,
+                                                 $singleaccessmode
+                                                ); usleep($slow2); #
+
+        # Write test value
+        Mimosis::mimosis_register_write(
+                                        $fpgalink,
+                                        $reg,
+                                        $val,
+                                        $singleaccessmode
+                                       ); usleep($slow2); # write value into register
+
+        # Get test value
+        my $testVal = Mimosis::mimosis_register_read(
+                                                     $fpgalink,
+                                                     $reg,
+                                                     $singleaccessmode
+                                                    ); usleep($slow2); #
+
+        # Compare
+        print("$testVal != $val\n") unless $testVal == $val;
+
+        # Write original value back into register
+        Mimosis::mimosis_register_write(
+                                        $fpgalink,
+                                        $reg,
+                                        $tmp,
+                                        $singleaccessmode
+                                       ); usleep($slow2);
     }
-    
-    if ($digitalcur =~ /^\d{1,4}$/ && $digitalcur <= $highleveldig && $digitalcur >= $lowleveldig) # Check if numeric and within good current range, all ok
-    {
-        $digicurcheck = 1;
-        print "You have entered a digital current of $digitalcur mA.\n";
-        print "This was accepted.\n";
+} while ask_continue();
+
+
+
+
+
+print "\n";
+print "############################################################################\n";
+print "###                               LINK TEST                              ###\n";
+print "############################################################################\n";
+print "\n";
+
+do {
+    my $currentWd = Cwd::cwd();
+    chdir("/d/jspc37/mimosis/scripts");
+    system("/d/jspc37/mimosis/scripts/start.sh");
+    chdir($currentWd);
+
+    my $cntBadLinks = 0;
+
+    for my $i (0 .. 7) {
+
+        my $reg = trb_register_read( $fpgalink, 0xa000 + $i );
+        $reg = ( $reg->{$fpgalink} & 0x7f00 ) >> 8;
+
+        $cntBadLinks += 1 if $reg >= 70;
+
+        $file{"Link_$i"} = $reg >= 70 ? "$reg\tBAD" : "$reg\tGOOD";
     }
 
+    # die "Bad links. Exiting.\n" if $cntBadLinks > 0;
+    print "Bad links.\n" if $cntBadLinks > 0;
 
-    elsif ($digitalcur =~ /^\d{1,4}$/ && ($digitalcur >= $highleveldig || $digitalcur <= $lowleveldig)) # Check if numeric and outside good current range, not ok, retry up to 4 further times
-    {
-        print "You have entered a digital current of $digitalcur mA.\n"; 
-        print "This is outside of the sensors specifications: $lowleveldig - $highleveldig mA.\n"; 
-        print "Make sure your connection is proper now.\n";
-        print "If you find a better connection, enter new current now.\n";
-        print "If not, confirm by pressing F. The sensor will be instantly rated faulty.\n";
-        print "You can redo the test later, but you have to delete the subfolder $sensorname first.\n";
-        print "Enter your choice now (current (mA)/F): ";
-        my $digicurcorr = <STDIN>;
-        chomp $digicurcorr;
-        
-        if ($digicurcorr =~ /^\d{1,4}$/)
-        {
-            $digitalcur = $digicurcorr;
-            $digicounter += 1;
-            break;
-        }
-        elsif ($digicurcorr eq 'F' || $digicurcorr eq 'f') { # Wilfull termination of program as sensor has bad digital current consumption.
-            $digicurcheck = 1;
-            my $message_write_digicur = <<"END_MESSAGE";
-cd $sensorname;
-echo \"Digitalcurrent\tF\t$digitalcur\" >> results.db;
-END_MESSAGE
-    system $message_write_digicur;
-            exit 0;                     # End because set as F
-        }
-        else {                          # When something entered is not F or numeric
-        $digicurcheck = 0;
-        $digitalcur = $digicurcorr;
-        print "Not a valid number, try again.\n"; 
-        print "Make sure that it is between 1 and 9999 mA.\n";
-        }
-           
+} while ask_continue();
+
+
+
+
+
+print "\n";
+print "#############################################################################\n";
+print "###                                BB TEST                                ###\n";
+print "#############################################################################\n";
+print "\n";
+
+open(BB_FH, '>', $sensorname . "/bb.csv") or die $!;
+
+do {
+    my $socket = IO::Socket::INET->new(PeerAddr => $peer, PeerPort => $port, Proto => "tcp", Type => SOCK_STREAM)
+      or die "ERROR: Cannot connect: $@";
+
+    # Save current BB seting for later
+    usleep 1e0; print $socket "INST OUT$bbCh\n";
+    usleep 1e5; print $socket "MEAS:VOLT?\n";
+    my $tmp = <$socket>;
+    chomp $tmp;
+
+    for (my $i = 0; $i <= 5.0; $i += 0.5) {
+
+        usleep 1e5; print $socket "VOLT $i\n";
+        usleep 1e5; print $socket "MEAS:VOLT?\n"; my $volt = <$socket>;
+        usleep 1e5; print $socket "MEAS:CURR?\n"; my $curr = <$socket>;
+
+        chomp $volt;
+        chomp $curr;
+
+        print BB_FH "$volt\t$curr\n";
     }
-    
-    else                                # All other cases not considered.
+
+    # Reset BB to what it was before
+    usleep 1e5; print $socket "VOLT $tmp\n";
+
+} while ask_continue();
+
+close BB_FH;
+
+
+
+
+print "\n";
+print "###########################################################################\n";
+print "###                     POWERING TEST DIGITAL                           ###\n";
+print "###########################################################################\n";
+print "\n";
+
+#Find out current drawn by sensor on digital and perform data checks.
+my $lowleveldig = 100; # Minimum digital current for passing as ok
+my $highleveldig = 200; # Maximum digital current for passing as ok
+
+
+do {
+    my $adc_addr = 0x48;
+    my $adc_wreg = 0x1;
+    my $adc_cmd  = 0xc380; #CHANGE ME
+    my $adc_rreg = 0x0;
+    my $adcConv = ( 2 * 4096 ) / (2**16 * 10);
+
+    Mimosis::adc_i2c_command(
+                             $fpgalink,
+                             $adc_addr,
+                             $adc_wreg,
+                             $adc_cmd,
+                             0, 0, 1
+                            ); usleep($adcSlow);
+
+    my $digitalcur = Mimosis::adc_i2c_command(
+                                     $fpgalink,
+                                     $adc_addr,
+                                     $adc_rreg,
+                                     0x0,
+                                     1, 0, 1 ); usleep($adcSlow);
+    $digitalcur *= $adcConv;
+
+    # Check if numeric and within good current range
+    if ( $digitalcur <= $highleveldig &&
+         $digitalcur >= $lowleveldig )
     {
-        $digicurcheck = 0;
-        $digitalcur = 0;
-        print "Not a valid number, try again.\n"; 
-        print "Make sure that it is between 1 and 9999 mA.\n";
+        $file{"Digitalcurrent"} = $digitalcur;
+        print "Digital current: $digitalcur mA.\n";
+
+    } else {
+
+        print "Digital current not in range: $digitalcur.\n";
+        $file{"Digitalcurrent"} = "F";
     }
-    
 
-} while ($digicurcheck == 0 && $digicounter lt 5);
+} while ask_continue();
+
 
 
 
-if ($digicounter eq 5) {                # Terminate program because too many tries gone wrong on entering digital current
-    print "You have reached the maximum tries of entering a digital current for sensor $sensorname.\n";
-    print "Try to clean the probe setup (Needles, etc?). If you get a current between $lowleveldig - $highleveldig mA, try again.\n";
-    print "To do this, you will have to delete the folder $sensorname, as the sensor is currently rated FAULTY.\n";
-    print "END OF PROGRAM, SENSOR STATUS F due to DIGITAL CURRENT.\n";
-    my $message_write_digicur = <<"END_MESSAGE";
-cd $sensorname;
-echo \"Digitalcurrent\tF\t$digitalcur\" >> results.db;
-END_MESSAGE
-    system $message_write_digicur;
-    
-    exit 0;                             # End because too many attempts to enter digital current.
-}
 
-my $message_write_digicur = <<"END_MESSAGE";
-cd $sensorname;
-echo \"Digitalcurrent\tS\t$digitalcur\" >> results.db;
-END_MESSAGE
-    system $message_write_digicur;
+print "\n";
+print "############################################################################\n";
+print "###                     POWERING TEST ANALOG                             ###\n";
+print "############################################################################\n";
+print "\n";
 
 #Find out current drawn by sensor on analog and perform data checks.
-my $lowlevelana = 10;                          # Minimum analog current for passing as ok
-my $highlevelana = 80;                         # Maximum analog current for passing as ok
-my $anacurcheck = 0;
-print "Please enter sensor $sensorname analog current in mA.\n";
-print "Round to the closest full number.\n";
-my $analogcur = 0;
+my $lowlevelana = 10; # Minimum analog current for passing as ok
+my $highlevelana = 80; # Maximum analog current for passing as ok
 
-my $anacounter = 1;
 
 do {
-
-    if ($analogcur eq 0) {
-        print "Enter sensor $sensorname analog current in mA now: ";   
-        $analogcur = <STDIN>;
-        chomp $analogcur;
-    }
-    
-    
-    if ($analogcur =~ /^\d{1,3}$/ && $analogcur <= $highlevelana && $analogcur >= $lowlevelana) # Check if numeric and within good current range, all ok
+    my $adc_addr = 0x48;
+    my $adc_wreg = 0x1;
+    my $adc_cmd  = 0xf380; #CHANGE ME
+    my $adc_rreg = 0x0;
+    my $adcConv = ( 2 * 4096 ) / (2**16 * 100);
+
+    Mimosis::adc_i2c_command(
+                             $fpgalink,
+                             $adc_addr,
+                             $adc_wreg,
+                             $adc_cmd,
+                             0, 0, 1
+                            ); usleep($adcSlow);
+
+    my $analogcur = Mimosis::adc_i2c_command(
+                                     $fpgalink,
+                                     $adc_addr,
+                                     $adc_rreg,
+                                     0x0,
+                                     1, 0, 1 ); usleep($adcSlow);
+
+    $analogcur *= $adcConv;
+
+    # Check if numeric and within good current range
+    if( $analogcur <= $highlevelana &&
+        $analogcur >= $lowlevelana )
     {
-        $anacurcheck = 1;
-        print "You have entered a analog current of $analogcur mA.\n";
-        print "This was accepted.\n";
+        $file{"Analogcurrent"} = $analogcur;
+        print "Analog current: $analogcur mA.\n";
+
+    } else {
+
+        print "Analog current not in range: $analogcur.\n";
+        $file{"Analogcurrent"} = "F";
     }
 
+} while ask_continue();
 
-    elsif ($analogcur =~ /^\d{1,3}$/ && ($analogcur >= $highlevelana || $analogcur <= $lowlevelana)) # Check if numeric and outside good current range, not ok, retry up to 4 further times
-    {
-        print "You have entered a analog current of $analogcur mA.\n"; 
-        print "This is outside of the sensors specifications: $lowlevelana - $highlevelana mA.\n"; 
-        print "Make sure your connection is proper now.\n";
-        print "If you find a better connection, enter new current now.\n";
-        print "If not, confirm by pressing F. The sensor will be instantly rated faulty.\n";
-        print "You can redo the test later, but you have to delete the subfolder $sensorname first.\n";
-        print "Enter your choice now (current (mA)/F): ";
-        my $anacurcorr = <STDIN>;
-        chomp $anacurcorr;
-        
-        if ($anacurcorr =~ /^\d{1,3}$/)
-        {
-            $analogcur = $anacurcorr;
-            $anacounter += 1;
-            break;
-        }
-        elsif ($anacurcorr eq 'F' || $anacurcorr eq 'f') { # Wilfull termination of program as sensor has bad analog current consumption.
-            $anacurcheck = 1;
-            my $message_write_anacur = <<"END_MESSAGE";
-cd $sensorname;
-echo \"Analogcurrent\tF\t$anacur\" >> results.db;
-END_MESSAGE
-    system $message_write_anacur;
-            exit 0;                     # End because set as F
-        }
-        else {                          # When something entered is not F or numeric
-        $anacurcheck = 0;
-        $analogcur = $anacurcorr;
-        print "Not a valid number, try again.\n"; 
-        print "Make sure that it is between 1 and 999 mA.\n";
+
+# print "$_\t$file{$_}\n" foreach (keys %file);
+
+
+
+
+print "\n";
+print "############################################################################\n";
+print "###                          FAST DACSCAN TEST                           ###\n";
+print "############################################################################\n";
+print "\n";
+
+do {
+    Mimosis::mimosis_dacscan_initial_test(
+                                          fpga => $fpgalink,
+                                          slow => 10000,
+                                          a => 1,
+                                          printall => 1,
+                                          plotname => $sensorname,
+        ikf => $fpgalink&1,
+                                         );
+
+    print "Please enter rapid DAC scan result classification.\n";
+    print "S = satisfactory if in grey areas\n";
+    print "F = unsatisfactory and exiting.\n";
+
+    while ( 1 ) {
+
+        print "Rapid DAC scan classification: ";
+        my $rapiddacclass = <STDIN>;
+        chomp $rapiddacclass;
+
+        if ( $rapiddacclass eq "S" ||
+             $rapiddacclass eq "s" ) {
+
+            $file{"RapidDACTest"} = "S";
+            last;
+
+        } elsif ( $rapiddacclass eq "F" ||
+                  $rapiddacclass eq "f" ) {
+
+            $file{"RapidDACTest"} = "F";
+            exit 0;
+
+        } else {
+            print "Invalid classification. Try again.\n";
         }
-           
-    }
-    
-    else                                # All other cases not considered.
-    {
-        $anacurcheck = 0;
-        print "Not a valid number, try again.\n"; 
-        print "Make sure that it is between 1 and 999 mA.\n";
     }
-    
 
-} while ($anacurcheck == 0 && $anacounter lt 5);
-
-if ($anacounter eq 5) {                 # Terminate program because too many tries gone wrong on entering analog current
-    print "You have reached the maximum tries of entering an analog current for sensor $sensorname.\n";
-    print "Try to clean the probe setup (Needles, etc?). If you get a current between $lowlevelana - $highlevelana mA, try again.\n";
-    print "To do this, you will have to delete the folder $sensorname, as the sensor is currently rated FAULTY.\n";
-    print "END OF PROGRAM, SENSOR STATUS F due to ANALOG CURRENT.\n";
-    my $message_write_anacur = <<"END_MESSAGE";
-cd $sensorname;
-echo \"Analogcurrent\tF\t$anacur\" >> results.db;
-END_MESSAGE
-    system $message_write_anacur;
-    
-    exit 0;                             # End because too many attempts to enter analog current.
-}
+} while ask_continue();
 
-my $message_write_anacur = <<"END_MESSAGE";
-cd $sensorname;
-echo \"Analogcurrent\tS\t$anacur\" >> results.db;
-END_MESSAGE
-    system $message_write_anacur;
 
+
+
+
+print "\n";
+print "############################################################################\n";
+print "###                           DACSCAN TEST                               ###\n";
+print "############################################################################\n";
 print "\n";
-print "Proceeding to preliminary DAC scans...\n";
-print "Validate that results from VPulseHigh, VPulseLow and VReset are in the steep grey area.\n";
-print "Validate that result from VPulseHighFine is in the gently inclined grey area.\n";
-
-my $message_quickdacscan = <<"END_MESSAGE";
-./dac.pl --p $sensorname
-cd $sensorname/
-display $sensorname.png &
-END_MESSAGE
-system $message_quickdacscan;
-
-print "Please enter rapid DAC scan result classification.\n";
-print "S = satisfactory if in grey areas, otherwise F = unsatisfactory.\n";
-print "A classification of F will instantly rate sensor $sensorname FAULTY.\n";
-my $rapiddacclassvar = 1;
+
+my $VPHFSlope;
+my $VPHOffsetElectron;
 
 do {
-print "Enter rapid DAC scan result classification now: ";
-my $rapiddacclass = <STDIN>;
-chomp $rapiddacclass;
-
-    if ($rapiddacclass eq "S" || $rapiddacclass eq "s") {
-        my $message_rapiddac = <<"END_MESSAGE";
-cd $sensorname;
-echo \"RapidDACTest\tS\" >> results.db;
-END_MESSAGE
-    system $message_rapiddac;
-        $rapiddacclassvar = 0;
+    chdir($sensorname);
+
+    my %dacVals = Mimosis::mimosis_dacscan_sf(
+                                              fpga => $fpgalink,
+                                              slow => 10000,
+                                              printall => 1,
+        ikf => $fpgalink&1,
+                                             );
+
+    chdir("..");
+
+    my %names = (
+                 'IBIAS' => 0x0040,
+                 'ITHR' => 0x0041,
+                 'IDB' => 0x0042,
+                 'VRESET' => 0x0043,
+                 'VPL' => 0x0044,
+                 'VPH' => 0x0045,
+                 'VPH_FINE' => 0x0046,
+                 'VCASP' => 0x0047,
+                 'VCASNA' => 0x0048,
+                 'VCASNB' => 0x0049,
+                 'VCASNC' => 0x004a,
+                 'VCASND' => 0x004b,
+                 'VCASN2' => 0x004c,
+                 'VCLIP' => 0x004d,
+                 'IBUFBIAS' => 0x004e,
+                );
+
+
+    my @VPHList = @{$dacVals{$names{"VPH"}}};
+    my @VPLList = @{$dacVals{$names{"VPL"}}};
+    my @VPHFINEList = @{$dacVals{$names{"VPH_FINE"}}};
+    my @VRESETList = @{$dacVals{$names{"VRESET"}}};
+    my @VCASNAList = @{$dacVals{$names{"VCASNA"}}};
+    my @VCASNBList = @{$dacVals{$names{"VCASNB"}}};
+    my @VCASNCList = @{$dacVals{$names{"VCASNC"}}};
+    my @VCASNDList = @{$dacVals{$names{"VCASND"}}};
+    my @VCASN2List = @{$dacVals{$names{"VCASN2"}}};
+    my @VCLIPList = @{$dacVals{$names{"VCLIP"}}};
+    my @VCASPList = @{$dacVals{$names{"VCASP"}}};
+    my @IBIASList = @{$dacVals{$names{"IBIAS"}}};
+    my @ITHRList = @{$dacVals{$names{"ITHR"}}};
+    my @IDBList = @{$dacVals{$names{"IDB"}}};
+
+
+    my($T,$N) = tempfile("plot-XXXX", "UNLINK", 1);
+
+    foreach my $dac (keys %names) {
+
+        foreach my $v (@{$dacVals{$names{$dac}}}) {
+            say $T $v;
+        }
+
+        print $T "\n\n";
+    }
+
+    close $T;
+
+
+    open my $P, "|-", "gnuplot" or die;
+
+    my $dacPng = "$sensorname/alldacs.png";
+
+    printflush $P qq[
+set terminal pngcairo size 1000,1000;
+set output "$dacPng";
+set key Left left top box;
+set xlabel "set.";
+set ylabel "[mV]";
+plot "$N" with l;
+
+set terminal qt;
+set xlabel "set.";
+set ylabel "[mV]";
+plot "$N" with l;
+];
+    <STDIN>;
+    close $P;
+
+
+    for my $i (0 .. scalar( @VPHFINEList ) - 1) {
+        $VPHFINEList[$i] = $VPHFINEList[$i] - $VPHList[0];
     }
-    elsif ($rapiddacclass eq "F" || $rapiddacclass eq "f") {
-    my $message_rapiddac = <<"END_MESSAGE";
-cd $sensorname;
-echo \"RapidDACTest\tF\" >> results.db
-END_MESSAGE
-    system $message_rapiddac;
-        exit 0;
+
+
+    my $sensorQuality = 4;
+
+    my $VPHOffset = $VPHList[0];
+    my $VPLOffset = $VPLList[0];
+    my $VRESETOffset = $VRESETList[0];
+    my $VPHFOffset = $VPHFINEList[0];
+    my $VPH210 = $VPHList[211];
+    my $VPL210 = $VPLList[211];
+    my $VRESET210 = $VRESETList[211];
+    my $VPHF210 = $VPHFINEList[211] - $VPHFOffset;
+
+
+    if ( (300 <= $VPHOffset) &&
+         (375 >= $VPHOffset) &&
+         (300 <= $VPLOffset) &&
+         (375 >= $VPLOffset) &&
+         (300 <= $VRESETOffset) &&
+         (375 >= $VRESETOffset) &&
+         ($VPH210 >= 1410) &&
+         ($VPL210 >= 1410) &&
+         ($VRESET210 >= 1410) &&
+         ($VPHFOffset <= 20) &&
+         ($VPHF210 >= 190) ) {
+
+        $sensorQuality = 3;
+
+        if ( max(@VCASNAList) > 1100 &&
+             max(@VCASNBList) > 1100 &&
+             max(@VCASNCList) > 1100 &&
+             max(@VCASNDList) > 1100 &&
+             max(@VCASN2List) > 1100 &&
+             max(@VCLIPList) > 550 &&
+             max(@VCASPList) > 550 &&
+             max(@IBIASList) >= 260 &&
+             max(@ITHRList) >= 260 &&
+             max(@IDBList) >= 260 ) {
+
+            $sensorQuality = 2;
+
+
+            sub calcAbsDNLAbsINL {
+
+                my @dac = @{$_[0][0]};
+
+                my $gain = ($dac[199] - $dac[24]) / 175.0;
+
+                my @dnl = ( 0 );
+                my @inl = ( 0 );
+
+                for my $i (21 .. 201) {
+
+                    my $currentDNL = ( ($dac[$i] - $dac[$i-1]) / $gain ) - 1;
+                    push(@dnl, $currentDNL);
+                    push(@inl, $inl[$i-21]+$currentDNL);
+                }
+
+                @dnl = reverse @dnl;
+                @inl = reverse @inl;
+                return ( @inl, @dnl );
+            }
+
+
+            my ( @IBIASINL, @IBIASDNL )     = calcAbsDNLAbsINL(\@IBIASList);
+            my ( @ITHRINL, @ITHRDNL )       = calcAbsDNLAbsINL(\@ITHRList);
+            my ( @IDBINL, @IDBDNL )         = calcAbsDNLAbsINL(\@IDBList);
+            my ( @VPHINL, @VPHDNL )         = calcAbsDNLAbsINL(\@VPHList);
+            my ( @VPLINL, @VPLDNL )         = calcAbsDNLAbsINL(\@VPLList);
+            my ( @VRESETINL, @VRESETDNL )   = calcAbsDNLAbsINL(\@VRESETList);
+            my ( @VPHFINEINL, @VPHFINEDNL ) = calcAbsDNLAbsINL(\@VPHFINEList);
+            my ( @VCASNAINL, @VCASNADNL )   = calcAbsDNLAbsINL(\@VCASNAList);
+            my ( @VCASNBINL, @VCASNBDNL )   = calcAbsDNLAbsINL(\@VCASNBList);
+            my ( @VCASNCINL, @VCASNCDNL )   = calcAbsDNLAbsINL(\@VCASNCList);
+            my ( @VCASNDINL, @VCASNDDNL )   = calcAbsDNLAbsINL(\@VCASNDList);
+            my ( @VCASN2INL, @VCASN2DNL )   = calcAbsDNLAbsINL(\@VCASN2List);
+            my ( @VCASPINL, @VCASPDNL )     = calcAbsDNLAbsINL(\@VCASPList);
+            my ( @VCLIPINL, @VCLIPDNL )     = calcAbsDNLAbsINL(\@VCLIPList);
+
+
+            my $goodDNL = 0;
+
+            if ( $IBIASDNL[2] < 1
+                 && $ITHRDNL[2] < 1
+                 && $IDBDNL[2] < 1
+                 && $VCASNADNL[2] < 1
+                 && $VCASNBDNL[2] < 1
+                 && $VCASNCDNL[2] < 1
+                 && $VCASNDDNL[2] < 1
+                 && $VCASN2DNL[2] < 1
+                 && $VCASPDNL[2] < 1
+                 && $VCLIPDNL[2] < 1
+                 && $VPHDNL[2] < 1
+                 && $VPLDNL[2] < 1
+                 && $VRESETDNL[2] < 1
+                 && $VPHFINEDNL[2] < 1
+               ) {
+                $goodDNL = 1;
+            }
+
+            my $goodINL = 0;
+
+            if ( $IBIASINL[2] < 5
+                 && $ITHRINL[2] < 5
+                 && $IDBINL[2] < 5
+                 && $VCASNAINL[2] < 5
+                 && $VCASNBINL[2] < 5
+                 && $VCASNCINL[2] < 5
+                 && $VCASNDINL[2] < 5
+                 && $VCASN2INL[2] < 5
+                 && $VCASPINL[2] < 5
+                 && $VCLIPINL[2] < 5
+                 && $VPHINL[2] < 1
+                 && $VPLINL[2] < 1
+                 && $VRESETINL[2] < 1
+                 && $VPHFINEINL[2] < 1
+               ) {
+                $goodINL = 1;
+            }
+
+            if ($goodDNL && $goodINL) {
+                $sensorQuality = 1;
+            }
+        }
     }
-    else {
-    print "Invalid classification.\n";
+
+    $VPHFSlope = ($VPHFINEList[255] - $VPHFINEList[0]) / 255.0;
+    $VPHOffsetElectron = 0;
+    my $SixtyElectronVPHSetting = 0;
+
+    for my $i  (0 .. scalar(@VPHList)) {
+
+        if ( 55.0 le ($VPHList[$i] - $VPLList[70]) &&
+             65.0 gt ($VPHList[$i] - $VPLList[70]) ) {
+
+            $SixtyElectronVPHSetting = $i;
+            $VPHOffsetElectron = $VPHList[$i] - $VPLList[70];
+            last;
+        }
     }
-} while ($rapiddacclassvar);
 
+    print("Sensor Quality for DACs: $sensorQuality\n");
 
-# Next step, acquire all DAC data and judge accordingly
+    $file{"DACQuality"} = $sensorQuality;
+    $file{"VPHFSlope"} = $VPHFSlope;
+    $file{"VPHSetting60Electrons"} = "$SixtyElectronVPHSetting\t$VPHOffsetElectron";
 
-my $message_slowdac = <<"END_MESSAGE";
-cd $sensorname;
-cp /d/jspc37/mimosis/scripts/dacscan/data/DACscan.py . ;
-mkdir dacscan_data;
-cd dacscan_data;
-perl -I/d/jspc37/mimosis/scripts -mMimosis -MHADES::TrbNet -e"trb_init_ports(); Mimosis::mimosis_dacscan_sf(fpga => $fpgalink, printall => 1);";
-cd .. ;
-python3 DACscan.py;
-END_MESSAGE
-system $message_slowdac;
+} while ask_continue();
 
 
 
-# S curve scan tests
 
-if ($backbias == 3000 && $irraddeg >= 1000) 
-{
-        $lowerlimitA = 88;
-        $upperlimitA = 88;
-        
-        $lowerlimitB = 88;
-        $upperlimitB = 88;
-        
-        $lowerlimitC = 88;
-        $upperlimitC = 88;
-        
-        $lowerlimitD = 88;
-        $upperlimitD = 88;
-}
 
-elsif ($backbias == 1000 && $irraddeg >= 1000) 
-{
-        $lowerlimitA = 60;
-        $upperlimitA = 85;
-        
-        $lowerlimitB = 88;
-        $upperlimitB = 88;
-        
-        $lowerlimitC = 88;
-        $upperlimitC = 88;
-        
-        $lowerlimitD = 88;
-        $upperlimitD = 88;
+sub fit_thr {
+    my ($fname, $vphOffsetElectron, $vphfSlope) = @_;
+    system("/d/jspc37/mimosis/scripts/pulse/fit-raw.py $fname.csv $vphOffsetElectron $vphfSlope");
 }
 
-else 
-{
-        $lowerlimitA = 60;
-        $upperlimitA = 160;
+# my $VPHFSlope = 1.0;
+# my $VPHOffsetElectron = 0;
+
+
+do {
+    print "\n";
+    print "############################################################################\n";
+    print "###                            SCURVE TEST                               ###\n";
+    print "############################################################################\n";
+    print "\n";
+
+    my $lowerlimitA = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 95 : 
+    (( $backbias == 1000 && $irraddeg >= 1000 ) ? 60 : (( $backbias == 1000 && $irraddeg == 0 ) ? 70 : (( $backbias == 3000 && $irraddeg == 0 ) ? 110 : 50 )));
+
+    my $upperlimitA = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 120 : 
+    (( $backbias == 1000 && $irraddeg >= 1000 ) ? 100 : (( $backbias == 1000 && $irraddeg == 0 ) ? 115 : (( $backbias == 3000 && $irraddeg == 0 ) ? 165 : 200 )));
+    
+    
+    my $lowerlimitB = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 100 : 
+    (( $backbias == 1000 && $irraddeg >= 1000 ) ? 75 : (( $backbias == 1000 && $irraddeg == 0 ) ? 95 : (( $backbias == 3000 && $irraddeg == 0 ) ? 130 : 50 )));
+
+    my $upperlimitB = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 150 : 
+    (( $backbias == 1000 && $irraddeg >= 1000 ) ? 125 : (( $backbias == 1000 && $irraddeg == 0 ) ? 140 : (( $backbias == 3000 && $irraddeg == 0 ) ? 185 : 200 )));
+    
+    
+    my $lowerlimitC = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 100 : 
+    (( $backbias == 1000 && $irraddeg >= 1000 ) ? 75 : (( $backbias == 1000 && $irraddeg == 0 ) ? 95 : (( $backbias == 3000 && $irraddeg == 0 ) ? 130 : 50 )));
+
+    my $upperlimitC = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 150 : 
+    (( $backbias == 1000 && $irraddeg >= 1000 ) ? 125 : (( $backbias == 1000 && $irraddeg == 0 ) ? 140 : (( $backbias == 3000 && $irraddeg == 0 ) ? 185 : 200 )));
+
+
+    my $lowerlimitD = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 95 : 
+    (( $backbias == 1000 && $irraddeg >= 1000 ) ? 60 : (( $backbias == 1000 && $irraddeg == 0 ) ? 75 : (( $backbias == 3000 && $irraddeg == 0 ) ? 115 : 50 )));
+
+    my $upperlimitD = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 120 : 
+    (( $backbias == 1000 && $irraddeg >= 1000 ) ? 100 : (( $backbias == 1000 && $irraddeg == 0 ) ? 140 : (( $backbias == 3000 && $irraddeg == 0 ) ? 180 : 200 )));
+    
+    
+    # my $lowerlimitD = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 100 :
+    #    ( ( $backbias == 1000 && $irraddeg >= 1000 ) ? 88 : 60);
+
+    # my $upperlimitD = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 180 :
+    #    ( ( $backbias == 1000 && $irraddeg >= 1000 ) ? 88 : 180);
         
-        $lowerlimitB = 80;
-        $upperlimitB = 180;
         
-        $lowerlimitC = 80;
-        $upperlimitC = 180;
+    # my $lowerlimitA = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 100 :
+    #    ( ( $backbias == 1000 && $irraddeg >= 1000 ) ? 60 : 60);
         
-        $lowerlimitD = 60;
-        $upperlimitD = 180;
-}
+    # my $upperlimitA = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 180 :
+    #    ( ( $backbias == 1000 && $irraddeg >= 1000 ) ? 85 : 180);
+    
+    # my $lowerlimitB = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 100 :
+    #    ( ( $backbias == 1000 && $irraddeg >= 1000 ) ? 88 : 80);
 
-print("Now starting rapid S curve scans.\n");
-$durRapidScurves = (($upperlimitA - $lowerlimitA) / 5. + ($upperlimitD - $lowerlimitD) / 5. + 2.) * (6. / 25.); 
-print("This will take approximately $durRapidScurves minutes.\n");
-
-my $message_QuickSCScan = <<"END_MESSAGE";
-cd $sensorname;
-mkdir RapidSCurves;
-cd RapidSCurves;
-mkdir Matrix_A;
-cd Matrix_A;
-mimosis -f $fpgalink scurves --region A --firstrow 250 --lastrow 260 --printrow --firstvcasn $lowerlimitA --lastvcasn $upperlimitA --vcasndiv 5;
-for i in *; do ../fpn $i; done
-cd .. ;
-END_MESSAGE
-system $message_QuickSCScan;
-
-print("\n");
-print("RAPID S CURVE SCANS COMPLETED.");
-print("Navigate to the sensor $sensorname / RapidSCurves subfolder.\n");
-print("Note down the VCASN for each submatrix, where the GMDT is closest to 150 e!\n");
-print("\n");
-print("IMPORTANT: If at a submatrix does not produce good S curve scans, enter \'F\' for it.\n");
-print("This will cause the sensor to be rated faulty IMMEDIATELY.\n");
-print("If you want to restart, you will have to delete folder $sensorname and rerun the script.\n");
-print("\n");
-print("Enter the appropriate VCASNA values or \'F\' if bad:");
-
-# FIXME implement checker for values. Just not in the mood now.
-
-$ScurveVCASNA = <STDIN>;
-chomp $ScurveVCASNA;
-
-print("Enter the appropriate VCASNB values or \'F\' if bad:");
-
-$ScurveVCASNB = <STDIN>;
-chomp $ScurveVCASNB;
-
-print("Enter the appropriate VCASNC values or \'F\' if bad:");
-
-$ScurveVCASNC = <STDIN>;
-chomp $ScurveVCASNC;
-
-print("Enter the appropriate VCASND values or \'F\' if bad:");
-
-$ScurveVCASND = <STDIN>;
-chomp $ScurveVCASND;
-
-if ($ScurveVCASNA eq "F" or $ScurveVCASNA eq "f" or $ScurveVCASNB eq "F" or $ScurveVCASNB eq "f" or $ScurveVCASNC eq "F" or $ScurveVCASNC eq "f" or $ScurveVCASND eq "F" or $ScurveVCASND eq "f") {
-    my $message_write_BadScurves = <<"END_MESSAGE";
-cd $sensorname;
-echo \"RapidSCurves,MatrixA\t$ScurveVCASNA\tSubA\" >> results.db;
-echo \"RapidSCurves,MatrixB\t$ScurveVCASNB\tSubB\" >> results.db;
-echo \"RapidSCurves,MatrixC\t$ScurveVCASNC\tSubC\" >> results.db;
-echo \"RapidSCurves,MatrixD\t$ScurveVCASND\tSubC\" >> results.db;
-END_MESSAGE
-    system $message_write_BadScurves;
-            exit 0;
-}
+    # my $upperlimitB = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 180 :
+    #    ( ( $backbias == 1000 && $irraddeg >= 1000 ) ? 88 : 180);
+    
+    # my $lowerlimitC = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 100 :
+    #    ( ( $backbias == 1000 && $irraddeg >= 1000 ) ? 88 : 80);
+
+    # my $upperlimitC = ( $backbias == 3000 && $irraddeg >= 1000 ) ? 180 :
+    #    ( ( $backbias == 1000 && $irraddeg >= 1000 ) ? 88 : 180);
+
+
+    my $SixtyElectronVPHSetting = 70;
+    Mimosis::mimosis_register_write( $fpgalink, 0x45, $SixtyElectronVPHSetting, $singleaccessmode );
+
+    my $settingsScurves = "./CONF_scurves.pl";
+
+    cp($settingsScurves, "$sensorname/$settingsScurves");
+
+    Mimosis::mimosis_load_file(
+                               fpga => $fpgalink,
+                               slow => $slow,
+                               a => $singleaccessmode,
+                               file => $settingsScurves
+                              );
+
+    my %matrixParams = (
+        A => {
+            VCASN => 0x48,
+        },
+        # B => {
+        #     VCASN => 0x49,
+        # },
+        # C => {
+        #     VCASN => 0x4a,
+        # },
+        # D => {
+        #     VCASN => 0x4b,
+        # },
+        );
+
+
+    chdir($sensorname);
+
+    foreach my $matrix ( sort keys %matrixParams ) {
+
+        my $matrixDir = "MATRIX-" . $matrix;
+        mkdir($matrixDir);
+        chdir($matrixDir);
+
+        Mimosis::mimosis_scan_region_loop(
+            fpga        => $fpgalink,
+            slow        => $slow,
+            # a           => $singleaccessmode,
+            a           => 0,
+            region      => $matrix,
+            # vcasnSta    => $lowerlimitA,
+            # vcasnEnd    => $upperlimitA,
+            vcasnSta    => 100,
+            vcasnStep   => 5,
+            ySta        => 250,
+            yEnd        => 253,
+            # yTra        => $yTraSc,
+            # xSta        => $xStaSc,
+            # xEnd        => $xEndSc,
+            # setSta      => $setStaSc,
+            # setEnd      => $setEndSc,
+            # setTra      => $setStepSc,
+            # setCnt      => $setCntSc,
+            # analogAlimA => $analogAlimASc,
+            # analogAlimB => $analogAlimBSc,
+            # analogDlimA => $analogDlimASc,
+            # analogDlimB => $analogDlimBSc,
+            # mod         => $modpulseSc,
+            );
+
+        opendir my $dir, "lastdir" or die "Cannot open directory: $!";
+
+        my @files = readdir $dir;
+
+        foreach my $f ( @files ) {
+
+            if ( $f =~ /VCASN/ ) {
+                chdir("lastdir/$f");
+
+                $matrixParams{$matrix}{"THREAD"} = threads->create(\&fit_thr, $f, $VPHOffsetElectron, $VPHFSlope);
+
+                chdir("../..");
+            }
+        }
 
-else{
-    die();
-}
+        closedir $dir;
+
+        chdir("..");
+    }
+
+    chdir("..");
+
+
+    print "Wait for fits to finish.\n";
+
+    foreach my $matrix ( sort keys %matrixParams ) {
+
+        $matrixParams{$matrix}{"THREAD"}->join();
+    }
+
+
+    print("Note down the VCASN for each submatrix, where the GMDT is closest to 150 e!\n");
+
+    my $foundF = 0;
+
+    foreach my $matrix ( sort keys %matrixParams ) {
+
+        while ( 1 ) {
+
+            print "Enter the appropriate VCASN$matrix value or \'F\' if bad:" ;
+
+            my $vcasnTmp = <STDIN>;
+            chomp $vcasnTmp;
+
+            if ( $vcasnTmp eq "F" or
+                 $vcasnTmp eq "f" ) {
+
+                $file{"RapidSCurves,MATRIX-$matrix"} = "F";
+
+                $foundF = 1;
+                last;
+
+            } else {
+
+                $file{"RapidSCurves,MATRIX-$matrix"} = $vcasnTmp;
+                last;
+            }
+        }
+    }
+    if ( $foundF ) { exit 0; }
 
-#Ziel: Schreibe 3 mal 0x00 und 0xFF und 0xAA in register 0x21 und 0x26 und schaue jeweils, welches register falsch zurück liest.
-#Schreibe das Register raus, sowie was sein soll und was zurück gelesen wird.
+} while ask_continue();
 
-$iter = 3;
 
 
+open(RESULTS_FH, '>', $sensorname . "/results.db") or die $!;
+print RESULTS_FH "$_\t$file{$_}\n" foreach (keys %file);
+close RESULTS_FH;
diff --git a/scripts/qa/dac.pl b/scripts/qa/dac.pl
deleted file mode 100755 (executable)
index 62468d8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/perl
-
-use Getopt::Long;
-use HADES::TrbNet;
-use lib '/d/jspc37/mimosis/scripts/';
-use Mimosis;
-#use Time::HiRes qw(usleep sleep);
-
-trb_init_ports() or die trb_strerror();
-my $plotname = 'test';
-Getopt::Long::Configure(qw(gnu_getopt));
-GetOptions(
-    "plotname|p=s" => \$plotname,
-);
-
-Mimosis::mimosis_dacscan_initial_test(fpga => 0xa000, slow => 10000, a => 1, printall => 1, plotname => $plotname);
-
diff --git a/scripts/qa/k/results.db b/scripts/qa/k/results.db
deleted file mode 100644 (file)
index fee9207..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Operatorname   k
-Sensorname     k
-Digitalcurrent S       100
-Analogcurrent  S       
diff --git a/scripts/qa/kj/CONF_scurves.pl b/scripts/qa/kj/CONF_scurves.pl
new file mode 100644 (file)
index 0000000..0d1d4c9
--- /dev/null
@@ -0,0 +1,18 @@
+#read files like my @config = do "CONF_allregisters.pl";
+
+  #DACs
+  [0x0040,     64  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
+  [0x0041,     52  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
+  [0x0042,     28  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
+  [0x0043,    171  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
+  [0x0044,     70  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
+  [0x0045,     90  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
+  [0x0046,      0  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
+  [0x0047,     67  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x0048,      0  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
+  [0x0049,      0  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
+  [0x004a,      0  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
+  [0x004b,      0  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
+  [0x004c,    150  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x004d,     50  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
+  [0x004e,    125  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
diff --git a/scripts/qa/kj/MATRIX-A/2024-5-17-16-47/METADATA b/scripts/qa/kj/MATRIX-A/2024-5-17-16-47/METADATA
new file mode 100644 (file)
index 0000000..4810467
--- /dev/null
@@ -0,0 +1,9 @@
+START: 2024-5-17-16-47
+VCASN:
+YMIN:  250
+YMAX:  253
+XMIN:  0
+XMAX:  127
+EXITSTATE:     TAKEDATA
+TIME(s):       325
+COMMENT:       <insert comment here>
diff --git a/scripts/qa/kj/MATRIX-A/lastdir b/scripts/qa/kj/MATRIX-A/lastdir
new file mode 120000 (symlink)
index 0000000..c533e41
--- /dev/null
@@ -0,0 +1 @@
+2024-5-17-16-47
\ No newline at end of file
diff --git a/scripts/qa/kk/CONF_scurves.pl b/scripts/qa/kk/CONF_scurves.pl
new file mode 100644 (file)
index 0000000..0d1d4c9
--- /dev/null
@@ -0,0 +1,18 @@
+#read files like my @config = do "CONF_allregisters.pl";
+
+  #DACs
+  [0x0040,     64  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
+  [0x0041,     52  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
+  [0x0042,     28  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
+  [0x0043,    171  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
+  [0x0044,     70  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
+  [0x0045,     90  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
+  [0x0046,      0  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
+  [0x0047,     67  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x0048,      0  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
+  [0x0049,      0  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
+  [0x004a,      0  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
+  [0x004b,      0  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
+  [0x004c,    150  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x004d,     50  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
+  [0x004e,    125  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
diff --git a/scripts/qa/kk/MATRIX-A/2024-5-17-17-7/METADATA b/scripts/qa/kk/MATRIX-A/2024-5-17-17-7/METADATA
new file mode 100644 (file)
index 0000000..10d4f42
--- /dev/null
@@ -0,0 +1,9 @@
+START: 2024-5-17-17-7
+VCASN:
+YMIN:  250
+YMAX:  253
+XMIN:  0
+XMAX:  127
+EXITSTATE:     TAKEDATA
+TIME(s):       76
+COMMENT:       <insert comment here>
diff --git a/scripts/qa/kk/MATRIX-A/lastdir b/scripts/qa/kk/MATRIX-A/lastdir
new file mode 120000 (symlink)
index 0000000..a8d0098
--- /dev/null
@@ -0,0 +1 @@
+2024-5-17-17-7
\ No newline at end of file
diff --git a/scripts/qa/lastdir b/scripts/qa/lastdir
new file mode 120000 (symlink)
index 0000000..730341d
--- /dev/null
@@ -0,0 +1 @@
+2024-5-17-18-32
\ No newline at end of file
diff --git a/scripts/qa/powering.pl b/scripts/qa/powering.pl
deleted file mode 100755 (executable)
index 1f1c293..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#!/usr/bin/perl
diff --git a/scripts/qa/s123/CONF_scurves.pl b/scripts/qa/s123/CONF_scurves.pl
new file mode 100644 (file)
index 0000000..0d1d4c9
--- /dev/null
@@ -0,0 +1,18 @@
+#read files like my @config = do "CONF_allregisters.pl";
+
+  #DACs
+  [0x0040,     64  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
+  [0x0041,     52  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
+  [0x0042,     28  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
+  [0x0043,    171  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
+  [0x0044,     70  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
+  [0x0045,     90  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
+  [0x0046,      0  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
+  [0x0047,     67  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x0048,      0  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
+  [0x0049,      0  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
+  [0x004a,      0  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
+  [0x004b,      0  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
+  [0x004c,    150  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x004d,     50  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
+  [0x004e,    125  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
diff --git a/scripts/qa/s123/DACscan.py b/scripts/qa/s123/DACscan.py
deleted file mode 100644 (file)
index f0de247..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-class DACScan():
-    def readFile(filepath = 'abc.txt'):
-        dac = []
-        file = open(filepath, 'r')
-        for line in file:
-            dac.append( float((line.split('\t'))[2]) )
-        return dac
-        
-
-    def calcGain(dac = []):
-        return (dac[199] - dac[24]) / 175.
-        
-    def calcOffset(dac = []):
-        return dac[0]
-
-    def calcAbsDNLAndAbsINL(dac = [], gain = 6.):
-        dnl = [0]
-        inl = [0]
-        for element in range(21, 201):
-            currentDNL = (dac[element] - dac[element - 1]) / gain - 1
-            dnl.append(currentDNL)
-            inl.append(inl[element - 21] + currentDNL)
-        dnl.sort(reverse=True)
-        inl.sort(reverse=True)
-        return inl, dnl
-            
-    iBiasList = readFile('dacscan_data/IBIAS.csv')
-    iDbList = readFile('dacscan_data/IDB.csv')
-    iThrList = readFile('dacscan_data/ITHR.csv')
-    
-    vPhList = readFile('dacscan_data/VPH.csv')
-    vPlList = readFile('dacscan_data/VPL.csv')
-    vResetList = readFile('dacscan_data/VRESET.csv')
-    vPhfList = readFile('dacscan_data/VPH_FINE.csv')
-    
-    for elements in range(1,256):
-        vPhfList[elements - 1] = vPhfList[elements-1] - vPhList[0]
-    
-    vCasnaList = readFile('dacscan_data/VCASNA.csv')
-    vCasnbList = readFile('dacscan_data/VCASNB.csv')
-    vCasncList = readFile('dacscan_data/VCASNC.csv')
-    vCasndList = readFile('dacscan_data/VCASND.csv')
-    vCasn2List = readFile('dacscan_data/VCASN2.csv')
-    vCaspList = readFile('dacscan_data/VCASP.csv')
-    vClipList = readFile('dacscan_data/VCLIP.csv')
-
-    VPHOffset = vPhList[0]
-    VPLOffset = vPlList[0]
-    VResetOffset = vResetList[0]
-    VPH210 = vPhList[211]
-    VPL210 = vPlList[211]
-    VReset210 = vResetList[211]
-    VPHFOffset = vPhfList[0]
-    VPHF210 = vPhfList[211] - VPHFOffset
-    
-    #print(VPHOffset)
-    #print(VPLOffset)
-    #print(VPHFOffset)
-    #print(VPHF210)
-    #print(VPH210)
-    #print(VPL210)
-    #print(VReset210)
-    
-    sensorQuality = 4
-    
-    if ( (300 <= VPHOffset <= 375) and (300 <= VPLOffset <= 375) and (300 <= VResetOffset <= 375) and VPH210 >= 1410 and VPL210 >= 1410 and VReset210 >= 1410 and VPHFOffset <= 20 and VPHF210 >= 190):
-        sensorQuality = 3
-        if ( max(vCasnaList) > 1100 and max(vCasnbList) > 1100 and max(vCasnbList) > 1100 and max(vCasncList) > 1100 and max(vCasndList) > 1100 and max(vCasn2List) > 1100 and max(vCasn2List) > 1100 and max(vClipList) > 550 and max(vCaspList) > 550 and max(iBiasList) >= 260 and max(iThrList) >= 260 and max(iDbList) >= 260):
-            sensorQuality = 2
-            
-            iBiasINL, iBiasDNL = calcAbsDNLAndAbsINL(iBiasList, calcGain(iBiasList))
-            iThrINL, iThrDNL = calcAbsDNLAndAbsINL(iThrList, calcGain(iThrList))
-            iDbINL, iDbDNL = calcAbsDNLAndAbsINL(iDbList, calcGain(iDbList))
-            
-            vPhINL, vPhDNL = calcAbsDNLAndAbsINL(vPhList, calcGain(vPhList))
-            vPlINL, vPlDNL = calcAbsDNLAndAbsINL(vPlList, calcGain(vPlList))
-            vResetINL, vResetDNL = calcAbsDNLAndAbsINL(vResetList, calcGain(vPlList))
-            vPhfINL, vPhfDNL = calcAbsDNLAndAbsINL(vPhfList, calcGain(vPhfList))
-            
-            vCasnaINL, vCasnaDNL = calcAbsDNLAndAbsINL(vCasnaList, calcGain(vCasnaList))
-            vCasnbINL, vCasnbDNL = calcAbsDNLAndAbsINL(vCasnbList, calcGain(vCasnbList))
-            vCasncINL, vCasncDNL = calcAbsDNLAndAbsINL(vCasncList, calcGain(vCasncList))
-            vCasndINL, vCasndDNL = calcAbsDNLAndAbsINL(vCasndList, calcGain(vCasndList))
-            vCasn2INL, vCasn2DNL = calcAbsDNLAndAbsINL(vCasn2List, calcGain(vCasn2List))
-            vCaspINL, vCaspDNL = calcAbsDNLAndAbsINL(vCaspList, calcGain(vCaspList))
-            vClipINL, vClipDNL = calcAbsDNLAndAbsINL(vClipList, calcGain(vClipList))
-            
-            goodDNL = False
-            if (iBiasDNL[2] < 1 and iThrDNL[2] < 1 and iDbDNL[2] < 1 and vCasnaDNL[2] < 1 and vCasnbDNL[2] < 1 and vCasncDNL[2] < 1 and vCasndDNL[2] < 1 and vCasn2DNL[2] < 1 and vCaspDNL[2] < 1 and vClipDNL[2] < 1 and vPhDNL[2] < 1 and vPlDNL[2] < 1 and vResetDNL[2] < 1 and vPhfDNL[2] < 1):
-                goodDNL = True
-            
-            goodINL = False
-            if (iBiasINL[2] < 5 and iThrINL[2] < 5 and iDbINL[2] < 5 and vCasnaINL[2] < 5 and vCasnbINL[2] < 5 and vCasncINL[2] < 5 and vCasndINL[2] < 5 and vCasn2INL[2] < 5 and vCaspINL[2] < 5 and vClipINL[2] < 5 and vPhINL[2] < 1 and vPlINL[2] < 1 and vResetINL[2] < 1 and vPhfINL[2] < 1):
-                goodINL = True
-            
-            if (goodDNL and goodINL):
-                sensorQuality = 1
-                
-    print("Sensor Quality for DACs is: " + str(sensorQuality))
-    f = open("results.db", "a")
-    f.write("DAC quality\t" + str(sensorQuality))
-    f.close()
-    
diff --git a/scripts/qa/s123/MATRIX-A/2024-5-21-10-44/METADATA b/scripts/qa/s123/MATRIX-A/2024-5-21-10-44/METADATA
new file mode 100644 (file)
index 0000000..53fa68a
--- /dev/null
@@ -0,0 +1,9 @@
+START: 2024-5-21-10-44
+VCASN:
+YMIN:  250
+YMAX:  253
+XMIN:  0
+XMAX:  127
+EXITSTATE:     TAKEDATA
+TIME(s):       4
+COMMENT:       <insert comment here>
diff --git a/scripts/qa/s123/MATRIX-A/lastdir b/scripts/qa/s123/MATRIX-A/lastdir
new file mode 120000 (symlink)
index 0000000..085a634
--- /dev/null
@@ -0,0 +1 @@
+2024-5-21-10-44
\ No newline at end of file
diff --git a/scripts/qa/s123/results.db b/scripts/qa/s123/results.db
deleted file mode 100644 (file)
index 09499cc..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Operatorname   Ben
-Sensorname     s123
-LinksWorking   8       G
-Digitalcurrent S       123
-Analogcurrent  S       
-RapidDACTest   S
diff --git a/scripts/qa/s1234/DACscan.py b/scripts/qa/s1234/DACscan.py
deleted file mode 100644 (file)
index f0de247..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-class DACScan():
-    def readFile(filepath = 'abc.txt'):
-        dac = []
-        file = open(filepath, 'r')
-        for line in file:
-            dac.append( float((line.split('\t'))[2]) )
-        return dac
-        
-
-    def calcGain(dac = []):
-        return (dac[199] - dac[24]) / 175.
-        
-    def calcOffset(dac = []):
-        return dac[0]
-
-    def calcAbsDNLAndAbsINL(dac = [], gain = 6.):
-        dnl = [0]
-        inl = [0]
-        for element in range(21, 201):
-            currentDNL = (dac[element] - dac[element - 1]) / gain - 1
-            dnl.append(currentDNL)
-            inl.append(inl[element - 21] + currentDNL)
-        dnl.sort(reverse=True)
-        inl.sort(reverse=True)
-        return inl, dnl
-            
-    iBiasList = readFile('dacscan_data/IBIAS.csv')
-    iDbList = readFile('dacscan_data/IDB.csv')
-    iThrList = readFile('dacscan_data/ITHR.csv')
-    
-    vPhList = readFile('dacscan_data/VPH.csv')
-    vPlList = readFile('dacscan_data/VPL.csv')
-    vResetList = readFile('dacscan_data/VRESET.csv')
-    vPhfList = readFile('dacscan_data/VPH_FINE.csv')
-    
-    for elements in range(1,256):
-        vPhfList[elements - 1] = vPhfList[elements-1] - vPhList[0]
-    
-    vCasnaList = readFile('dacscan_data/VCASNA.csv')
-    vCasnbList = readFile('dacscan_data/VCASNB.csv')
-    vCasncList = readFile('dacscan_data/VCASNC.csv')
-    vCasndList = readFile('dacscan_data/VCASND.csv')
-    vCasn2List = readFile('dacscan_data/VCASN2.csv')
-    vCaspList = readFile('dacscan_data/VCASP.csv')
-    vClipList = readFile('dacscan_data/VCLIP.csv')
-
-    VPHOffset = vPhList[0]
-    VPLOffset = vPlList[0]
-    VResetOffset = vResetList[0]
-    VPH210 = vPhList[211]
-    VPL210 = vPlList[211]
-    VReset210 = vResetList[211]
-    VPHFOffset = vPhfList[0]
-    VPHF210 = vPhfList[211] - VPHFOffset
-    
-    #print(VPHOffset)
-    #print(VPLOffset)
-    #print(VPHFOffset)
-    #print(VPHF210)
-    #print(VPH210)
-    #print(VPL210)
-    #print(VReset210)
-    
-    sensorQuality = 4
-    
-    if ( (300 <= VPHOffset <= 375) and (300 <= VPLOffset <= 375) and (300 <= VResetOffset <= 375) and VPH210 >= 1410 and VPL210 >= 1410 and VReset210 >= 1410 and VPHFOffset <= 20 and VPHF210 >= 190):
-        sensorQuality = 3
-        if ( max(vCasnaList) > 1100 and max(vCasnbList) > 1100 and max(vCasnbList) > 1100 and max(vCasncList) > 1100 and max(vCasndList) > 1100 and max(vCasn2List) > 1100 and max(vCasn2List) > 1100 and max(vClipList) > 550 and max(vCaspList) > 550 and max(iBiasList) >= 260 and max(iThrList) >= 260 and max(iDbList) >= 260):
-            sensorQuality = 2
-            
-            iBiasINL, iBiasDNL = calcAbsDNLAndAbsINL(iBiasList, calcGain(iBiasList))
-            iThrINL, iThrDNL = calcAbsDNLAndAbsINL(iThrList, calcGain(iThrList))
-            iDbINL, iDbDNL = calcAbsDNLAndAbsINL(iDbList, calcGain(iDbList))
-            
-            vPhINL, vPhDNL = calcAbsDNLAndAbsINL(vPhList, calcGain(vPhList))
-            vPlINL, vPlDNL = calcAbsDNLAndAbsINL(vPlList, calcGain(vPlList))
-            vResetINL, vResetDNL = calcAbsDNLAndAbsINL(vResetList, calcGain(vPlList))
-            vPhfINL, vPhfDNL = calcAbsDNLAndAbsINL(vPhfList, calcGain(vPhfList))
-            
-            vCasnaINL, vCasnaDNL = calcAbsDNLAndAbsINL(vCasnaList, calcGain(vCasnaList))
-            vCasnbINL, vCasnbDNL = calcAbsDNLAndAbsINL(vCasnbList, calcGain(vCasnbList))
-            vCasncINL, vCasncDNL = calcAbsDNLAndAbsINL(vCasncList, calcGain(vCasncList))
-            vCasndINL, vCasndDNL = calcAbsDNLAndAbsINL(vCasndList, calcGain(vCasndList))
-            vCasn2INL, vCasn2DNL = calcAbsDNLAndAbsINL(vCasn2List, calcGain(vCasn2List))
-            vCaspINL, vCaspDNL = calcAbsDNLAndAbsINL(vCaspList, calcGain(vCaspList))
-            vClipINL, vClipDNL = calcAbsDNLAndAbsINL(vClipList, calcGain(vClipList))
-            
-            goodDNL = False
-            if (iBiasDNL[2] < 1 and iThrDNL[2] < 1 and iDbDNL[2] < 1 and vCasnaDNL[2] < 1 and vCasnbDNL[2] < 1 and vCasncDNL[2] < 1 and vCasndDNL[2] < 1 and vCasn2DNL[2] < 1 and vCaspDNL[2] < 1 and vClipDNL[2] < 1 and vPhDNL[2] < 1 and vPlDNL[2] < 1 and vResetDNL[2] < 1 and vPhfDNL[2] < 1):
-                goodDNL = True
-            
-            goodINL = False
-            if (iBiasINL[2] < 5 and iThrINL[2] < 5 and iDbINL[2] < 5 and vCasnaINL[2] < 5 and vCasnbINL[2] < 5 and vCasncINL[2] < 5 and vCasndINL[2] < 5 and vCasn2INL[2] < 5 and vCaspINL[2] < 5 and vClipINL[2] < 5 and vPhINL[2] < 1 and vPlINL[2] < 1 and vResetINL[2] < 1 and vPhfINL[2] < 1):
-                goodINL = True
-            
-            if (goodDNL and goodINL):
-                sensorQuality = 1
-                
-    print("Sensor Quality for DACs is: " + str(sensorQuality))
-    f = open("results.db", "a")
-    f.write("DAC quality\t" + str(sensorQuality))
-    f.close()
-    
diff --git a/scripts/qa/s1234/results.db b/scripts/qa/s1234/results.db
deleted file mode 100644 (file)
index 9b9ac00..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-Operatorname   Ben
-Sensorname     s1234
-LinksWorking   G       8
-Digitalcurrent S       123
-Analogcurrent  S       
-RapidDACTest   S
-DAC quality    2RapidSCurves,MatrixA   F       SubA
-RapidSCurves,MatrixB   F       SubB
-RapidSCurves,MatrixC   F       SubC
-RapidSCurves,MatrixD   F       SubC
diff --git a/scripts/qa/s12345/results.db b/scripts/qa/s12345/results.db
deleted file mode 100644 (file)
index f32c1f0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Operatorname   Ben
-Sensorname     s12345
-LinksWorking   G       8
-Digitalcurrent S       123
-Analogcurrent  S       
-RapidDACTest   F
diff --git a/scripts/qa/s1234543/results.db b/scripts/qa/s1234543/results.db
deleted file mode 100644 (file)
index d1c78c1..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Operatorname   Ben
-Sensorname     s1234543
-Digitalcurrent S       100
-Analogcurrent  S       
diff --git a/scripts/qa/s123456/results.db b/scripts/qa/s123456/results.db
deleted file mode 100644 (file)
index 12c44f9..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Operatorname   Ben
-Sensorname     s123456
-LinksWorking   G       8
-Digitalcurrent S       123
-Analogcurrent  S       
diff --git a/scripts/qa/s2222/results.db b/scripts/qa/s2222/results.db
new file mode 100644 (file)
index 0000000..0f276bf
--- /dev/null
@@ -0,0 +1 @@
+SensorName     s2222
diff --git a/scripts/qa/s2345/results.db b/scripts/qa/s2345/results.db
deleted file mode 100644 (file)
index 1d89d5f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Operatorname   Ben
-Sensorname     s2345
-LinksWorking   G       8
-Digitalcurrent S       123
-Analogcurrent  S       
diff --git a/scripts/qa/uu/CONF_scurves.pl b/scripts/qa/uu/CONF_scurves.pl
new file mode 100644 (file)
index 0000000..0d1d4c9
--- /dev/null
@@ -0,0 +1,18 @@
+#read files like my @config = do "CONF_allregisters.pl";
+
+  #DACs
+  [0x0040,     64  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
+  [0x0041,     52  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
+  [0x0042,     28  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
+  [0x0043,    171  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
+  [0x0044,     70  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
+  [0x0045,     90  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
+  [0x0046,      0  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
+  [0x0047,     67  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x0048,      0  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
+  [0x0049,      0  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
+  [0x004a,      0  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
+  [0x004b,      0  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
+  [0x004c,    150  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x004d,     50  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
+  [0x004e,    125  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
diff --git a/scripts/qa/uu/MATRIX-A/2024-5-17-17-1/METADATA b/scripts/qa/uu/MATRIX-A/2024-5-17-17-1/METADATA
new file mode 100644 (file)
index 0000000..e74e1bb
--- /dev/null
@@ -0,0 +1,9 @@
+START: 2024-5-17-17-1
+VCASN:
+YMIN:  250
+YMAX:  253
+XMIN:  0
+XMAX:  127
+EXITSTATE:     TAKEDATA
+TIME(s):       14
+COMMENT:       <insert comment here>
diff --git a/scripts/qa/uu/MATRIX-A/lastdir b/scripts/qa/uu/MATRIX-A/lastdir
new file mode 120000 (symlink)
index 0000000..6f0a44d
--- /dev/null
@@ -0,0 +1 @@
+2024-5-17-17-1
\ No newline at end of file
diff --git a/scripts/qa/yyy/CONF_scurves.pl b/scripts/qa/yyy/CONF_scurves.pl
new file mode 100644 (file)
index 0000000..0d1d4c9
--- /dev/null
@@ -0,0 +1,18 @@
+#read files like my @config = do "CONF_allregisters.pl";
+
+  #DACs
+  [0x0040,     64  ], #IBIAS       0 - 80 nA      ,  312 pA     Pixel current
+  [0x0041,     52  ], #ITHR        0 - 2.5 nA     ,  9.8 pA     Pixel current
+  [0x0042,     28  ], #IDB         0 - 40 nA      ,  157 pA     Pixel current
+  [0x0043,    171  ], #VRESET      0.37 - 1.79 V  ,  6 mV       Pixel input amplifier reset voltage
+  [0x0044,     70  ], #VPL         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (low  value)
+  [0x0045,     90  ], #VPH         0.37 - 1.79 V  ,  6 mV       Pixel voltage for charge injection (high
+  [0x0046,      0  ], #VPH_FINE    0 - 256 mV     ,  1 mV           value) VPH+VPH_FINE
+  [0x0047,     67  ], #VCASP       0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x0048,      0  ], #VCASNA      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix A
+  [0x0049,      0  ], #VCASNB      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix B
+  [0x004a,      0  ], #VCASNC      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix C
+  [0x004b,      0  ], #VCASND      0 - 1.54 V     ,  6 mV       Pixel threshold voltage for submatrix D
+  [0x004c,    150  ], #VCASN2      0 - 1.54 V     ,  6 mV       Pixel voltage
+  [0x004d,     50  ], #VCLIP       0 - 1.54 V     ,  6 mV       Pixel clipping amplifier voltage
+  [0x004e,    125  ], #IBUFBIAS    0 - 10 μA      ,  312 pA     Internal buffer bias (not in pixel)
diff --git a/scripts/qa/yyy/MATRIX-A/2024-5-17-17-46/METADATA b/scripts/qa/yyy/MATRIX-A/2024-5-17-17-46/METADATA
new file mode 100644 (file)
index 0000000..384c411
--- /dev/null
@@ -0,0 +1,9 @@
+START: 2024-5-17-17-46
+VCASN:
+YMIN:  250
+YMAX:  253
+XMIN:  0
+XMAX:  127
+EXITSTATE:     TAKEDATA
+TIME(s):       46
+COMMENT:       <insert comment here>
diff --git a/scripts/qa/yyy/MATRIX-A/lastdir b/scripts/qa/yyy/MATRIX-A/lastdir
new file mode 120000 (symlink)
index 0000000..d70f849
--- /dev/null
@@ -0,0 +1 @@
+2024-5-17-17-46
\ No newline at end of file
index df7a1a27be9e3ab1fab3dde8e14aa1eed09be32e..7a24b429e46a64820aa5d9e03e0b973093256066 100755 (executable)
@@ -1,49 +1,26 @@
 #!/bin/bash
-#echo Reset and Config TrbNet
-#cd ../trbnet/
-#./start.sh
-#cd -
 
 echo Mimosis reset
 cd ../git/daqtools/xml-db
-./put.pl Mimosis 0xfe82 MimosisReset 0
-sleep .1
-./put.pl Mimosis 0xfe82 MimosisReset 1
-sleep .1
+./put.pl Mimosis 0xfe82 MimosisReset 0; sleep 1
+./put.pl Mimosis 0xfe82 MimosisReset 1; sleep 1
 cd -
 
 echo Load basic settings
-#./basicsettings.pl -s -d conf/CONF_allregisters.pl --fpga 0xfe82
-#./basicsettings.pl -s -d conf/CONF_testmode_enable.pl --fpga 0xfe82
-mimosis -f 0xfe82 -a load conf/CONF_allregisters.pl
-mimosis -f 0xfe82 -a load conf/CONF_testmode_enable.pl
-# cd gbtsc
-# ./set_reg.sh # = CONF_allregisters.pl
-# ./sca-main.pl -f 0xa001 0x1 0x3 0x40 0x00204800;
-# ./sca-main.pl -f 0xa001 0x1 0x3 0xda 0x12000000; # = testmode_enable
-#cd -
-sleep .1
+mimosis -f 0xfe82 -a load -w conf/CONF_allregisters.pl; sleep .1
+mimosis -f 0xfe82 -a load -w conf/CONF_testmode_enable.pl; sleep .1
 
 echo Bit and word align
 cd ../git/daqtools/xml-db
 ./put.pl Mimosis 0xfe82 InputReset 1
-./put.pl Mimosis 0xfe82 InputReset 0
-sleep .1
-./get.pl Mimosis 0xfe82 DelayPosition
-sleep .1
-./put.pl Mimosis 0xfe82 AlignFixed 0
-sleep .1
+./put.pl Mimosis 0xfe82 InputReset 0; sleep .1
+./get.pl Mimosis 0xfe82 DelayPosition; sleep .1
+./put.pl Mimosis 0xfe82 AlignFixed 0; sleep .1
 ./put.pl Mimosis 0xfe82 AlignFixed 1
 ./get.pl Mimosis 0xfe82 LastWord
 cd -
 
-
 mimosis -f 0xfe82 -a load conf/CONF_testmode_disable.pl
-#./basicsettings.pl -s -d conf/CONF_testmode_disable.pl --fpga 0xfe82
-# cd gbtsc
-# ./sca-main.pl -f 0xa001 0x1 0x3 0x40 0x00204000;
-# ./sca-main.pl -f 0xa001 0x1 0x3 0xda 0x12000000; # = testmode_disable
-# cd -
 
 cd ../git/daqtools/xml-db
 #./get.pl Mimosis 0xfe82 CounterHeader rates #nicht implementiert...
@@ -51,7 +28,6 @@ cd ../git/daqtools/xml-db
 cd -
 
 echo Config CTS
-
 if [[ "$DAQOPSERVER" == "jspc29:150" ]]; then
     #01.317 setup
     trbcmd w       0xc000 0xa146 0x000186a0   #1kHz pulser
@@ -65,4 +41,3 @@ elif [[ "$DAQOPSERVER" == "jspc29:31" ]]; then
 else
     echo "problem.."
 fi
-