Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems that the time sequence cannot be too long. #95

Open
Moriaty-TT opened this issue Aug 11, 2022 · 4 comments
Open

It seems that the time sequence cannot be too long. #95

Moriaty-TT opened this issue Aug 11, 2022 · 4 comments

Comments

@Moriaty-TT
Copy link

My initial timing duration is about 25s, and it can run well. But when I tried to cycle my experiment three times, my experiment logic script like this:

t = 0
start()
for i in range(3):
     #my experiment. about 25s
stop(t)

I‘ve encountered this error:

Traceback (most recent call last):
  File "C:\Users\Tao\labscript-suite\userlib\labscriptlib\DFG_MOT_load\DFG_MOT_load_0811.py", line 288, in <module>
    stop(t)
  File "c:\labscript\lib\site-packages\labscript\labscript.py", line 3588, in stop
    generate_code()
  File "c:\labscript\lib\site-packages\labscript\labscript.py", line 3407, in generate_code
    device.generate_code(hdf5_file)
  File "c:\labscript\lib\site-packages\labscript_devices\PrawnBlaster\labscript_devices.py", line 450, in generate_code
    # pulse_program[j]["half_period"] = instruction["half_period"]
OverflowError: Python int too large to convert to C long
Compilation aborted.

Is there any way to solve it?Thanks!
@mjasperse @chrisjbillington @philipstarkey

@philipstarkey
Copy link
Member

There was a similar report here: https://groups.google.com/g/labscriptsuite/c/q2sBrLmELn8/m/b4CAIWEcAQAJ

I was never able to reproduce the issue myself locally. Do you have a full example script that reproduces it you would be willing to share?

@Moriaty-TT
Copy link
Author

Thank you Phil!

a full example script
No problem,but it's a little long.
This is my full example script:

from labscript import start,stop,add_time_marker
from labscript.labscript import AnalogOut,DigitalOut
from labscript_devices.NI_DAQmx.labscript_devices import NI_PXIe_6535
from labscript_devices.NI_DAQmx.labscript_devices import NI_PXI_6733
from labscript_devices.NI_DAQmx.labscript_devices import NI_PXIe_6738
from labscript_devices.PrawnBlaster.labscript_devices import PrawnBlaster

#Device define
PrawnBlaster(name='prawn', com_port='COM3',num_pseudoclocks=4)
NI_PXIe_6535(name='Dev1',MAX_name='Dev1',parent_device=prawn.clocklines[0],clock_terminal='/Dev1/PFI4')
NI_PXIe_6535(name='Dev2',MAX_name='Dev2',parent_device=prawn.clocklines[1],clock_terminal='/Dev2/PFI4')
NI_PXI_6733(name='Dev3',MAX_name='Dev3',parent_device=prawn.clocklines[2],clock_terminal='/Dev3/PFI0')
#NI_PXI_6733(name='Dev4',MAX_name='Dev4',parent_device=prawn.clocklines[0],clock_terminal='/Dev4/PFI0')
NI_PXIe_6738(name='Dev5',MAX_name='Dev5',parent_device=prawn.clocklines[3],clock_terminal='/Dev5/PFI0')


#analogout define
#dev5 analogout define
AnalogOut(name='TmpAna',parent_device=Dev5,connection='ao0')
AnalogOut(name='SlowPwr', parent_device=Dev5, connection='ao19')
AnalogOut(name='SlowFreq', parent_device=Dev5, connection='ao2')
AnalogOut(name='laser399_MOTPwr', parent_device=Dev5, connection='ao5')
AnalogOut(name='laser399_MOTFre', parent_device=Dev5, connection='ao6')
AnalogOut(name='MOTCoilI', parent_device=Dev5, connection='ao9')
AnalogOut(name='laser556_MOTFre', parent_device=Dev5, connection='ao7')
AnalogOut(name='laser556_MOTpower', parent_device=Dev5, connection='ao11')
AnalogOut(name='MOTCoilMonitor', parent_device=Dev5, connection='ao10')
AnalogOut(name='Start_coil_I', parent_device=Dev5, connection='ao13')
AnalogOut(name='DecreaseCoilI', parent_device=Dev5, connection='ao14')
AnalogOut(name='Bias_coil_I', parent_device=Dev5, connection='ao15')
AnalogOut(name='MOTBiasX_analog', parent_device=Dev5, connection='ao16')
AnalogOut(name='MOTBiasY_analog', parent_device=Dev5, connection='ao17')
AnalogOut(name='MOTBiasZ_analog', parent_device=Dev5, connection='ao18')
AnalogOut(name='TODTSetpoint', parent_device=Dev5, connection='ao21')
AnalogOut(name='laser399_IMGFre', parent_device=Dev5, connection='ao1')
AnalogOut(name='SODT_setpoint', parent_device=Dev5, connection='ao8')
#dev3 analogout define
AnalogOut(name='TempFastAan', parent_device=Dev3, connection='ao0')
AnalogOut(name='dev3_for_env',parent_device=Dev3,connection='ao1')

#digitalotut define
#dev1 digital out define
DigitalOut(name='TmpTTL', parent_device=Dev1, connection='port0/line0')
DigitalOut(name='AtomShut', parent_device=Dev1, connection='port0/line1')
DigitalOut(name='MOTCoilTTL', parent_device=Dev1, connection='port0/line5')
DigitalOut(name='laser556_MOTTTL', parent_device=Dev1, connection='port0/line6')
DigitalOut(name='SlowShut', parent_device=Dev1, connection='port3/line1')
DigitalOut(name='ZSProShut', parent_device=Dev1, connection='port3/line7')
DigitalOut(name='CCDTri', parent_device=Dev1, connection='port1/line0')
DigitalOut(name='Img_AOM_TTL', parent_device=Dev1, connection='port2/line6')
DigitalOut(name='Img_Shut', parent_device=Dev1, connection='port2/line7')  
DigitalOut(name='Blue_MOT_shut', parent_device=Dev1, connection='port0/line2')
DigitalOut(name='ODT_Tri', parent_device=Dev1, connection='port1/line1')
DigitalOut(name='dev1_for_env', parent_device=Dev1, connection='port2/line5')

#dev2 digital out define
DigitalOut(name='IMG_AOMTTL', parent_device=Dev2, connection='port2/line0')
DigitalOut(name='SODT_TTL', parent_device=Dev2, connection='port1/line2')
DigitalOut(name='SODT_Dumper', parent_device=Dev2, connection='port1/line3')
DigitalOut(name='StartCoil', parent_device=Dev2, connection='port0/line0')
DigitalOut(name='DecreaseCoil', parent_device=Dev2, connection='port0/line1')
DigitalOut(name='BiasCoil', parent_device=Dev2, connection='port0/line2')
DigitalOut(name='MOTBiasX_digital', parent_device=Dev2, connection='port0/line3')
DigitalOut(name='MOTBiasY_digital', parent_device=Dev2, connection='port0/line4')
DigitalOut(name='MOTBiasZ_digital', parent_device=Dev2, connection='port0/line5')
DigitalOut(name='TODT', parent_device=Dev2, connection='port3/line7')
DigitalOut(name='laser532_Flipmirror', parent_device=Dev2, connection='port3/line5')
DigitalOut(name='laser556_MOTshutter', parent_device=Dev2, connection='port3/line0')
DigitalOut(name='TODTFlipmirror', parent_device=Dev2, connection='port1/line0')
DigitalOut(name='dev2_for_env', parent_device=Dev2, connection='port1/line1')


#experiment logic
t = 0
start()

for i in range(2):
    # t=0

    #Init
    #analog
    TmpAna.constant(t,value=0)
    SlowPwr.constant(t,value=0.9)
    SlowFreq.constant(t,value=6.75)
    #TmpFastAan.constant(t,value=0)
    laser399_MOTPwr.constant(t,value=1.1)#value=1.1,now it's testing for a global parameter.
    laser399_MOTFre.constant(t,value=1.195)
    MOTCoilI.constant(t,value=0)
    laser556_MOTFre.constant(t,value=5.6)
    laser556_MOTpower.constant(t,value=0.685)
    MOTCoilMonitor.constant(t,value=0)
    Start_coil_I.constant(t,value=0)
    DecreaseCoilI.constant(t,value=0)
    Bias_coil_I.constant(t,value=0)
    MOTBiasX_analog.constant(t,value=0)
    MOTBiasY_analog.constant(t,value=0)
    MOTBiasZ_analog.constant(t,value=0)
    TODTSetpoint.constant(t,value=0)
    laser399_IMGFre.constant(t,value=0)
    SODT_setpoint.constant(t,value=0)
    #digital
    TmpTTL.go_low(t)
    AtomShut.go_low(t)
    MOTCoilTTL.go_low(t)
    laser556_MOTTTL.go_low(t)
    StartCoil.go_low(t)
    DecreaseCoil.go_low(t)
    BiasCoil.go_low(t)
    MOTBiasX_digital.go_low(t)
    MOTBiasY_digital.go_low(t)
    MOTBiasZ_digital.go_low(t)
    ZSProShut.go_low(t)
    SlowShut.go_high(t)
    CCDTri.go_low(t)
    Img_AOM_TTL.go_high(t)
    Img_Shut.go_low(t)
    TODT.go_high(t)
    laser532_Flipmirror.go_low(t)
    Blue_MOT_shut.go_high(t)
    ODT_Tri.go_low(t)
    laser556_MOTshutter.go_low(t)
    TODTFlipmirror.go_high(t)
    IMG_AOMTTL.go_high(t)
    SODT_TTL.go_high(t)
    SODT_Dumper.go_high(t)
    t+=0.1

    #ODTFlipMirror
    TODT.go_low(t)
    TODTFlipmirror.go_low(t)
    SODT_TTL.go_low(t)
    SODT_Dumper.go_low(t)
    t+=2

    #MOTLoad1
    #analog
    MOTCoilI.constant(t,value=0.265)
    laser556_MOTFre.constant(t,value=5.39)
    Start_coil_I.constant(t,value=satar_coil)  #zeman slower  0-3.5,initial value = 1.295
    DecreaseCoilI.constant(t,value=decreasecoilI)    #zeman slower   0-3.5 , initial value = 2.473
    Bias_coil_I.constant(t,value=bias_coil_I)             #zeman slower  0-3.5 , initial value = 1.95
    MOTBiasX_analog.constant(t,value=MOTBiasX)           #MOTBiasX  0-0.5  ,initial value = 0.25
    MOTBiasY_analog.constant(t,value=MOTBiasY)            #MOTBiasY  0-0.5  ,initial value = 0.1
    MOTBiasZ_analog.constant(t,value=MOTBiasZ)            #MOTBiasZ  0-0.5  ,initial value = 0.2
    TODTSetpoint.constant(t,value=5)
    laser399_IMGFre.constant(t,value=5.4)
    SODT_setpoint.constant(t,value=5)
    #digital
    TmpTTL.go_high(t)
    AtomShut.go_high(t)
    MOTCoilTTL.go_high(t)
    laser556_MOTTTL.go_high(t)
    StartCoil.go_high(t)
    DecreaseCoil.go_high(t)
    BiasCoil.go_high(t)
    MOTBiasX_digital.go_high(t)
    MOTBiasY_digital.go_high(t)
    MOTBiasZ_digital.go_high(t)
    laser556_MOTshutter.go_high(t)
    t+=20

    #MOTLoad2
    #analog
    #SODT_setpoint.constant(t,value=0)
    #digital
    TmpTTL.go_low(t)
    TODTFlipmirror.go_high(t)
    SODT_Dumper.go_high(t)
    #  SlowShut and Blue_MOT_shut
    t+=0.95
    SlowShut.go_low(t)                  #off slower
    Blue_MOT_shut.go_low(t)             #off blue MOT
    t += 0.05

    #CMOT
    #duration of CMOT 
    CMOT_time=0.1
    #analog
    MOTCoilI.ramp(t,CMOT_time,0.265,1.5,1e4,None)
    laser556_MOTFre.ramp(t,CMOT_time,5.39,5.04,1e4,None)
    laser556_MOTpower.ramp(t,CMOT_time,0.685,1.35,1e4,None)
    SODT_setpoint.ramp(t,CMOT_time,0,4.7643,1e4,None)
    #digital
    AtomShut.go_low(t)
    StartCoil.go_low(t)
    DecreaseCoil.go_low(t)
    BiasCoil.go_low(t)
    ODT_Tri.go_high(t)
    TODTFlipmirror.go_high(t)
    t += CMOT_time
    #SODT_Dumper.go_high(t)



    #CMOT Hold
    #analog
    MOTCoilI.constant(t,value=1.5)
    laser556_MOTFre.constant(t,value=5.04)
    laser556_MOTpower.constant(t,value=1.35)
    SODT_setpoint.constant(t,value=4.7643)
    #digital
    ODT_Tri.go_low(t)
    t+=0.03
    Img_Shut.go_high(t)        #OnImag
    t += 0.02

    # #ODT Hold
    # #analog
    # MOTCoilI.constant(t,value=0)
    # MOTBiasX_analog.constant(t,value=0)
    # MOTBiasY_analog.constant(t,value=0)
    # MOTBiasZ_analog.constant(t,value=0)
    # #digital
    # MOTCoilTTL.go_low(t)
    # laser556_MOTTTL.go_low(t)
    # MOTBiasX_digital.go_low(t)
    # MOTBiasY_digital.go_low(t)
    # MOTBiasZ_digital.go_low(t)
    # laser556_MOTshutter.go_low(t)

    # t+=0.05

    #TOF
    #analog

    #digital

    #Img_AOM_TTL.go_low(t)
    #IMG_AOMTTL.go_low(t)

    # t+=0

    #ImgAtom
    #analog
    MOTBiasY_analog.constant(t,value=0.4)
    # #digital
    MOTCoilTTL.go_low(t)
    laser556_MOTTTL.go_low(t)
    MOTBiasX_digital.go_low(t)
    MOTBiasZ_digital.go_low(t)
    TODT.go_high(t)
    laser556_MOTshutter.go_low(t)
    SODT_TTL.go_high(t)
    CCDTri.go_high(t)
    #Img_AOM_TTL.go_high(t)
    #IMG_AOMTTL.go_high(t)

    t+=1e-4

    # #wait CCD
    # #digital
    MOTBiasY_digital.go_low(t)
    CCDTri.go_low(t)
    Img_AOM_TTL.go_low(t)
    IMG_AOMTTL.go_low(t)

    t+=0.1

    #ImgRef
    #analog

    #digital
    CCDTri.go_high(t)
    Img_AOM_TTL.go_high(t)
    IMG_AOMTTL.go_high(t)

    t+=1e-4

    #wait CCD
    #digital
    CCDTri.go_low(t)
    Img_AOM_TTL.go_low(t)
    Img_Shut.go_low(t)
    IMG_AOMTTL.go_low(t)

    t+=0.1

    #ImgDark
    #digital
    CCDTri.go_high(t)

    t+=1e-4

    #end
    #digital
    CCDTri.go_low(t)
    t+=2
stop(t)

When I only execute a single time sequence, it works well. Once I start the cycle, the above error will occur. I've tried to shorten the sequence time of my single cycle by about 5 second, and when I cycle it three times, it can run. But my actual experiment can not shorten my sequence time.

@philipstarkey
Copy link
Member

So I haven't had chance to try and compile this yet, but looking at it I think I understand what the issue is.

The outputs on Dev3 aren't used during the shot. And they are the only outputs on PrawnBlaster clockline 2. Which means that labscript attempts to generate a very long single clock tick to cover the majority of the shot length. This exceeds the maximum length of a pulse the PrawnBlaster supports.

It seems like a bit of a deficiency that we don't have a way for pseudoclocks to tell labscript what their maximum clock tick period is. Unfortunately I can't immediately see an easy way to add this into labscript. It has to be done around the collect_change_times() part of the generation algorithm. But that happens before ramps are expanded. So it get's a little tricky to calculate what each clock tick length is at that point (I guess it's not impossible though) in order to determine whether to insert additional clock ticks to restrict the period length below the devices maximum.

Anyway...fortunately there is an easy work around. Which is that you just need to use an output on Dev3 in your loop. You can set it to the same value each time (it doesn't have to change). You just have to force labscript to tick every prawnblaster clockline at least once every 42 seconds. TempFastAan.constant(t, value=0) in the #InitAnalog section of the loop should do it.

Please let me know if this fixes the issue! We'll keep this open until we have a proper fix in labscript that covers all pseudoclocks.

@Moriaty-TT
Copy link
Author

You just have to force labscript to tick every prawnblaster clockline at least once every 42 seconds. TempFastAan.constant(t, value=0) in the #InitAnalog section of the loop should do it.

Thanks Phil!Now it can run successfully!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants