Examples and tips
PROGRAMMING MANUAL
279
Revi
si
on 3.0
6.2
Practical examples
6.2.1
Shell program
fig. 49
Good programming practice requires a good shell program. A shell
program starts, stops and resets the application programs. The
shell program is not necessary, but gives structure to the
applications and makes the method to program the motion
controller more effective.
Find below an example of a shell program. make sure that you
modify the program to the specific needs of the application. Check
correct operation before you rely on the safe operation of the
program. This program is typically set to run at power-up at low
priority.
Example
'================================================
'EXAMPLE OF SHELL PROGRAM
'THIS VERSION IS DESIGNED FOR MECHATROLINK SERVOS
'ADAPT THIS PROGRAM ACCORDING TO YOUR APPLICATION
'================================================
'IN THIS EXAMPLE ANY ERROR MAKES STOP ALL
'PROGRAMS AND MOVEMENTS STOP
'WE USE A GLOBAL VARIABLE (VR(0)) FOR PROGRAM
'MANAGEMENT.
' VR(0)bit0 To start the application (rising edge)
' VR(0)bit1 To RESET all alarms (rising edge)
' VR(0)bit2 To STOP the application (rising edge)
'================================================
'This example is for an application with three
'servos
'AXIS 1, 2 and 3
'================================================
'Variable initialisation
max_axis=2
'project_status
'=0 initial value
Stop Application
programs and
movements.
Start Application
programs
Alarm?
Start_application
VR(0)bit0
VR(0)bit2
VR(0)bit1
Main_loop
No
No
Yes
Yes
Yes
Yes
Yes
No
No
No
Store status for
diagnostics
Stop Application
programs and
movements
Reset Sequence
Start?
Alarm or
Stop?
Alarm?
Alarm?
Reset?
I52E-EN-03.book Seite 279 Freitag, 29. Juni 2007 11:55 11