08-25-2023 03:02 PM
Hi i am Rahul i am a novice in LabVIEW i just started out.i was using a boolean array for alarm history.i need to indicate a particular boolean value was true and time it was turned into true.i am using a event structure with value change the problem is show the both the values of the bit From False to True and True to False here i only need the False to true data.i don't know how to do that,so i came here to hope you guys would help me! Thanks in advance
(PS:I am not very good at English)
08-25-2023 04:00 PM
False to True is like a rising edge. You can refer to Edge Detection for the implementation.
08-26-2023 10:52 AM
I have a colleague who started using LabVIEW before I did (my "goto" language for handling data, not acquiring it, was Pascal). We "connected" and helped debug each other's code. From Pascal (and reading about Structured Programming), I learned about Programming "Style", and brought it to LabVIEW. His "style" was "get it done fast, don't worry about neatness" (and it showed!). My favorite thing to say to him was "Don't explain to me how you did something, tell me what you want to do".
So "What" do you want to do? You want to know when (in milliiseconds from some starting time) a Boolean Indicator goes True. You have a (single) Boolean Control with the Mechanical Action "Switch when Pressed". If you have an Event Loop with a "Value Changed" event for this one Boolean Control, every time you press it, the Boolean Event will "fire" and you can simply read if the Value is True or False.
Suppose it is True. What does this mean? It means you pressed the button (which was False) and it now is "True" -- this is the Event you want to time. But time from "when"? How about from the start of your Program? Great, what was the time that you started your Program? There are several functions on the Timing Palette that can give you a Time value (let's call this time "t0"). Use the same function in your Event Structure to get the time of the "switching to True" Event, subtract, and you have the time of your Event "since you started the Program". If you need other time differences (for example, since the last time it went True), you just need to keep track of that time, as well.
But what happens when you push the button again, and it switches to False? Another (actually, the same) Value Changed Event will fire. But now the Button will be False. What do you want to do? Possibly nothing, if you are only interested in "Going to True" events.
How simple! Think about what you want to do, and let the how take care of itself.
Ask yourself, if you run this program for an hour, how much data will it accumulate? As many data points as you have Button Pushes (from False to True, or 1/2 the total button pushes). You code (which I didn't understand) seems to have a Polling Loop that runs at 1 kHz, so when nothing is happening, you are using a lot of CPU time doing almost nothing. And it didn't do "what you wanted it to do".
Bob Schor
08-27-2023 06:24 AM
Hi Rahul,
Boolean arrays default to "switched" mechanical action which produces an event in both directions (on/off).
You can fake a "latched" mode by placing a Boolean array local variable (write) in the Value Change event.
Connect it to the OldVal output of the event. This will turn off the alarm button without causing an event.
Note: If you use the Initialize Array function to create your Boolean Array it's easy to see the size of the array.
08-27-2023 11:57 AM
See if the attached very simple version can give you some ideas...