LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labVIEW not reading data correctly

Solved!
Go to solution

I'm new to LabVIEW (using it for a subject at university) but I've coded up a short program that counts rising and falling edges of a signal (to be used with input of a quadrature encoder).

 

I've tested it at low frequency using the Simulate Signal block and it works fine, but as soon as I pump it up to anything above 4 Hz, it starts playing up (counting a positive edge as a negative edge). At 10 Hz, it doesn't count any edges at all. Same thing with the encoder - when we turn it very slowly the counts register fine, but turn it at even a moderate speed and it'll start missing.

 

Not sure what the issue is. The code is pretty simple so I'm not sure how that'd cause the problem. Here's a copy of my counter block (the true/false input tells it whether to count up or down).

0 Kudos
Message 1 of 11
(3,966 Views)

How are you running this?  It is setup as a single run VI.  It runs, it ends.  There is no while loop around your code to keep it running.   (Please don't tell me you are using the Run Continuously button.)

 

I doubt you'll get this working.  You are really on software timing.  Meaning the code has to run fast enough in software to detect all the transistions.

 

There are some odd constructs in there as well.  A case structure that has a False constant in the True case and a True constant on the False case.  Just use a Not function.  The number of feedback nodes you are using seems excessive as well.

 

 

0 Kudos
Message 2 of 11
(3,962 Views)

That's the subVI - it's being called from another VI which has the while loop and signal inputs.

 

Currently on a computer without LabVIEW so I can't edit the file, but surely the software should be able to easily manage 10 Hertz (or even 5, for that matter), despite the convoluted constructs?

0 Kudos
Message 3 of 11
(3,955 Views)

You might try some of the functions in the Waveform functions palette for your application.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 4 of 11
(3,945 Views)

The loop will probably need to run at least twice as fast as the pulse signal you are trying to measure to guarantee that you won't miss a pulse.  So that would be 20 Hz or about a 50 msec loop iteration.  That should be doable.

 

Put some timing functions into your main VI and subVI to see how long each section of your code is taking to run.  In order to really give more suggestions, we'd have to see the main VI so we can see how the loop is setup.  Are you using a continuous data acquisition, or are you starting and stopping your DAQ task in the main VI?

0 Kudos
Message 5 of 11
(3,939 Views)

I've editted the counter file to include time measurement and also included a test file from which I run the counter. It seems to struggle above 5 Hz. I've ran it in my actual file (which is similar to the test but also counts edges of a second signal) and get the same interval between codes, so the actual code doesn't seem to be the limiting factor here.

Download All
0 Kudos
Message 6 of 11
(3,933 Views)

I don't have LV 2011 installed, so I can't view those files.  If you could attach them as 2010 or earlier, please.

0 Kudos
Message 7 of 11
(3,927 Views)

I'd look but.... I'm installing 2011.    YAWN!


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 11
(3,924 Views)

I've attached version 9 compatible files. Appreciate the help.

Download All
0 Kudos
Message 9 of 11
(3,921 Views)
Solution
Accepted by topic author blueview

Are you adjusting the length of your simulated waveform when you vary the frequency?

 

Your subVI appears to only be looking for one transition within a waveform.

 

Your simulated signal Express VI is set up for 1000 Hz sample rate and 100 samples.  So the outer loop iterates at 10 Hz.  If your frequency is 5 Hz, then you are only going to have 1 transition in the section of waveform and you'll detect it.  You go higher in frequency, then you might have multiple transitions in your waveform, but the subVI is only looking for the first one, and it might not even get that one.  Remember when I said you need to run your loop twice as fast as the incoming waveform?  Well you are now seeing that 2:1 ratio.

 

Adjust you length of your simulated waveform as you adjust the frequency so that you don't get multiple transitions on the waveform you are generating each loop iteration.

Message 10 of 11
(3,917 Views)