m-labs / artiq

A leading-edge control system for quantum information experiments
https://m-labs.hk/artiq
GNU Lesser General Public License v3.0
434 stars 200 forks source link

Determining if an edge was rise or fall from gate_both #639

Open vontell opened 7 years ago

vontell commented 7 years ago

The gate_both(self, duration) method, or _set_sensitivity(3) configuration for a TTLInOut object returns timestamps at which a rising or falling edge has been detected. However, is there any way to determine if the edge was a rise or fall, such as a tag which gets sent with the timestamp?

sbourdeauducq commented 7 years ago

It's alternating rises and falls, so all you really need is the initial value. What do you need that for?

vontell commented 7 years ago

My current approach is also to use the initial value. However, how would I get this initial value; is there a TTLInOut method which would allow me to query the current input state of the channel? desired functionality is at issue vontell/artiq-control#7

sbourdeauducq commented 7 years ago

In 3.x you can use this: https://m-labs.hk/artiq/manual-master/_modules/artiq/coredevice/ttl.html#TTLInOut.sample_input But doing what you want without any race condition is not completely straightforward (e.g. what happens if an edge arrives at the same time as when you are sampling the first time?)