TM440 Motion Control Basic Functions
TM440 Motion Control Basic Functions
TM440
TM440TRE.00-ENG
2012/02/01
Requirements
Training modules: TM410 – The Basics of ASiM
Software Automation Studio 3.0.90
Automation Runtime 3.08
ACP10_MC Library 2.280
Hardware None
TABLE OF CONTENTS
1 INTRODUCTION.................................................................................................................................. 4
1.1 Training module objectives..................................................................................................... 4
2 THE PLCOPEN STANDARD............................................................................................................... 5
2.1 General information.................................................................................................................5
2.2 Advantages..............................................................................................................................5
3 THE PLCOPEN MOTION LIBRARY....................................................................................................7
3.1 Structure and composition...................................................................................................... 7
3.2 Function groups...................................................................................................................... 8
4 INTEGRATION IN THE CONTROL PROJECT................................................................................... 9
4.1 Using the axis reference.........................................................................................................9
5 APPLICATION BASICS......................................................................................................................10
5.1 Controlling the function blocks..............................................................................................10
5.2 Overview of the drive states................................................................................................. 14
5.3 Periodic axes - Rotary axis.................................................................................................. 16
6 TIPS FOR PROGRAMMING..............................................................................................................20
6.1 Uses of control structures.....................................................................................................20
6.2 Error handling in the application program............................................................................ 21
7 USING THE SAMPLE PROGRAMS..................................................................................................24
7.1 Overview - Adapting samples...............................................................................................24
8 MANAGING DRIVE PARAMETERS.................................................................................................. 26
8.1 Initializing and reading individual parameters.......................................................................26
8.2 Transferring and initializing parameter sets..........................................................................27
8.3 Reading and writing parameters cyclically........................................................................... 29
9 CONTROLLING SEVERAL SINGLE AXES - SOFTWARE CONFIGURATION.................................31
10 SUMMARY....................................................................................................................................... 34
1 INTRODUCTION
In this training module we will also take a look at using and inte-
grating positioning functions in an application program.
Working through different exercises will help us to understand the
behavior of function blocks and provide us with important basic
knowledge for applying these functions.
The PLCopen Motion Control standard plays a central role in the
operating concept of B&R's drive solution.
In this training module, you will be given an overview of how to apply and integrate the PLCopen library.
You will receive information about ...
• ... the advantages of using PLCopen functions
• ... integrating PLCopen functions into your project
• ... the structure and functionality of function blocks
• ... the basic functions for preparing the drive and carrying out standard movements
• ... the typical structure of application programs
• ... the process for adapting the sample programs
Detailed information about the PLCopen organization and their activities can be found on the Internet
here: http://www.plcopen.org/
Guidelines are being developed to ensure that different system solutions are all operated in the same
way.
All automation solution suppliers who belong to this organization provide a uniform software interface
for their system that is defined using PLCopen. B&R is an active member.
2.2 Advantages
The PLCopen motion library is listed in the Automation Studio help documentation and in Automation
Studio itself as the ACP10_MC library. It includes standardized PLCopen function blocks to control B&R
drive solutions.
In addition to these standardized function blocks, this library also includes B&R-specific expansions.
For example, powerful tools for connecting drives are provided (see TM441 Motion Control: ASiM Mul-
ti-axis Functions). Basic positioning functions are also available with advanced options.
The ACP10_MC library has been expanded to include additional B&R-specific functions that allow the
user to take advantage of these functionalities in a uniform manner. These advanced functions are op-
erated exactly the same as the standard functions.
ACP10_MC library
The ACP10_MC library contains a relatively large number of function blocks, which can be roughly
divided into several groups according to their use and function.
The process for creating a drive configuration in Automation Studio is described in the preceding training
module (TM410). Specific commands may already have been transferred to a drive using the "NC Test"
diagnostics tool.
The following example shows how an application program for controlling axis movements can be struc-
tured.
An axis reference for accessing the axis object will be needed first. This axis reference has already been
generated by the Motion Wizard and added to the mapping table.
The wizard creates a global PV of type ACP10AXIS_typ with the same name that is listed in the NC
mapping table. The connection is then made from the software object to the actual hardware via POW-
ERLINK.
5 APPLICATION BASICS
This section provides some basic information about using ACP10_MC function blocks. We will look at
how to operate the function blocks as well as possibilities available for monitoring procedures.
All function blocks are accessed using uniform operating and status parameters.
This standardized operation of all function blocks makes it easier to use the program and helps to ensure
a clear overview during programming.
Parameters Description
Axis Specifies the axis reference to determine the axis for which the function block
should be used.
Enable Function blocks with an enable input control tasks according to the level on this
input. The values on the function block inputs are taken over when it is set to
TRUE. When the input is set to FALSE, an action is also carried out and all out-
puts are reset.
Execute Function blocks with an "Execute" input read their input values and execute their
tasks one time when a positive edge occurs on the "Execute" input. (For exam-
ple, a new set speed is taken over when a positive edge occurs on Execute).
If a function is started with this input, it cannot be ended prematurely by reset-
ting the input. Another block must be called to interrupt or stop it. (For example
MC_Halt, MC_Stop, MC_Move, etc.)
Busy Indicates that the respective action has been successfully started and is current-
ly being executed. As long as the output is set, the function block must continue
to be called, otherwise the status information, function, etc. is negatively affect-
ed.
"Done" Each function block contains a status input that indicates the successful com-
pletion of the action. This output is labeled differently depending on the function
block, but always serves the same purpose.
CommandAborted Signals that the command was aborted by another function block call.
Error Signals that an error occurred during the function block call.
ErrorID If an error occurs, the corresponding error number is returned here. This pro-
vides information about the cause of error A listing of the error numbers can be
found in the Automation Studio online help.
Table: Description of standard parameters and status information
The process is started when a positive edge occurs on the Execute input. Active processing of a com-
mand is indicated via the Busy output. Done (or InVelocity, InGear, etc.) indicates that the action has
been completed successfully.
In this case, an error occurs after enabling the action. If the "Error" output is active, then a corresponding
error number is indicated using "ErrorID".
In this case, the command that is about to be processed is interrupted by another command. This is
always the case when the executed function block affects an already active function block Busy= 1).
Summary
The status information Done, Command Aborted, Error and ErrorID remain the same until the Execute
input is reset.
If the Execute input is already inactive before these signals arrive, the status outputs and error indicators
are set for the duration of one cycle:
In order to reset the function block outputs if an error occurs, the Execute / Enable input must be set
tot FALSE, the cause of the error must be corrected (and the error may have to be acknowledged) and
then the function must be restarted.
The function blocks with an Enable input are only active as long as this input remains set. Otherwise the
action is ended and the status values on the function block outputs are reset.
The function block calls for the PLCopen functions must be called in the cyclic section of the
program. In high level language programs, we recommend calling the function at the end of
the program for all instances.
For graphic programming languages, special care must be taken if networks are to be jumped
over within the flow of the program.
The right approach can also be taken the sample programs (see 7 "Using the sample programs"
).
The axis reference should be linked to all function blocks. So you do not have to call the address
function all the time, the address can be stored as an internal variable and then passed on to
the function blocks. This makes it easy to replace the axis reference in the application program.
Init program
Cyclic program
The MC_Power function block is required to switch on the controller and the power elements.
On an ACOPOSmulti system, it is also required to switch on the power supply module.
The initialization value of the function block instances must be empty. Accordingly, no variables
with the "permanent" or "retain" attribute may be used.
Defined states are determined for operating a drive. These states provide a simpler overview of complex
movement procedures and make it easier to process error situations.
Status Description
Disabled The drive controller is switched off.
Standstill The drive is not currently executing a movement and is ready for position-
ing commands.
Homing The drive is executing a homing procedure.
Errorstop The drive is at a standstill after an error. (= error stop)
Stopping The drive is stopping an active movement.
Discrete motion The drive is executing a movement with a target position. Therefore, the
movement has a defined end.
Continuous motion The drive is executing a movement without a target position. The move-
ment has no defined end.
Synchronized motion The drive is coupled to another drive.
Table: Overview of the drive states
Progression of states
Let's assume that the axis is in the Standstill state. As soon as it has successfully performed a homing
procedure, the MC_MoveAbsolute command can be used to start a movement.
After the target position has been reached, the drive returns to its "initial state". If a drive error occurs
during the positioning action, then the axis enters error state (Errorstop). This can be acknowledged
using the MC_Reset function after the drive error has been corrected.
The most important drive states are included in the diagram. They can be used for coordinating posi-
tioning sequences. The MC_ReadStatus function block is used to read the current status from an axis.
A virtual axis does not have a drive controller. Unlike the real axis, the virtual axis does not have
a Disabled status. The NC object "virtual axis" starts in the Standstill state and does not need
the MC_Power function block for activation.
In the image above, 3600 units are divided into five axis revolutions, resulting in 720 units per revolution.
This makes it possible to divide the revolutions according to requirements (keeping the maximum reso-
lution of the encoder in mind). DINT is the data type for the position.
All PLCopen function blocks use the REAL data type for position specifications.
Values for the position period and position factor can be specified for the
PLCopen_ModPos="<Period>,<Factor>" entry in the NC mapping table to adjust the position value:
Axis period
For continuous axis movements, it is frequently necessary to determine a position value periodically. If
a value greater than 0 is being used for the period, then the position value is adjusted according to this
entry. It refers directly to the scaling of the axis in the encoder parameters. All PLCopen function blocks
"work" with this periodic position.
For example, if the value <Period> = 1000, then the position value always increases from 0 to 999 during
a positive movement before being reset to 0 and increasing again to 999.
Periodic position conversion can be disabled by entering <Period>=0 if periodic behavior is not required
but a specific factor still has to be used. In this case, the axis movement range is limited to ±8,388,608
units (±223) because this is the largest number which can be displayed by the REAL data type without
losing accuracy.
Axis factor
PLCopen function blocks use the REAL data type for the axis position. This data type allows us to use
decimal places, which in turn can make simplified scaling pretty interesting.
What exactly is "scaling"?
Scaling can also be referred to as conversion. The following example should help to illustrate this:
A certain application requires positioning to be accurate down to 1 µm. Let's assume that the
way we've configured the encoder parameters allows us to set up a 1 µm distance per posi-
tioning unit.
Now it might be beneficial if we could specify the distance in millimeters for our positioning
task with PLCopen function blocks. And that is precisely what is achieved with this factor. The
So if we set the factor to a value of 1000, we will get our scaling to millimeters. If we now start
a movement for a distance of value 1 with the corresponding PLCopen function block, our axis
will actually travel 1000 axis parameter units.
The carrier is driven by a gear (gear ratio= 5:1) using a servo motor.
Find the suitable encoder settings and advanced position value settings for this task.
Possible solution:
The basic settings for the encoder are made in the Init parameter module. Therefore, for the position
resolution in 0.1° steps, 3600 units are required for one revolution of the rotating carrier. These units are
distributed over 5 motor revolutions.
If a movement of 3600 units is now executed, then the motor performs exactly 5 revolutions and the
carrier is rotated exactly 360°. The gear has now been fully configured.
To now get the desired scaling for the positioning function, the value 10 must be defined for the factor
and the value 3600 for the period (based directly on the encoder setting):
Each function block can be executed as needed (Enable, Execute). Processes can be started at a defined
point in the program using commands.
Status outputs and output parameters provide information about the current state:
• Execution successful?
• If not, which error occurred?
• Status of the process:
° Is the axis moving?
° Has the axis arrived at the target position?
° Was the homing procedure successful?
The function blocks can be activated with Execute in the individual steps of the control structure. Status
parameters such as Error, Done and ErrorID can be used to determine the step where the application
will continue.
This gives the application a clear design and opens it up for future expansion.
Samples using this concept that have already been implemented can be imported in Automation Studio
(see 7 "Using the sample programs").
If an error occurs when calling a function block, it's absolutely necessary to reset the block
before the next time it is used so that the error status remains. This is done by executing the
function block with Enable=0 or Execute=0.
• With PLCopen function block errors, the system first checks to determine if the error was
caused by the drive (ErrorID 29226). It is then possible to acknowledge the errors and exit the
error step.
• After both routines have been executed, the drive status should be checked as well. In certain
cases, the drive can be set to the "Error stop" status. This status will remain in effect until a
status reset (MC_Reset) is carried out (see 5.2 "Overview of the drive states").
The application can then be continued once all errors have been corrected and acknowledged.
This program sequence should in no way be seen as a guideline for implementing error han-
dling. Instead, it should merely serve as a universal approach or basis for implementing this
type of routine. Detailed information can be found in the sample programs (see 7 "Using the
sample programs").
In addition, the sample program for multi-axis operation included with the Automation Studio
installation provides valuable ideas for implementing error handling ("ErrorHandling" program).
The Automation Studio installation includes sample programs for positioning applications that use the
most important functions in the ACP10_MC library. This makes it possible to add a functional application
section to a project that already includes axes.
Basic movement types can thus be handled in the control application without additional programming.
The Automation Studio installation also includes several sample programs that can be used as a basis
for fast and easy drive control in the control application.
The samples are provided in the Ladder Diagram, Structured Text and ANSI C programming languages.
Samples for single axes, axis linking, cam profiles and other applications are available.
Importing samples
The samples that are available can be added to an Automation Studio project in the logical view using
wizards. In the wizards, there is a Samples field with the subgroup Motion samples.
All required components are then added to the Automation Studio project, and the sample program is
stored in a separate package in the logical view.
A precise overview of these samples and their names can be found in the Automation Studio help doc-
umentation.
Sample functionality
Samples are configured according to the recommendations for programming discussed previously (see
6 "Tips for programming".
In a large structure, there is a substructure for commands, axis parameters and status messages that
can be used to operate the machine. The axis reference can be modified in the sample's Init subprogram.
A description of necessary steps and how to design the control structures can be found for each sample
in the Automation Studio help documentation.
3) Modify the axis reference in the Init subprogram for the sample program as needed.
6) Test the commands and check the results of the sample program.
A few function blocks are provided in the ACP10_MC library for managing the parameters on the drive.
These parameters can be used to set up the drive as well as to handle positioning tasks. In general,
these parameters are managed by the NC operating system.
In some applications, however, direct access (read and write) to different parameters is required during
runtime.
By manipulating ParIDs as needed, the drive configuration can be adapted to handle specific
situations.
These functions are only offered for the B&R drive solution, i.e. they can only be implemented
using B&R-specific function blocks. The use of these function blocks (operation, status check,
etc.) still conforms to the PLCopen Motion Control standard, however.
Individual ParIDs can be initialized or read automatically with each TC#1 cycle by setting up
a cyclic transfer:
• MC_BR_InitCyclicWrite
• MC_BR_InitCyclicRead
• MC_BR_CyclicWrite
• MC_BR_CyclicRead
Initializing means making a specific value "operational" for a parameter on the drive. Initializa-
tion does not always take play automatically after a transfer. Some functions only transfer pa-
rameter values to the drive. In these cases, initialization can be carried out at a later point.
An additional function block can be used to establish independent cyclic communication for
a ParID between individual ACOPOS devices:
• MC_BR_InitMasterParIDTransfer
This function block is used for a cam profile automat's additive axes and for Smart Process Technology
functions.
Other function blocks for managing drive parameters support the transfer and initialization of multiple
ParIDs.
Parameter tables
Parameters entered in an ACOPOS parameter table are individually transferred to the drive in each NC
Manager task cycle and immediately initialized using the MC_BR_InitParTableObj function block.
Parameter lists
Parameter configuration and value assignment can be easily adjusted during runtime using a parameter
list.
There is an additional data type for this purpose that contains an element for the parameter ID and an
element for the parameter value. You can use this data type to create an array in the program. Entries
in this list can then be changed from inside the application program during runtime.
All parameters in the parameter list, like ACOPOS parameter tables, are transferred to the drive in each
NC Manager task cycle and immediately initialized using the MC_BR_InitParList function block.
Unlike the initialization variant using predefined ACOPOS parameter tables, parameter arrays
make it possible to change both the parameters contained inside the array as well as their
values while the application is running.
Parameter sequences
A parameter sequence uses the same array as the parameter list.
Unlike ACOPOS parameter tables or parameter lists, however, the parameters in a parameter sequence
are transferred as a data block (not individually) to the drive during the NC Manager idle time task
(MC_BR_DownloadParSequ). Once there, it is not immediately initialized; instead, it is only saved as
a "recipe".
These parameters can then be activated with the "Initialize sequence" command (MC_BR_InitParSequ).
Because each parameter is assigned an index, it is possible to place multiple parameter configurations
together on the drive and initialize them selectively.
Each of these function blocks includes a "DataAddress" input parameter for connecting parameters
grouped together in a parameter list or parameter sequence. An ACP10DATBL_typ structure variable
still must be provided here as an "intermediary".
The diagram shows a simplified version of this relationship. The parameter group is located on the
left as a parameter array. The group is connected to the function block via the variable for transfer
configuration (ACP10DATBL_typ). The parameters can be downloaded once the assignments have been
made correctly ("Execute= 1").
Depending on the application, additional drive information or changes to the closed loop drive control may
be required in the control program. Typically, this is done by cyclically reading and writing parameters.
Possibilities were already illustrated in one of the previous sections (see 8.1 "Initializing and reading
individual parameters").
However, there are not only functional blocks for reading and writing parameter IDs, but also function
blocks that relate directly to functionality.
ParID Description
214 Actual stator current of the quadrature component
381 Temperature sensor: Temperature
277 Motor: Torque
Table: Overview of the drive parameters to be read
ParID Description
343 CTRL torque limiter: Override
Table: Overview of the drive parameters to be read
Because there are a total of four parameters to be written, the data should be transferred in an
array of data type ncPAR_TYP_VOID.
Programming \ Libraries \ Motion libraries \ ACP10_MC \ Function blocks \ Cyclic set values
In a control project, it is often necessary to operate several single axes. Although it is possible to create
a separate program for each drive axis in the logical view, this is not very efficient. For example, soft-
ware changes must be performed multiple times, which makes use and maintenance extremely prone
to errors.
The following section explains some suggested solutions for controlling several single axes using a
single program.
The program is compiled and executed multiple times on the controller. In the application, the axis ref-
erence must be assigned for each instance of the program. Here, it is necessary to determine which of
the tasks that are assigned to the software configuration is being referred to, e.g. in the Init subprogram.
This can be determined using the functions in the "SYS_lib" library. A link is then established between
the program code and the task names.
Declaration VAR
sTaskName : STRING[80];
status : UINT;
AxRef : UDINT;
END_VAR
Program code: (*Determining the particular task names*)
status := ST_name(0, ADR(sTaskName), 0);
The local command variable can then be linked with a higher-level management program that controls
the individual axes using variable assignment. The variable assignment window can be opened in the
physical view using the CPU's shortcut menu.
Opening the variable assignment window using the CPU's shortcut menu
Furthermore, it is also possible for the management program to transparently access and control the
command structure of the single axis program using a pointer.
Specifying a "Define" with the option "-D AXIS1" in the task properties of the software configuration
In the program code, it is now possible to query which "Defines" are specified.
Project management \ The workspace \ General project settings \ Settings for IEC compliance
Programming \ Programs \ Preprocessor for IEC programs
10 SUMMARY
Powerful function blocks are provided for controlling the B&R drive
solution. These are created based on the PLCopen Motion Control
standard and feature a uniform design regarding functional usage.
Once the user is familiar with this standardized operation, it is possi-
ble to begin combining the corresponding function blocks needed for
the process from the pool of functions included in the Motion Control
library (ACP10_MC).
The automatic sequence can be optimally implemented using a step
sequencer. Error handling routines turn the sequence into a com- PLCopen Motion Control logo
plete positioning application.
In addition to the standard, specific function blocks are also provided for controlling drives. They handle
special functions relating to the B&R drive solution. This enables the programmer to access the full range
of functions to solve any positioning task.
TRAINING MODULES