LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Single pulse train to relay

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

 

Capture.PNG

0 Kudos
Message 1 of 4
(2,543 Views)

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?

0 Kudos
Message 2 of 4
(2,492 Views)

Not entirely..

 

The pulse is what turns the relay off and on..

 

I am not sure how I make the pulse happen only once

0 Kudos
Message 3 of 4
(2,365 Views)

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.

0 Kudos
Message 4 of 4
(2,340 Views)