From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I get two different outputs with "Digital 1D U8 1Chan NSamp"

I have two variations of a program that I am using to try and synchronize data collection at different rates.
 

Version A:
I have an anemometer attached to the DAQmx Create Channel (DI).vi
The Create Channel VI enters a while loop, and connects to DAQmx (Digital 1D U8 1Chan NSamp).vi, collecting 2000 samples
This create an output that feeds into a Build Waveform
The output of the waveform goes into NI_MAPro.lvlib:Extract Single Tone Information.vi to determine the dominant freqency of the pulses from the anemometer
The frequency gets multiplied through by a constant to determine the reading off the anemometer.

When I run this version of the program, I get that the windspeed is approximately 4-4.5 mph
 
However, I then needed to coordinate this 2-second collection rate with a photogate that is measuring rpm of a gear (60 teeth, approximately 20rpm, so pulses on about a 50ms cycle).  I then created version B of my program
 

Version B:
Utilizes two While loops.
  While loop #1: Just as in version A, but the reading off the anemometer at the end gets fed into a global variable (which is initialized to zero at the very start)
  While loop #2: Uses a series of nested Case Structures to determine if the photogate has detected a new pulse, and if so, updates all outputs derived from the photogate data to determine what tooth we're on, the rpm, the time since the program started, and pulls the current value of the global variable.
 
Both While loops are slaved to a Wait Until Next ms Multiple delay of 1ms to try and synchronize the two loops.

 
Now, when I run this program, in the exact same conditions, I get a windspeed of about 8-9mph, and the values from the global variable update about every 4 seconds (which seems to imply that there's a related problem). 
 
Can anyone help with this?
 
-G-
 
0 Kudos
Message 1 of 4
(2,444 Views)
Do you use timed DIO?

Presumable not but you should look at that (there's something in the LV help)
Most likely you are now bound to software timing and that's not very reliable (I doubt you'll get 1000 readings each seconds)

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 4
(2,436 Views)

I'm sifting through the results for Time DIO (thanks for the quick suggestion).  In the meantime, here are the two versions of the program.  From what I've seen distant professional colleagues do, it should be fairly straightforward Smiley Happy

 

 

Download All
0 Kudos
Message 3 of 4
(2,430 Views)

Hi Gordon,

I am not sure how your wind speed is being correlated to your data. Is there a more simple example which can exhibit the same problem – without using DAQ. (since your DAQ is software timed, this should be easy to simulate). I may also suggest doing a producer consumer loop instead of shared variables. An example of this can be found here: File >> New >> Producer/Consumer (under VI >> From Template >> Frameworks >> Design Pattern). The fact that your variable is being updated every 4 seconds only means that is what you are seeing. The variable will be updated at the rate of the DAQmx acquire, and (I suspect) that data is being overwritten and lost since your variable can only hold one number. This is why I suggested a producer/consumer queue previously, as it is a first in first out (FIFO) and as long as it is big enough, you will not loose data.

David L.
Systems Engineering
National Instruments
0 Kudos
Message 4 of 4
(2,405 Views)