Read Multiple inputs and control an output


frobate

Recommended Posts

Hello I have a need to read multiple channels (pressure transducers) and when any of those channels go above 1.5 volts, I want a Digital output to change states.

I have done this with a SWITCH statement but I cannot get the sequence to run continuously. Looking at the definition of the switch it looks like I may be using the wrong function.

So, how bout this;

WHILE (1)
   IF (INPUT [0] >1.5)
	   DIO_1=1
   ELSE
	   DIO_1=0
   ENDIF
   DELAY(1)
ENDWHILE

This seems to work for one channel but how can I include all 8 input channels?

Maybe put an event on each channel that writes to DIO_1?

Link to comment
Share on other sites

a) you aren't using switch(), you are using if(), and truthfully, you want to use if()

:rolleyes: I would expect that sequence to run continuously, as long as Input and DIO_1 exist. If it is stopping, what is the error?

c) you don't want to use channel events because the logic would be wrong. You really want a boolean OR.

Anyhow, just change the if() in your sequence to something like:

if ((input[0] > 1.5) || (input1[0] > 1.5) || (input2[0] > 1.5))

Repeat for all 8 channels, changing the input, input1, input2, etc to your real channel names. This does a boolean OR and if any of the channels are above 1.5 it will turn DIO_1 on, but if all are below, it turns it off.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.