LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter Problem

Solved!
Go to solution

Hi

 

I am trying to make a counter, where I compare values from DAQ to a preset value. My problem is that the way I have it set up right now the counter keeps counting continuously until the values are not the same. I want it to count just once for every time the values are the same, no matter how long the equal values last.

 

Any ideas?

0 Kudos
Message 1 of 5
(2,832 Views)

Without seeing your code I am just guessing.

 

Put the current value into a shift register or feedback node and compare the new value to the previous value.  When different increment the counter.

 

If your DAQ Read is producing floating point numbers, be cautious with equality comparisons.   Due to the way numbers are represented in binary, numbers which are very close to each other and which should nominally be equal will return False from the Equal? comparison.  Search the Forum for many threads on that subject.

 

Lynn

0 Kudos
Message 2 of 5
(2,825 Views)

Ok, maybe I should have done this in the beginning, but I have attached a simplified version of my code (since my code includes a lot of other stuff that would probably just confuse you).

I am sure that your previous answer still applies, but I opened LabVIEW for the first on monday, and I have had no lessons or anything, just been learning by myself. If you could be just a little bit more specific (even upload a picture of how you would solve it, if you have time) I'd be really grateful!

0 Kudos
Message 3 of 5
(2,812 Views)
Solution
Accepted by topic author bjarkijoha

First, I recommend that you work through the on-line tutoriasl to help you get started with LabVIEW. Doing that will save you a lot of time and beginner mistakes.

 

The image you posted shows two of them. That code will only run one time and then quit. You do not have anything to compare. It suggests that you may be using the Run Continuously button.  For a variety of reasons that is not a good practice.  Place a while loop around your code and add a Stop button to the front panel to stop the loop and your program.

 

The other is the use of a local variable.  In LabVIEW the wires are the "variables" and the controls and indicators are only places for the user to gain access to the data. The local variable is linked to the indicator and is not a holder for the data.

 

Lynn

Message 4 of 5
(2,807 Views)

Absolutely brilliant!! Thank you so much, it's working just as I want it now!!

Regarding the tutorials, I wish I had time But after I finish the project I'm working on now I probably will do some tutorials.

 

Thanks again 🙂

0 Kudos
Message 5 of 5
(2,774 Views)