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 #189 background imageLoading...
Page #189 background image
Part 1: Programming
Moog Animatics SmartMotor Developer's Guide,Rev. L
Page 189 of 909
Program Flow Examples
The following are techniques that can be used for flow control in your SmartMotor program.
All sample code shows advanced use of program flow syntax. Additionally, there are
references to lesser-used math functions and system parameters to enforce learning of new
programming techniques.
NOTE: The Variables and Math section should be referenced for a better
understanding of the following example programs. For details, see Variables and
Math on page 195.
IF, ELSEIF, ELSE, ENDIF Examples
The following example shows the proper use of the IF, ELSE and ENDIF commands along with
nested conditions and math capabilities. For more details on the IF, ELSE and ENDIF
commands, see IF, ENDIF on page 184.
'Find shortest dist. to Top Dead Center Shaft position from present position
IF (PA%RES)>(RES/2) 'Check shortest distance using Modulo Math function
PRT=RES-(PA%RES)'Set Relative Position to Modulo Remainder
ELSE
PRT=-(PA%RES) 'Otherwise Set to RES - Modulo remainder
ENDIF
The following example uses #define to associate values and I/O points for use in code.
#define UpperLimit 3000 'Set high voltage threshold
#define LowerLimit 1500 'Set low Voltage threshold
#define MyVoltage INA(V1,3) 'Set input Port to read
C124
IF (UpperLimit>MyVoltage) & MyVoltage>LowerLimit
PRINT("Voltage is in range",#13)
ELSEIF MyVoltage>=UpperLimit
PRINT("Voltage is too high",#13)
ELSE
PRINT("Voltage is too low",#13)
ENDIF
RETURN
WHILE, LOOPExamples
The following example shows the proper use of the WHILE and LOOP commands. For more
details on these commands, see WHILE, LOOP on page 186.
Part 1: Programming: Program Flow Examples

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