Modicon M241 Logic Controller PTOPWM Library Guide
Modicon M241 Logic Controller PTOPWM Library Guide
EIO0000001450 04/2014
www.schneider-electric.com
The information provided in this documentation contains general descriptions and/or technical
characteristics of the performance of the products contained herein. This documentation is not
intended as a substitute for and is not to be used for determining suitability or reliability of these
products for specific user applications. It is the duty of any such user or integrator to perform the
appropriate and complete risk analysis, evaluation and testing of the products with respect to the
relevant specific application or use thereof. Neither Schneider Electric nor any of its affiliates or
subsidiaries shall be responsible or liable for misuse of the information contained herein. If you
have any suggestions for improvements or amendments or have found errors in this publication,
please notify us.
No part of this document may be reproduced in any form or by any means, electronic or
mechanical, including photocopying, without express written permission of Schneider Electric.
All pertinent state, regional, and local safety regulations must be observed when installing and
using this product. For reasons of safety and to help ensure compliance with documented system
data, only the manufacturer should perform repairs to components.
When devices are used for applications with technical safety requirements, the relevant
instructions must be followed.
Failure to use Schneider Electric software or approved software with our hardware products may
result in injury, harm, or improper operating results.
Failure to observe this information can result in injury or equipment damage.
© 2014 Schneider Electric. All rights reserved.
2 EIO0000001450 04/2014
Table of Contents
Safety Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
About the Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Part I Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Chapter 1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Expert I/O Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Embedded Expert I/O Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Chapter 2 Generalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Dedicated Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
General Information on Function Block Management . . . . . . . . . . . . . 26
Part II Pulse Train Output (PTO). . . . . . . . . . . . . . . . . . . . 27
Chapter 3 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Pulse Train Output (PTO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Chapter 4 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
PTO Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Pulse Output Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Start/Stop Velocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Probe Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Backlash Compensation (Only Available in Quadrature Mode) . . . . . 45
Positioning Limits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.2 Home Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Home Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Position Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Long Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Long Reference & Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Short Reference Reversal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Short Reference No Reversal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Short Reference & Index Outside . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Short Reference & Index Inside. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Home Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
EIO0000001450 04/2014 3
Chapter 5 Data Unit Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
AXIS_REF_PTO Data Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
MC_BUFFER_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
MC_DIRECTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
PTO_HOMING_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
PTO_PARAMETER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
PTO_ERROR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Chapter 6 Motion Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . 79
6.1 Operation Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Motion State Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Buffer Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Timing Diagram Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.2 MC_Power_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
MC_Power_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
6.3 MC_MoveVelocity_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . 99
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
MC_MoveVelocity_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . 101
6.4 MC_MoveRelative_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . 105
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
MC_MoveRelative_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . 107
6.5 MC_MoveAbsolute_PTO Function Block. . . . . . . . . . . . . . . . . . . . . . . 111
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
MC_MoveAbsolute_PTO Function Block. . . . . . . . . . . . . . . . . . . . . . . 113
6.6 MC_Home_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
MC_Home_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
6.7 MC_SetPosition_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . 122
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
MC_SetPosition_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . 124
6.8 MC_Stop_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
MC_Stop_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
6.9 MC_Halt_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
MC_Halt_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
6.10 Adding a Motion Function Block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Adding a Motion Function Block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
4 EIO0000001450 04/2014
Chapter 7 Administrative Function Blocks . . . . . . . . . . . . . . . . . . 137
7.1 Status Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
MC_ReadActualVelocity_PTO Function Block . . . . . . . . . . . . . . . . . . 139
MC_ReadActualPosition_PTO Function Block . . . . . . . . . . . . . . . . . . 141
MC_ReadStatus_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . 142
MC_ReadMotionState_PTO Function Block . . . . . . . . . . . . . . . . . . . . 144
7.2 Parameters Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
MC_ReadParameter_PTO Function Block . . . . . . . . . . . . . . . . . . . . . 147
MC_WriteParameter_PTO Function Block . . . . . . . . . . . . . . . . . . . . . 149
MC_ReadBoolParameter_PTO Function Block . . . . . . . . . . . . . . . . . 151
MC_WriteBoolParameter_PTO Function Block. . . . . . . . . . . . . . . . . . 153
7.3 Probe Function Blocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
MC_TouchProbe_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . 156
MC_AbortTrigger_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . 158
7.4 Error Handling Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
MC_ReadAxisError_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . 160
MC_Reset_PTO Function Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
7.5 Adding an Administrative Function Block . . . . . . . . . . . . . . . . . . . . . . 163
Adding an Administrative Function Block . . . . . . . . . . . . . . . . . . . . . . 163
Part III Pulse Width Modulation (PWM). . . . . . . . . . . . . . . 165
Chapter 8 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
FG/PWM Naming Convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Synchronization and Enable Functions . . . . . . . . . . . . . . . . . . . . . . . . 171
Chapter 9 Configuration and Programming . . . . . . . . . . . . . . . . . 173
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Programming the PWM Function Block. . . . . . . . . . . . . . . . . . . . . . . . 179
Chapter 10 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
FREQGEN_PWM_ERR_TYPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Part IV Frequency Generator (FG) . . . . . . . . . . . . . . . . . . . 183
Chapter 11 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
FG Naming Convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Synchronization and Enable Functions . . . . . . . . . . . . . . . . . . . . . . . . 188
EIO0000001450 04/2014 5
Chapter 12 Configuration and Programming . . . . . . . . . . . . . . . . . 189
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Appendix A Function and Function Block Representation . . . . . . 199
Differences Between a Function and a Function Block . . . . . . . . . . . . 200
How to Use a Function or a Function Block in IL Language . . . . . . . . 201
How to Use a Function or a Function Block in ST Language. . . . . . . . 205
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
6 EIO0000001450 04/2014
Safety Information
Important Information
NOTICE
Read these instructions carefully, and look at the equipment to become familiar with the device
before trying to install, operate, or maintain it. The following special messages may appear
throughout this documentation or on the equipment to warn of potential hazards or to call attention
to information that clarifies or simplifies a procedure.
EIO0000001450 04/2014 7
PLEASE NOTE
Electrical equipment should be installed, operated, serviced, and maintained only by qualified
personnel. No responsibility is assumed by Schneider Electric for any consequences arising out of
the use of this material.
A qualified person is one who has skills and knowledge related to the construction and operation
of electrical equipment and its installation, and has received safety training to recognize and avoid
the hazards involved.
WARNING
UNGUARDED EQUIPMENT
Do not use this software and related automation equipment on equipment which does not have
point-of-operation protection.
Do not reach into machinery during operation.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
This automation equipment and related software is used to control a variety of industrial processes.
The type or model of automation equipment suitable for each application will vary depending on
factors such as the control function required, degree of protection required, production methods,
unusual conditions, government regulations, etc. In some applications, more than one processor
may be required, as when backup redundancy is needed.
Only you, the user, machine builder or system integrator can be aware of all the conditions and
factors present during setup, operation, and maintenance of the machine and, therefore, can
determine the automation equipment and the related safeties and interlocks which can be properly
used. When selecting automation and control equipment and related software for a particular
application, you should refer to the applicable local and national standards and regulations. The
National Safety Council’s Accident Prevention Manual (nationally recognized in the United States
of America) also provides much useful information.
In some applications, such as packaging machinery, additional operator protection such as point-
of-operation guarding must be provided. This is necessary if the operator’s hands and other parts
of the body are free to enter the pinch points or other hazardous areas and serious injury can occur.
Software products alone cannot protect an operator from injury. For this reason the software
cannot be substituted for or take the place of point-of-operation protection.
8 EIO0000001450 04/2014
Ensure that appropriate safeties and mechanical/electrical interlocks related to point-of-operation
protection have been installed and are operational before placing the equipment into service. All
interlocks and safeties related to point-of-operation protection must be coordinated with the related
automation equipment and software programming.
NOTE: Coordination of safeties and mechanical/electrical interlocks for point-of-operation
protection is outside the scope of the Function Block Library, System User Guide, or other
implementation referenced in this documentation.
CAUTION
EQUIPMENT OPERATION HAZARD
Verify that all installation and set up procedures have been completed.
Before operational tests are performed, remove all blocks or other temporary holding means
used for shipment from all component devices.
Remove tools, meters, and debris from equipment.
Failure to follow these instructions can result in injury or equipment damage.
Follow all start-up tests recommended in the equipment documentation. Store all equipment
documentation for future references.
Software testing must be done in both simulated and real environments.
Verify that the completed system is free from all short circuits and temporary grounds that are not
installed according to local regulations (according to the National Electrical Code in the U.S.A, for
instance). If high-potential voltage testing is necessary, follow recommendations in equipment
documentation to prevent accidental equipment damage.
Before energizing equipment:
Remove tools, meters, and debris from equipment.
Close the equipment enclosure door.
Remove all temporary grounds from incoming power lines.
Perform all start-up tests recommended by the manufacturer.
EIO0000001450 04/2014 9
OPERATION AND ADJUSTMENTS
The following precautions are from the NEMA Standards Publication ICS 7.1-1995 (English
version prevails):
Regardless of the care exercised in the design and manufacture of equipment or in the selection
and ratings of components, there are hazards that can be encountered if such equipment is
improperly operated.
It is sometimes possible to misadjust the equipment and thus produce unsatisfactory or unsafe
operation. Always use the manufacturer’s instructions as a guide for functional adjustments.
Personnel who have access to these adjustments should be familiar with the equipment
manufacturer’s instructions and the machinery used with the electrical equipment.
Only those operational adjustments actually required by the operator should be accessible to
the operator. Access to other controls should be restricted to prevent unauthorized changes in
operating characteristics.
10 EIO0000001450 04/2014
About the Book
At a Glance
Document Scope
This documentation acquaints you with the pulse train output (PTO), pulse width modulation
(PWM) and frequency generator (FG) functions offered within the Modicon M241 Logic Controller.
This document describes the data types and functions of the M241 PTOPWM Library.
In order to use this manual, you must:
Have a thorough understanding of the M241, including its design, functionality, and implemen-
tation within control systems.
Be proficient in the use of the following IEC 61131-3 PLC programming languages:
Function Block Diagram (FBD)
Ladder Diagram (LD)
Structured Text (ST)
Instruction List (IL)
Sequential Function Chart (SFC)
NOTE: The term “functional safety” and “safety”, as used in this document, is defined by the
standards EN ISO 13849-1, EN 15011, and EN 14439.
Validity Note
This document has been updated with the release of SoMachine V4.1.
Related Documents
You can download these technical publications and other technical information from our website
at www.schneider-electric.com.
EIO0000001450 04/2014 11
Product Related Information
WARNING
LOSS OF CONTROL
The designer of any control scheme must consider the potential failure modes of control paths
and, for certain critical control functions, provide a means to achieve a safe state during and
after a path failure. Examples of critical control functions are emergency stop and overtravel
stop, power outage and restart.
Separate or redundant control paths must be provided for critical control functions.
System control paths may include communication links. Consideration must be given to the
implications of unanticipated transmission delays or failures of the link.
Observe all accident prevention regulations and local safety guidelines.1
Each implementation of this equipment must be individually and thoroughly tested for proper
operation before being placed into service.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
1For additional information, refer to NEMA ICS 1.1 (latest edition), "Safety Guidelines for the
Application, Installation, and Maintenance of Solid State Control" and to NEMA ICS 7.1 (latest
edition), "Safety Standards for Construction and Guide for Selection, Installation and Operation of
Adjustable-Speed Drive Systems" or their equivalent governing your particular location.
WARNING
UNINTENDED EQUIPMENT OPERATION
Only use software approved by Schneider Electric for use with this equipment.
Update your application program every time you change the physical hardware configuration.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
12 EIO0000001450 04/2014
Modicon M241 Logic Controller
Introduction
EIO0000001450 04/2014
Part I
Introduction
Introduction
Overview
This part provides an overview description, available modes, functionality and performances of the
different functions.
EIO0000001450 04/2014 13
Introduction
14 EIO0000001450 04/2014
Modicon M241 Logic Controller
Overview
EIO0000001450 04/2014
Chapter 1
Overview
Overview
Overview
This chapter provides an overview description, functionality, and performances of the Frequency
Generator (FG), Pulse Train Output (PTO), and Pulse Width Modulation (PWM)
functions.
The functions provide simple, yet powerful solutions for your application. In particular, they are
extremely useful for controlling movement. However, the use and application of the information
contained herein require expertise in the design and programming of automated control systems.
Only you, the user, machine builder or integrator, can be aware of all the conditions and factors
present during installation and setup, operation, and maintenance of the machine or related
processes, and can therefore determine the automation and associated equipment and the related
safeties and interlocks which can be effectively and properly used. When selecting automation and
control equipment, and any other related equipment or software, for a particular application, you
must also consider any applicable local, regional or national standards and/or regulations.
WARNING
REGULATORY INCOMPATIBILITY
Ensure that all equipment applied and systems designed comply with all applicable local,
regional, and national regulations and standards.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
The functions provided by the M241 PTOPWM library were conceived and designed assuming that
you incorporate the necessary safety hardware into your application architecture, such as, but not
limited to, appropriate limit switches and emergency stop hardware and controlling circuitry. It is
implicitly assumed that functional safety measures are present in your machine design to prevent
undesirable machine behavior such as over-travel or other forms of uncontrolled movement.
Further, it is assumed that you have performed a functional safety analysis and risk assessment
appropriate to your machine or process.
EIO0000001450 04/2014 15
Overview
WARNING
UNINTENDED EQUIPMENT OPERATION
Ensure that a risk assessment is conducted and respected according to EN/ISO 12100 during
the design of your machine.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
16 EIO0000001450 04/2014
Overview
Introduction
The M241 logic controller provides:
Functions Description
Counters HSC Simple The HSC functions can execute fast counts of pulses from
HSC Main Single Phase sensors, switches, and so on, that are connected to the fast
inputs.
HSC Main Dual Phase For more information about the HSC functions, refer to the High
Frequency Meter Speed Counter types (see Modicon M241 Logic Controller, High
Speed Counting, HSC Library Guide).
Period Meter
Pulse PTO (see page 27) The PTO function generates a pulse train output to control a
Generators linear single-axis stepper or servo drive in open loop mode.
PWM (see page 165) The PWM function generates a square wave signal on dedicated
output channels with a variable duty cycle.
Frequency Generator The frequency generator function generates a square wave
(see page 183) signal on dedicated output channels with a fixed duty cycle
(50%).
NOTE:
When an input is used as Run/Stop, it cannot be used by an expert function.
When an output is used as Alarm, it cannot be used by an expert function.
For more details, refer to Embedded Functions Configuration (see Modicon M241 Logic Controller,
Programming Guide).
EIO0000001450 04/2014 17
Overview
Step Description
1 Double-click the Counters or Pulse_Generators node in the Devices Tree.
Result: The Counters or Pulse_Generators function window appears:
When inputs are used in expert functions (Latch, HSC,…), integrator filter is replaced by anti-
bounce filter. Filter value is configured in expert configuration screen.
18 EIO0000001450 04/2014
Overview
EIO0000001450 04/2014 19
Overview
20 EIO0000001450 04/2014
Overview
EIO0000001450 04/2014 21
Overview
I/O Summary
The IO Summary window displays the I/Os used by the expert functions.
To display the IO Summary window:
Step Action
1 In the Devices tree tab, right-click the MyController node and choose IO Summary.
22 EIO0000001450 04/2014
Modicon M241 Logic Controller
Generalities
EIO0000001450 04/2014
Chapter 2
Generalities
Generalities
Overview
This chapter provides general information of the Frequency Generator (FG), Pulse Train Output
(PTO), and Pulse Width Modulation (PWM) functions.
The functions provide simple, yet powerful solutions for your application. In particular, they are
extremely useful for controlling movement. However, the use and application of the information
contained herein require expertise in the design and programming of automated control systems.
Only you, the user, machine builder or integrator, can be aware of all the conditions and factors
present during installation and setup, operation, and maintenance of the machine or related
processes, and can therefore determine the automation and associated equipment and the related
safeties and interlocks which can be effectively and properly used. When selecting automation and
control equipment, and any other related equipment or software, for a particular application, you
must also consider any applicable local, regional or national standards and/or regulations.
WARNING
REGULATORY INCOMPATIBILITY
Ensure that all equipment applied and systems designed comply with all applicable local,
regional, and national regulations and standards.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
The functions provided by the M241 PTOPWM library were conceived and designed assuming that
you incorporate the necessary safety hardware into your application architecture, such as, but not
limited to, appropriate limit switches and emergency stop hardware and controlling circuitry. It is
implicitly assumed that functional safety measures are present in your machine design to prevent
undesirable machine behavior such as over-travel or other forms of uncontrolled movement.
Further, it is assumed that you have performed a functional safety analysis and risk assessment
appropriate to your machine or process.
WARNING
UNINTENDED EQUIPMENT OPERATION
Ensure that a risk assessment is conducted and respected according to EN/ISO 12100 during
the design of your machine.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
EIO0000001450 04/2014 23
Generalities
24 EIO0000001450 04/2014
Generalities
Dedicated Features
Bounce Filter
This table shows the maximum counter frequencies determined by the filtering values used to
reduce the bounce effect on the input:
Dedicated Outputs
Outputs used by the Frequency Generator, Pulse Train Output, Pulse Width Modulation, and High
Speed Counters can only be accessed through the function block. They can not be read or written
directly within the application.
WARNING
UNINTENDED EQUIPMENT OPERATION
Do not use the same instance of a function block in more than 1 task.
Do not modify function block references (••_REF_IN) while the function block is active
(executing).
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
EIO0000001450 04/2014 25
Generalities
When an instance of a function block receives a new Execute before it is finished (as a series of
commands on the same instance), the function block does not return any feedback, like Done, for
the previous action.
Error Handling
All blocks have 2 outputs that can report a detected error during the execution of the function block:
Error= The rising edge of this bit informs that a detected error occurred.
ErrID= The detected error number
When an Error occurs, the other output signals, such as Done are reset.
26 EIO0000001450 04/2014
Modicon M241 Logic Controller
PTO
EIO0000001450 04/2014
Part II
Pulse Train Output (PTO)
Overview
This part describes the Pulse Train Output function.
EIO0000001450 04/2014 27
PTO
28 EIO0000001450 04/2014
Modicon M241 Logic Controller
PTO - Overview
EIO0000001450 04/2014
Chapter 3
Overview
Overview
Introduction
The PTO function provides 2 pulse train output channels for a specified number of pulses and a
specified velocity (frequency). The PTO function is used to control the positioning or speed of 2
independent linear single-axis stepper or servo drives in open loop mode (for example with Lexium
23D).
The PTO function does not have any position feedback information from the process, and the
position loop is integrated in the drive.
The PTO, PWM (pulse width modulation), and FG (frequency generation) functions use the same
dedicated outputs. Only one of these 3 functions can be used on the same channel. Using different
functions on channel 0 and channel 1 is allowed.
A PTO channel can use up to:
6 physical inputs, if optional interface signals for homing (ref/index), event (probe), limits (limP,
limN), or drive interface (driveReady), are used,
3 physical outputs, if optional drive interface signal is used (driveEnable).
Automatic origin offset and backlash compensation are also managed to improve positioning
accuracy. Diagnostics are available for status monitoring, allowing a comprehensive and quick
troubleshooting.
Supported Functions
The 2 PTO channels support the following functions:
3 output modes, including quadrature,
single axis moves (velocity and position),
relative and absolute positioning,
automatic trapezoidal acceleration and deceleration,
homing (7 modes, with offset compensation),
on-the-fly acceleration, deceleration, velocity, and position modification,
switch from speed to position mode,
move queuing (buffer of 1 move),
position capture and move trigger on event (using probe input),
backlash compensation (in quadrature mode),
limits (hardware and software),
diagnostics.
EIO0000001450 04/2014 29
PTO - Overview
NOTE: The motion function blocks act on the motion state diagram (see page 81), to modify the
motion of the axis. The administrative function blocks do not influence the motion state diagram.
NOTE:
Each function block can be called by any application task.
MC_Power_PTO function block is mandatory before a move command can be issued.
30 EIO0000001450 04/2014
PTO - Overview
WARNING
UNINTENTED EQUIPMENT OPERATION
Do not use the same function block instance in different program tasks.
Do not change the function block reference (AXIS_REF_PTO) while the function block is
active (executing).
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
PTO Performances
The PTO function has the following performances:
Characteristic Value
Number of channels 2
Number of axis 1 per channel
Position range -2,147,483,648...2,147,483,647 (32 bits)
Minimum velocity 1 Hz
Maximum velocity 100 kHz (for a 40/60 duty cycle and 200 mA)
Minimum step 1 Hz
Acceleration / deceleration min 1 Hz/ms
Acceleration / deceleration max 100,000 Hz/ms
Start move IEC 300 µs + 1 pulse output time
Start move on probe event
Change move parameter
Accuracy on velocity 0.5 %
Accuracy in position Depend on the delay to take into account the command
EIO0000001450 04/2014 31
PTO - Overview
32 EIO0000001450 04/2014
Modicon M241 Logic Controller
Configuration
EIO0000001450 04/2014
Chapter 4
Configuration
Configuration
Overview
This chapter describes how to configure a PTO channel and the associated parameters.
EIO0000001450 04/2014 33
Configuration
Section 4.1
Configuration
Configuration
Overview
This section describes how to configure a PTO channel and the associated parameters.
34 EIO0000001450 04/2014
Configuration
PTO Configuration
Hardware Configuration
There are up to 6 physical inputs for a PTO channel:
3 are associated to the PTO function by configuring and taken into account immediately on
event:
REF input,
INDEX input,
PROBE input.
3 are used through MC_Power_PTO function block; they have no fixed allocation on the terminal
block (they are freely allocated, that is, not configured in the configuration screen), and are
sampled at the scan time of the task:
Drive ready input,
Limit positive input,
Limit negative input.
NOTE: The positive and negative limit inputs are required to help prevent certains types of
movements from experiencing uncontrolled over-travel.
NOTE: These inputs are managed as any other regular input, but are used by the PTO controller
when used by MC_Power_PTO function block.
When the PTO channel is disabled, or when the Drive ready input is not used for the PTO channel,
these inputs can be used as any other regular input.
There are up to 3 physical outputs for a PTO channel:
2 are mandatory to manage pulse and direction; they have a fixed allocation on the terminal
block, and must be enabled by configuration:
A / CW / Pulse,
B / CCW / Direction.
The other output, DriveEnable, is used through MC_Power_PTO function block; it has no fixed
allocation on the terminal block (it is freely allocated), and is sampled at the scan time of the
task.
NOTE: This output is managed as any other regular output, but is controlled by the PTO controller
when used by MC_Power_PTO function block.
When the PTO channel is disabled, these outputs can be used as any other regular output.
EIO0000001450 04/2014 35
Configuration
36 EIO0000001450 04/2014
Configuration
The table describes each parameter available when the channel is configured in PTO mode:
EIO0000001450 04/2014 37
Configuration
38 EIO0000001450 04/2014
Configuration
Overview
There are 3 possible output modes:
A ClockWise / B CounterClockwise
A Pulse / B direction
Quadrature
EIO0000001450 04/2014 39
Configuration
Quadrature Mode
This mode generates 2 signals in quadrature phase on the PTO outputs (the phase sign depends
on motor direction).
40 EIO0000001450 04/2014
Configuration
Start/Stop Velocity
Overview
The start/stop velocity is the maximum frequency at which a stepper motor can start/stop, with a
load applied, without loss of steps.
Start Velocity
Start Velocity parameter is used when starting a motion from velocity 0.
Start Velocity must be in the range 0...MaxVelocityAppl (see page 76).
Value 0 means that the Start Velocity parameter is not used. In this case, the motion will start at
a velocity = acceleration rate x 1 ms.
Stop Velocity
Stop Velocity is only used when moving from a higher velocity than Stop Velocity, down to
velocity 0.
Stop Velocity must be in the range 0...MaxVelocityAppl (see page 76).
Value 0 means that the Stop Velocity parameter is not used. In this case, the motion will stop at
a velocity = deceleration rate x 1 ms.
Automatic Ramp
The ramping-up from Start Velocity to target velocity (conversely ramping-down from target
velocity to Stop Velocity) is automatically managed by the PTO function, according to acceleration
(conversely deceleration) parameter. In Hz/ms units, the parameter directly represents the rate of
velocity change. In ms units, the parameter represents the time to go from 0 to Maximum velocity.
EIO0000001450 04/2014 41
Configuration
Probe Event
Description
The PROBE input is enabled by configuration, and activated using the MC_TouchProbe_PTO
function block.
The PROBE input is used as an event, to:
capture the current position (setpoint position),
start a move independently of the task.
The input event can be enabled by an enable window (WindowOnly), defined by position limits. In
this case, only the window defined by FirstPosition and LastPosition is used to accept
trigger events (MC_TouchProbe_PTO (see page 156)).
Both functions can be active at the same time, that is, the same event captures the current position
and start a motion function block (see page 79).
NOTE: Only the first event after the rising edge at the MC_TouchProbe_PTO function block Busy
pin is valid. Once the Done output pin is set, subsequent events are ignored. The function block
needs to be reactivated to respond to other events.
Position Capture
The position catured is available in MC_TouchProbe_PTO.RecordedPosition.
Motion Trigger
The BufferMode input of a motion function block must be set to seTrigger.
This example illustrates a change target velocity with enable windows:
42 EIO0000001450 04/2014
Configuration
This example illustrates a move of pre-programmed distance, with simple profile and no enable
window:
This example illustrates a move of pre-programmed distance, with complex profile and enable
window:
EIO0000001450 04/2014 43
Configuration
44 EIO0000001450 04/2014
Configuration
Description
The Backlash Compensation parameter is defined as the amount of motion needed to
compensate the mechanical clearance in gears, when movement is reversed:
NOTE: The function does not take into account any external sources of movement, such as inertia
movement or other forms of induced movement.
Backlash compensation is set in number of pulses (0...255, default value is 0). When set, at each
direction reversal, the specified number of pulses is first output at start velocity, and then the
programmed movement is executed. The backlash compensation pulses are not added to the
position counter.
EIO0000001450 04/2014 45
Configuration
NOTE:
Before the initial movement is started, the function cannot determine the amount of backlash to
compensate for. Therefore, the backlash compensation is only active after a homing is
successfully performed. If the homing is performed without movement, it is assumed that the
initial movement applies no compensation, and the compensation is applied at the first direction
reversal.
Once started, the compensation pulses are output until completion, even if an aborting
command is received in the meantime. In this case, the aborting command is buffered and will
start as soon as compensation pulses are output. No additional buffered command is accepted
in this case.
If the axis is stopped by an error detected before all the compensation pulses are output, the
backlash compensation is reset. A new homing procedure is needed to reinitialize the backlash
compensation.
Backlash timeout of 80 s: The system does not accept to configure a movement of more than
80 s. So if a backlash is configured, it may for example not be more than 80 pulses to 1 Hz. The
error detected in case of this timeout is "Invalid acceleration" (code 1000).
46 EIO0000001450 04/2014
Configuration
Positioning Limits
Introduction
Positive and negative limits can be set to control the movement boundaries in both directions. Both
hardware and software limits are managed by the controller.
Hardware and software limit switches are used to manage boundaries in the controller application
only. They are not intended to replace any functional safety limit switches wired to the drive. The
controller application limit switches must necessarily be activated before the functional safety limit
switches wired to the drive. In any case, the type of functional safety architecture, which is beyond
the scope of the present document, that you deploy depends on your safety analysis, including,
but not limited to:
risk assessment according to EN/ISO 12100
FMEA according to EN 60812
WARNING
REGULATORY INCOMPATIBILITY
Ensure that all equipment applied and systems designed comply with all applicable local,
regional, and national regulations and standards.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
EIO0000001450 04/2014 47
Configuration
The axis is back to Standstill state after a successful execution of MC_Reset_PTO. As long as the
axis is outside the limits, any move is forbidden in the current direction (function block terminates
with ErrorId=InvalidDirectionValue) while it is still possible to move in the opposite
direction. If no further status update is given, it indicates that the current position is outside the
limits.
NOTE: Once either the software negative or positive limits are crossed, an error is detected and a
Fast stop deceleration is performed. In this case, it is not possible to initiate another move in the
same direction.
Software Limits
Software limits can be set to control the movement boundaries in both directions.
Limit values are enabled and set in the configuration screen, such that:
Positive limit > Negative limit
Values in the range -2,147,483,648 to 2,147,483,647
48 EIO0000001450 04/2014
Configuration
Hardware Limits
Hardware limits are required for the homing procedure, and for helping to prevent damage to the
machine. The appropriate inputs must be used on the MC_Power_PTO.LimP and
MC_Power_PTO.LimN input bits. The hardware limit devices must be of a normally closed type
such that the input to the function block is FALSE when the respective limit is reached.
WARNING
UNINTENTED EQUIPMENT OPERATION
Ensure that controller hardware limit switches are integrated in the design and logic of your
application.
Mount the controller hardware limit switches in a position that allows for an adequate braking
distance.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
NOTE: Adequate braking distance is dependent on the maximum velocity, maximum load (mass)
of the equipment being moved, and the value of the Fast stop deceleration parameter.
EIO0000001450 04/2014 49
Configuration
Section 4.2
Home Modes
Home Modes
Overview
This section describes the PTO home modes.
50 EIO0000001450 04/2014
Configuration
Home Modes
Description
A homing is a movement to a defined position. This position is defined as the reference point (or
origin), being the point of reference for absolute movements.
A homing movement can be made using different methods. The M241 PTO channels provide 7
standard homing movement types:
position setting (see page 54),
long reference (see page 55),
long reference and index (see page 57),
short reference reversal (see page 59),
short reference no reversal (see page 61),
short reference and index outside (see page 63),
short reference and index inside (see page 66).
A homing movement must be terminated without interruption for the new reference point to be
valid. If the reference movement is interrupted, it needs to be started again.
Refer to MC_Home_PTO (see page 117) and PTO_HOMING_MODE (see page 75).
EIO0000001450 04/2014 51
Configuration
Home Position
When the homing is done with an external switch, the homing position is defined on the switch
edge. Then the motion is decelerated until stop.
The actual position of the axis at the end of the motion sequence may therefore differ from the
position parameter set on the function block:
To simplify the representation of a stop in the homing mode diagrams, the following presentation
is made to represent the actual position of the axis:
52 EIO0000001450 04/2014
Configuration
Limits
Hardware limits are necessary for the correct functioning of the MC_Home_PTO function block
(Positioning Limits (see page 47) and MC_Power_PTO (see page 93)). Depending on the
movement type you request with the homing mode, the hardware limits help assure that the end
of travel is respected by the function block.
When a homing action is initiated in a direction away from the reference switch, the hardware limits
serve to either:
indicate a reversal of direction is required (to move the axis toward the reference switch) or,
indicate that an error has been detected as the reference switch was not found before reaching
the end of travel.
For homing movement types that allow for reversal of direction, when the movement reaches the
hardware limit the axis stops using the configured deceleration, and resumes motion in a reversed
direction.
In homing movement types that do not allow for the reversal of direction, when the movement
reaches the hardware limit, the homing procedure is aborted with a detected error, and the axis
stops with the Fast stop deceleration.
WARNING
UNINTENTED EQUIPMENT OPERATION
Ensure that controller hardware limit switches are integrated in the design and logic of your
application.
Mount the controller hardware limit switches in a position that allows for an adequate braking
distance.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
NOTE: Adequate braking distance is dependent on the maximum velocity, maximum load (mass)
of the equipment being moved, and the value of the Fast stop deceleration parameter.
EIO0000001450 04/2014 53
Configuration
Position Setting
Description
In the case of position setting, the current position is set to the specified position value. No move
is performed.
54 EIO0000001450 04/2014
Configuration
Long Reference
EIO0000001450 04/2014 55
Configuration
56 EIO0000001450 04/2014
Configuration
EIO0000001450 04/2014 57
Configuration
58 EIO0000001450 04/2014
Configuration
EIO0000001450 04/2014 59
Configuration
60 EIO0000001450 04/2014
Configuration
EIO0000001450 04/2014 61
Configuration
62 EIO0000001450 04/2014
Configuration
EIO0000001450 04/2014 63
Configuration
64 EIO0000001450 04/2014
Configuration
EIO0000001450 04/2014 65
Configuration
66 EIO0000001450 04/2014
Configuration
EIO0000001450 04/2014 67
Configuration
68 EIO0000001450 04/2014
Configuration
Home Offset
Description
If the origin cannot be defined by switches with enough accuracy, it is possible to make the axis
move to a specific position away from the origin switch. Home offset allows making a difference
between mechanical origin and electrical origin.
Home offset is set in number of pulses (-2,147,483,648...2,147,483,647, default value 0). When
set by configuration, the MC_Home_PTO (see page 117) command is executed first, and then the
specified number of pulses is output at the home low velocity in the specified direction. The
parameter is only effective during a reference movement without index pulse.
NOTE: The wait time between MC_Home_PTO command stop on origin switch and start of offset
movement is fixed, set to 500 ms. The MC_Home_PTO command busy flag is only released after
origin offset has been completed.
EIO0000001450 04/2014 69
Configuration
70 EIO0000001450 04/2014
Modicon M241 Logic Controller
Data Unit Types
EIO0000001450 04/2014
Chapter 5
Data Unit Types
Overview
This chapter describes the data unit types of the M241 PTO Library.
EIO0000001450 04/2014 71
Data Unit Types
72 EIO0000001450 04/2014
Data Unit Types
MC_BUFFER_MODE
EIO0000001450 04/2014 73
Data Unit Types
MC_DIRECTION
74 EIO0000001450 04/2014
Data Unit Types
PTO_HOMING_MODE
EIO0000001450 04/2014 75
Data Unit Types
PTO_PARAMETER
76 EIO0000001450 04/2014
Data Unit Types
PTO_ERROR
EIO0000001450 04/2014 77
Data Unit Types
An Axis Control Error switches the axis in ErrorStop state (MC_Reset_PTO is mandatory to get
out of ErrorStop state). The resulting axis status is reflected by MC_ReadStatus_PTO and
MC_ReadAxisError_PTO.
A Motion State Error or a Range Error does not affect the axis state, nor any move currently
executing, nor the move queue. In this case, the detected error is only local to the applicable
function block: the Error output is set, and the ErrorId pin is set to the appropriate
PTO_ERROR value.
78 EIO0000001450 04/2014
Modicon M241 Logic Controller
Motion Function Blocks
EIO0000001450 04/2014
Chapter 6
Motion Function Blocks
Overview
This chapter describes the motion function blocks.
A motion function block acts on the diagram of axis state, to modify the motion of the axis. These
function blocks can return a status to the application before the move is complete. The application
program uses these status bits to determine the move status (Done, Busy, Active,
CommandAborted, and detected Error). For axis status, you can use the MC_ReadStatus_PTO
function block.
EIO0000001450 04/2014 79
Motion Function Blocks
Section 6.1
Operation Modes
Operation Modes
Overview
This section describes the operation modes.
80 EIO0000001450 04/2014
Motion Function Blocks
State Diagram
The axis is always in one of the defined states in this diagram:
State Description
Disabled Initial state of the axis, no motion command is allowed. The axis is not homed.
Standstill Power is on, there is no detected error, and there are no motion commands active on
the axis. Motion command is allowed.
ErrorStop Highest priority, applicable when an error is detected on the axis or in the controller.
Any ongoing move is aborted by a deceleration to stop, according to Fast Stop
Deceleration configuration parameter. Error pin is set on applicable function blocks,
and ErrorId pin is set according to the detected error type. As long as an error is
pending, the state remains ErrorStop. No further motion command is accepted until
a reset has been done using MC_Reset_PTO.
Homing Applicable when MC_Home_PTO has control on the axis.
EIO0000001450 04/2014 81
Motion Function Blocks
State Description
Discrete Applicable when MC_MoveRelative_PTO, MC_MoveAbsolute_PTO, or
MC_Halt_PTO has control on the axis.
Continuous Applicable when MC_MoveVelocity_PTO has control on the axis.
Stopping Applicable when MC_Stop_PTO has control on the axis.
NOTE: Function blocks which are not listed in the state diagram do not affect the state of the state
diagram, that is, whenever they are called the state does not change.
The entire motion command including acceleration and deceleration ramps cannot exceed
4,294,967,295 pulses. At the maximum frequency of 100 kHz, it would limit the duration of
acceleration/deceleration ramps to 80 seconds.
Command Next
Home MoveVelocity MoveRelative MoveAbsolute Halt Stop
Current Standstill Allowed Allowed (1)
Allowed (1)
Allowed (1) Allowed Allowed
82 EIO0000001450 04/2014
Motion Function Blocks
Buffer Mode
Description
Some of the motion function blocks have an input called BufferMode. With this input, the function
block can either start immediately, start on probe event, or be buffered.
The available options are defined in the enumeration of type MC_BUFFER_MODE (see page 73):
An aborting motion (mcAborting) starts immediately, aborting any ongoing move, and clearing
the motion queue.
A buffered motion (mcBuffered, mcBlendingPrevious, seBufferedDelay) is queued,
that is, appended to any moves currently executing or waiting to execute, and will start when the
previous motion is done.
An event motion (seTrigger) is a buffered motion, starting on probe event (see page 42).
EIO0000001450 04/2014 83
Motion Function Blocks
mcBlendingPrevious: when the position and velocity targets of current function block are
reached.
seTrigger: when a valid event is detected on the probe input.
The motion queue is cleared (all buffered motions are deleted):
When an aborting move is triggered (mcAborting): CommandAborted pin is set on buffered
function blocks.
When a MC_Stop_PTO function is executed: Error pin is set on cleared buffered function
blocks, with ErrorId=StoppingActive (see page 77).
When a transition to ErrorStop state is detected: Error pin is set on buffered function blocks,
with ErrorId=ErrorStopActive (see page 77).
NOTE:
Only a valid motion can be queued. If the function block execution terminates with the Error
output set, the move is not queued, any move currently executing is not affected, and the queue
is not cleared.
When the queue is already full, the Error output is set on the applicable function block, and
ErrorId output returns a detected error MotionQueueFull (see page 77).
84 EIO0000001450 04/2014
Motion Function Blocks
EIO0000001450 04/2014 85
Motion Function Blocks
1 Execute rising edge: command parameters are latched, movement is started with target velocity 1000.
2 Target velocity 1000 is reached.
3 Velocity parameter changed to 2000: not applied (no rising edge on Execute input, and
ContinuousUpdate was latched with value 0 at start of the movement).
4 Execute falling edge: status bits are cleared.
5 Execute rising edge: command parameters are latched, movement is started with target velocity 2000
and ContinuousUpdate active.
6 Velocity parameter changed to 500: applied ContinuousUpdate is true). Note: previous target
velocity 2000 is not reached.
7 Target velocity 500 is reached.
8 Velocity parameter changed to 2000: applied ContinuousUpdate is true).
9 Execute falling edge: status bits are cleared.
10 Target velocity 2000 is reached, InVelocity is set for 1 cycle (Execute pin is reset).
11 Velocity parameter changed to 3000: not applied (movement is still active, but no longer busy).
86 EIO0000001450 04/2014
Motion Function Blocks
EIO0000001450 04/2014 87
Motion Function Blocks
1 FB1 Execute rising edge: command parameters are latched, movement is started with target velocity
2000 and distance 1000.
2 Movement ends: distance traveled is 1000.
3 FB1 Execute rising edge: command parameters are latched, movement is started with target velocity
2000 and distance 2000.
4 FB2 Execute rising edge: command parameters are latched, movement is started with target velocity
1000 and distance 500. Note: FB1 is aborted.
5 Movement ends.
88 EIO0000001450 04/2014
Motion Function Blocks
EIO0000001450 04/2014 89
Motion Function Blocks
1 FB1 Execute rising edge: command parameters are latched, movement is started with target velocity
2000 and distance 1800.
2 FB2 Execute rising edge: command parameters are latched, FB1 is aborted, and movement continues
with target velocity 1000 and targetposition 3400. Automatic direction management: direction
reversal is needed to reach target position, move to stop at deceleration of FB2.
3 Velocity 0, direction reversal, movement resumes with target velocity 1000 and target position 3400.
4 Movement ends: target position 3400 reached.
90 EIO0000001450 04/2014
Motion Function Blocks
EIO0000001450 04/2014 91
Motion Function Blocks
92 EIO0000001450 04/2014
Motion Function Blocks
Section 6.2
MC_Power_PTO Function Block
Overview
This section describes the MC_Power_PTO function block.
EIO0000001450 04/2014 93
Motion Function Blocks
Description
Overview
The MC_Power_PTO function block allows enabling power to the axis, switching the axis state from
Disabled to Standstill. No motion function block is allowed on the axis until the
MC_Power_PTO.Status bit is TRUE.
Disabling power (MC_Power_PTO.Enable = FALSE) switches the axis:
from Standstill, back to Disabled state.
from any ongoing move, to ErrorStop, and then Disabled when the detected error is reset.
94 EIO0000001450 04/2014
Motion Function Blocks
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
EIO0000001450 04/2014 95
Motion Function Blocks
Input Variables
This table describes the input variables:
DriveReady(1) BOOL FALSE Drive ready information from the drive. Must be TRUE when
the drive is ready to start executing motion.
If the drive signal is connected to the controller, use the
appropriate %Ix input. If the drive does not provide this
signal, you can select the value TRUE for this input.
(1)
: DriveReady, LimP, and LimN are scanned at the task cycle time.
96 EIO0000001450 04/2014
Motion Function Blocks
Output Variables
This table describes the output variables:
EIO0000001450 04/2014 97
Motion Function Blocks
98 EIO0000001450 04/2014
Motion Function Blocks
Section 6.3
MC_MoveVelocity_PTO Function Block
Overview
This section describes the MC_MoveVelocity_PTO function block.
EIO0000001450 04/2014 99
Motion Function Blocks
Description
Overview
This function causes the specified axis to move at the specified speed, and transfers the axis to
the state Continuous. This continuous movement is maintained until a software limit is reached,
an aborting move is triggered, or a transition to ErrorStop state is detected.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
NOTE:
To stop the motion, the function block has to be interrupted by another function bloc issuing a
new command.
If a motion is ongoing, and the direction is reversed, first the motion is halted with the
deceleration of the MC_MoveVelocity_PTO function block, and then the motion resumes
backward.
The acceleration/decceleration duration of the segment block must not exceed 80 s.
The diagram illustrates a complex profile from Continuous state with change of direction:
Section 6.4
MC_MoveRelative_PTO Function Block
Overview
This section describes the MC_MoveRelative_PTO function block.
Description
Overview
This function causes the specified axis to move of an incremental distance, and transfers the axis
to the state Discrete. The target position is referenced from the current position at execution time,
incremented by a distance.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
NOTE:
The function block completes with velocity zero if no further blocks are pending.
If the distance is too short for the target velocity to be reached, the movement profile is
triangular, rather than trapezoidal.
If a motion is ongoing, and the commanded distance is exceeded due to the current motion
parameters, the direction reversal is automatically managed: the motion is first halted with the
deceleration of the MC_MoveRelative_PTO function block, and then the motion resumes
backward.
The acceleration/decceleration duration of the segment block must not exceed 80 s.
The diagram illustrates a complex profile from Continuous state with change of direction:
The diagram illustrates a complex profile from Discrete state with change of direction:
Section 6.5
MC_MoveAbsolute_PTO Function Block
Overview
This section describes the MC_MoveAbsolute_PTO function block.
Description
Overview
This function causes the specified axis to move towards a given position at the specified speed,
and transfers the axis to the state Discrete. The function block terminates with Error set to 1, if
the axis is not homed (that is, no reference absolute position is defined). In this case, ErrorId is
set to InvalidAbsolute.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
NOTE:
The function block completes with velocity zero if no further blocks are pending.
The motion direction is automatically set, according to the current and target positions.
If the distance is too short for the target velocity to be reached, the movement profile is
triangular, rather than trapezoidal.
If the position cannot be reached with the current direction, the direction reversal is
automatically managed. If a motion is ongoing, it is first halted with the deceleration of the
MC_MoveAbsolute_PTO function block, and then the motion resumes backward.
The acceleration/decceleration duration of the segment block must not exceed 80 s.
The diagram illustrates a complex profile from Discrete state with change of direction:
Section 6.6
MC_Home_PTO Function Block
Overview
This section describes the MC_Home_PTO function block.
Description
Overview
This function block commands the axis to perform the sequence defining the reference absolute
position, and transfers the axis to the state Homing. The details of this sequence depend on
homing configuration parameter settings.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
NOTE: The acceleration/decceleration duration of the segment block must not exceed 80 s.
Section 6.7
MC_SetPosition_PTO Function Block
Overview
This section describes the MC_SetPosition_PTO function block.
Description
Overview
This function block shifts the actual position of the axis without any movement caused. This
function block cannot be used during motion (that is, only allowed when the axis is in Standstill
state).
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Section 6.8
MC_Stop_PTO Function Block
Overview
This section describes the MC_Stop_PTO function block.
Description
Overview
This function block commands a controlled motion stop and transfers the axis to the state
Stopping. It aborts any ongoing move execution. While the axis is in state Stopping, no other
function block can perform any motion on the same axis. This function block is primarily intended
for exception situations, or fast stop functionality (for example, machine detected error managed
by the user).
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
NOTE:
Calling this function block in state Standstill changes the state to Stopping, and back to
Standstill when Execute is FALSE.
The state Stopping is kept as long as the input Execute is true.
TheDone output is set when the stop ramp is finished.
If Deceleration = 0, the fast stop deceleration is used.
The function block completes with velocity zero.
The decceleration duration of the segment block must not exceed 80 s.
Section 6.9
MC_Halt_PTO Function Block
Overview
This section describes the MC_Halt_PTO function block.
Description
Overview
This function block commands a controlled motion stop until the velocity is zero, and transfers the
axis to the state Discrete. With the Done output set, the state is transferred to Standstill.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Section 6.10
Adding a Motion Function Block
Procedure
Follow these steps to add and create the instance of a motion function block:
Step Action
1 Add a POU (see SoMachine, Programming Guide) in the Applications tree.
2 Select the Libraries tab in the Software Catalog and click Libraries.
Select Controller →M241 →M241 PTOPWM →PTO →Motion →MC_xxxxxx_PTO in the list,
drag-and-drop the item onto the POU window.
3 Create the function block instance by clicking:
4 Associate the input/output variables (see page 79) of the function block.
Chapter 7
Administrative Function Blocks
Overview
This chapter describes the administrative function blocks.
Administrative function blocks do not influence the state diagram (see page 81).
Section 7.1
Status Function Blocks
Overview
This section describes the status function blocks.
Function Description
This function block returns the value of the actual velocity of the axis.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Function Description
This function block returns the value of the actual position of the axis.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Function Description
This function block returns the state diagram (see page 81) status of the axis.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Function Description
This function block returns the actual motion status of the axis.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Section 7.2
Parameters Function Blocks
Overview
This section describes the parameters function blocks.
Function Description
This function block is used to get parameters from the PTO.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Function Description
This function block is used to write parameters to the PTO.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Function Description
This function block is used to get BOOL parameters from the PTO.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Function Description
This function block is used to write BOOL parameters to the PTO.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Section 7.3
Probe Function Blocks
Overview
This section describes the probe function blocks.
Function Description
This function block is used to activate a trigger event on the probe input. This trigger event allows
to record the axis position, and/or to start a buffered move.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Function Description
This function block is used to abort function blocks which are connected to trigger events (for
example, MC_TouchProbe_PTO).
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Section 7.4
Error Handling Function Blocks
Overview
This section describes the error handling function blocks.
Function Description
This function block returns a detected axis control error. If no axis control error is pending, the
function block returns AxisErrorId = 0 (detected errors referring to the function block are not
considered here).
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Function Description
This function block resets all axis-related detected errors, if possible, allowing a transition from the
state ErrorStop to Standstill. It does not affect the output of the function blocks instances.
Graphical Representation
IL and ST Representation
To see the general representation in IL or ST language, refer to the chapter Function and Function
Block Representation (see page 199).
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Section 7.5
Adding an Administrative Function Block
Procedure
Follow these steps to add and create the instance of an administrative function block:
Step Action
1 Add a POU (see SoMachine, Programming Guide) in the Applications tree.
2 Select the Libraries tab in the Software Catalog and click Libraries.
Select Controller →M241 →M241 PTOPWM →PTO →Administrative →MC_xxxxxx_PTO in
the list, drag-and-drop the item onto the POU window.
3 Create the function block instance by clicking:
4 Associate the input/output variables (see page 137) of the function block.
Part III
Pulse Width Modulation (PWM)
Overview
This part describes the Pulse Width Modulation function.
Chapter 8
Introduction
Introduction
Overview
This chapter provides a description of the PWM functions.
Description
Overview
The pulse width modulation function generates a programmable pulse wave signal on a dedicated
output with adjustable duty cycle and frequency.
Signal Form
The signal form depends on the following input parameters:
Frequency configurable from 0.1 Hz to 20 kHz with a 0.1 Hz step
Duty Cycle of the output signal from 0% to 100%
Duty Cycle=Tp/T
Tp pulse width
T pulse period (1/Frequency)
Modifying the duty cycle in the program modulates the width of the signal. Below is an illustration
of an output signal with varying duty cycles.
When duty cycle is below 4% or above 96%, depending on the frequency, the deviation is above
1% as illustrated in the graphic below:
Definition
Frequency Generator and Pulse Width Modulation uses 1 fast physical output and up to 2 physical
inputs.
In this document, use the following naming convention:
Name Description
SYNC Synchronization function (see page 171).
EN Enable function (see page 171).
IN_SYNC Physical input dedicated to the SYNC function.
IN_EN Physical input dedicated to the EN function.
OUT_PWM Physical output dedicated to the FG or PWM.
Introduction
This section presents the functions used by the FG/PWM:
Synchronization function
Enable function
NOTE: (function) stands either for Enable (for Enable function) or Sync (for Synchronization
function).
If the physical input is required, enable it in the configuration screen (see page 174).
Synchronization Function
The Synchronization function is used to interrupt the current FG/PWM cycle and then restart a
new cycle.
Enable Function
The Enable function is used to activate the FG/PWM:
Chapter 9
Configuration and Programming
Overview
This chapter provides configuration and programming guidelines for using PWM functions.
Configuration
Overview
2 pulse width modulation functions can be configured on the controller.
Step Action
1 Double-click the Pulse Generators node of your controller in the Devices Tree.
2 Double-click the Pulse generation function value and select PWM.
Result: The PWM configuration parameters appear.
Parameters
The figure provides an example of a PWM configuration window:
Function Blocks
Overview
The Pulse Width Modulation function block commands a pulse width modulated signal output
at the specified frequency and duty cycle.
Graphical Representation
This illustration is a Pulse Width Modulation function block:
IL and ST Representation
To see the general representation in IL or ST language, refer to the Differences Between a
Function and a Function Block (see page 200) chapter.
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
NOTE: When the required frequency cannot be reached for any reason, the InFrequency output
is not set to TRUE, but Error stays to FALSE.
Procedure
Follow these steps to program a PWM function block:
Step Action
1 Select the Libraries tab in the Software Catalog and click Libraries.
Select Controller →M241 →M241 PTOPWM →PWM →PWM_M241 in the list, drag-and-drop the
item onto the POU window.
2
Select the function block instance by clicking .
The Input Assistant dialog is displayed. Select the global variable which references to the added
PWM (see page 174) during the configuration and confirm.
NOTE: If the function block instance is not visible, verify if the PWM is configured.
3 The inputs/outputs are detailed in the function block (see page 177).
Chapter 10
Data Types
Data Types
FREQGEN_PWM_ERR_TYPE
Part IV
Frequency Generator (FG)
Overview
This part describes the Frequency Generator function.
Chapter 11
Introduction
Introduction
Overview
This chapter provides a description of the FG functions.
Description
Overview
The frequency generator function generates a square wave signal on dedicated output channels
with a fixed duty cycle (50%).
Frequency is configurable from 0.1 Hz to 100 kHz with a 0.1 Hz step.
FG Naming Convention
Description
FG/PWM Naming Convention (see page 170)
Description
Synchronization and Enable Functions (see page 171)
Chapter 12
Configuration and Programming
Overview
This chapter provides configuration and programming guidelines for using FG functions.
Configuration
Overview
2 frequency generator functions can be configured on the controller.
Step Action
1 Double-click the Pulse Generators node of your controller in the Devices Tree.
2 Double-click the Pulse generation function value and select FreqGen.
Result: The frequency generator configuration parameters are displayed.
Parameters
The figure provides an example of a frequency generator configuration window:
Function Blocks
Overview
The Frequency Generator function block commands a square wave signal output at the
specified frequency.
IL and ST Representation
To see the general representation in IL or ST language, refer to the Differences Between a
Function and a Function Block (see page 200) chapter.
Input Variables
This table describes the input variables:
Output Variables
This table describes the output variables:
Programming
Procedure
Follow these steps to program a Frequency Generator function block:
Step Action
1 Select the Libraries tab in the Software Catalog and click Libraries.
Select Controller →M241 →M241 PTOPWM →Frequency Generator →
FrequencyGenerator_M241 in the list; drag-and-drop the item onto the POU window.
2
Select the function block instance by clicking .
The Input Assistant screen appears. Select the global variable which references to the added
FreqGen (see page 190) during the configuration and confirm.
NOTE: If the function block instance is not visible, verify if the frequency generator is configured.
3 The inputs/outputs are detailed in the function block (see page 193).
EIO0000001450 04/2014
Appendices
Appendix A
Function and Function Block Representation
Overview
Each function can be represented in the following languages:
IL: Instruction List
ST: Structured Text
LD: Ladder Diagram
FBD: Function Block Diagram
CFC: Continuous Function Chart
This chapter provides functions and function blocks representation examples and explains how to
use them for IL and ST languages.
Function
A function:
is a POU (Program Organization Unit) that returns one immediate result.
is directly called with its name (not through an instance).
has no persistent state from one call to the other.
can be used as an operand in other expressions.
Function Block
A function block:
is a POU (Program Organization Unit) that returns one or more outputs.
needs to be called by an instance (function block copy with dedicated name and variables).
each instance has a persistent state (outputs and internal variables) from one call to the other
from a function block or a program.
Examples: timers, counters
In the example, Timer_ON is an instance of the function block TON:
General Information
This part explains how to implement a function and a function block in IL language.
Functions IsFirstMastCycle and SetRTCDrift and Function Block TON are used as
examples to show implementations.
Step Action
1 Open or create a new POU in Instruction List language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding
and Calling POUs (see SoMachine, Programming Guide).
2 Create the variables that the function requires.
3 If the function has 1 or more inputs, start loading the first input using LD instruction.
4 Insert a new line below and:
type the name of the function in the operator column (left field), or
use the Input Assistant to select the function (select Insert Box in the context menu).
5 If the function has more than 1 input and when Input Assistant is used, the necessary number of lines
is automatically created with ??? in the fields on the right. Replace the ??? with the appropriate
value or variable that corresponds to the order of inputs.
6 Insert a new line to store the result of the function into the appropriate variable: type ST instruction
in the operator column (left field) and the variable name in the field on the right.
To illustrate the procedure, consider the Functions IsFirstMastCycle (without input parameter)
and SetRTCDrift (with input parameters) graphically presented below:
IL example of a function
with input parameters:
SetRTCDrift
Step Action
1 Open or create a new POU in Instruction List language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding and
Calling POUs (see SoMachine, Programming Guide).
2 Create the variables that the function block requires, including the instance name.
3 Function Blocks are called using a CAL instruction:
Use the Input Assistant to select the FB (right-click and select Insert Box in the context menu).
Automatically, the CAL instruction and the necessary I/O are created.
4 In the CAL right-side field, replace ??? with the instance name.
5 Replace other ??? with an appropriate variable or immediate value.
To illustrate the procedure, consider this example with the TON Function Block graphically
presented below:
In IL language, the function block name is used directly in the operator column:
General Information
This part explains how to implement a Function and a Function Block in ST language.
Function SetRTCDrift and Function Block TON are used as examples to show implementations.
Step Action
1 Open or create a new POU in Structured Text language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding
and Calling POUs (see SoMachine, Programming Guide).
2 Create the variables that the function requires.
3 Use the general syntax in the POU ST Editor for the ST language of a function. The general
syntax is:
FunctionResult:= FunctionName(VarInput1, VarInput2,.. VarInputx);
To illustrate the procedure, consider the function SetRTCDrift graphically presented below:
Step Action
1 Open or create a new POU in Structured Text language.
NOTE: The procedure to create a POU is not detailed here. For more information on
adding, declaring and calling POUs, refer to the related documentation
(see SoMachine, Programming Guide).
2 Create the input and output variables and the instance required for the function block:
Input variables are the input parameters required by the function block
Output variables receive the value returned by the function block
3 Use the general syntax in the POU ST Editor for the ST language of a Function
Block. The general syntax is:
FunctionBlock_InstanceName(Input1:=VarInput1,
Input2:=VarInput2,... Ouput1=>VarOutput1,
Ouput2=>VarOutput2,...);
To illustrate the procedure, consider this example with the TON function block graphically
presented below:
Glossary
A
application
A program including configuration data, symbols, and documentation.
B
byte
A type that is encoded in an 8-bit format, ranging from 16#00 to 16#FF in hexadecimal
representation.
C
CFC
(continuous function chart) A graphical programming language (an extension of the IEC 61131-3
standard) based on the function block diagram language that works like a flowchart. However, no
networks are used and free positioning of graphic elements is possible, which allows feedback
loops. For each block, the inputs are on the left and the outputs on the right. You can link the block
outputs to the inputs of other blocks to create complex expressions.
F
FB
(function block) A convenient programming mechanism that consolidates a group of programming
instructions to perform a specific and normalized action, such as speed control, interval control, or
counting. A function block may comprise configuration data, a set of internal or external operating
parameters and usually 1 or more data inputs and outputs.
function
A programming unit that has 1 input and returns 1 immediate result. However, unlike FBs, it is
directly called with its name (as opposed to through an instance), has no persistent state from one
call to the next and can be used as an operand in other programming expressions.
Examples: boolean (AND) operators, calculations, conversions (BYTE_TO_INT)
function block diagram
One of the 5 languages for logic or control supported by the standard IEC 61131-3 for control
systems. Function block diagram is a graphically oriented programming language. It works with a
list of networks where each network contains a graphical structure of boxes and connection lines
representing either a logical or arithmetic expression, the call of a function block, a jump, or a return
instruction.
I
IEC 61131-3
Part 3 of a 3-part IEC standard for industrial automation equipment. IEC 61131-3 is concerned with
controller programming languages and defines 2 graphical and 2 textual programming language
standards. The graphical programming languages are ladder diagram and function block diagram.
The textual programming languages include structured text and instruction list.
IL
(instruction list) A program written in the language that is composed of a series of text-based
instructions executed sequentially by the controller. Each instruction includes a line number, an
instruction code, and an operand (refer to IEC 61131-3).
INT
(integer) A whole number encoded in 16 bits.
L
LD
(ladder diagram) A graphical representation of the instructions of a controller program with symbols
for contacts, coils, and blocks in a series of rungs executed sequentially by a controller (refer to
IEC 61131-3).
P
POU
(program organization unit) A variable declaration in source code and a corresponding instruction
set. POUs facilitate the modular re-use of software programs, functions, and function blocks. Once
declared, POUs are available to one another.
S
ST
(structured text) A language that includes complex statements and nested instructions (such as
iteration loops, conditional executions, or functions). ST is compliant with IEC 61131-3.
V
variable
A memory unit that is addressed and modified by a program.
Index
A in IL language, 201
how to use a function or a function block
AXIS_REF_PTO, 72
in ST language, 205
synchronization, 171
D
data unit types M
AXIS_REF_PTO, 72
management of status variables
FREQGEN_PWM_ERR_TYPE, 181
Busy, 26
MC_BUFFER_MODE, 73
CommandAborted, 26
MC_DIRECTION, 74
Done, 26
PTO_ERROR, 77
ErrID, 26
PTO_HOMING_MODE, 75
Error, 26
PTO_PARAMETER, 76
Execute, 26
dedicated features, 25
MC_BUFFER_MODE, 73
MC_DIRECTION, 74
E
error handling P
ErrID, 26
Programming
Error, 26
PWM, 179
PTO
F configuration, 35
Functionalities, 29
FREQGEN_PWM_ERR_TYPE, 181 PTO_ERROR, 77
frequency generator PTO_HOMING_MODE, 75
configuration, 190 PTO_PARAMETER, 76
description, 186 pulse width modulation
function blocks, 193 configuration, 174
programming, 195 description, 168
function blocks function blocks, 177
frequency generator, 193 PWM
pulse width modulation, 177 Programming, 179
Functionalities
PTO, 29
functions
differences between a function and a
function block, 200
enable, 171
how to use a function or a function block