labscript-suite-oldfinal1 / labscript

The labscript Python library provides a translation from simple Python code to complex hardware instructions. The library is used to construct a "connection table" containing information about what hardware is being used and how it is interconnected. Devices described in this connection table can then have their outputs set by using a range of functions, including arbitrary ramps.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Ability to define duration of a constant instruction #54

Open philipstarkey opened 5 years ago

philipstarkey commented 5 years ago

Original report (archived issue) by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


An issue that wasted a lot of time for someone here is that they intended to set an output to a value for some amount of time, but it turned out that a function being called later in the script was setting the same output to some other value "in advance", something like:

def stage_1(t, duration):
    output.constant(t, value)
    return duration

def stage_2(t, duration):
    output.constant(t - offset, some_other_value)
    return duration

start()
t = 0
t += stage_1(t, duration_1)
t += stage_2(t, duration_2)
stop(t)

Ideally one would be able to specify a duration to the .constant() method in stage_1() so that any instructions to the same output within some duration will result in a compile time error.

Also, a ramp instruction should be able to have a duration provided that exceeds the actual ramping duration, so that the final value being held as a constant can also be guaranteed by the compiler not be be cut short of some desired length of time.

Not sure how easy this will be to add to labscript as is, so whilst anyone should feel free to hack it in if they want, I'll try to include it in labscript 3.

philipstarkey commented 5 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Ian suggest a keyword argument block_until to instructions, which seems like a good name to disambiguate from other instruction time intervals like the duration of the ramp. block_until sounds like it takes an absolute time, so the argument should be an absolute time, or named block_for or similar if its a duration.