LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simultaneous counter and analog acquisition

The goal: simultaneous counter input and analog input acquisition

 

Hardware: NI9401, NI9234, a controller (cRIO or cDAQ)

 

Dear NI Community,

 

I am a bit of LabView noob and kindly ask You for comment on my case.

 

I would like to perform simultaneous counter and analog input acquisition - by this I mean foremost simultaneous trigger of start and stop of the acquisitions rather than synchronization of measurements having different sampling techniques. Of course, if there will be a possibility for counter and analog sampling synchronization, it will be great.

 

I have attached an example vi for simultaneous counter and analog acquisition (Trigger Counter... .vi) and the example modified (Trigger Counter ... modified_09.04.25.vi, modifications.png) to get settings like in the express DAQmx 'counter-measuring_method.png'.


Can You help me with answering on the following questions?

1. Are the modifications consistent with the rest of the modified example programme (Trigger Counter ... modified_09.04.25.vi, modifications.png)?

2. Do the modifications (modifications.png) introduce changes connected with the settings in express DAQmx (counter-measuring_method.png)? If not, then which other changes would You recommend me to make in order to obtain counter settings like in "counter-measuring_method.png"?

3. Does the programme "Trigger Counter and Analog ... modified_09.04.25.vi" should work with the Hardware I have? Do You have any recommendation on this? I also attach the hardware scheme (hardware_scheme.png).

 

Best regards,

Karolina

0 Kudos
Message 1 of 4
(276 Views)

If you want to synchronize analog and counter tasks, see Synchronous Analog and Encoder Inputs

If you want to add a start trigger, simply configure it for the analog task. The counter tasks, as the slave will follow the master analog task.

 

The above will work with your hardware scheme.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
0 Kudos
Message 2 of 4
(175 Views)

Your modified code is a pretty decent start, but more work will be needed.  I don't know exactly what you need your app to ultimately do, so I can only offer up some limited thoughts.

 

The Good:

1. You're configuring the "Arm Start" trigger for your counter task.  This trips up a lot of people b/c it's unique to counter input operations.  Most tasks use the regular "Start" trigger (including your AI task).

2. You've successfully configured your tasks for proper triggering by having both of them trigger off the same edge of the same signal.

3. You made use of TDMS logging for the AI task, a simple & effective way to capture and retain all the AI task data.

 

The Bad:

4. You configured the counter task for Finite sampling without specifying the # of samples to acquire.  But the downstream code uses iterative reads, which is typically associated with Continuous sampling (like your AI task).

5. Though triggering is configured correctly, it isn't clear whether your tasks will definitely start at the same t=0 time.  The sequence frame containing the task starts *does* help them start at *almost* the same time, but it's possible that they'll be triggered at a different instant.  For example, if your triggering signal is an always-present high-frequency clock, it's not likely both tasks will execute "DAQmx Start" SO simultaneously that they'll be triggered by the exact same edge.

6. Though AI data is being captured, counter data isn't.  You just have a fleeting glimpse of single values onscreen that keep getting updated.  None are saved to file the way AI is being saved.

7. I don't know cDAQ hardware in all its detail, but you likely can't do "Sample Clock" sampling for your counter period measurement.  You probably need to choose "Implicit (Counter)"

8. You are only reading 1 sample at a time from the counter task in your loop.  This is probably not a great choice.  Keep reading for a (likely) better choice.

 

More Thoughts:

9. If you DO have an always-present high frequency clock as a trigger source, here's an outline of an approach to manage it.  Configure the counter to be Arm Start triggered by the signal "DEVICENAME/ai/StartTrigger".  Be sure to call DAQmx Start for the counter task *before* calling it for AI.  Leave AI to be triggered by the external signal.   So the counter task gets armed first but doesn't trigger to actually begin measurement until the AI task asserts that it has received its trigger.

10. I would configure the counter task for Continuous sampling and read from both tasks in a single loop in the following way.  After reading from AI, do a multi-sample read from the Counter task.  Specify the "magic" (and default) value (-1) as the # of samples to read.  This means, "read all the samples available from wherever I left off before".

11. As a starting point, consider setting up TDMS logging for the counter task.  You'll need to specify a different file than the one used for the AI task.  At some later point, you'll probably need to work on better schemes for saving all your data into one common file, probably via explicit TDMS writes.

 

I'm not sure I'll be able to keep engaging in this thread in a lot of detail.  Hopefully you can use these "bread crumbs" to help in the search for a more complete solution.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 3 of 4
(166 Views)

The Sound and Vibration Toolkit (Full edition) has DAQmx examples for synchronizing vibration (analog) inputs with tachometer (analog or counter). Do you happen to have a license to SVT?

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 4 of 4
(153 Views)