09-09-2013 03:55 AM
Hi
I have an application which needs to send out a signal on the USB-4431 and then capture it via an input on the same device.
Current I'm using two tasks to do this, one for input and another for output. I've found out that a trigger (on the RTSI bus) can sychronise the start operations of the send/capture cycles so that there can be a constant delay between the captured signal and the output signal.
Unfortunately the code I've found is for Matlab. I can't find an equivalent for it in the NIdaq C API. The method is described here;http://www.mathworks.in/help/daq/synchronize-analog-input-and-output-using-rtsi.html.
What I can't figure out is how to implement this on the analogue input:
ai.ExternalTriggerDriveLine = 'RTSI0';
Can anyone shed any light on how to do this?
The rest of the stuff described here, looks to be doable with a normal trigger:
ao.TriggerType = 'HwDigital'; ao.HwDigitalTriggerSource = 'RTSI0'; ao.TriggerCondition = 'PositiveEdge';
Thanks
Nirvtek
Solved! Go to Solution.
09-09-2013 04:48 AM - edited 09-09-2013 04:57 AM
There's an example in the C NIdaq samples. Unfortunately that doesn't use the RTSI clock, but instead is hardcoded to use specific chassis.
It doesn't appear to work with a USB-4431:
DAQmx Error: NI Platform Services: The specified resource is reserved. The oper
ation could not be completed as specified.
Task Name: _unnamedTask<1>
Status Code: -50103
This is the VC_SyncAI_AO example.
09-09-2013 05:05 PM - edited 09-09-2013 05:15 PM
You can synchronize AI and AO by sharing the start trigger between your two tasks.
Pick one of your tasks to be the "master" and one to be the "slave" (doesn't matter which).
Setup a digital edge start trigger on the slave task and set the source of the trigger to be the start trigger of the master.
Let's assume the following:
Your device's name is "Dev1"
AI is the master task
AO is the slave task
Here's what you'd do to synchronize the two:
1) Create the AI and AO tasks in any order you wish
2) Set up timing on both the AI and AO tasks (the sample rates you choose will need to be the same or power-of-2 multiples of one another (e.g. 100K, 50K, 25K, 12.5K, etc..))
3) Configure your slave task (the AO task) to have a digital edge start trigger and make the source be the start trigger from the master task (the AI task). In our case, "Dev1/ai/StartTrigger".
4) Write some data (a sine wave, presumably) to your AO task
5) Start the slave task (the AO task). The AO task is now in the "started" state, but since you configured a digital start trigger, it won't actually generate data until it sees a digital edge from "Dev1/ai/StartTrigger".
6) Start the master task (the AI task). The AI task does not have a digital start trigger, so the driver software will immediately generate a start trigger, which also causes a digital edge on "Dev1/ai/StartTrigger", which causes the AO task to start at the exact same time.
7) Read from your AI task.
You'll notice some 0's at the start of your AI data. This is a result of something called "Filter Delay" and it is an inherent feature of all DSA devices -- see the DSA user manual and this KB article for more information on what it is and how to deal with it.
Hope this helps.
EDIT: I just noticed that you pointed out an existing C example. That's exactly what you want. I don't know why you got a resource reserved error -- I tried it out myself and (after changing the AO range from +/-10V to +/-3.5V), it worked just fine. Try resetting your device in MAX (or by calling DAQmxResetDevice() from your program)
09-10-2013 08:21 AM
Thanks! That answers my question.
09-13-2013 11:56 AM - edited 09-13-2013 12:16 PM
I got this to work really well as far as synching goes, thanks.
Unfortunately sometimes I get buffer underflow error (code -200621) from time to time. The message sometimes indicate that the there's too much data and at other times that the internal buffer on the device underran due to bus transfer issues.
What's going on? I'm using a 1000 sample input buffer and a 30000 samples output buffer running in a (often) continuouse loop. The output rate is 48 kHz.
09-13-2013 12:52 PM
And this:
I managed to get the previous message to disappear by increasing the input buffer size to 100 KS as per http://digital.ni.com/public.nsf/allkb/E1E67695E76BA75B86256DB1004E9B07
09-15-2013 01:56 AM
The tasks runs for around 2-3 s @48 kHz. The timeout was set to 10 s and subsequently increased to 30 s.
At the end of a run the app locks up for around 10-30 s and then the error pops up.
02-02-2023 09:32 PM
May the USB 4431 work with an external sampling clock?
Or a similar card with 24bit resolution but may work wiht a external sampling clock.
02-02-2023 09:34 PM
Hi nirvtek,
May the USB 4431 work with an external sampling clock?
Or a similar card with 24bit resolution but may work wiht a external sampling clock.
02-08-2023 11:45 AM
@zhm0204 wrote:
Hi nirvtek,
May the USB 4431 work with an external sampling clock?
Or a similar card with 24bit resolution but may work wiht a external sampling clock.
Please do not hijack threads, you've been provided with an answer at https://forums.ni.com/t5/Multifunction-DAQ/USB-Multi-DAQ-card-with-24bit-resolution/td-p/4281755