Initialization – Yaskawa SMC–4000 User Manual

Page 310

Advertising
background image

300

SMC–4000 User Manual

Initialization

Programs should start by initializing any special parameters and user variables that will be used later in the
program. Remember that variables must be initialized before use, or a command error will result later in
the program. The initialization section contains code that never needs to run after the initial power up.
Programmers may choose to incorporate a homing routine near the end of the initialization, just before
entering the main loop of the program.

Sometimes programmers will not want some variables to be reinitialized at power up because they contain
job specific values. Variables can be saved to flash memory by using the BV command within the
program. A handy trick for variables that must retain their values after power cycle is to include their
initialization ABOVE the #AUTO label. The variables would only get initialized if the XQ command is
issued from the terminal. This is because the XQ command with no argument causes the program to
execute at the first line. In contrast, with the #AUTO label is included in the program, program execution
starts at the label and continues from there, which would skip those other commands and variables above
it.

The following is an example of an initialization section.

#AUTO; InitPass=0 // Auto execute at power up, and init success flag set to false.

// ------------------ Wizard Shell Code Initialization Section -------------------

MOX; OP0 // Make sure motor is off and outputs are reset.

Error=0 // Initialize Application Wizard error code system

LimIgnor=0 // Initialize flag for limit switches during homing.

TRUE=1; FALSE=0

NT=_TM/1024 // Normalized Time, only required if servo update changed from 1000 uSec default.

// --------------- Homing Initialization -----------------

homing=0 // 1 When homing, 0 when not

homed=0 // 1 When homed,0 When not homed

H_SW=-1; h_sw=-1 // Active state of the home input All caps is original config, small is program switchable.

// ------------------ Rotary Table Initialization ----------------------------

DM Accel[9]

DM ApprDist[9]

DM ApprOP[9]

DM Dwell1[9]

DM Position[9]

DM PostDWOp[9]

DM Scurve[9]

DM Speed[9]

DM Station[9]

DM StatOP[9]

DM Modulus[3], OPosO[3], DL72[3]; i=0 // For the rotary calculations

#InitMod; Modulus[i]=0; OPosO[i]=0; DL72[i]=0; i=i+1; JP #InitMod,i<3

OldIndex=0; MachCyc=40960.0

Bit=5; JS #XtoY; BitMaskO=XtoY

MinBit=5; MaxBit=8; JS #MakeMsk; BitMask=MakeMsk

WT 500/NT

SHX; WT500/NT

InitPass=1 // Initialization success flag, for special label usage

Advertising