10-27-2024 05:18 AM
Dear all,
I'm trying to trigger an analog output task with a counter output.
When I run the code withtout triggering, it works (but the tasks are not synchronized, as expected).
But, when I trigger the analog task with the output of the counter, I encounter an error directly after the "DAQmx Write" vi.
The error is:
Error -200262
An attempt has been made to configure a trigger without configuring the appropriate sample clock properties or when Sample Timing Type was set to On Demand.
Configure the sample clock type to something other than On Demand to use a trigger.
As you can imagine, I tried to configure the sample clock but I encounter another error (Non-buffered hardware-timed operations are not supported for this device and Channel Type.
Set the Buffer Size to greater than 0, do not configure Sample Clock timing, or set Sample Timing Type to On Demand.)
Could you help me please?
Thank you!
10-27-2024 09:43 AM
First and foremost, what DAQ model are you using? as the features vary widely by models.
10-27-2024 01:25 PM
Hello,
It's a USB-6363.
Thanks,
Sébastien
10-28-2024 07:47 AM
I must admit, I was kinda surprised to read that triggering wasn't allowed for an on-demand output task (and which may also apply for input tasks?). I guess I never ran into a situation where I wanted to try to do that.
Can you describe in more detail what you hope to accomplish with that specific kind of config? There are probably some decent workarounds available, but I'd first need to know what target you're aiming at.
I suspect that in the code you posted, the counter task is only there to simulate a pulse signal that will later come from some external source that you don't control. There's really no other purpose I can see for the counter task as the code stands now -- it only seems to get in the way with this attempt to use it as a software-controlled trigger signal.
You could simply get rid of the counter task altogether and configure the AO task without a trigger to get the behavior your code is trying to accomplish (after managing a couple details about the sequence of writing to the task, starting the task, and whether the write operation enables 'auto-start' or not.)
-Kevin P
10-28-2024 08:29 AM
Hello,
My application is to control a microscope with 4 cameras, 8 lasr lines, 3 axes stages, etc.
I really need to use a counter that sends pulses on demand during a defined time.
This counter will trigger 8 AO generation, 4 DO generation with a rising edge and other DO on the falling edge.
The synchronization of all tasks with the counter is really comfortable (I already did that with another system).
Do you understand now my purpose? The counter trigger everything on my system.
Sébastien
10-29-2024 09:15 PM - edited 10-29-2024 09:21 PM
No, I don't understand your purpose yet, at least not well enough. Among the things I'm not sure of:
1. You say you want the counter pulse to "trigger" AO and DO. One thing I've seen pretty often on the forums is a mixup between a trigger and a sample clock. These are very distinct things in the world of DAQmx. It seems that many instruments use the term "trigger" to refer to the thing that DAQmx calls a "sample clock", so folks who have prior experience with other kinds of devices often talk about a trigger when in the DAQmx world, they should be talking about a sample clock.
In short, I don't yet know if you & I mean the same thing when using the term "trigger." So for the sake of clarity, I would need to understand your intentions and expectations about what the AO and DO should do in response to the counter's pulse(s).
2. I don't believe that you can have 2 distinct DO tasks active at the same time. So I don't think it's even possible to have one such task react to a rising edge while the other reacts to a falling edge of the same signal. Your device would only support 1 such DO task at a time and you'd need to choose just 1 polarity to react to.
-Kevin P
10-30-2024 02:40 AM - edited 10-30-2024 02:45 AM
Thank you.
In the world of research in electronics and computer engineering, we talk about TRIGGERING when a device receive or send a TTL pulse to be activated / desactivated / make a task, etc.
Here, I'm not speaking about sample clock.
I really mean TRIGGER.
You CAN haeve pultiple DO and AI and AO at the same time and they can be synchronized but a pulse coming from a counter.
I already did it with 8 AO and 4 DO.
My purpose is that I don't want to send a waveform but simply a value to the analog ports.
10-30-2024 02:45 AM
10-30-2024 07:51 AM
The timing diagram is very helpful. I'm basing my detailed comments on what I see there.
Summary: in addition to your master counter output task, you need 1 buffered AO task (where the buffer is filled with the constant value 5V), and 3 additional counter output tasks (note: not DO tasks!)
1. Master Counter Pulse task
Set the frequency and pulse width you need. Wait and be sure to start this task LAST.
2. AO task
This needs to be a buffered & triggered continuous task, triggered by the rising edge of your master counter. Write multiple 5V values to the buffer before starting the task. The default behavior is to keep regenerating the values in the buffer, so you need to write a big enough buffer to allow the repeated USB transfer of buffer values to work efficiently. 0.1 second worth of values will likely be enough.
There's also a way to configure your task to do regeneration from the onboard buffer rather than via repeated USB transfer. That can work too, but is probably not necessary to learn for this app if you don't already know how to do it.
3. Laser On/Off task
The falling edge doesn't seem to correlate with any other digital transition. Thus, this needs to be a retriggerable single pulse counter task. It triggers off the master counter's falling edge and has the pulse width you choose. Note: if your pulse width lis onger than the time until the next master counter falling edge, you'll miss that next trigger. The laser won't react again until the trigger after it has completed its full pulse width.
4. Camera pulse tasks - the common parts
Similar considerations as the laser pulse. Falling edges don't correlate to any other signal so they need to be retriggerable single pulse counter tasks. They seem to have minimal pulse width so you're probably unlikely to have issues with missed triggers. The only apparent difference is that they are triggered by opposite edges of the master counter.
5. Camera Readout End task - the unique part
While this task will normally be retriggered by the master counter's rising edge, it doesn't want to be started by the very first rising edge. It wants to wait until the 2nd rising edge.
There's actually a way to do this with a counter task. In addition to the normal rising edge Start Trigger, you'll also need to configure the special "Arm Start trigger". The Arm Start trigger needs to happen to put the task into active mode. After that, every "regular" start trigger will re-trigger this task to generate a single pulse.
So here, you can set the Arm Start trigger to be the falling edge of your master counter task. The first falling edge arms it so that the 2nd rising edge begins the retriggering behavior.
I'm running out of time now, but a little searching should get you more details about configuring the Arm Start trigger and retriggering for single pulses.
-Kevin P