On Tue, Nov 1, 2016 at 5:25 PM, Aaron Vontell <aaronvont...@gmail.com> wrote:
> I am wondering what the best way is to place an event into the timeline as
> soon as possible after detecting an input event. For instance, I would like
> to run a pulse on, say, TTL1 immediately after receiving a single rising
> edge on PMT0. For context, I am trying to complete this method which would
> run a kernel / place commands into the timeline upon seeing that the count
> of PMT0 is greater that 0. I am not entirely sure on how to implement this
> functionality, as I commonly run into RTIOUnderflow errors.

Something like this should work. See also the unittests and the tdr example.

latency = seconds_to_mu(1*us)   # or whatever ends up working reliably

t = now_mu()
delay(10*us)
self.ttl2.pulse(10*us)  # connect ttl2 to pmt0

at_mu(t)
self.pmt0.gate_rising(100*us)
r = self.pmt0.timestamp_mu()
if r > 0:  # pulse received during gate
    at_mu(r + latency)
    self.ttl1.on()

-- 
Robert Jördens.
_______________________________________________
ARTIQ mailing list
https://ssl.serverraum.org/lists/listinfo/artiq

Reply via email to