LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

hold a boolean output for 15 sec

I have a boolean value output from a function that is true most of the time. It goes false for a short time at irregular intervals.

I need to feed the false to a hold function that will output false for at least 15 sec.

I'm using Labview 6.1.

This is probably too easy a problem for you guys. 🙂

But thanks in advance for your help.


I'd rather you tell me how to do it rather than give me a completed vi as I have seen done in other topics. Thanks.
0 Kudos
Message 1 of 12
(8,181 Views)
Two simple ways to do this would be to either use an Event structure with a case for that boolean --> value change. In the case, check if the value changed to false, and if it did, enter a case structure that contains a Wait until next ms multiple, wired with a 15000 constant.
 
The other easy way to do this is to have a parallel while loop, continuously check the value of the boolean, and if it is false, enter the same case structure as described in the first case. If you use this method, make sure to also place a small wait in the main  body of the while loop (this stops it from checking your boolean millions of times per second, which uses up 100% of your CPU).
 
If you have any questions about that, or want better descriptions of sections of that, post back with more questions!
 
Hope that helps!
Jeff


Using Labview 7 Express
0 Kudos
Message 2 of 12
(8,174 Views)
Thanks!

I think I got it working using the event structure.

Only I couldn't find a way to make it watch for a false, only for a value change.

I'll have to monitor it a while to be sure, as the false only happens about every 9 minutes.


I had not previously  looked at event structures. They look to be useful.

Thnaks again.

Bill
0 Kudos
Message 3 of 12
(8,152 Views)

Event structures are a very powerful tool! They are a very effective way of running your user interface.



cbgaloot wrote:

Only I couldn't find a way to make it watch for a false, only for a value change.


On the right side of the value change event, there should be a little connector called NewVal. Since you are monitoring a boolean, that value will either be true (if the value was just changed to true) or false (if it just became false). The event will occur for every value change, but as long as you connect the output of NewVal to a case structure, leaving the true case empty and putting a 15second wait in the false case, it should work fine!
Jeff


Using Labview 7 Express
Message 4 of 12
(8,142 Views)
OK, I'm still confused. I think we may have strayed. I think I wasn't very good at describing what I need to do.

Let's back up and try again.

I think my main problem is I just don't get how to synchronize things.

I have a boolean signal. It stays true most of the time.

It goes false for a varying amount of time, usually 5 or 10 sec.

I need to feed that False into a While Loop to stop that while loop, so the while loop can then feed its data to the next step. the while loop runs about every ten seconds. I have a 5 second delay in it and it takes about 5 seconds to gather the data it is  gathering from a SQL data base. So it checks it's inputs about every 10 sec.

My problem is if the False input doesn't synchronize with the timeing of the while loop the while loop never sees the false and never stops.

I need a function that when it's input changes, in whichever direction, it will change immediately and hold it's output for 15 seconds.

If the input is true, then changes briefly to false, the output needs to change to false and stay false for 15 seconds.

It could work the same way for true, since true stay true for about 9 minutes.



I hope I did a better job of describing the problem. 😞




0 Kudos
Message 5 of 12
(8,128 Views)
I understand you dont want a while loop iterating very quickly and a while loop can miss the false if it is only present for a split second, however an event structure will not miss the value change.
 
Create an Event structure with a case for *Boolean Name* Value Change
 
Wire the NewVal terminal to a case structure, leave the True case empty and put a 15000 Wait in the false case.
 
I would draw this for you, but Im very busy right now, however when I have some free time later today, I will make you an example if you still have difficulties with it.
 
Oh wait hoold up. You want it to wait 15 seconds regardless of whether it switchs to true or false? In that case, still use the event structure, but dont bother with a case structure in the event, just put a 15000 Wait in the Value Change event.
 
If you are still confused, post back, I will try and reply
Jeff


Using Labview 7 Express
0 Kudos
Message 6 of 12
(8,119 Views)
Ok I made up a little sample program, but there are a few limitations to this program.
 
First: The event structure queues events, so if your boolean changes to false (signalling) an event is generated. You want an event that freezes for 15 seconds, BUT if the boolean changes value several times during that 15 seconds, all of those value changes will be queued in memory, so after the first event executes, all the events that occurred during that 15 seconds will be processed.
 
Example: Your program returns false every 30 seconds, other than that it is true. This event structure I have set up will work fine, holding the false for 15 seconds.
Second Example: Your program stays true for some time, and then switchs between false and true three times in 15 seconds....the event structure will hold the false value for 45 seconds (15 seconds for each false generated).
 
So if you are holding the value for 15 seconds, but false values occur more frequently than once every 15 seconds, the stored value will ALWAYS be false. I dont think there is any way to purge the queue of events waiting to be processed.
 
Anyway, I have attached the example vi to give you an idea. You can ignore the top while loop, I just use it to generate a boolean signal that turns false momentarily every 30 seconds. The thing you should notice in that loop is that I use a property node with value signalling. This generates an event. If you just change the value programatically, no event is generated, so the event structure will do nothing. 
 
Note: This isnt really a solution, since you said you didnt want one, but this should help you understand the event structure method of monitoring your boolean.
Oh and someone will probably find a much better way of doing this and post right after me. haha
Jeff


Using Labview 7 Express
0 Kudos
Message 7 of 12
(8,100 Views)
Thanks I got it.

You second explaination got through to me.

It appears to be working fine now.

I would have replied earlier but the internet went down at work. Nobody knows why, but I have a suspision it had something to do with the back-hoe working in front of the building.

Thanks again for the help. I'm a rookie with Labview.

Bill




0 Kudos
Message 8 of 12
(8,088 Views)
Oops,

And thanks for that .vi

I'll take a look at it tommorow. I'll probably learn a lot from it.
0 Kudos
Message 9 of 12
(8,087 Views)
The .vi didn't work for me because the system I work on runs 6.1.

So far as the loss of the internet yesterday. It wasn't the back-hoe, it was the fence company who drove about a dozen metal poles for a chain link fence through the buried cable. Seems the cable company marked where the cable was with orange paint. Then the fencing forman marked where the fence was supposed to go with orange paint, 8 inches away from and perfectly parallel to the cable line. Then the workers drove the posts on the wrong line.


In case you are wondering what the heck I am actually doing.

I maintain a MXProline process control system. The software is written in Labview.

The product we make comes off the line in rolls.

All the data for each roll is stored in a SQL database.

Each roll is numbered.

I had previously written a .vi that watches the roll number and then collects stored data from the SQL database and dumps that into a text file.

They wanted to also be able to look and see what the machine speed and several other parameters were throughout each roll. Since the MXProline didn't do that I had to write another .vi to collect that data live.

The new .vi  monitors the roll number, and while the roll number has not changed makes the boolean we have been talking about go true.

That activates a while structure that starts checking certain values every ten seconds, and dropping that into arrays.

When the roll number changes a false is generated which stops the while structure, and sends the data in the arrays to be printed into a file.

The system is meant to be a control system, and didn't have the capability of giving us the data we wanted in electronic format so the bean counters and quality guys, and so forth can crunch the numbers.

So I set out to build this .vi It is finished and appears to be working fine.


And I very much appreciate the help you gave me in accomplishing this!

Thanks again

Bill
0 Kudos
Message 10 of 12
(8,052 Views)