SCX11/IMC: Logical Operators and Conditional Statements ms

User avatar
Posts: 1058
Joined: Fri Mar 12, 2010 2:59 pm
Location: Torrance, CA

SCX11/IMC: Logical Operators and Conditional Statements ms

Postby om_tech_support_JT » Wed Jun 10, 2015 10:34 am

When using a conditional a statement in a programming language, one would normally use the logical operator within the parameters of the conditional statement. However, the way the IMC for SCX software is structured, it only recognizes one value as a parameter for the conditional statement.

For example,

IF (IN1 = 0)
IF (IN2 = 1)

but not

IF (X = IN1|IN2)

Because the program does not recognize the concatenation of variables and operators as a valid assignment you would get a syntax error. In cases where a user would try to compare two input signals IN1 and IN2 using an OR operator in conjunction with an IF statement, the best option would be to create a dummy variable that would be initialized by the OR operator and then use the dummy variable as the parameter for the IF statement.

An example where this would be relevant is when checking two inputs to see if either of them are turned on, and if one of them is, initiate a sequence. To do this you would first initialize a dummy variable X using the OR operator to determine if either input IN1 or IN2 are turned on.

X = IN1|IN2

After, you would create an IF statement where the sequence begins if the condition of having either input on is met.

IF (X=1)

The same can be applied for the rest of the logical operators and conditional statements and extended to multiple inputs. The important thing to remember is to use that dummy variable.

Here's an example of a program that uses the IF, OR statement and a LOOP to continuously check for the status of 2 inputs. If any of the inputs turn ON, then the motor will move continuously in the positive direction. If the input turns OFF, then the motor will stop. Please use this as a reference only.

( 1) LOOP
( 2) X = IN1|IN2
( 3) IF (X=1)
( 4) VS 0.1
( 5) VR 1
( 6) TA 0.5
( 7) TD 0.5
( 8) MCP
( 9) X = 0
( 10) ENDIF
( 11) mstop
( 12) mend
( 13) endl

Return to “Stepping Motors & Controls”

Who is online

Users browsing this forum: No registered users and 2 guests