LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you count the frequency of a boolean signal?

Solved!
Go to solution

aeastet wrote:
This vi should work for you

 

 
Sorry, but this VI just earned a honorary mention in our Rube Goldberg thread. 😄
0 Kudos
Message 11 of 27
(2,478 Views)
Here is the simplified version. In the past I thought the to double did nto give the fractional numbers. That is why I did the complex conversions.
Tim
GHSP
0 Kudos
Message 12 of 27
(2,450 Views)

Altenbach forgot to mention the slight abusive use of unnecessary Local Variables. 

The medical term for this abuse is "Localitis".  There is a cure..

 

 

Wiring directly would have eliminated 2 indicators and 2 Locals  plus eliminated the need for a Flat Sequence Structure...  An added bonus would have been cleaner code.

For the code to actually run correctly as an example, it should have been in a For Loop which has 2 iterations.
 
Message Edited by Ray.R on 03-11-2010 08:05 AM
0 Kudos
Message 13 of 27
(2,448 Views)

Here's a snippet without Locals.

 

The reason for 2 iterations is to initialize t = 0.  Actually, depending on the rest of your code, you would not even need the loop.  I'll do another snippet.

 

 

 

This one below  is probably more appropriate since the above was simply a self executing example and not how you would implement it.

 

 

Message Edited by Ray.R on 03-11-2010 08:20 AM
Download All
0 Kudos
Message 14 of 27
(2,440 Views)

Will

 

It is blowing my mind that this code worked for you.  You didnt have to take into account the sampling rate of your digital I/O?

 

Chill

Herrlin

Just trying to spread the LabVIEW love.
0 Kudos
Message 15 of 27
(2,435 Views)
How would you have done this with a fore loop? You do not know when the boolean value will change so you will only get one event at a time. The boolean will only change state once. I would love to see what you can do?
Tim
GHSP
0 Kudos
Message 16 of 27
(2,434 Views)

aeastet

 

This is my take on your code with a while loop.  Still blows my mind that this worked for Will.

 

boolean freq.png

Herrlin

Just trying to spread the LabVIEW love.
0 Kudos
Message 17 of 27
(2,426 Views)

aeastet wrote:
How would you have done this with a fore loop? You do not know when the boolean value will change so you will only get one event at a time. The boolean will only change state once. I would love to see what you can do?

Sorry about that..

 

In my haste, I missed the boolean, which is an important part of this..  Also the trouble with jumping intoa thread from an external link..

 

Can't delete my useless posts.  😮  😞

 

I'll go back and try to understand the initial post.

 

 

0 Kudos
Message 18 of 27
(2,423 Views)


Will

 

It is blowing my mind that this code worked for you.  You didn't have to take into account the sampling rate of your digital I/O?

 

Chill


 
Herrlin
I am not sure why you are having trouble with it. I made the code independent of timing. That is the whole reason that I did it the way I did. I look to see when the Boolean changes and recorded the time and when it changes again I recorded the time and do the calculation. I does not matter how fast the loop is going for something this slow.
Tim
GHSP
0 Kudos
Message 19 of 27
(2,418 Views)

aeastet wrote:
I am not sure why you are having trouble with it. I made the code independent of timing. That is the whole reason that I did it the way I did. I look to see when the Boolean changes and recorded the time and when it changes again I recorded the time and do the calculation. I does not matter how fast the loop is going for something this slow.

I still would like to see how Will is getting his data from the digitial IO.  In my mind for this code to kinda work the data would have to be streaming real time.

Herrlin

Just trying to spread the LabVIEW love.
0 Kudos
Message 20 of 27
(2,416 Views)