05-04-2015 04:31 PM
Hi,
I am working on, how to control a boolean switch to turn ON from OFF Condition after running it for a specific time. (The boolean switch is controlling an NC Relay). So when it is in OFF condition it is initially allow the relay to have a closed circuit there by run my application (DC Motor). But I want to have it stopped after running it for 3 seconds or whatever time (which the user will input).
I have three NC Relays, so each relay's boolean switch will be in off condition for that specific time (which is dependent on user input) and after running for that long, the boolean switch must be changed to ON condition. i.e., for example I want boolean switch 1 to operate for 3 seconds and after 3 seconds, the boolean switch must change it's value from False to True. And simultaneously I will have boolean switch 2 and boolean switch 3 in an array which will be running for time as per user defined and then change it's value from False to True after that specific time inputs.
I am using Digital SW Timed Output example from the Labview to manually turn On and OFF the boolean switch. But, it will be lot helpful for me to have the time dependent boolean switch condition changing.
I have attached the picture of my VI, (what I have tried so far). I hope someone can help me achieve this.
05-05-2015
06:29 AM
- last edited on
05-13-2025
02:32 PM
by
Content Cleaner
You should go through the LabVIEW tutorials, and specially that part which describes how to design and create state machines.
Here you can find many links:
https://forums.ni.com/t5/Community-Documents/Unofficial-Forum-Rules-and-Guidelines/ta-p/3536495
Under section "Looking For Free Training".
05-05-2015 11:29 AM
I have looked at state machine examples before posting this and also read in other threads state machines can do this task. I tried that way and I have seen an example of changing ONE boolean switch using state machine. I was not able to understand how to split the three boolean switches from the array and control them using state machine. Is there any other possible way. I tried to use cluster in my program instead of boolean array so that, I can unbundle the boolean switches but then build array and send it to the DAQ task, so that I can have access to three boolean switches. But, now I want help in changing the values of these three individual boolean switches with time.
05-05-2015
11:34 AM
- last edited on
05-13-2025
02:33 PM
by
Content Cleaner
Hey siks,
I agree with Blokk that a state machine would be a good option for what you're trying to do here. If you're not sure how to design that, there are many great resources online. One of the best is https://learn.ni.com/learn/article/labview-tutorial
Have a look at this and see if you can use the state machine information to achieve what you're looking for.
05-05-2015 11:41 AM
"I tried that way and I have seen an example of changing ONE boolean switch using state machine. I was not able to understand how to split the three boolean switches from the array and control them using state machine."
With a state machine this can be easily done. You have an array of boolean states, yes? These can be changed by your 3 switches. You can go either with an Event driven state machine, or via a simple polling state machine, where you have a "check" state to see if the user changed a switch state on your GUI. What you can do in both cases, to store your boolean array in a shift register. You can replace (so change) a single element of this array, or more of them easily using the array functions. So if one case of your state machine changes for example one boolean state of this array, it goes again into the shift register, so this information is reserved and available for the other state machine cases. Sorry, right now i do not have time to put together an example, but try to do it yourself, and later me or someone can give hints how to do it. But at least build a starting point, a state machine "skeleton".
05-05-2015 04:18 PM
Hi, I have tried to follow your instructions. They are hard for me to understand provided the limited knowledge I have.
I have tried to build the vi based on what I understood from you suggestion and using some of my idea. What I tried to do in this vi is to have each boolean switch's elapsed time to be compared with the time input (numeric control) that the user will provide and whenever the elapsed time exceeds the user's input time, the boolean switch will change it's value. Please see my vi and help me to develop my vi further. Thanks,MSC
05-06-2015
03:59 AM
- last edited on
05-13-2025
02:33 PM
by
Content Cleaner
First you should learn how to setup properly a state machine. Just forget your DAQmx and other tasks, first you need to make a flow chart indicating the states and the transitions between them. After this you can start to build a simple state machine. We already gave you links where you can learn LabVIEW. Sorry, still right now I have no time to put together an example.
05-06-2015 04:49 PM
Hey siks,
Generally we try not to provide prewritten code on the forums, but I already had a VI similar to this on my computer so I figured I could go ahead and post it.
I can't guarantee that this VI will work for you, but it should give you a better idea of how to architect your program to write to your DAQ device with a state machine.