示例#1
0
    print usageMSG
    exit(-1)

SN          = str(sys.argv[1])
ASIC        = int(sys.argv[2])
NumAvgs     = int(sys.argv[3])
interface   = "eth4"


#--------- ETHERNET CONFIGURATION ----------#
addr_fpga = '192.168.20.5'
addr_pc = '192.168.20.1'
port_pc = '28672'
port_fpga = '24576'
syncwd="000000010253594e4300000000" # must be send before every command string
ctrl = linkEth.UDP(addr_fpga, port_fpga, addr_pc, port_pc, interface)
ctrl.open()


#--- BUILD CONFIGURATION COMMANDS ---#
cmdZeroTh = cmdHVoff = syncwd
for asicNo in range (10):
    for Ich in range (16):
        cmdHVoff  += hex( int('C',16)*(2**28) | asicNo*(2**20) | (Ich)*(2**16) | 255 ).split('x')[1]+"AE000100"
        cmdZeroTh += hex( int('B',16)*(2**28) | asicNo*(2**24) | (2*Ich)*(2**16) | 0 ).split('x')[1]+"AE000100"

cmd_FIFO_reset = syncwd + "AF260000"+"AE000100"+"AF260800"+"AE000100"+"AF260000"+"AE000100"+"AF261080"

trig_cmd = syncwd + "AF00FFFF"+"AF00FFFF"+"AF370001"+"AE000001"+"AF370000"+"AE000001"+"AF320001"+"AE000001"+"AF320000" # modified original from AF00FFF+AF00FFFFF / CK

if len(sys.argv) == 4:
    SN = str(sys.argv[1])
    rawHV = str(sys.argv[2])
    asicNo = int(sys.argv[3])
if len(sys.argv) != 4 or asicNo < 0 or asicNo > 9:
    print usageMSG
    exit(-1)

#--------- ETHERNET CONFIGURATION ----------#
addr_fpga = '192.168.20.5'
addr_pc = '192.168.20.1'
port_pc = '28672'
port_fpga = '24576'
syncwd = "000000010253594e4300000000"  # must be send before every command string
# Make UDP class for receiving/sending UDP Packets
ctrl = linkEth.UDP(addr_fpga, port_fpga, addr_pc, port_pc, "eth4")
ctrl.open()

#--- CONFIGURE SCROD(?) & SET TRIG. THRESHOLD AND HV TO NULL ---#
cmdZeroTh = cmdHVoff = syncwd
for Ich in range(0, 16):
    cmdHVoff += hex(
        int('C', 16) * (2**28) | asicNo * (2**20) | (Ich) * (2**16)
        | 255).split('x')[1]
    cmdZeroTh += hex(
        int('B', 16) * (2**28) | asicNo * (2**24) | (2 * Ich) *
        (2**16) | 0).split('x')[1] + "AE000100"
#--------------------------------------------------------------------------#
#----------------------SET GAIN AND TRIGGER THRESHOLDS---------------------#
#--------------------------------------------------------------------------#
calib_file_name = "calib/" + SN + "_HV" + rawHV + "_" + "ASIC" + str(
示例#3
0
def main():
    if len(sys.argv) != 4:
        print bcolors.FAIL+"Wrong number of arguments: usage "+\
	    "./tx_writeDacReg <ASIC#> <ASIC REG#> <DAC VAL>"+bcolors.ENDC
        sys.exit()

    asicno = sys.argv[1]
    regNum = sys.argv[2]
    regVal = sys.argv[3]

    try:
	asicno = int(asicno)
	if ( asicno < 0 or asicno > 9):
	    print bcolors.FAIL+"Invalid asic number, exiting"+bcolors.ENDC
	    sys.exit()
    except ValueError:
	print bcolors.FAIL+"Invalid asic number, exiting"+bcolors.ENDC
	sys.exit()

    try:
        regNum = int(regNum)
        if ( regNum < 0 or regNum > 1024):
            print bcolors.FAIL+"Invalid register number, exiting"+bcolors.ENDC
            sys.exit()
    except ValueError:
        print bcolors.FAIL+"Invalid register number, exiting"+bcolors.ENDC
        sys.exit()

    try:
        regVal = int(regVal)
        if ( regVal < 0 or regVal > 4095):
            print bcolors.FAIL+"Invalid register value, exiting"+bcolors.ENDC
            sys.exit()
    except ValueError:
        print bcolors.FAIL+"Invalid register value, exiting"+bcolors.ENDC
        sys.exit()

    print "Start DAC Program Process - Writing ASIC # "+str(asicno)+\
	"\tRegister "+str(regNum)+"\tValue "+str(regVal)

    # create ethernet interface
    addr_fpga = '192.168.20.5'
    addr_pc = '192.168.20.1'
    port_pc = '28672'
    port_fpga = '24576'
    interface = 'eth1'
    ctrl = linkEth.UDP(addr_fpga, port_fpga, addr_pc, port_pc, interface)

    # Create packet to send
    asicreg = "B"  # hex ctrl word
    asicno_hex = hex(asicno).lstrip('0x')
    if asicno_hex == '':
	asicno_hex = '0'
    regNum_hex = hex(regNum).lstrip('0x')
    
    if regNum_hex == '':
	regNum_hex = '00'
    elif len(regNum_hex) < 2:
	regNum_hex = "0"+regNum_hex
    regVal_hex = hex(regVal).lstrip('0x')
    if regVal_hex == '':
	regVal_hex = '0000'
    elif len(regVal_hex) < 4 and len(regVal_hex) >= 3:
        regVal_hex = "0"+regVal_hex
    elif len(regVal_hex) < 3 and len(regVal_hex) >= 2:
        regVal_hex = "00"+regVal_hex
    elif len(regVal_hex) < 2 and len(regVal_hex) >= 1:
        regVal_hex = "000"+regVal_hex

    data_packet = asicreg + asicno_hex + regNum_hex + regVal_hex
    
    if DEBUG:
	print asicreg
	print asicno_hex
	print regNum_hex
	print regVal_hex

    # Send packet
    ctrl.send(data_packet)

    del ctrl

    '''
示例#4
0
ROOT.gROOT.LoadMacro("root/GainStudies/MultiGaussFit.cxx")
ROOT.gROOT.LoadMacro("root/TTreeMgmt/PlotPedestalStatistics.cxx")
time.sleep(0.1)

######################################### Only need to
##         TAKE CALIB DATA             ## do this once
######################################### per raw HV setting
#for ASIC in range(10):
#    if ((2**ASIC & int(ASICmask,2)) > 0):
#        os.system("sudo ./py/ThresholdScan/SingleASIC_Starting_Values.py %s %s %d %s" % (SN,strRawHV,ASIC,HVmask))
#        time.sleep(0.1)
#time.sleep(0.1)
#print("Threshold scan finished.\n\n")
#
ctrl = linkEth.UDP(
    '192.168.20.5', '24576', '192.168.20.1', '28672',
    "eth4")  # (addr_fpga, port_fpga, addr_pc, port_pc, interface):
cmd = cmd_lib.CMD(SN, strRawHV, ASICmask)
cmdHVoff = cmd.Generate_ASIC_HV_cmd(0, [255 for i in range(15)])
cmdThOff = cmd.Generate_ASIC_TH_cmd(0, [4095 for i in range(15)])
thBase = cmd.Get_ASIC_TH_from_file(0)
HV_DAC = cmd.Get_ASIC_HV_from_file(0)

#########################################
###   Measure Pedestal Distribution   ###
#########################################
#print("\nMeasuring pedestal distributions\n")
#numPedEvtsPerWindow = 1
#time.sleep(0.1)
#os.system("echo -n > temp/data.dat") #clean file without removing (prevents ownership change to root in this script)
#f = open('temp/data.dat','ab') #a=append, b=binary