check discrete input status, move on...

Current program I’m working on needs to include some logic that will check status on several discrete inputs, then issue a value (command) only to the axes that correspond to the discrete inputs that are “on” (and of course teh program needs to keep running). For example: Switch 1, 3, 4 are ON, Switch 2 is OFF, so the program only commands Valves 1, 3, 4.

Any thoughts on what that should look like? Thanks!

In a command in a user programs, the Command Axes box has an option called “Use Expression”. This lets you use a DWORD variable to choose which axes to send the command to. In the variable, the bits 0-31 correspond to the axes 0-31 (you can’t have 31 axes of course!), and the command will be set to the axes for which the corresponding bit is set. In the RMCTools Help, on the Index tab, type “Commanded Axes” and choose “Using Expressions”. The topic explains how you can do this. You will also, of course, first need to set the bits in the variable according to the states of the discrete inputs, which can be done with an IF THEN ELSE statement.

I think I follow that well enough.

So if I understand correctly: I can command a move to whichever axes are activated (in this case, according to my IF statements/Discrete inputs) using an Expression and a DWORD. The DWORD bits in this scenario will automatically(?) refer to my axes, such that my program will automagically apply a given input to the activated axes…? (see attached)


Yep, looks like you got it, assuming that you do understand that bit 0 is Axis 0, bit 1 is Axis 1, bit 2 is axis 2, etc.

In the expression, you may be able to write just 4 lines if you do this:

ValveOn.BPV1 := SV_2;