beautypg.com

1 single-axis motion control in st, Single-axis motion control in st, L-force | plc designer - softmotion – Lenze PLC Designer PLC-Designer (R2-x) SoftMotion User Manual

Page 268

background image

L-force | PLC Designer - SoftMotion

SoftMotion programming examples

Single-axis motion control in ST

268

L

DMS 5.2 EN 03/2011 TD17

13.1

Single-axis motion control in ST

Tip!
See also the example project PLCopenSingle.pro provided with SoftMotion.

This example shows how a drive can be controlled by means of the function blocks that

have been standardised in accordance with PLCopen.
The SM_PLCopen.lib library must also be linked to the project as well as the Drive Interface

libraries.
A linear drive named "Drive" is defined in the PLC configuration:

In the task configuration, call the "Ipo" program, which generates a motion on this axis.
This program must then be created as follows, whereby a program in ST language is set up

and populated in the Object Organiser:
Before you can start to move the drive, you must ensure that it has been found and

initialised by the driver. If this is the case, you must set the controller enable for the drive

and, if applicable, release the brake. This function is performed by the MC_Power program

organisation unit:

You can now control the drive in the ELSE branch of the first IF condition. In this example,

this should be done using the MC_MoveAbsolute positioning POU. First, declare an

instance of this module as local variable named MoveAbsolute and a target position p of

type REAL, which will be initialized with "100". Now call this POU instance in each cycle

with the required values. When the programmed position has been reached, the program

organisation unit's Done output will be set and you must set the Execute input to FALSE if

you want to start a new motion, as the program organisation unit will only start a new

motion on a rising edge:

PROGRAM Ipo
VAR
Init: BOOL := FALSE;
Power: MC_Power;
END_VAR
IF NOT Init THEN
Power(Enable:=TRUE, bRegulatorOn:=TRUE, bDriveStart:=TRUE,Axis:=Drive);
Init:= Power.Status;
ELSE
END_IF

... (* Continuation of the program shown above *)
ELSE
MoveAbsolute(Execute:=TRUE, Position:=p, Velocity:=100, Acceleration:=100,
Deceleration:=100, Axis:=Drive);
IF MoveAbsolute.Done THEN
MoveAbsolute(Execute:=FALSE, Axis:=Drive);
END_IF
END_IF