EasyManuals Logo

Moog SmartMotor User Manual

Moog SmartMotor
909 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #185 background imageLoading...
Page #185 background image
Part 1: Programming
Moog Animatics SmartMotor Developer's Guide,Rev. L
Page 185 of 909
Variable "b" gets set to one only when variable "a" is equal to one. If a is not equal to one,
then the program continues to execute using the command following the ENDIF command.
Also, notice that the SmartMotor language uses a single equal sign (=) to make an
assignment, such as where variable a is set to equal the logical state of input 0. Alternatively,
a double equal sign (==) is used as a test, to query whether variable a is equal to 1 without
making any change to it. These are two different functions. Having two different syntaxes has
other benefits.
ELSE, ELSEIF
The ELSE and ELSEIF commands can be used to add flexibility to the IF statement. If it were
necessary to execute different code for each possible state of variable "a", the program could
be written as follows:
a=IN(0) 'Variable "a" set 0,1
a=a+IN(1) 'Variable "a" 0,1,2
IF a==0 'Use double "=" test
b=1 'Set "b" to one
ELSEIF a==1
c=1 'Set "c" to one
ELSEIF a==2
c=2 'Set "c" to two
ELSE 'If not 0 or 1
d=1 'Set "d" to one
ENDIF 'End IF
There can be many ELSEIF statements but only one ELSE. If ELSE is used, it needs to be the
last statement in the structure before the ENDIF. There can also be IF structures inside IF
structures that’s called "nesting" and there is no practical limit to the number of IF
structures that can nest within one another.
The commands that can conditionally direct program flow based on a test, such as the IF,
where the test may be a==1, can have far more elaborate tests inclusive of virtually any
number of operators and operands. The result of a comparison test is zero if "false", and one
if "true". For example:
IF ABS(EA-5)>x 'A numeric test
'placing further commands here
ENDIF
IF (a<b)&(c<d) 'A logical test using bit-wise AND
'placing further commands here
ENDIF
IF (a==b)|(c!=d)'A logical test using bit-wise OR
'placing further commands here
ENDIF
Complex logical tests involving bit-wise AND, OR and exclusive OR depend on whether the
result of an operation is zero or one. Any test for zero or not zero must be made explicitly.
IF (a<b)&c 'This should be avoided and replaced by
IF (a<b)&(c!=0) 'an explicit test of c not zero
Part 1: Programming: ELSE, ELSEIF

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Moog SmartMotor and is the answer not in the manual?

Moog SmartMotor Specifications

General IconGeneral
BrandMoog
ModelSmartMotor
CategoryServo Drives
LanguageEnglish

Related product manuals