LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter slows while loop with analog inputs

I'm currently developing a DAQ system for a lawn mower engine (class project). I recently switched to a Producer-Consumer model at the suggestion of this forum. I have two DAQ cards (a MyDAQ and a USB-9201) with a total of 6 analog inputs being used - 2 on the MyDAQ and 4 on the USB-9201. I'm using two inputs on the MyDAQ because the MyDAQ also has the counter that I'm using to measure the period of a trigger wheel signal - I figure that synchronizing the acquisition will be easier if they originate from the same piece of hardware (these two particular analog inputs, along with the counter period, are used to calculate mass flow). However, this isn't proving to be the case. I've found that collecting data from the counter in the same While loop as the analog input tasks causes a major delay in processing - I have a photoresistor (in place of a thermisistor - I don't have the thermistor with me right now so this gives me a similar effect) that I can wave my hand over and there is a 2 or 3 second delay in updating the Thermometer on the front panel, along with a general choppiness to the data. This same effect is not present when I remove the counter task from the While loop.

 

It's definitely possible that I'm not configuring the counter task correctly - this is my first time using the counter functionality of the MyDAQ and I'm still working my way through it. I've attached my VI and am putting a screen shot of the relevant portion of the block diagram below:

(with counter)

producer_with_counter.PNG

(without counter)

producer_with_ai_only.PNG

(Front panel configuration)

front_panel_config.PNG

I have also tried "Number of Samples Per Channel 2" with values like -1 (everything in buffer), 10 and 100 - all produce the same effect.

 

In another thread it was mentioned that I should try and configure the sample clock to use the 100 MHz internal clock (because my signal can be anywhere from 300 Hz to 4.8 kHz) however I have yet to figure out how to do that, every time I've tried configuring the sample clock I get an error, either about an internal buffer or the sample clock mode (either Implicit or On Demand are all that are listed as available for the MyDAQ). If someone has an example of configuring the MyDAQ sample clock for a counter that'd be awesome.

 

Thanks!

 

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

Forgot to attach my VI!

 

Note: The VI is still pretty rough, I'm currently moving my old VI in to this one before I clean things up - this is still an early testing stage.

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

Here is an example that has a sample clock configured to complete a CI Period task. I would recommend modifying your code to have a sample clock so you can set the rate at which the counter is counting. 

 

https://decibel.ni.com/content/docs/DOC-26286

 

Please let me know if this helps you out!

 

 

Applications Engineer
National Instruments
0 Kudos
Message 3 of 5
(3,008 Views)

I tried your program with the MyDAQ and got the following error:

mydaq_timing_error.PNG

 

Not really sure how to get rid of that.

0 Kudos
Message 4 of 5
(2,978 Views)

After looking into it further, you cannot do a Hardware timed Counter Input - Period task using the myDAQ. You can only do a software timed - On Demand task which was how you had it originally set up. It seems to be taking a while to perform the CI-Period measurement. I'm not sure how to reduce the time it takes to do that measurement.

 

You could try using tools like Profile Performance and Memory (Tools>>Profiler>>Performance and Memory) to quantify which VIs are taking up how much time to execute. 

 

You could try putting it in a seperate while loop if you want the other AI measurements to loop at a faster rate. If you want the AI measurement to eventually be synchronized with the period measurement, you may need to take AI measurements at a slower rate.

 

Please let me know if you've made any progress or have more questions!

Applications Engineer
National Instruments
0 Kudos
Message 5 of 5
(2,950 Views)