Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Rookie mistake: Synchronisation and acquisition of multiple analogue and digital signals

Solved!
Go to solution

Hello everyone,

 

I am trying to use my brand new cDAQ-9184 for the acquisition of three signals – 2 analogue voltage (Ni 9225) and one digital frequency (NI9403/9401/9375). These measurements should be synchronised and logged. I’ve never done cDAQ programming, so I came across a few issues here.

 

I can perform the measurements by using the DAQ assistant and then split the signals to depict the plots. Logging is also quite straight forward. But I want to do some DAQ advanced programming for flexibility so I was hoping that you can help me out.

 

Since I need to measure two analogue voltage I was using the example “Voltage – Continuous Input”. Works perfectly fine, but when I am copying the existing code for acquisition and changing a physical channel to my AI (second signal), waveform chart for it remains blank during the measurements. The first AI graph is still perfectly fine. But at the same time, the code shows that the Actual sample rate for the second channel is the same as for the first one. But the chart still does not depict the plot. From here my first question is, at which sample rate the data will be acquired and saved? Specified by us sample rate or the Actual Sample rate? And also, what’s the most suitable option for frequency acquisition in the range of 20-2000 Hz? Checked this thread: http://forums.ni.com/t5/NI-DAQmx-Examples/Measure-Digital-Period-Low-Frequency-with-One-Counter/gpm-... but want to know an opinion from somebody’s experience if it is possible.

 

By using the example “Analog Input – Voltage and thermocouple in a single task” I measure my two voltage signals (replaced the thermocouple part on the voltage code). So I have two voltage signals on one graph, which is perfectly fine. But again, I can’t work out how to add a digital signal acquisition part to the existing voltage codes.

 

I was checking the codes from: http://www.ni.com/tutorial/5376/en/ and http://www.ni.com/product-documentation/4322/en/ , but looks like I am doing something wrong there since I am getting the error 88717, or the second chart is always empty as well.

 

​​​​​Will highly appreciate is somebody can help me to sort this out, at least in terms of the understanding why my DAQ codes don’t work properly. Thank you in advance.

0 Kudos
Message 1 of 5
(3,456 Views)

Hi ESturov,

 

Great job finding all those resources so far, you're definitely on the right track to build your application.

 

1) Have you looked at the synchronization> Analog Input Synchronization.vi? You want to actually have 2 or 3 separate tasks for your digital and analog reads, not combined like in the other example you were referencing.

 

2) Are your analog readings the same or different sampling rates? If they are the same, you can extend your task to include both channels.

How Do I Select More Than One NI-DAQmx Channel in LabVIEW?
http://digital.ni.com/public.nsf/allkb/A3A05920BF915F1486256D210069BE49

 

3) If you need further help, please share your code so we can see exactly what you are attempting to do

0 Kudos
Message 2 of 5
(3,396 Views)

Hi Kodester,

 

Thank you for your reply.

 

1. Yes, I’ve tried it before. The problem is that it has different Synchronisation types, and looks like none of the presented suit my board. I’ve tried to change the default case, but basically stuck when I was trying to change the DAQmx Timing settings in the case loop. Since I don’t know which of the options on my board will mimic the existing properties and nodes (Master Timebase. Source and Master TimeBase.Rate). I was trying to change them to Sample Clock – Source and Rate respectively, and gives me the error 89131,

 

“An attempt has been made to perform a route when the source and the destination are the same terminal.

In many cases, such as when configuring an external clock or a counter source, you must select a PFI, PXI Trigger, or RTSI line as the source terminal.

Property: Start.DigEdge.Src

Property: Start.DigEdge.Edge

Source Device: cDAQ9184-1A8C7E2

Source Terminal: ai/StartTrigger”

 

To simplify the code (and hopefully get rid of the digital triggering I deleted “GetFullNameTeminal.vi” and “DAQmx Start Trigger.vi”. After that it gives me the error 50103 at DAQmx Start Task.vi:7220002

“Possible reason(s):

The specified resource is reserved. The operation could not be completed as specified.”

 

Overall, I reckon this example is a good start (since I need my signals synchronised) but I can’t figure out how to deal with  that case loop and the time settings there. Or am I doing something wrong here? In any case, I've attached this code.

 

2. Yes, I know about, it can help to make the code tidier, since I can combine two analogue signals. But still the same issues with regards to a third (digital) signal (since I want it on another graph). And yes, they should have the same sampling rate.

 

I’ve attached the modified thermocouple code for two analogue measurements that I was using before. Will highly appreciate if you can tell me how I can modify it further to a digital signal measurement as well (on the different chart from the analogue measurements). Or maybe the Synchronisation example will suit better. 

 

Thank you in advance if you can help me out.

0 Kudos
Message 3 of 5
(3,384 Views)
Solution
Accepted by topic author ESturov

Esturov,

 

I kept running into yours and other errors when trying to set the synchronization settings, because synch settings are really meant for 2 separate devices. Since both of our modules are onboard a cDAQ chassis, they'll share the same timebase (meaning we don't need to do as much set up for synchronization)

 

Look at the code I've attached. I put both AI tasks in a master task, exported it's start trigger to a slave digital task. This is basically the example with the synchronization settings removed and the DAQmx read tasks fixed.

0 Kudos
Message 4 of 5
(3,373 Views)

Thank you for your comments, Kodester, totally make sense.

 

I’ve added another channel to the AI voltage channel , so overall I am having two analogue signal and a digital signal in one run. The point is that with the used sample rate and Samples per loop I am getting some time (depends on the Ampl and frequency of the input AC signal or the amp of the input DC signal) the following error: 200279.

“Possible reason(s):

The application is not able to keep up with the hardware acquisition.

Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.

Property: RelativeTo

Corresponding Value: Current Read Position

Property: Offset

Corresponding Value: 0”

​​​​​

And I reckon a solution is related to my second question, i.e. the sample rate of the execution. Because with the operating code I will implement logging. And this case I need to know (or set) its sample rate. I am looking for the rate of 5ms for the analogue signals and as fast as possible for the digital signal. Regarding the AI modules, for NI 9225 the data rate is the range of 1.6 – 50 kS/s, so I reckon 5 ms (200Hz) is achievable with the board and this module. Unless I am refereeing to some unrelated values. In any case, thank you in advance if you are able to help me out. Have a good one.

0 Kudos
Message 5 of 5
(3,354 Views)