06-20-2018 09:24 AM
Dears,
I apologize for the simple question but I need help.
I would like to know how is possibile to determine how long a boolean is true. In other words, I would like to know after a boolean come true for how much time it is stil true.
I am trying with Time Elapsed but I do not really understand how to use it.
Thank you so much for the help!
Solved! Go to Solution.
06-20-2018 09:27 AM
06-20-2018 09:33 AM - edited 06-20-2018 09:33 AM
@GerdW wrote:
Hi mb,
you need the timestamp for the rising edge and the timestamp for the falling edge. Then subtract both.
To easily detect boolean edges you can use the BooleanCrossing (PtByPt) function…
Is there an example to learn how to use it?? I am really a beginner about VI, can you help me?
06-20-2018 09:37 AM
06-20-2018 09:41 AM
@GerdW wrote:
Hi mb,
the simplest example you can get, realized in less than 60s:
How long do you need to recreate it?
Thank you so much! I will let you better understand my problem.
I would like to know if a boolean become true and after how long it is true. If it is for 2 seconds then another bolean become true.
06-20-2018 10:00 AM
LabVIEW has functions that return the time. Your situation is how to call this when you Boolean variable changes. I'm guessing you have not taken advantage of all of the Tutorial Material mentioned on the first page of this Forum, which would discuss things like how to recognize changes to variables. You also haven't put this question "in context" by saying what else will be going on and how you intend to use this information.
I urge you to take advantage of the tutorials. You need to get the "LabVIEW Model" of programming into your head, particularly the Principle of Data Flow, which if done right, can allow you to ask (and answer) the question you raised.
Bob Schor
06-20-2018 10:13 AM
okay thanks..
06-20-2018 10:39 AM
What makes the boolean change? Is this from a DIO measurement, from some computations, or from user interactions on the front panel? What kind of time resolution do you need? (nanoseconds? days?)
You basically have a state machine with three states:
So you need a case structure with three states inside a while loop that polls the boolean. You also need a shift register or feedback node to retain the boolean value for the next iteration so you have something to compare it with. You were told how to detect state changes already.
You need a second shift register to keep track of the elapsed time. You can use "tick count" (millisecond units, U32 integer) or "high resolution relative seconds" (unit in seconds, but high resolution), both in the timing palette.
In the three mentioned states do:
There are plenty of examples posted in the forum to do just that.
06-20-2018 10:57 AM
@altenbach wrote:
What makes the boolean change? Is this from a DIO measurement, from some computations, or from user interactions on the front panel? What kind of time resolution do you need? (nanoseconds? days?)
You basically have a state machine with three states:
- No change from the previous iteration
- Changed from FALSE to TRUE
- Changed from TRUE to FALSE
So you need a case structure with three states inside a while loop that polls the boolean. You also need a shift register or feedback node to retain the boolean value for the next iteration so you have something to compare it with. You were told how to detect state changes already.
You need a second shift register to keep track of the elapsed time. You can use "tick count" (millisecond units, U32 integer) or "high resolution relative seconds" (unit in seconds, but high resolution), both in the timing palette.
In the three mentioned states do:
- nothing, just wire the tick across. You can still do the subtraction to show the updated elapsed time in the current true state (or zero if the state is false).
- Place the current tick into the shift register as new time reference
- Subtract the current tick from the one in the shift register to display the elapsed TRUE time.
There are plenty of examples posted in the forum to do just that.
Thank you so much for all the help! It seems clear now, but not having a good knowledge of LabVIEW it is not simple to undarstand quikly. Could you be so kind to link me some of these examples, because I am trying to find them but without success.
The boolean represents an error and change the state of the clutch of a motor, engaging it. I would like to engage it only after 2 seconds in which the boolean come true.
06-22-2018 01:53 AM
I guess this might help you.