05-09-2014 08:12 AM
This seems pretty easy but I am stuck. I have a code to run a continuous pulse train to trigger a relay. I have a boolean I want to control this. If 'TRUE' the pulse should be continuous. If 'FALSE' the pulse should run only once.
Code below runs the pulse continuously. Currently, as below, the 'Boolean' is a button that stays latched and the while loop executes. 'Injecting' tells me if the relay is on (duration) or off (delay).
What I need to add is a switch toggle so that I can do:
Relay Power on AND Continuous(true) > run the while loop until the relay power button is unlatched again by user
Relay Power on AND Single(false) > run the while loop once and unlatch the relay power
05-12-2014 03:19 PM
Sounds to me like you need to use a case structure. The case structure would have one case for Continuous, and another case for Single. In the Single case, you could have a flag that gets set indicating that the single pulse has already been sent. If the pulse has been sent it does not send it again. Perhaps it would help if we diagram all the different possible state transitions for this. Is the expected behavior as follows:
Case (Continuous)
if(relay power is true)
send pulses
else
do nothing
Case (Single)
if(relay power and pulse not sent)
send pulse
else
do nothing
Is this more or less what you are trying to do?
06-17-2014 12:34 PM
Not entirely..
The pulse is what turns the relay off and on..
I am not sure how I make the pulse happen only once
06-18-2014 04:48 PM
Take a look at the attached VI. I did not implement all the logic, but this perhaps will give you a better idea of how to get started. I use a flag to ensure that the pulse is only sent a single time. After the pulse is sent, the flag is set high to ensure that the pulse is not sent again.