def set_bias_voltage(channel, voltage, sc): v = float(voltage) c = int(channel) #print "channel=%d" % c #print "voltage=%f" % v adc_val = int(4096.*v/2.5/2.) # Vout = 2*Vref*x/4096 # Vref = 2.5V if adc_val < 0 or adc_val > 4095: "ADC value out of range, possible values are 0 ... 4.99 V" #print "ADC value=0x%x" % adc_val i2c_address = 0xA8320000 # a write access looks like: # - I2C address # - pointer (channel address) # - two data bytes: # 15:14 register = 11 for the output register # 13:2 DAC value (Vout) # 1:0 padding = 00 i2c_data = (c & 0xFF)<<16 | 0xC000 | (adc_val & 0xFFF)<<2 # open I2C on connector 8 SlowControl.write_list(sc, 0x1877, [0xE0300000], [0x80], False) # set the DAC value SlowControl.write_list(sc, 0x1877, [i2c_address], [i2c_data], False)
def set_bias_voltage(channel, voltage, sc): v = float(voltage) c = int(channel) #print "channel=%d" % c #print "voltage=%f" % v adc_val = int(4096. * v / 2.5 / 2.) # Vout = 2*Vref*x/4096 # Vref = 2.5V if adc_val < 0 or adc_val > 4095: "ADC value out of range, possible values are 0 ... 4.99 V" #print "ADC value=0x%x" % adc_val i2c_address = 0xA8320000 # a write access looks like: # - I2C address # - pointer (channel address) # - two data bytes: # 15:14 register = 11 for the output register # 13:2 DAC value (Vout) # 1:0 padding = 00 i2c_data = (c & 0xFF) << 16 | 0xC000 | (adc_val & 0xFFF) << 2 # open I2C on connector 8 SlowControl.write_list(sc, 0x1877, [0xE0300000], [0x80], False) # set the DAC value SlowControl.write_list(sc, 0x1877, [i2c_address], [i2c_data], False)
def main(): if not (len(sys.argv) == 3): print 'received {0:d} '.format(len(sys.argv)), \ 'instead of 2 parameters!' print './biasDAC.py <channel> <voltage>' print '\tchannel: 0..15' print '\tvoltage: 0 .. 4.99 (in Volts)' return 1 else: sc = SlowControl.SlowControl(0) set_bias_voltage(sys.argv[1], sys.argv[2], sc) return 0
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code dHLVDS = SlowControl.SlowControl(0) dADC = SlowControl.SlowControl(1) SlowControl.read_burst(dHLVDS, 6039, 26, 4, False) SlowControl.read_burst(dADC, 6039, 10, 4, False) quit()
#! /usr/bin/env python ## ## starting continous readout of the FEC HLVDS only ## import SlowControl # slow control code m = SlowControl.SlowControl(0) # HLVDS FEC (master) # enable digital I/Os on the master SlowControl.write_list(m, 0x1977, [0x2, 0x1], [ 0x300, 0x1FF ], False) # enable sync on the master # start readout SlowControl.write_list(m, 6039, [ 0x16 ], [ 0x1 ], False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time sc = SlowControl.SlowControl(1) rply = SlowControl.read_burst(sc, 6039, 7, 1) dcm_status = 0x3FFFF while rply.success == False or rply.errors[0] != 0x0 or rply.data[0] != dcm_status: print "Rebooting FEC ADC as it doesn't seem to be ready!" if rply.success == True: print "DCM status: 0x%x" % rply.data[0] else: print "Readout not successful!" SlowControl.write_list(sc, 6007, [0xFFFFFFFF], [0xFFFF8000]) time.sleep(15) rply = SlowControl.read_burst(sc, 6039, 7, 1) print "ADC DCM seems to be alright" quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time m = SlowControl.SlowControl(0) # HLVDS FEC (master) s = SlowControl.SlowControl(1) # ADC FEC (slave) # enable digital I/Os on the master SlowControl.write_list(m, 0x1977, [0x2, 0x1], [0x300, 0x1FF], False) # enable slave SlowControl.write_burst(s, 6039, 0x3, [0x1], False) time.sleep(1) # enable sync on the master # start readout SlowControl.write_list(m, 6039, [0x19, 0x16], [0x1, 0x1], False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code dHLVDS = SlowControl.SlowControl(0) dADC = SlowControl.SlowControl(1) # HLVDS: trigger is in register 24 # 1: 0 triggering mode: 0 = auto, 1 = ext 2 = TLU # 2 TLU reset signal enable # 3 busy mode: 0 = excluding driver, 1 = including driver # 10: 4 clk div # 18:12 wait length trg_set = 2 # = TLU + busy w/o driver trg_set = trg_set | (0x18 << 4 ) # clk divider (0x18) (minimum working 0x5 in the lab) trg_set = trg_set | (0x2f << 12) # wait length (0x2f) SlowControl.write_list(dHLVDS, 6039, [24], [trg_set], False) SlowControl.write_list(dADC, 6039, [2], [trg_set], False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time sc = SlowControl.SlowControl(1) SlowControl.write_list(sc, 6007, [ 0xFFFFFFFF ], [ 0xFFFF8000 ], False, False) quit()
#! /usr/bin/env python ## ## synchronous reset via slow control of the FEC HLVDS ## import SlowControl # slow control code sc = SlowControl.SlowControl(0) # send a reset pulse of 1 us to all parts of the application unit, # with a synchronous reset # # bit 0: complete synchronous reset # 1: send reset to all asynchronous reset lines # 2: reset the DUT driver only # 3: reset the trigger unit # 4: reset the timer # reset register is located at the address 0xFFFFFFFF # value: # 15 downto 0: reset signal lines # 23 downto 16: length of the reset pulse (x+1)*100ns # 31 downto 24: ??? # issue asynchronous reset for 1 us: SlowControl.write_list(sc, 6039, [0xFFFFFFFF], [0x90002], False) quit()
0b0111111100000, # 0x0a (10) global reset settings by state (0 = active, 1 = inactive) # .*=-.*=-.*=-. # stReset (0), stInit (1), stDly (2), stTrigWait (3), stPreAcq (4), # stAcq (5), stAcqWait (6), stRdoWait (7), stRdoStart (8), # stRdoFirst (9), stRdoPause (10), stRdo (11), stPostEvtDly (12) 0x2, # 0x0b (11) nim_out signal assignment (0 = off, 1 = on) # a_pulse_ref (0), combined_busy (1) 0x0, # 0x0c (12) 0x0, # 0x0d (13) 0x0, # 0x0e (14) 0x0, # 0x0f (15) 0x0, # 0x10 (16) 0x0, # 0x11 (17) 0x0, # 0x12 (18) 0x0, # 0x13 (19) 0x0, # 0x14 (20) 0x0, # 0x15 (21) # general configuration rdo_settings, # 0x16 (22) readout control 8832, # 0x17 (23) maximum frame size trg_settings # 0x18 (24) trigger control ] # all higher addresses are read-only SlowControl.write_burst(m, 6039, 0x0, values_HLVDS, False) biasDAC.set_bias_voltage(12, 1.6, m) # Vreset biasDAC.set_bias_voltage(8, 0.4, m) # VCASN biasDAC.set_bias_voltage(10, 0.6, m) # VCASP quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code dADC = SlowControl.SlowControl(1) #SlowControl.write_burst(dADC, 6519, 0x1, [0x0, 0x0, 0x0, 0x0], False) SlowControl.write_list(dADC, 6519, [0x2, 0x3, 0x4], [0x0, 0x0, 0x0], False) # 01 = power down CH0 # 02 = power down CH1 # 03 = equalizer level 0 # 04 = equalizer level 1 # 05 = TRGOUT enable # 06 = BCLK enable # Register Bit 7 6 5 4 3 2 1 0 # HDMI connector 4 5 6 7 0 1 2 3 quit()
#! /usr/bin/env python ## ## prepare the SRS for the readout of an Explorer-1 in single-event ## readout mode ## import SlowControl # slow control code import time m = SlowControl.SlowControl(0) # HLVDS FEC (master) # enable digital I/Os on the master (0x1977 = 6519) SlowControl.write_list(m, 0x1977, [0x2, 0x1], [0x300, 0x1FF], False) # activate the single-event readout mode (0x16 -> 0x4) # this bit has to be set to make trigger/timer unit running SlowControl.write_list(m, 6039, [0x16], [0x4], False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time m = SlowControl.SlowControl(0) # HLVDS FEC (master) s = SlowControl.SlowControl(1) # ADC FEC (slave) # enable digital I/Os on the master SlowControl.write_list(m, 0x1977, [0x2, 0x1], [ 0x300, 0x1FF ], False) # enable slave SlowControl.write_burst(s, 6039, 0x3, [ 0x1 ], False) time.sleep(1) # enable sync on the master (0x18 -> 0x1) # and # activate the single-event readout mode (0x16 -> 0x4) # this bit has to be set to make trigger/timer unit running SlowControl.write_list(m, 6039, [ 0x19, 0x16 ], [ 0x1, 0x4 ], False) quit()
#! /usr/bin/env python ## ## standard configuration of the FEC HLVDS for the use ## with the pALPIDE with the Padua Proximity board V1 ## import sys import os import SlowControl # slow control code import biasDAC # special code to setup up the voltage biases m = SlowControl.SlowControl(0) # HLVDS FEC (master) # was the integration time given as a commandline argument? if len(sys.argv) >= 2: integration_time = int(float(sys.argv[1]) / 0.00625) # Acquisition time is expected to specified in micro seconds (us) else: integration_time = 0xf600 # default value if len(sys.argv) >= 3: trigger_delay = int(float(sys.argv[2]) / 0.00625) # Acquisition time is expected to specified in micro seconds (us) else: trigger_delay = 0 # default value # 0x16 (22) readout control # # The bits (2:0) are not set during configuration, as they are set during the # (start-up of a) measurement. # # 3: driver loop mode (activates the complete sequence although no data is sent)
#! /usr/bin/env python import sys import SlowControl # slow control code if (len(sys.argv) < 2): print "ERROR: please specific FEC ID" quit(1) s = SlowControl.SlowControl(int(sys.argv[1])) # GIT information of the firmware is located in the system register (port 6007) # add the addresses 15 to 23 rply = SlowControl.read_burst(s, 6007, 15, 9) # check whether the reply if len(rply.data) != 9 or rply.success == False: print "ERROR: read request was not successful" print str(rply) quit(2) else: print "FEC_VERSION=0x%x" % rply.data[0] print "GIT_HASH=0x%0.8x%0.8x%0.8x%0.8x%0.8x" % \ ( rply.data[5], rply.data[4], rply.data[3], rply.data[2], rply.data[1] ) print "GIT_HASH_ABBR=0x%0.7x" % (rply.data[5] >> 4) print "BUILD_DATE=%0.8x" % rply.data[6] print "BUILD_TIME=%0.4x" % rply.data[7] print "BUILD_MOD=%d" % rply.data[8] print "" print str(rply)
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code dHLVDS = SlowControl.SlowControl(0) SlowControl.read_burst(dHLVDS, 6039, 0, 32, False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code master = SlowControl.SlowControl(0) #slave = SlowControl.SlowControl(1) ### TESTING USING THE FUNCTIONS #SlowControl.read_burst(master, 6007, 0, 24, False) #addresses = [ 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23 ] #SlowControl.read_list(master, 6039, addresses, False) #SlowControl.write_burst(master, 0x1977, 0x00000100, [ 0x3200 ], False) SlowControl.write_list(master, 6039, [ 0x18, 0x16 ], [ 0x2, 0x1 ], False) #addresses = [ 26, 27, 28 ] #SlowControl.write_list(master, 6039, addresses, data, False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time sc = SlowControl.SlowControl(1) rply = SlowControl.read_burst(sc, 6039, 7, 1) dcm_status = 0x3ffff while rply.success == False or rply.errors[0] != 0x0 or rply.data[0] != dcm_status: print "Rebooting FEC ADC as it doesn't seem to be ready!" if rply.success == True: print "DCM status: 0x%x" % rply.data[0] else: print "Readout not successful!" SlowControl.write_list(sc, 6007, [ 0xFFFFFFFF ], [ 0xFFFF8000 ]) time.sleep(15) rply = SlowControl.read_burst(sc, 6039, 7, 1) print "ADC DCM seems to be alright" quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time m = SlowControl.SlowControl(0) # HLVDS FEC (master) # request a single event # in order to make the trigger/timer unit running, 0x4 (3rd bit) in # register 0x15 has to be set SlowControl.write_list(m, 6039, [0x16], [0x6], True, False) SlowControl.write_list(m, 6039, [0x16], [0x4], True, False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code m = SlowControl.SlowControl(0) # HLVDS FEC (master) s = SlowControl.SlowControl(1) # HLVDS ADC (slave) clk_high = 0x1 clk_low = 0x3 readout_start = 0x674 readout_end = readout_start + (60*60+90*90)*2*(clk_high+clk_low)-1 # two memories per pixel, every fourth clock cycle is readout # 0x16 (22) readout control # # 3: driver loop mode (activates the complete sequence although no data is sent) # 2: single-event readout enable # 1: single-event readout request (rising edge sensitive, need to toggle!) # 0: continuous readout enable rdo_settings = 0x0 # 0x8 # 0x18 (24) trigger control # # 18-12: tlu wait cycles (default = 0x0c << 4) # 10- 4: tlu clock div (default = 0x00 << 12) # 3: driver busy enable ( 0x8 ) # 2: tlu reset enable ( 0x4 ) # 1- 0: trig mode (0b00 = auto/continuously, 0b01 = NIM in, 0b10 = TLU triggering trg_settings = 0x2 | (0x0c << 4) | (0x00 << 12)
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code dHLVDS = SlowControl.SlowControl(0) dADC = SlowControl.SlowControl(1) SlowControl.read_burst(dHLVDS, 6039, 0, 32, False) SlowControl.read_burst(dADC, 6039, 0, 16, False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time sc = SlowControl.SlowControl(0) SlowControl.write_list(sc, 6007, [0xFFFFFFFF], [0xFFFF0001], False, False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time m = SlowControl.SlowControl(0) # HLVDS FEC (master) # request a single event # in order to make the trigger/timer unit running, 0x4 (3rd bit) in # register 0x15 has to be set SlowControl.write_list(m, 6039, [ 0x16 ], [ 0x6 ], True, False) SlowControl.write_list(m, 6039, [ 0x16 ], [ 0x4 ], True, False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code import time m = SlowControl.SlowControl(0) # HLVDS FEC (master) s = SlowControl.SlowControl(1) # ADC FEC (slave) # enable digital I/Os on the master SlowControl.write_list(m, 0x1977, [0x2, 0x1], [ 0x300, 0x100 ], False) # disaable sync on the master # stop readout SlowControl.write_list(m, 6039, [ 0x16, 0x19 ], [ 0x0, 0x0 ], False) time.sleep(1) # disable slave SlowControl.write_burst(s, 6039, 0x3, [ 0x0 ], False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code master = SlowControl.SlowControl(0) SlowControl.write_list(master, 0x1977, [0x2, 0x1], [0x300, 0x1FF], False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code dHLVDS = SlowControl.SlowControl(0) dADC = SlowControl.SlowControl(1) # HLVDS: trigger is in register 24 # 1: 0 triggering mode: 0 = auto, 1 = ext 2 = TLU # 2 TLU reset signal enable # 3 busy mode: 0 = excluding driver, 1 = including driver # 10: 4 clk div # 18:12 wait length trg_set = 2 # = TLU + busy w/o driver trg_set = trg_set | (0x18 << 4) # clk divider (0x18) (minimum working 0x5 in the lab) trg_set = trg_set | (0x2F << 12) # wait length (0x2f) SlowControl.write_list(dHLVDS, 6039, [24], [trg_set], False) SlowControl.write_list(dADC, 6039, [2], [trg_set], False) quit()
#! /usr/bin/env python ## ## code testing of class SlowControl ## import SlowControl # slow control code master = SlowControl.SlowControl(0) # open I2C on connector 8 SlowControl.write_list(master, 0x1877, [0xE0300000], [0x80], False) # set the reset voltages # 12 bit precision # Vout = 2*Vref*x/4096 # Vref = 2.5V # # value has to be shifted two bits to the left (*4) (see explanation below) # # 0x51e = 0.4V # 0xa3c = 0.8V # # a write access looks like: # - I2C address # - pointer (channel address) # - two data bytes: # 15:14 register = 11 for the output register # 13:2 DAC value (Vout) # 1:0 padding = 00 SlowControl.write_list(master, 0x1877, [0xA8320000, 0xA8320000, 0xA8320000, 0xA8320000], [0x03CA3C, 0x06CA3C, 0x07CA3C, 0x0BCA3C], False)