Programming – Lenze PM94P01C User Manual

Page 55

Advertising
background image

PM94P01C

53

Programming

2.11.11

Motion Queue and Statement Execution while in Motion

By default when the program executes a MOVE, MOVED or MOVEP statement, it waits until the motion is complete
before going on to the next statement. This effectively will suspend the program until the requested motion is done. Note
that “EVENTS” are not suspended however and continue executing in parallel with the User Program. The Continue “C”
argument is very useful when it is necessary to trigger an action (handle I/O) while the motor is in motion. Below is an
example of the Continue “C” argument.

;This program monitors I/O in parallel with motion:
START:

MOVED 100,C

;start moving max 100 revs

WHILE F_MCOMPLETE=0

;while moving

IF IN_A2 == 1

;if sensor detected

OUT1=1

;turn ON output

WAIT TIME 500 ;500 mS

OUT1=0

;turn output OFF

WAIT TIME 500 ;wait 500 ms

ENDIF

ENDWHILE
MOVED -100

;Return back

WAIT TIME 1000

;wait time

GOTO START

;and start all over

END
This program starts a motion of 100 revolutions. While the motor is in motion, input A2 is monitored. If Input A2 is
made during the move, then output 1 is turned on for 500ms and then turned off. The program will continue to loop in
the WHILE statement, monitoring input A2, until the move is completed. If input 2 remains ON, or made, during the
move, then Output 1 will continue to toggle On and Off every 500ms until the move is complete. If input A2 is only
made while the motion passes by a sensor wired to the input, then output 1 will stay on for 500ms only. By adding the
“Continue” argument “C” to the MOVE statement, the program is able to monitor the input while executing the motion
profile. Without this modifier the program would be suspended until all motion is done making it impossible to look for
the input during the move. After the motor has traveled the full distance it then returns back to its initial position and the
process repeats. This program could be used for a simple paint mechanism which turns ON a paint spray gun as soon
as the part’s edge (or part guide) crosses the sensor(s) because delays, such as the one created by the ‘Wait Time 500’
statement are not allowed in an events task, this processor needs to be executed from the main program with the ‘,C’
modifier on the move statement as shown.

Figure 21 illustrates the structure and operation of the Motion Queue. All moves are loaded into the Motion Queue
before they are executed. If the move is a standard move, “MOVEP 10” or “MOVED 10”, then the move will be loaded
into the queue and the execution of the User Program will be suspended until the move is completed. If the move has
the continue argument, e.g. “MOVEP 10,C” or “MOVED 10,C”, or if it is an “MDV” move, then the moves will be loaded
into Motion Queue and executed simultaneously with the User Program.

Advertising