LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Count Boolean changed

Solved!
Go to solution

Hi ,

 

I am newbie to labview. In my project i want count the boolean  value has changed  within 5 sec or not?

 

if  changed I want  to trigger the hardware if not i just need to continue the loop

0 Kudos
Message 1 of 15
(4,537 Views)

Have you read/viewed/studied any LabVIEW Tutorials, such as the ones mentioned on the first page of this Forum?  If so, you should be able to:

  • Construct a loop that will execute its contents every so-many milliseconds.  [Hint -- Timing Palette; getting Help for LabVIEW Functions].
  • Know how to save a value of a Control so it will be available to you when the loop next runs.  [Hint -- Shift Register].
  • How to detect if a Control or Value is the same on this loop as in the previous loop.
  • What structure to use to "do different things depending on some value on a wire".

Give it a try.  When you next Reply to this message, attach your VI so that we can either (a) congratulate you for figuring out how to do this, and for putting a little effort into learning enough basic LabVIEW (like the first few Tutorials), or (b) give you just a little hint to correct a mis-impression or lack of understanding of LabVIEW's Data Flow paradigm.

 

Bob Schor

0 Kudos
Message 2 of 15
(4,535 Views)

Hi Bob,

Thanks for reply...I can create a loop to generate Boolean and I can compare old and previous value...what my main problem was how to check with in 5 sec any value ( Boolean ) changed or not

0 Kudos
Message 3 of 15
(4,518 Views)

It is always a good idea when you have a LabVIEW Question to post your LabVIEW code where you try (and, maybe, fail) to solve it.  For example, you say "Boolean value", but it is unclear if this is a Boolean control or a Boolean variable.

 

Why does it make a difference?  LabVIEW (as you may have discovered) is a little different from other Programming Environments.  For one thing, Time is treated as an intrinsic concept in LabVIEW.  Not only are there Timing functions, there is also the Event Structure, which allows you to "take notice" when a Control changes.

 

You ask "How do I check within 5 seconds whether a Boolean value changed or not".  One way to do this is called "Polling" -- ask over-and-over (either "as fast as you can", which tends to waste CPU cycles, or "every <time-interval>") if the value has changed.  The other way is to "fire an Event" when a change occurs.

 

When you say "check within 5 seconds", do you mean "If it changes at 1 second, wait until 5 seconds is up and say It Changed!" or "If it changes at 1 second, immediately say It Changed!"?  If the former, what if it changes twice (On, then back Off) during the 5 second interval -- do you count those two "Changes" as a "Change"?

 

Next time you reply, attach the VI where you've attempted to solve your own problem.  We try to not do Homework for other Forum Users, neither are we trying to develop yet another set of LabVIEW Tutorials or Classes (there are plenty on the Web).

 

Bob Schor

0 Kudos
Message 4 of 15
(4,508 Views)

@RNR wrote:

 

In my project i want count the boolean  value has changed  within 5 sec or not?

 

if  changed I want  to trigger the hardware if not i just need to continue the loop


Your two sentences don't seem to agree because they talk about two different problems.. Counting transition will tell you how many times a boolean has changed over that time interval, i.e. if gives you an integer number, but you seem only be interested if it has changed at all, i.e. only two possible outputs (changed, not changed).

 

Do you want to count over a specific time interval (specific start and end time) or do you want to continuously detect if the boolean has changed within the last 5 seconds?

 

It would probably help if you could show us your code.

0 Kudos
Message 5 of 15
(4,493 Views)

Hi,

I want detect continuously in past 5 sec the Boolean value changed or not?

I want to detect the boolean  variable value's in particular timestamp , and  if there is any change in value for particular time stamp, i want to trigger event .

 

Note:- This vi  i have created for demo/ part model of my project,

thanks for reply and support. I am thinking about shared variable and queue to implement. please try to give me the logic

0 Kudos
Message 6 of 15
(4,460 Views)

If you just want to detect a boolean change, what's the significance of the 5 seconds? Makes no sense to me. What should happen after five seconds if no change occurred? What if more than one change occurred?

 

Also have a look at "boolean crossing ptbypt".

 

Do you want to ignore all changes for five seconds after a change has been detected?

 

I don't understand your code. Your boolean changes 10x per second. What's the significance of the sequence frame? I also think you have wired the indicator to the wrong output of the feedback node. To detect odd/even, you don't need Q&R, a simple "AND 1" followed by "equal zero" is preferred. I don't see any time stamps.

0 Kudos
Message 7 of 15
(4,452 Views)

Hi,

please go through my code to have better understanding

0 Kudos
Message 8 of 15
(4,447 Views)

RNR wrote:

please go through my code to have better understanding


Sorry, that code does not really help me understand. Most of it makes no sense. Are you trying to detect if the boolean is TRUE for more than 5 seconds?

0 Kudos
Message 9 of 15
(4,439 Views)

Yess ..I am detecting Boolean high on 5 sec 

0 Kudos
Message 10 of 15
(4,436 Views)