09-08-2022 09:21 AM
I have a task that involves an analog output that causes an LED to flash on and off repeatedly in a particular pattern. I need AO because the intensity of the LED needs to be set via the DAQ. The flashing continues until user interruption. I could achieve what I describe by storing the waveform in the device buffer and cycling through it repeatedly in regen mode. However, I am stumped by an additional constraint. If the task ends with the LED beam on, I need to ramp down intensity gradually over about 100 ms. This must only happen at the end of the task and not during the on/off cycling. I can not predict predict when this needs to happen. I believe this may be hard or impossible to do using buffered acquisition (at least no way that does not involve an interruption or a latency); is this the case?
One solution I am contemplating is to add an optional RC circuit to the LED AO control line to filter the offset and so add a decay. I am thinking of gating the AO signal through this circuit using a transistor or a relay that I activate with a TTL signal when the user terminates the process. Is something like this the only option I have?
Solved! Go to Solution.
09-08-2022 12:07 PM
09-08-2022 12:15 PM
You can do it without *interruption*, but probably not without *latency*.
In older times, you couldn't write new data to a regenerating AO task but I was surprised to learn a few years ago that it had become possible. I don't really know when the support was added to DAQmx, I hadn't bothered trying for many years prior.
Anyway, you should be able to do 2 full-buffer writes back to back to accomplish what you need.
- write a full buffer that includes the ramp-down to zero from whatever was the last value in the original regenerating buffer. Pad with more zeros at the end if needed.
- write a second full buffer of nothing but zeros
- wait long enough to know that your ramp & zeros have worked through the task buffer and the device FIFO, then stop the task.
The amount of latency will be a combo of your task buffer size, where your generation task is within that buffer at the time you want to initiate the ramp-down, and the size & fill state of the device's onboard FIFO buffer (which is often configurable with DAQmx properties).
I've found that different devices use different methods to control the FIFO buffer. For some, it's a direct property to set the buffer size. For others, you get fuzzy control with the "data transfer request condition" which can be one of (less than full, half full, almost empty). There are yet other related properties that apply to USB-connected devices that I know less about.
-Kevin P
09-08-2022 02:38 PM
I'm using DAQmx via thin wrappers in MATLAB or maybe also NI's library in Python.
09-08-2022 02:43 PM
Anyway, you should be able to do 2 full-buffer writes back to back to accomplish what you need.
- write a full buffer that includes the ramp-down to zero from whatever was the last value in the original regenerating buffer. Pad with more zeros at the end if needed.
- write a second full buffer of nothing but zeros
Hmmm... So you are saying I can simply write to the buffer without stopping the task and this will play out what I need? That could well do what I need as I can keep the buffer small. I was planning on using a USB DAQ but I'd think again if it didn't work with one of these.
09-08-2022 10:26 PM