--- /dev/null
+#! /bin/bash
+#####################################
+### gain: 4 mV/fC
+#~ peaking time: 15 ns
+#~ tail cancellation shaper settings:
+#~ TC1C=13.5 pF, TC1R=19 kΩ,
+#~ TC2C=1.5 pF, TC2R=23 kΩ
+#~ trbcmd w 0xfe91 0xa200 0x50011
+#~ trbcmd w 0xfe91 0xa201 0x5012c
+#~ trbcmd w 0xfe91 0xa202 0x50236
+#~ trbcmd w 0xfe91 0xa210 0x50011
+#~ trbcmd w 0xfe91 0xa211 0x5012c
+#~ trbcmd w 0xfe91 0xa212 0x50236
+#~ trbcmd w 0xfe91 0xa220 0x50011
+#~ trbcmd w 0xfe91 0xa221 0x5012c
+#~ trbcmd w 0xfe91 0xa222 0x50236
+#~ trbcmd w 0xfe91 0xa230 0x50011
+#~ trbcmd w 0xfe91 0xa231 0x5012c
+#~ trbcmd w 0xfe91 0xa232 0x50236
+#####################################
+### gain: 4 mV/fC
+#~ peaking time: 10 ns
+#~ tail cancellation shaper settings:
+#~ TC1C=13.5 pF, TC1R=19 kΩ,
+#~ TC2C=1.5 pF, TC2R=23 kΩ
+#~ trbcmd w 0xfe91 0xa200 0x50010
+#~ trbcmd w 0xfe91 0xa201 0x5012c
+#~ trbcmd w 0xfe91 0xa202 0x50236
+#~ trbcmd w 0xfe91 0xa210 0x50010
+#~ trbcmd w 0xfe91 0xa211 0x5012c
+#~ trbcmd w 0xfe91 0xa212 0x50236
+#~ trbcmd w 0xfe91 0xa220 0x50010
+#~ trbcmd w 0xfe91 0xa221 0x5012c
+#~ trbcmd w 0xfe91 0xa222 0x50236
+#~ trbcmd w 0xfe91 0xa230 0x50010
+#~ trbcmd w 0xfe91 0xa231 0x5012c
+#~ trbcmd w 0xfe91 0xa232 0x50236
+#####################################
+#####################################
+### gain: 4 mV/fC
+#~ peaking time: 10 ns
+#~ tail cancellation shaper settings:
+#~ TC1C=6.0 pF, TC1R=23 kΩ,
+#~ TC2C=0.6 pF, TC2R=11 kΩ
+# trbcmd w 0xfe91 0xa200 0x50010
+# trbcmd w 0xfe91 0xa201 0x50105
+# trbcmd w 0xfe91 0xa202 0x50202
+# trbcmd w 0xfe91 0xa210 0x50010
+# trbcmd w 0xfe91 0xa211 0x50105
+# trbcmd w 0xfe91 0xa212 0x50202
+# trbcmd w 0xfe91 0xa220 0x50010
+# trbcmd w 0xfe91 0xa221 0x50105
+# trbcmd w 0xfe91 0xa222 0x50202
+# trbcmd w 0xfe91 0xa230 0x50010
+# trbcmd w 0xfe91 0xa231 0x50105
+# trbcmd w 0xfe91 0xa232 0x50202
+#####################################
+#####################################
+### gain: 4 mV/fC
+#~ peaking time: 10 ns
+#~ tail cancellation shaper settings:
+#~ TC1C=7.5 pF, TC1R=27 kΩ,
+#~ TC2C=0.75 pF, TC2R=17 kΩ
+# trbcmd w 0xfe91 0xa200 0x50010
+# trbcmd w 0xfe91 0xa201 0x5010E
+# trbcmd w 0xfe91 0xa202 0x5020C
+# trbcmd w 0xfe91 0xa210 0x50010
+# trbcmd w 0xfe91 0xa211 0x5010E
+# trbcmd w 0xfe91 0xa212 0x5020C
+# trbcmd w 0xfe91 0xa220 0x50010
+# trbcmd w 0xfe91 0xa221 0x5010E
+# trbcmd w 0xfe91 0xa222 0x5020C
+# trbcmd w 0xfe91 0xa230 0x50010
+# trbcmd w 0xfe91 0xa231 0x5010E
+# trbcmd w 0xfe91 0xa232 0x5020C
+#####################################
+#####################################
+### gain: 4 mV/fC
+#~ peaking time: 10 ns
+#~ tail cancellation shaper settings:
+#~ TC1C=15 pF, TC1R=7 kΩ, --> 50131
+#~ TC2C=0.6 pF, TC2R=8 kΩ --> 50201
+# trbcmd w 0xfe91 0xa200 0x50010
+# trbcmd w 0xfe91 0xa201 0x50131
+# trbcmd w 0xfe91 0xa202 0x50201
+# trbcmd w 0xfe91 0xa210 0x50010
+# trbcmd w 0xfe91 0xa211 0x50131
+# trbcmd w 0xfe91 0xa212 0x50201
+# trbcmd w 0xfe91 0xa220 0x50010
+# trbcmd w 0xfe91 0xa221 0x50131
+# trbcmd w 0xfe91 0xa222 0x50201
+# trbcmd w 0xfe91 0xa230 0x50010
+# trbcmd w 0xfe91 0xa231 0x50131
+# trbcmd w 0xfe91 0xa232 0x50201
+#####################################
+#####DEFUALT black setting #####################
+### gain: 4 mV/fC
+#~ peaking time: 10 ns
+#~ tail cancellation shaper settings:
+#~ TC1C=10.5 pF, TC1R=27 kΩ, --> 5011E
+#~ TC2C=0.9 pF, TC2R= 20 kΩ --> 50215
+trbcmd w 0xfe91 0xa200 0x50010
+trbcmd w 0xfe91 0xa201 0x5011E
+trbcmd w 0xfe91 0xa202 0x50215
+trbcmd w 0xfe91 0xa210 0x50010
+trbcmd w 0xfe91 0xa211 0x5011E
+trbcmd w 0xfe91 0xa212 0x50215
+trbcmd w 0xfe91 0xa220 0x50010
+trbcmd w 0xfe91 0xa221 0x5011E
+trbcmd w 0xfe91 0xa222 0x50215
+trbcmd w 0xfe91 0xa230 0x50010
+trbcmd w 0xfe91 0xa231 0x5011E
+trbcmd w 0xfe91 0xa232 0x50215
+#####################################
\ No newline at end of file
--- /dev/null
+#!/usr/bin/perl
+
+use Getopt::Long;
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+use Data::Dumper;
+
+
+trb_init_ports() or die trb_strerror();
+
+
+i2c_cmd(0xfe90,0x30,0xd2,0xe1);
+usleep(1000);
+
+i2c_cmd(0xfe90,0x30,,0xb4);
+usleep(2000);
+
+i2c_cmd(0xfe90,0x30,0xa5,0xcc);
+usleep(2000);
+i2c_cmd(0xfe90,0x30,0xa5,0x44);
+usleep(2000);
+
+sleep(1);
+
+i2c_cmd(0xfe90,0x30,,0xb4);
+usleep(2000);
+
+i2c_cmd(0xfe90,0x30,0xa5,0xcc);
+usleep(2000);
+i2c_cmd(0xfe90,0x30,0xa5,0xbe);
+usleep(2000);
+
+i2c_cmd(0xfe90,0x30,0x96);
+usleep(2000);
+i2c_cmd(0xfe90,0x30,0xe1,0xe1);
+usleep(2000);
+my $ret1 = i2c_cmd(0xfe90,0x30,0xe1);
+
+i2c_cmd(0xfe90,0x30,0x96);
+usleep(2000);
+i2c_cmd(0xfe90,0x30,0xe1,0xe1);
+usleep(2000);
+my $ret2 = i2c_cmd(0xfe90,0x30,0xe1);
+
+foreach my $f (keys %$ret1) {
+ next if ($ret1->{$f} == 0xff && $ret2->{$f} == 0xff);
+ printf("%04x\t%2.1f\n",$f,($ret1->{$f}+($ret2->{$f} << 8))/16);
+ }
+
+
+
+sub i2c_cmd {
+ my ($fpga,$addr,$cmd,$byte1,$byte2) = @_;
+ my $reg_data = (($byte2||0) << 24) + (($byte1||0) << 16) + (($cmd||0) << 8) + 0x80 + ($addr >> 1);
+ my $reg_flag = 0;
+ my $word = (defined $byte2)?1:0;
+
+ if(defined($cmd)) {
+ $reg_flag = $word? 0x001 : 0x000;
+ }
+ else {
+ $reg_flag = $word? 0x011 : 0x010;
+ }
+
+ if(defined($byte1)) {
+ trb_register_write_mem($fpga,0xd681,0,[$reg_flag,$reg_data],2);
+ }
+ else {
+ $reg_flag |= 0x100;
+ trb_register_write_mem($fpga,0xd681,0,[$reg_flag,$reg_data],2);
+ usleep(1000);
+ $reg_return = trb_register_read($fpga,0xd684);
+
+ my $ret;
+ foreach my $f (keys %$reg_return) {
+ $ret->{$f} = $reg_return->{$f}&($word?0xffff:0xff);
+ }
+ return $ret;
+ }
+ }
+
+
--- /dev/null
+THRES=$2
+S=$1
+for mbo in 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ do
+ for tdc in 0 1 2
+ do
+ for PT in 0 1 2 3
+ do
+ ./pasttrec_set_threshold.pl -b 0xa$S$mbo$tdc -p $PT $THRES
+ done
+ done
+ done
+
+# ## II1 MBO A
+# ./pasttrec_set_threshold.pl -b 0xa7a0 -p 0 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7a0 -p 1 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7a0 -p 2 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7a0 -p 3 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7a1 -p 0 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7a1 -p 1 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7a1 -p 2 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7a1 -p 3 $THRES
+# ## II1 MBO b
+# ./pasttrec_set_threshold.pl -b 0xa7B0 -p 0 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7B0 -p 1 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7B0 -p 2 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7b0 -p 3 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7b1 -p 0 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7b1 -p 1 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7b1 -p 2 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7b1 -p 3 $THRES
+#
+# ## II2 MBO E
+# ./pasttrec_set_threshold.pl -b 0xa8e0 -p 0 50
+# #./pasttrec_set_threshold.pl -b 0xa7e0 -p 1 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa7e0 -p 2 100
+# ./pasttrec_set_threshold.pl -b 0xa8e0 -p 3 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa8e1 -p 0 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa8e1 -p 1 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa8e1 -p 2 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa8e1 -p 3 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa8e2 -p 0 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa8e2 -p 1 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa8e2 -p 2 $THRES
+# ./pasttrec_set_threshold.pl -b 0xa8e2 -p 3 $THRES