Introduction to Multi-Tasking
Terminology Program: A BASIC or IEC program Task: IEC61131-3 task containing one or more programs Process: Processing slot that runs a Task or BASIC program Kernel: Processing of the servo and motion firmware
Controller type determines the max number of processes Comparison table Controller type determines the max number of processes Controller # Processes Axes MC403 6 2½ / 3 (16 in s/w) MC405 10 4½ / 5 (16 in s/w) MC664 22 24 / 64 (64 in s/w) MC664-X 22 24 / 128 (128 in s/w) Euro404 10 4 (16 in S/W) Euro408 22 8 (16 in S/W)
Multi-Tasking: Benefits Division of Tasks Smaller, dedicated programs (processes) can be written to handle specific functions of the machine. Concurrency Each process acts like a virtual controller and operates independently of the others. Simplified Error Handling A simple process can be dedicated to error trapping with no overhead in the main tasks. Command Line The command line / Motion Perfect Link is always available, even when programs are running.
Multi-Tasking: Division of tasks STARTUP: Initialise Axis Parameters and User Memory (Generated by MotionPerfect) MAIN: Error Handler and Safety Interlocks MAIN (Error Handler) STARTUP (Axis Params /Variables) Runs Once HOMING: Axis Datuming Continuous Loop MOTION1: Main Motion Loop HOMING MOTION1 LADDER IEC61131-3 MOTION2 MOTION2: Alternative Motion Loop
Multi-Tasking: Servo Period 1 msec Servos & Motion System User User User Processor Interrupts Each interrupt causes a process switch. All data from running program and the line number are stored Data for next process slot is retrieved Programs run from where they left off last time As more programs are run, they appear to slow down.
Multi-Tasking: Servo Period 1 msec Servos & Motion System User User User 500 usec 500 usec Servos & Motion System User Servos & Motion User User 250 usec 250 usec 250 usec 250 usec Servos & Motion Sys Servos & Motion User Servos & Motion User Servos & Motion User
Multi-Tasking: Servo Period 1 msec Servos & Motion System User User User SYSTEM_LOAD (% of processing time) More axes running. Servo and Motion processing takes longer. Less time shared between multi-tasking processes.
Multi-Tasking: Program priority
Multi-Tasking: Program priority
Multi-Tasking: Program priority
Multi-Tasking: Program priority
* Expert tip ! See process % in Terminal #0 >>PROCESS Process Type Status Name Line hhhh:mm:ss.ms [CPU %] ------- ---- -------- -------------------------------- ----- ----------------------- 19 Slow Pause STARTUP 6 0000:00:11.995 [ 0.00%] 20 Fast Run USER_PROGRAM2 2 0000:00:15.671 [30.57%] 21 Fast Run USER_PROGRAM1 2 0000:00:16.526 [33.20%] 22 SYS Run Command Line 0000:00:49.191 [ 0.06%] 23 SYS Run Protocol Scheduler 0000:00:47.478 [ 4.89%] 24 SYS Run MPE 0000:00:49.195 [ 4.89%] 25 SYS Suspend CAN Server 0000:00:49.198 [ 0.00%] 26 SYS Run TCP/IP Server 0000:00:47.483 [ 4.90%] 27 SYS Run ECAT async 0000:00:47.485 [ 4.89%] 28 SYS Sleep[ 0] Data Backup 0000:00:47.487 [ 0.98%] 29 SYS Sleep[ 9] Directory Backup 0000:00:47.488 [ 0.00%] 33 SYS Run Display Manager 0000:00:47.491 [ 1.75%] KERNEL SYS Run Motion/Housekeeping 0000:00:49.207 [13.86%] >>
Kernel: Processing motion 1 msec Kernel System User User User SYSTEM_LOAD (% of processing time) Kernel runs closed loop and motion profile generation. System slot runs communications. User slots run BASIC and IEC programs. ?SYSTEM_LOAD 47.7697 >>
Multi-tasking and Motion Servo loops and velocity profile Move type Next move type Motion Buffers and Alarms
Multi-tasking and Motion BASIC Multi-Tasking Velocity Profile Unit Servo Control Runs BASIC programs SPEED=1200 ACCEL=3400 MOVE(340) WAIT IDLE PMOVE Generates motion profile points. NTYPE … MTYPE DPOS DEMAND_SPEED Calculates Servo control values for all axes. MPOS…ENCODER Servo control algorithm DAC_OUT Task switch 3 times per msec No guaranteed loop times. Processed once per servo period [Deterministic] Processed once per servo period [Deterministic]