Motion Programming Using MotionPRO Developer User Manual F900H A11229 PRO UM Rev1 (optred)
User Manual: F900H
Open the PDF directly: View PDF
.
Page Count: 720
| Download | |
| Open PDF In Browser | View PDF |
Motion Programming using MotionPRO Developer ElectroCraft Document Number A11229 Rev 1 © ElectroCraft 2013 User Manual ELECTROCRAFT Motion Programming using MotionPRO User Manual ElectroCraft Document No. A11229 ElectroCraft 4480 Varsity Drive Suite G Ann Arbor, MI 48108 Tel.: (734) 662-7771 www.electrocraft.com Read This First Whilst ElectroCraft believes that the information and guidance given in this manual is correct, all parties must rely upon their own skill and judgment when making use of it. ElectroCraft does not assume any liability to anyone for any loss or damage caused by any error or omission in the work, whether such error or omission is the result of negligence or any other cause. Any and all such liability is disclaimed. All rights reserved. No part or parts of this document may be reproduced or transmitted in any form or by any means, electrical or mechanical including photocopying, recording or by any information-retrieval system without permission in writing from ElectroCraft. The information in this document is subject to change without notice. About This Manual This book is a technical reference manual for the MotionPRO Developer software. In order to operate any ElectroCraft drive, you need to pass through 3 steps: Step 1 Hardware installation Step 2 Drive setup using ElectroCraft PROconfig or MotionPRO Developer software for drive commissioning Step 3 Motion Programming using one of the options: A CANOpen or EtherCAT master The drive built-in motion controller executing a ElectroCraft Motion Program Language (MPL) program developed using ElectroCraft MotionPRO Developer software A MPL_LIB motion library for PCs (Windows or Linux) A MPL_LIB motion library for PLCs A distributed control approach which combines the above options, like for example a host calling motion functions programmed on the drives in MPL This manual covers Steps 2 and 3 in detail. For detailed information regarding the first step, refer to the specific documentation of each drive. Notational Conventions This document uses the following conventions: MPL – ElectroCraft Motion Program Language Faxx – Firmware versions with A = 0, 1, 2, 3, 4 or 9; Examples: F005K, F120B,F900H FBxx – Firmware versions with B = 5, 6, 7, 8; Examples: F500B, F600C, F800I Programmable drive – a drive with an embedded motion controller capable to execute high-level motion language programs Programmable motor – a motor with an embedded programmable drive SI units – International standard units (meter for length, seconds for time, etc.) IU units – Internal units of the drive © ElectroCraft 2013 I MPD User Manual Related Documentation Help of the PROconfig software – describes how to use PROconfig to quickly setup any ElectroCraft drive for your application using only 2 dialogues. The output of PROconfig is a set of setup data that can be downloaded into the drive EEPROM or saved on a PC file. At power-on, the drive is initialized with the setup data read from its EEPROM. With PROconfig it is also possible to retrieve the complete setup information from a drive previously programmed. PROconfig includes a firmware programmer with allows you to update your drive firmware to the latest revision. PROconfig is part of the ElectroCraft Motion PRO Suite. Motion PRO Suite is available as part of a PRO Series Drive Evaluation Kit. Please contact ElectroCraft or your local ElectroCraft sales representative for more information on obtaining MotionPRO Suite or an evaluation kit. CANopen Programming (Document No. A11226) – explains how to program the ElectroCraft programmable drives using CANopen protocol. Describes the associated DS-301 communication profile and CiA-402 device profile. CANopen over EtherCAT Programming (Document No. A11227) – explains how to program the ElectroCraft Programmable drives with EtherCAT interface using CANopen over EtherCAT protocol. Presents the CiA-402 associated drive profile and object dictionary. Help of the MotionPRO Developer software – describes how to use MotionPRO Developer to create motion programs using ElectroCraft Motion Program Language (MPL). MotionPRO Developer platform includes PROconfig for the drive/motor setup, and a Motion Editor for the motion Programming. The Motion Editor provides a simple way of creating motion programs and automatically generates all the MPL instructions. With MotionPRO Developer you can fully benefit from a key advantage of ElectroCraft drives – their capability to execute complex motions without requiring an external motion controller, thanks to their built-in motion controller. PRO Series and LIB v2.0 (Document Number A11230) – explains how to program in C, C++,C#, Visual Basic or Delphi Pascal a motion application for the ElectroCraft Programmable drives using ElectroCraft motion control library for PCs. The MPL_lib includes ready-to-run examples that can be executed on Windows or Linux (x86 and x64). PRO Series and LabVIEW v2.0 (Document No. A11231) – explains how to program in LabVIEW a motion application for the ElectroCraft Programmable drives using MPL_LIB_Labview v2.0 motion control library for PCs. The MPL_Lib_LabVIEW includes over 40 ready-to-run examples. PRO Series and LIB_S7 (Document No. A11232 ) – explains how to program, in a PLC Siemens series S7-300 or S7-400, a motion application for the ElectroCraft Programmable drives using MPL_LIB_S7 motion control library. The MPL_LIB_S7 library is IEC61131-3 compatible. PRO Series and CJ1 (Document No. A11233) – explains how to program, in a PLC Omron series CJ1, a motion application for the ElectroCraft Programmable drives using MPL_LIB_CJ1 motion control library. The MPL_LIB_CJ1 library is IEC61131-3 compatible. PRO Series and X20 (Document No. A11234) – explains how to program, in a PLC B&R series X20, a motion application for the ElectroCraft Programmable drives using MPL_LIB_X20 motion control library. The MPL_LIB_X20 library is IEC61131-3 compatible. ElectroCAN (Document No. A11235) – presents ElectroCAN protocol – an extension of the CANopen communication profile used for MPL commands © ElectroCraft 2013 II MPD User Manual If you Need Assistance … If you want to … Contact ElectroCraft at … Visit ElectroCraft online World Wide Web: http://www.electrocraft.com/ Receive general information or assistance (see Note) World Wide Web: http://www.electrocraft.com/ Ask questions about product operation or report suspected problems (see Note) Email: drivesupport@electrocraft.com Fax: (41) 32 732 55 04 Email: : drivesupport@electrocraft.com Make suggestions about, or report errors in documentation. Mail: ElectroCraft 4480 Varsity Drive Suite G Ann Arbor, MI 48108 Tel.: (734) 662-7771 © ElectroCraft 2013 III MPD User Manual This page is empty © ElectroCraft 2013 IV MPD User Manual Contents Read This First ..................................................................................................... I 1. Overview ..................................................................................................... 1 1.1. 2. Project Management .................................................................................. 9 2.1. Project File Concept ......................................................................................... 9 2.2. Memory Setting .............................................................................................. 12 2.3. Application - Setup ......................................................................................... 14 2.4. Application - Motion ........................................................................................ 16 2.4.1. 2.4.2. 2.4.3. 2.4.4. 2.4.5. 2.4.6. 2.4.7. 2.4.8. 3. Homing Modes ........................................................................................................ 19 Homing Modes Edit ................................................................................................. 21 Functions ................................................................................................................. 22 Functions Edit.......................................................................................................... 23 Interrupts ................................................................................................................. 24 Interrupts Edit .......................................................................................................... 25 CAM Tables ............................................................................................................. 26 CAM Tables Edit ..................................................................................................... 28 MotionPRO Developer Workspace ......................................................... 30 3.1. 3.1.1. 3.1.2. 3.1.3. 3.1.4. 3.1.5. 3.1.6. 3.1.7. 3.1.8. 3.1.9. 3.2. 4. Getting Started with MotionPRO Developer ..................................................... 1 Menu Bar ........................................................................................................ 31 Project Menu ........................................................................................................... 31 Application Menu ..................................................................................................... 32 Application | Setup Menu ........................................................................................ 33 Application | Motion Menu ....................................................................................... 34 Communication Menu ............................................................................................. 35 View Menu............................................................................................................... 36 Logger ..................................................................................................................... 36 Control Panel........................................................................................................... 38 Help ......................................................................................................................... 39 Toolbar ........................................................................................................... 40 Evaluation Tools....................................................................................... 42 4.1. Data Logger.................................................................................................... 42 © ElectroCraft 2013 V MPD User Manual 4.1.1. 4.1.2. 4.1.3. 4.1.4. 4.1.5. 4.1.6. 4.2. Data Logger............................................................................................................. 42 Data Logger - Start .................................................................................................. 43 Data Logger - Plot Options ...................................................................................... 44 Data Logger - Plot Setup ......................................................................................... 46 Data Logger - Variables .......................................................................................... 48 Data Logger - Other Options ................................................................................... 50 Control Panel.................................................................................................. 52 4.2.1. 4.2.2. 4.2.3. 4.2.4. 4.2.5. 4.2.6. 4.2.7. 4.2.8. 4.2.9. 4.2.10. 4.2.11. 4.2.12. 4.2.13. 5. Control Panel........................................................................................................... 52 Control Panel - Show Value .................................................................................... 58 Control Panel - Scope ............................................................................................. 60 Control Panel - Double Scope ................................................................................. 62 Control Panel - Y(X) Scope Object .......................................................................... 64 Control Panel - Gauge............................................................................................. 66 Control Panel - Slider .............................................................................................. 68 Control Panel - Input ............................................................................................... 70 Control Panel - Bit Value ......................................................................................... 71 Control Panel - User Defined MPL Sequence Object .......................................... 72 Control Panel - Label ........................................................................................... 73 Control Panel - Output ......................................................................................... 74 Control Panel Properties ...................................................................................... 75 4.3. Command Interpreter ..................................................................................... 75 4.4. Binary Code Viewer ........................................................................................ 78 4.5. Memory View.................................................................................................. 80 Communication ........................................................................................ 81 5.1. 5.1.1. 5.1.2. 5.1.3. 5.1.4. 5.1.5. 5.1.6. 5.1.7. 5.1.8. 5.2. 5.2.1. 5.2.2. 5.2.3. Communication Setup .................................................................................... 81 RS-232 Communication Setup ................................................................................ 83 RS-232 Communication Troubleshoots .................................................................. 85 CAN-bus Communication Setup ............................................................................. 86 CAN-bus Communication Troubleshoots ................................................................ 89 User implemented serial driver example ................................................................. 90 User Implemented Serial Driver Setup .................................................................... 94 User Implemented Serial Driver Troubleshoots ...................................................... 97 Advanced Communication Setup ............................................................................ 98 Communication Protocols............................................................................. 101 Message Structure. Axis ID and Group ID ............................................................ 103 Serial communication. RS-232 and RS-485 protocols .......................................... 106 CAN-bus communication. ElectroCAN protocol .................................................... 115 © ElectroCraft 2013 VI MPD User Manual 5.2.4. 6. CAN-bus communication. MPLCAN protocol ........................................................ 128 Application Programming ..................................................................... 134 6.1. Motion Programming – drives with built-in Motion Controller........................ 134 6.1.1. 6.1.2. 6.1.3. 6.1.4. 6.1.5. 6.1.6. 6.1.7. 6.1.8. 6.1.9. 6.1.10. 6.1.11. 6.1.12. 6.1.13. 6.1.14. 6.1.15. 6.1.16. 6.1.17. 6.1.18. 6.1.19. 6.1.20. 6.1.21. 6.1.22. 6.1.23. 6.1.24. 6.1.25. 6.2. 6.2.1. 6.2.2. 6.2.3. 6.2.4. 6.2.5. 6.2.6. 6.2.7. Motion Programming Toolbars .............................................................................. 138 Motion Trapezoidal Profile..................................................................................... 143 Motion S-Curve Profile .......................................................................................... 146 Motion PT .............................................................................................................. 148 Motion PVT............................................................................................................ 151 Motion External ..................................................................................................... 154 Motion Electronic Gearing ..................................................................................... 157 Motion Electronic Camming .................................................................................. 161 Motor Commands .................................................................................................. 166 Motion Position Triggers .................................................................................... 169 Motion Homing ................................................................................................... 170 Motion Contouring .............................................................................................. 172 Motion Test ........................................................................................................ 176 Events Dialogue ................................................................................................. 178 Jumps and Function Calls .................................................................................. 192 I/O General I/O (Firmware FAxx) ....................................................................... 194 I/O General I/O (Firmware FBxx) ....................................................................... 197 Assignment & Data Transfer - Setup 16-bit variable .......................................... 199 Assignment & Data Transfer - Setup 32-bit variable .......................................... 200 Assignment & Data Transfer - Arithmetic Operations ........................................ 203 Assignment & Data Transfer - Data Transfer Between Axes ............................. 205 Send data to host ............................................................................................... 208 Assignment & Data Transfer - Miscellaneous .................................................... 210 MPL Interrupt Settings ....................................................................................... 213 Free text ............................................................................................................. 218 ElectroCraft Motion Language ...................................................................... 219 Basic Concepts ..................................................................................................... 219 MPL Description .................................................................................................... 239 Electronic Gearing - MPL Programming Details .................................................... 274 MPL Instruction set................................................................................................ 365 Instructions descriptions ........................................................................................ 382 MPL Registers ....................................................................................................... 654 Bit 9 SPDLP. Speed loop status............................................................................ 667 6.3. Internal Units and Scaling Factors ................................................................ 687 6.4. PRO EEPROM Programmer ........................................................................ 687 © ElectroCraft 2013 VII MPD User Manual 6.4.1. 6.4.2. PRO EEPROM Programmer ................................................................................. 687 PRO EEPROM Programmer File Format .............................................................. 691 Appendix A : MPL Instructions List ............................................................... 693 7. Appendix B : MPL Data List................................................................... 701 © ElectroCraft 2013 VIII MPD User Manual 1. Overview 1.1. Getting Started with MotionPRO Developer MotionPRO Developer is an integrated development environment for the setup and motion programming of ElectroCraft Programmable drives and motors. The output of MotionPRO Developer is a set of setup data and a motion program, which can be downloaded to the drive/motor EEPROM or saved on your PC for later use. MotionPRO Developer includes a set of evaluation tools like the Data Logger, the Control Panel and the Command Interpreter which help you to quickly develop, test, measure and analyze your motion application. MotionPRO Developer works with projects. A project contains one or several Applications. Each application describes a motion system for one axis. It has 2 components: the Setup data and the Motion program and an associated axis number: an integer value between 1 and 255. An application may be used either to describe: 1. One axis in a multiple-axis system 2. An alternate configuration (set of parameters) for the same axis. In the first case, each application has a different axis number corresponding to the axis ID of the drives/motors from the network. All data exchanges are done with the drive/motor having the same address as the selected application. In the second case, all the applications have the same axis number. The setup component contains all the information needed to configure and parameterize a ElectroCraft drive/motor. This information is preserved in the drive/motor EEPROM in the setup table. The setup table is copied at power-on into the RAM memory of the drive/motor and is used during runtime. The motion component contains the motion sequences to do. These are described via a MPL (ElectroCraft Motion Program Language) program, which is executed by the drives/motors built-in motion controller. © ElectroCraft 2013 1 MPD User Manual Step 1 Crreate a new project p MotionPR RO Developerr starts with an a empty window from wh here you can create a new w project or open a previously y created one e. When you u start a new project, MotiionPRO Deve eloper autom atically create es a first app plication. Additional applications can be added later. You can duplica ate an applica ation or insert one defined in another pro oject. w button to open o the “New w Project” dia alogue. Set th he axis numb ber for Press New your first application equal e with you ur drive/moto or axis ID. Th he initial value e proposed iss 255 which is the xis ID of the drives/motors d s. Press New w button and select your d drive/motor tyype. Depending on default ax the product chosen, the selection may m continue with the moto or technologyy (for example e: brushless m motor, m 3 phas se stepper), the t control mode m (for exa ample open-lo oop or closed d-loop) and tyype of brushed motor, feedback device (for ex xample: incre emental encod der, SSI enco oder) © ElectroC Craft 2013 2 MPD U User Manual Validate your y selection n with a mou use click. MottionPRO Devveloper openss the Project window whe ere on the left side you can see the stru ucture of a project. p At be eginning both h the new p project and itss first he application n has 2 compo onents: S Settup and M Mo otion (program m). application are named “Untitled”. Th © ElectroC Craft 2013 3 MPD U User Manual Step 2 Establish communication If you have a drive/motor connected with your PC, now its time to check the communication. Use menu command Communication | Setup to check/change your PC communication settings. Press the Help button of the dialogue opened. Here you can find detailed information about how to setup your drive/motor and the connections. Power on the drive/motor, then close the Communication | Setup dialogue with OK. If the communication is established, MotionPRO Developer displays in the status bar (the bottom line) the text “Online” plus the axis ID of your drive/motor and its firmware version. Otherwise the text displayed is “Offline” and a communication error message tells you the error type. In this case, return to the Communication | Setup dialogue, press the Help button and check troubleshoots. Remark: When first started, MotionPRO Developer tries to communicate with your drive/motor via RS232 and COM1 (default communication settings). If your drive/motor is powered and connected to your PC port COM1 via an RS-232 cable, the communication can be automatically established. Step 3 Setup drive/motor In the project window left side, select “S Setup”, to access the setup data for your application. Press View/Modify button . This opens 2 setup dialogues: for Motor Setup and for Drive setup through which you can configure and parameterize a ElectroCraft drive/motor. In the © ElectroCraft 2013 4 MPD User Manual Motor setup dialogue you can introduce the data of your motor and the associated sensors. Data introduction is accompanied by a series of tests having as goal to check the connections to the drive and/or to determine or validate a part of the motor and sensors parameters. In the Drive setup dialogue you can configure and parameterize the drive for your application. In each dialogue you will find a Guideline Assistant, which will guide you through the whole process of introducing and/or checking your data. to download your setup data in the Press the Download to Drive/Motor button drive/motor EEPROM memory in the setup table. From now on, at each power-on, the setup data is copied into the drive/motor RAM memory which is used during runtime. It is also possible to save the setup data on your PC and use it in other applications. Note that you can upload the complete setup data from a drive/motor. To summarize, you can define or change the setup data of an application in the following ways: • create a new setup data by going through the motor and drive dialogues • use setup data previously saved in the PC • upload setup data from a drive/motor EEPROM memory Step 4 Program motion In the project window left side, select “M Motion”, for motion programming. © ElectroCraft 2013 5 MPD User Manual One of the key advantages of the ElectroCraft drives/motors is their capability to execute complex motions without requiring an external motion controller. This is possible because ElectroCraft drives/motors include both a state of art digital drive and a powerful motion controller. Programming motion on a ElectroCraft drive/motor means to create and download a MPL (ElectroCraft Motion Program Language) program into the drive/motor memory. The MPL allows you to: • Set various motion modes (profiles, PVT, PT, electronic gearing or camming, etc.) • Change the motion modes and/or the motion parameters • Execute homing sequences • Control the program flow through: o Conditional jumps and calls of MPL functions o MPL interrupts generated on pre-defined or programmable conditions (protections triggered, transitions on limit switch or capture inputs, etc.) o Waits for programmed events to occur • Handle digital I/O and analogue input signals • Execute arithmetic and logic operations • Perform data transfers between axes • Control motion of an axis from another one via motion commands sent between axes • Send commands to a group of axes (multicast). This includes the possibility to start simultaneously motion sequences on all the axes from the group • Synchronize all the axes from a network © ElectroCraft 2013 6 MPD User Manual With MPL, you can really distribute the intelligence between the master and the drives/motors in complex multi-axis applications. Thus, instead of trying to command each step of an axis movement, you can program the drives/motors using MPL to execute complex tasks and inform the master when these are done. Thus for each axis the master task may be reduced at: calling MPL functions (with possibility to abort their execution if needed) and waiting for a message, which confirms the execution. If needed, the drives/motors may also be programmed to send periodically information messages to the master so it can monitor a task progress. In order to help you create a MPL program, MotionPRO Developer includes a Motion Editor. This offers you the possibility to program all the motion sequences using high level graphical dialogues which automatically generate the corresponding MPL instructions. With Motion Editor you can develop motion programs using almost all the MPL instructions without needing to learn them. The Motion Editor is automatically activated when you select “M Motion” in the project window left side. When activated, Motion Editor adds a set of toolbar buttons in the project window just below the title. Each button opens a programming dialogue. When a programming dialogue is closed, the associated MPL instructions are automatically generated. Note that, the MPL instructions generated are not a simple text included in a file, but a motion object. Therefore with Motion Editor you define your motion program as a collection of motion objects. The major advantage of encapsulating programming instructions in motion objects is that you can very easily manipulate them. For example, you can: • Save and reuse a complete motion program or parts of it in other applications • Add, delete, move, copy, insert, enable or disable one or more motion objects • Group several motion objects and work with bigger objects that perform more complex functions As a starting point, push for example the leftmost Motion Editor button – Trapezoidal profiles, and set a position or speed profile. Then press the Run button. At this point the following operations are done automatically: • A MPL program is created by inserting your motion objects into a predefined template • The MPL program is compiled and downloaded to the drive/motor • The MPL program execution is started For learning how to send commands from your host/master, check the Application | Binary Code Viewer. This tool helps you to quickly find how to send MPL commands using one of the communication channels and protocols supported by the drives/motors. Using this tool, you can get the exact contents of the messages to send as well as of those expected to be received as answers. Step 5 Evaluate motion application performances MotionPRO Developer includes a set of evaluation tools like the Data Logger, the Control Panel and the Command Interpreter which help you to quickly measure and analyze your motion application. Step 6 Create an EEPROM image file for programming in production Once you have validated your application, you can create with the menu command Application | Create PRO EEPROM Programmer File a software file (with extension .sw) which contains all the data to write in the EEPROM of your drive/motor. This includes both the setup data and the motion program. The .sw file can be programmed into a drive/motor, using the PRO EEPROM Programmer tool, which comes with MotionPRO Developer but may also be installed separately. The PRO EEPROM Programmer was specifically designed for repetitive fast and easy setup and programming of ElectroCraft drives/motors in production. © ElectroCraft 2013 7 MPD User Manual See also: MotionPRO Developer Workspace © ElectroCraft 2013 8 MPD User Manual 2. Project Management 2.1. Project File Concept MotionPRO Developer works with projects. A project contains one or several Applications. Each application describes a motion system for one axis. It has 2 main components: the Setup data and the Motion program and an associated axis number: an integer value between 1 and 255. Applications for ElectroCraft Motion Controller contain also a third component Axis Selection. An application may be used either to describe: 1. One axis in a multiple-axis system 2. An alternate configuration (set of parameters) for the same axis. In the first case, each application has a different axis number corresponding to the axis ID of the drives/motors from the network. All data exchanges are done with the motion controller/programmable drive or motor having the same address as the selected application. In the second case, all the applications have the same axis number. The setup component contains all the information needed to configure and parameterize a ElectroCraft drive/motor. This information is preserved in the drive/motor EEPROM in the setup table. The setup table is copied at power-on into the RAM memory of the drive/motor and is used during runtime. The motion component contains the motion sequences to do. These are described via a MPL (ElectroCraft Motion Program Language) program, which is executed by the built-in motion controller. In case of motion controller applications the Axis Selection allows multi-axes system description. The information is used by the motion controller to configure and command the slave axes. When you start a new project, MotionPRO Developer automatically creates a first application. Additional applications can be added later. You can duplicate an application or insert one defined in another project. © ElectroCraft 2013 9 MPD User Manual u select an application a fro om the left sid de selection tree, the App plication General Inform mation When you view open ns on the right, summarizin ng the basic data: d • Application A ID D: contains an array of cha aracters you can create to o quickly iden ntify an appliccation. The application ID is set in n the setup component, c tthe Drive Settup dialogue at Drive Info o. The pplication ID is saved in th he drive/motorr EEPROM w with the setup data ap • Axis A number:: must match h the axis Ax xis ID of the associated m motion contro oller/programm mable drrive or motor.. • Memory M Settiings: shows how the ass sociated mot ion controllerr/programmab ble drive or motor memory m is use ed and allows s you to modiffy the space reserved for different secttions to match h your ap pplication nee eds • Drive D • o Product ID: I displays the drive/motor executio on/order cod de. ElectroCrraft writes it in a reserved area a of the EE EPROM. o Firmware ID: shows the firmware re equired by the e selected configuration. T The actual firm mware ve/motor mustt have the same number a and a revision n letter equal o or higher. on the driv o Setup ID: displays the setup s configu uration o E2ROM: shows s the size e of the drive//motor E2RO OM memory. o RAM: show ws the size of drive/motor RAM memorry. Motor: M display ys the name of o the motor used u o Type: pres sents the mottor type: brushless, brushe ed, stepper: ro otary or linear © ElectroC Craft 2013 10 0 MPD U User Manual • Sensors: presents the sensors used for the load and motor position and for the motor speed (when these sensors are present) o Load Position: type of position sensor for the load. o Motor Position: type of position sensor for the motor o Motor Speed: type of speed sensor for the motor On the selection tree, for each application selected, you can access the 2 main components: the Setup data and the Motion program. The application tree for motion controller contains also the Axis Selection. Continue with: Application – Setup Application – Motion See also : MotionPRO Developer Workspace © ElectroCraft 2013 11 MPD User Manual 2.2. Memory y Setting The Memory Settings dialogue d allow ws you to cus stomize the m memory space e reserved fo or different secctions pplication as well w as where e the MPL pro ogram is load ed and execu uted. The memory settingss refer of your ap to 2 types s of memories s: RAM and EEPROM. E The RAM M memory has s an area reserved for PV VT / PT buffe er followed b by a customizzable area. T This is typically used u for the Logger L data acquisitions a and to store th he cam tabless during runtime. It may allso be used to te emporary storre MPL progra ams. The EEPR ROM memory y has an area a reserved forr the setup tab ble preceded by a customizable area. T This is used to sttore the MPL programs and the cam tab bles. The exactt amount of EEPROM E mem mory is speciffic for each drrive/motor. In the CA AM Tables sec ction, you can n adjust the space s reserve ed for the cam m tables sele ected to be ussed in your application. The cam tables are a first downloaded into the EEPROM memory a and at runtim me are copied intto the RAM memory. m Therrefore, the ca am tables’ sp pace is reservved in both R RAM and EEP PROM memories s. You can fin nd how much h of the space e reserved is really occup pied by the ca am tables from the CAM Tables View whic ch shows you u at Buffer Frree Space the e remaining sspace reserve ed for cam tab bles. If your ap pplication doesn’t use ca am tables yo ou can free tthe space re eserved to in ncrease the sspace allocated for data acqu uisition. PL program se ection, you ca an choose where to downlo oad and execcute the MPL program. Typ pically In the MP you down nload and ex xecute the MP PL program in the non-vo olatile EEPROM from, sta arting from itts first location (4 4000h) which h is checked at a power on in n the AUTOR UN mode. If your configuration includes an abs solute encode er with positio on read via S SSI or EnDat p protocols, the e MPL M be dow wnloaded into o the EEPROM and execu uted from the RAM. In thesse cases, whe en the program MUST MPL prog gram execute es the ENDIN NIT comman nd, the EEPR ROM memoryy can no lon nger be acce essed. Therefore e, for these configurations c s, MotionPRO O Developer a automaticallyy adds to you ur MPL progrram a copy sequ uence which is executed immediately as the MPL program starrts to run. Th he copy sequ uence, copies yo our MPL prog gram from th he EEPROM memory into o the RAM m memory and tthen it passe es the control. The T whole process is tran nsparent for the user, wh hose only oblligation is to set the dow wnload address in n the EEPRO OM and the run address in the RAM. © ElectroC Craft 2013 12 2 MPD U User Manual For test purposes, you can also download and run the MPL programs from the RAM memory. This option speeds up the download process and may be useful if your MPL program is large and you intend to execute a lot of tests. See also: Project Concept Memory Map © ElectroCraft 2013 13 MPD User Manual 2.3. Application - Setup In the Setup view you can create a new configuration, load a previously saved setup, upload from drive/motor, view or change the selected configuration, save or download the configuration. The setup view is split in 3 sections as follows: • • In the left section you can define or load a setup configuration: o Create a New drive/motor setup. Opens the “Select ElectroCraft Product“ dialogue. Select your drive/motor type. Depending on the product chosen, the selection may continue with the motor technology (for example: brushless motor, brushed motor) or the control mode (for example stepper – open-loop or stepper – closed-loop) and type of feedback device (for example: incremental encoder, SSI encoder). o Open an existing setup. Loads a drive/motor setup configuration, which was previously defined and saved on your PC. The command opens the “Select Drive/Motor Setup" dialogue, allowing you to select a drive/motor setup. Note that a setup is not a single file, but a collection of files which are saved together in the same folder. The folder name is the name of the setup. Hence you select a setup by choosing a folder. By default, MotionPRO Developer saves the setup data in "Setup Files" subdirectory of the MotionPRO Developer main folder o Upload from Drive/Motor the setup data. In the middle section you can view and edit the setup data. You may also load and convert setup data from a previous versions: © ElectroCraft 2013 14 MPD User Manual • o View/Modify setup. Opens 2 setup dialogues: for Motor Setup and for Drive setup through which you can configure and parameterize a ElectroCraft drive/motor. In the Motor setup dialogue you can introduce the data of your motor and the associated sensors. Data introduction is accompanied by a series of tests having as goal to check the connections to the drive and/or to determine or validate a part of the motor and sensors parameters. In the Drive setup dialogue you can configure and parameterize the drive for your application. o Load from a previous version. Converts setup data from a previous version into the upto-date version. The command is foreseen to provide migration of setup data defined long time ago into the latest version for that configuration. The command has sense only if there are differences between the user interface opened with the old setup data and that opened for the same configuration (drive, motor and sensor) with the command New. In the right section, you can save the setup data on your PC or download it on the drive/motor o Save. Opens “Save Drive/Motor Setup” dialogue where you can select where to save the setup data. Note that a setup is not a single file, but a collection of files which are saved together in the same folder. The setup name gives the name of the associated folder. By default, MotionPRO Developer saves the setup data in "Setup Files" subdirectory of the MotionPRO Developer main folder o Download to Drive/Motor. The command will download the actual setup data into the drive EEPROM in the setup table. See also: Application – Motion Application – Axis Selection Motion Project Concept © ElectroCraft 2013 15 MPD User Manual 2.4. Application - Motion In the Motion part of an application, you can program the motion sequences to be executed by the motion controller (dedicated or built-in programmable drives/motors). Programming motion on a ElectroCraft motion controller or programmable drive/motor means to create and download a MPL (ElectroCraft Motion Program Language) program into the motion controller/drive/motor memory. The MPL allows you to: • Set independent motion modes (profiles, PVT, PT, electronic gearing or camming, etc.) • Set 2D/3D coordinate motion modes (Vector Mode, Linear Interpolation) • Change the motion modes and/or the motion parameters • Execute homing sequences • Control the program flow through: o Conditional jumps and calls of MPL functions o MPL interrupts generated on pre-defined or programmable conditions (protections triggered, transitions on limit switch or capture inputs, etc.) o Waits for programmed events to occur • Handle digital I/O and • analogue input signals • Execute arithmetic and logic operations • Perform data transfers between axes • Slave axes management from Motion Controller • Control motion of an axis from another one via motion commands sent between axes • Send commands to a group of axes (multicast). This includes the possibility to start simultaneously motion sequences on all the axes from the group • Synchronize all the axes from a network A MPL program includes a main section, followed by the subroutines used: functions, interrupt service routines and homing procedures. The MPL program may also include cam tables used for electronic camming applications. When you select the “M Motion” part of an application, you access the main section of your application MPL program. © ElectroCraft 2013 16 MPD User Manual You can select the other components of a MPL program too. Each has 2 types of access views: • Definition and/or selection view, with the following purposes: • Homing Modes: select the homing procedure(s) to use from a list of already defined procedures. • Functions: create new MPL functions (initially void) and manipulate those defined: delete, rename, change their order in the program • Interrupts: choose the MPL interrupt service routines you want to view/change their default implementation • Cam Tables: create new cam tables loaded from other applications or imported from text files and manipulate those defined: select those to be downloaded and their order, delete or rename. Remark: The Cam Table are available only in applications developed for programmable drive/motors. • Edit view – for editing the contents. There is one edit view for each homing procedure and cam table selected, for each function defined and each interrupt chosen for view/edit. When you start a new application the edit views of the above components are not present as there is none defined. After you have defined/selected the first homing procedure(s), function(s), interrupt(s) or cam table(s), select again the corresponding view in the project window left side tree. Below it, you’ll see the component(s) defined/created. Choose one and on the right side you’ll see the corresponding edit view. © ElectroCraft 2013 17 MPD User Manual In order to help you create a MPL program, MotionPRO Developer includes a Motion Editor which is automatically activated when you select “M Motion” – the main section view or an edit view for a homing procedure, function or interrupt service routine. The Motion Editor adds a set of toolbar buttons in the project window just below the title bar. Each button opens a programming dialogue. When a programming dialogue is closed, the associated MPL instructions are automatically generated. Note that, the MPL instructions generated are not a simple text included in a file, but a motion object. Therefore with Motion Editor you define your motion program as a collection of motion objects. The major advantage of encapsulating programming instructions in motion objects is that you can very easily manipulate them. For example, you can: • Save and reuse a complete motion program or parts of it in other applications • Add, delete, move, copy, insert, enable or disable one or more motion objects • Group several motion objects and work with bigger objects that perform more complex functions See also: Motion Editor toolbar buttons for motion programming MotionPRO Developer Workspace Homing Modes Functions Interrupts CAM Tables Application – Setup Application – Axis Selection Motion Project Concept © ElectroCraft 2013 18 MPD User Manual 2.4.1. Homing Modes This view allows you to choose the homing procedures associated with the selected application. Electrocraft provides for each programmable drive/motor a collection of up to 32 homing procedures. These are predefined MPL functions, which you may call after setting the homing parameters. You may use these homing procedures as they are, or you may modify them according with your application needs. In this view you can see all the homing procedures defined for your drive/motor, together with a short description of how it works. In order to select a homing procedure, check its associated button. You may choose more then homing procedure, if you intend to use execute different homing operations in the same application. The selected homing modes appear in the project window left side selection tree, in the current application, as a sub-tree of the Homing Modes section. Select a homing procedure from this list. On the right side you’ll see the associated function in the Homing Procedures Edit. Here you can check and modify the contents of the selected homing procedure(s). Remark: Only the selected homing modes are available as options in the Motion – Homing dialogue. Once modified, a homing procedure is memorized together with the application. However, if you’ll create a new application, the homing procedure changes will are not preserved. If you want to preserve them, either create the new application by duplicating that with modified homing procedures, or load the entire motion from the application with modified homing procedures. Press the Reload Default button to restore the default homing procedure. See also: Homing Modes Edit © ElectroCraft 2013 19 MPD User Manual Application – Motion © ElectroCraft 2013 20 MPD User Manual 2.4.2. Homing Modes Edit In the Homing Procedures Edit, you can view and modify the contents of the homing procedure selected on the left-side tree. This is a standard motion view offering access to all the MPL programming features. See also: Motion Editor toolbar buttons for motion programming MotionPRO Developer Workspace Homing Modes Application – Motion © ElectroCraft 2013 21 MPD User Manual 2.4.3. Functions This view allows you to add and remove the MPL functions associated with the selected application. You may also rename and change the functions download order. Type in the edit the name, and press the Add button to create a new function. Select a function from the list and press Rename to change its name, Delete to erase it, Move Up or Move Down to change its position in the list. The MPL functions defined appear in the project window left side selection tree, in the current application, as a sub-tree of the Functions section. Select a function from this list. On the right side you’ll see the function contents in the Functions Edit. See also: Functions Edit Application – Motion © ElectroCraft 2013 22 MPD User Manual 2.4.4. Functions Edit In the Functions Edit, you can view and modify the contents of the MPL function selected on the left-side tree. This is a standard motion view offering access to all the MPL Programming features. See also: Motion Editor toolbar buttons for motion programming MotionPRO Developer Workspace Functions Application – Motion © ElectroCraft 2013 23 MPD User Manual 2.4.5. Interrupts This view allows you to see, define and modify the MPL interrupt service routines (ISR). Each drive/motor has a default ISR for each of the 12 MPL interrupts. In order to use the default ISR, select Default for all the MPL interrupts. If you want to see or modify any of the default ISR, choose option User defined. The MPL interrupts with option User defined appear in the project window left side selection tree, in the current application, as a sub-tree of the Interrupts section. Select an interrupt from this list. On the right side you’ll see the ISR contents in the Interrupt Edit. Here you can check and modify the selected ISR according with your needs. In can cancel your modifications and to return to the starting point i.e. the default ISR by pressing Reload Default button. You can also return at any moment to the default ISR by selecting again the Default option. Remark: Some of the drive/motor protections may not work properly if the MPL Interrupts are handled incorrectly. In order to avoid this situation keep in mind the following rules: • The MPL interrupts must be kept globally enabled to allow execution of the ISR for those MPL interrupts triggered by protections. As during a MPL interrupt execution, the MPL interrupts are globally disabled, you should keep the ISR as short as possible, without waiting loops. If this is not possible, you must globally enable the interrupts with EINT command during your ISR execution. • If you modify the interrupt service routines for Int 0 to Int 4, make sure that you keep the original MPL commands from the default ISR. Put in other words, you may add your own commands, but these should not interfere with the original MPL commands. Moreover, the original MPL commands must be present in all the ISR execution paths. See also: Interrupts Edit Application – Motion © ElectroCraft 2013 24 MPD User Manual 2.4.6. Interrupts Edit In the ISR Edit, you can view and modify the contents of the service routine for the MPL interrupt selected on the left-side tree. This is a standard motion view offering access to all the MPL programming features. See also: Motion Editor toolbar buttons for motion programming MotionPRO Developer Workspace Interrupts Application – Motion © ElectroCraft 2013 25 MPD User Manual 2.4.7. CAM Tables This view allows you to specify the cam tables associated with the selected application. You can: • Load cam files (with extension .cam) defined in other applications • Import cam tables from text files with format: 2 columns, one for X, the other for Y, separated by space or tab • Add new cam files Once defined, a cam table can be placed in one of the following two lists: Available or Selected. Move in the Selected list those cam tables you intend to use in your application. You can have one or more cam tables, up to the limit of the memory space reserved for cams (the remaining memory for cam tables is shown by Free Buffer Space indicator). Use Move Up and Move Down buttons to change the cam tables order in the Selected list i.e. the order in which these cam tables will be downloaded. Move in the Available list all the cam tables you don’t use now, but may use later. Use Delete to remove a cam table from the Available list. Select a cam from either list and change its name with Rename or use [ < ] or [ > ] to move it from one list to the other. Use [ << ] or [ >> ] to move all the cams from one list to the other. By default, all the new added cam tables are placed in the category Selected. Remark: Check the application Memory Settings if you want to change the space reserved for cam tables First time when you run (i.e. press the Run button) a new application, the associated cam tables from the Selected list are automatically downloaded into the drive/motor together with the motion application. Later on, the cam tables download is repeated only if these are modified of the Selected list is changed. © ElectroCraft 2013 26 MPD User Manual There is also a dedicated menu command Application | Motion | Download CAM Tables, for the cam tables download. Once defined, all the cams from the Selected list appear in the project window left side selection tree, in the current application, as a sub-tree of the CAM Tables section. Select a cam table from this list. On the right side you’ll see graphically the cam profile in the CAM Tables Edit, view, where you may edit the cam file. When you create a new cam table, you must: • Type its name in the edit field and press the Add button • Select the cam table from the left side selection tree and edit or import the points See also: CAM Tables Edit Application – Motion © ElectroCraft 2013 27 MPD User Manual 2.4.8. CAM Tables Edit In the CAM Tables Edit, you can view, modify, export or import a cam table. All these operations refer to the selected cam on the left-side tree. The cam tables are arrays of X, Y points, where X is the cam input i.e. the master position and Y is the cam output i.e. the slave position. The X points are expressed in the master internal position units, while the Y points are expressed in the slave internal position units. Both X and Y points 32-bit long integer values. The X points must be positive (including 0) and equally spaced at: 1, 2, 4, 8, 16, 32, 64 or 128 i.e. having the interpolation step a power of 2 between 0 and 7. The maximum number of points for one cam table is 8192. As the X points are equally spaced, these are completely defined by only 2 data: the Master start value or the first X point and the Interpolation step providing the distance between the X points. When you create a new cam table, you may either import or edit its points. Press the Import… button to import the cam table points from a simple text file (.txt), with 2 columns, first the X points and the column with Y points. A tab or a space must separate the columns. © ElectroCraft 2013 28 MPD User Manual In order to edit a cam table: • Set the first X point value in Master start value • Set a value between 0 and 7 in Interpolation step 2^ • Set the first Y value and press the Insert button. Repeat these operations until you define all the cam Y points. Remark: The X points are automatically calculated and displayed as you introduce the Y points. To navigate between the cam table points use [ ≤< ] , [ >≥ ] buttons. Use Remove or Update to delete or change the currently selected cam table point. You may also Export a cam table in the same text file format (.txt) used for import. When the project is saved, for each application, the associated cam files (.cam.) are saved in the application folder. See also: CAM Tables Motion – Electronic Camming Application – Motion © ElectroCraft 2013 29 MPD User Manual 3. MotionPRO Developer Workspace Menu Bar The Menu Bar is the toolbar at the top of the screen that contains all MotionPRO Developer menu commands. When MotionPRO Developer creates a new project, besides the Project window, it opens also the Logger and 3 predefined Control Panel windows (1_Motion Status and 2_Drive IO and 3_Drive Status). Toolbar The buttons in the toolbar represent commonly used MotionPRO Developer commands. Status bar In the status bar you will find the following information: • The communication status: o ”Online” if the communication between the drive/motor associated with to the selected and MotionPRO Developer is established o “Offline” if the MotionPRO Developer can’t communicate with the drive/motor associated to the selected application. • Axis ID – the axis ID of the selected application if the communication between the drive/motor and MotionPRO Developer is established • Product ID – the product ID of the drive/motor associated to the selected application • Firmware ID – the version of the firmware found on the drive/motor • Setup ID – the identification code for the setup configuration used in the selected application • The coordinates of the mouse pointer in the data logger graphs. This information is available only when the Data Logger is selected. See also: Motion Programming Toolbars Application – Motion Functions Edit Interrupts Edit © ElectroCraft 2013 30 MPD User Manual 3.1. Menu Bar The Menu Bar is the toolbar that contains all MotionPRO Developer menu commands: 3.1.1. Project Menu New. Use this command to create a new project. The "New Project" menu dialog will open. Open. Use this command to open an already defined Motion System project that was previously saved and closed. An "Open MotionPRO Developer project" dialogue will open, allowing you to select a project name Close. Use this command to close the current project. Save. In order to save the changes done to the current project use this command. Save As….Use this command to save the current project with a appropriate name. The “Save Project” window opens, allowing you to create a new folder where the project will be saved. Archive. Use this command in order to compress all the files of a project. This command creates a unique file, having the name of the project and the suffix .m.zip. Restore. An .m.zip file, saved by default in the /Archives subdirectory, can be copied into a different location (another computer), and then re-opened using this command. This will simplify the process of project transfer from one location to another, as the project consists from more files, which must be restored into specific sub-directories, in relation to the applications included in the project. Print. to generate a printed image of some of the project windows (as logger, MPL source code), select the respective window, and use this command. Print Preview. Use this menu command in order to preview the plot before printing Print Setup. The command opens a dialogue where you configure the printer used by MotionPRO Developer A list of the last projects opened. Exit. In order to quit the MotionPRO Developer use this menu command. © ElectroCraft 2013 31 MPD User Manual 3.1.2. Application Menu New…Use this command in order to add a new application to your current project. Duplicate. Use this command to duplicate the currently active application. This command creates an identical application in the project, asking you for a different application name. The duplicate operation copies all the contents of the directory associated to the copied application, and create the new one in the current project. This operation is useful if you want to modify an existing application, while keeping the original one unchanged. Selecting one application or another will allow you to execute and compare the two applications in a straightforward manner. Insert… Using you can include an already defined application from a different project. This command opens a dialog that allows you to select the application to be copied. The import operation copies all the contents of the directory associated to the copied application, and create a new one in the current project. You can rename the application in order to change its name. Edit….. This command opens the Application Attributes dialogue that allows you to rename the currently active application and/or to change the Axis ID. Delete. You can delete the currently active application using this command. Setup Motion Run. Use this menu command to start you application. Axis On. This command enables the PWM signals of the drive/motor associated to the selected application. Axis Off. This command disables the PWM signals of the drive/motor associated to the selected application. Reset. Use this command to reset the drive/motor associated to the selected application. Show slave errors. This command displays the errors reported by the slave axes to a multi-axes Motion Controller. Binary Code Viewer The “Binary Code Viewer” is a tool included in MotionPRO Developer which offers you a quick way to find the binary code that must be sent / will be received by your host processor, when communicating with a ElectroCraft drive. Create PRO EEPROM Program File. The option Motion and Setup creates a .sw file with complete information including setup data, MPL programs, cam tables (if present) and the drive/motor configuration ID. The option Setup Only produces a .sw file identical with that produced by PROconfig i.e. having only the setup data and the configuration ID. Export to MPL_LIB. With this command you export the setup information, of the selected application, for use with MPL_LIB. The setup information will be stored in two files setup.cfg and variables.cfg. © ElectroCraft 2013 32 MPD User Manual 3.1.3. Application | Setup Menu New… Create a new drive/motor setup using this command. A new window “Select ElectroCraft Product “will open in which you need to select the template on which the new motion application will be based. The collection of MotionPRO Developer templates is organized for different configurations, based on the different types of ElectroCraft drives, and the associated types of motors that can be driven by these drives. Open… Use this menu command for opening an already defined drive/motor setup that was previously saved and closed. A “Select Drive/Motor Setup" dialogue will open, allowing you to select a drive/motor setup name. By default, MotionPRO Developer saves each motion project as a separate directory having the same name as the project itself, in the "Setup Files" subdirectory of the MotionPRO Developer program directory. Upload from Drive/Motor. Use this command to upload the setup from the drive/motor. Import from a Previous Version… Converts setup data from a previous version into the up-to-date version. The command is foreseen to provide migration of setup data defined long time ago into the latest version for that configuration. Edit/New. Using this menu command will open the drive setup window and motor setup window. In these windows you can view or change the drive and motor settings. Download to Drive/Motor. Use this command to download the setup to drive/motor. Save As…Use this command to save the setup on the disk. A “Save Drive/Motor Setup” window will open in which you can create a new folder for the setup to be saved in. © ElectroCraft 2013 33 MPD User Manual 3.1.4. Application | Motion Menu Build. Using this command you compile and link the MPL program, the result is a file with out extension ready to be downloaded to the drive/motor. Download CAM Tables. Use the command to download on the drive/motor EEPROM the cam tables defined for the selected application. Download Program. The command downloads on the drive/motor the out file created for the selected application. The out file is created using the command Build. Load from Another Application… This command allows you to load the motion section defined in a different application. All motion section components (motion sequences, functions, ISR or homing sequence) of the current application are overwritten by this command. Import Sequence… This command allows you to load/insert motion objects previously saved in *.msq files. These are appended below the current position e.g. the immediately after the selected motion object. Export Sequence… Use this command to save a part of your program (one or more motion object) in a separate motion file .The operation saves the selected motion objects in a file with extension *.msq. Import G-Code file… This command allows you to convert G-Code sequences into MPL motion language instructions for a multi-axis Motion Controller. Edit. Use this command after select a motion sequence to change its parameters. The dialogue associated with the selected motion sequence opens. Insert. Reserved for future developments. View Generated MPL Code… This command allows you to view the MPL Code generated for the motion sequences selected in the Motion Editor dialogue. Duplicate. This command duplicates the selected motion sequence. Move Up. This command moves up the selected motion sequence. Move Down. This command moves down the selected motion sequence. Delete. This command allows you to delete the selected motion sequence. Group. This command allows you to group a number of motion sequences in a new object containing all the selected motion objects Ungroup. Use this command to restore the motion objects list instead of the group object. Enable For debugging, you have the possibility to remove motion sequences (one or more motion objects) from the motion program like commenting lines in a text program. Use this menu command to uncomment (enable) the selected motion sequences. Disable .Use this command to comment (disable) the selected motion sequences. Add Function. This command creates a new function (named “Untitled”) and the “Function Window” will open. In this window you can insert the motion sequences to be executed when the function is called. Delete Function. This command deletes the currently selected function. © ElectroCraft 2013 34 MPD User Manual 3.1.5. Communication Menu Setup… The “communication setup” dialogue will open which allows you to select the communication type between RS-232, RS-485 and CAN-bus with several PC to CAN interface boards, to choose the desired baud rate and to setup the communication parameters. Refresh Select the command if during operation the communication is interrupted (for example if the drives power is turned off) in order to restore communication Work Offline When this option is selected the MotionPRO Developer doesn’t attempt to communicate with the drives/motors associated to the defined applications. Show Info In Output View | The menu command allows selecting the information listed in the output view. The output view is showed/hided from menu View | Output. None – when you select this option no information is presented in Output view. Errors – use this option to view errors occurred during communication. Errors due to programming error, detected during program build, are automatically listed in Output View. Warnings – when this option is selected in the Output view appears the warning messages of the selected communication channel. Traffic – when this option is selected in the Output view are listed all messages send or received by MotionPRO Developer. Unrequested messages – use this option to list messages send automatically by the drive connected to the PC. EEPROM Write Protection. From this menu you access the options related to EEPROM write protection feature. You have the following options: Do not protect EEPROM after download – when this option is selected the EEPROM is not protected Write protect last ¼ of EEPROM after download – when this option is selected the last quarter of the EEPROM is write protected after the download of setup data or MPL program Write protect last ½ of EEPROM after download – when this option is selected the last half of the EEPROM is write protected after the download of setup data or MPL program Write protect entire EEPROM after download – when this option is selected the entire EEPROM is write protected after the download of setup data or MPL program Scan Network. Use this command to detect online drives/motors, members of a CAN network. The drives/motors detect are listed in the Output View along with their axis ID and firmware version. © ElectroCraft 2013 35 MPD User Manual 3.1.6. View Menu Project. Use this command to visualize the “Project Window” Command Interpreter. Use this command to visualize the “Command Interpreter Window” Logger. Use this command to visualize the “Logger Window” Multi-Axis Logger. Use this command to visualize the “Multi-Axis Logger Window” Control Panel. Use this command to show/hide the “Control Panel” windows defined for the selected application. By default there are 3 control panels defined. Check the windows you want to show/hide from the list. • 1_Motion Status • 2_Drive IO • 3_Drive Status Memory The command opens the Memory Window, within you can view/modify the drive/motor memory contents. Remark: This is a feature is a very low level function, it is NOT recommended to modify memory contents without a deep knowledge of the use made by the ElectroCraft drive of each memory location you intend to modify. Output. Use this command to visualize the “Output Window”. From Communication | Show Info In Output View menu you select what information is presented in the window. Refresh The command refreshes the content of Memory window. It’s available only when the Memory window is active. Toolbar. Use this command to hide/show the MotionPRO Developer toolbar. Status bar. Use this command to hide/show the status bar from the bottom of MotionPRO Developer window. View graph plot. Previously saved plots from Logger or during controllers tuning can be opened from this menu command. 3.1.7. Logger Variables… This menu command opens the dialogue from where you manage the plotted variables. Plot Setup… This menu command allows you to select and group on specific graphic subplots the variables which will be stored during the motion execution through the data logging procedure. Plot Options… This menu command allows you to set the graphical parameters of all the variables selected to be plotted in any of the four subplots of Logger View, as colors, line width and pattern, background, axes colors, grid options and measurement units. Arrange | From this menu entry you can define the position of the subplots on the Logger View. The command is effective if more than one subplot are defined Auto: use a default disposal of the subplots, depending on their number (2, 3 or 4). © ElectroCraft 2013 36 MPD User Manual Horizontal: the plot window is divided in horizontal regions for sub-plotting. The subplots are displayed in a row, from left to right, on the graphic window. Vertical: the plot window is divided in vertical regions for sub-plotting. The subplots are displayed one below the other Zoom | This menu commands allows you to select fixed zoom areas of the first subplot on the Logger View Zoom In: zoom-in the graphical image of the first subplot. Zoom Prev: zoom-out one step the graphical image of the first subplot. Zoom Out: zoom-out back to the initial graphical image of the first subplot. Start Use this menu command to start storing data onto the drive/motor memory. Upload Data. Use this menu command to get the data from the drive/motor memory and display them in the logger window. Stop Data Upload. Use this menu command to stop the logged data uploading process Import… Use this menu command in order to load a pre-defined logger configuration into a special format file. Thus, all logger settings, including selected variables, pre-defined sub-plots contents, and other preferences (colors, etc), can be loaded, replacing the actual logger settings. Export…Use this menu command in order to save the actual logger configuration into a special format file. Thus, all logger settings, including selected variables, pre-defined sub-plots contents, and other preferences (colors, etc), can be saved on that file Save graph as… This menu command allows saving the selected graph into ElectroCraft plot files format, with extension TPT. A dialog is opened which ask the user to indicate the name of the file. The saved file may be opened using the menu command View | View Plot Graph… Export to WMF. This menu command will be used to save the actual graphic window contents to a file on the system disk, into a standard format, the Windows Metafile Format (or WMF). A special dialog is opened, similar to the Export… one, which asks the user to indicate the name of the metafile file (its default extension is “.WMF”). The saved file may then be imported in other Windows applications that have adequate graphic filters and recognize the metafile format. Thus, the graphics may be included in other documents; more text may be added to the plots, colors and other features may be changed Export to ASCII. This menu command will be used to save the actual values of all the uploaded variables values, on a file on the system disk, into a standard ASCII text format. A special dialog is opened, similar to the Export… one, which asks you to indicate the name of the ASCII file (its default extension is “.txt”). The saved file may then be examined, and also read and imported in different other programs as Excel, Word, etc. Print… The command opens the dialogue from where you can print the selected plot Print Preview With this command you can preview the plot before printing Print Setup…The command opens a dialogue where you configure the printer used by MotionPRO Developer © ElectroCraft 2013 37 MPD User Manual 3.1.8. Control Panel Start. Use this menu command to start the control panels of an application. From this moment, all the contents of all the objects contained in the visible control panels of that application will be updated and displayed on the screen. Stop. Use this menu command in order to stop the update of information on the control panels of the application. Note that this command will delete all the information associated to that control panel Customize. Use this menu command in order to be able to customize a control panel. A special toolbar will be displayed, containing all the possible objects, which can be added in a control panel. You’ll be able to add, remove and parameterize all the objects of a control panel. Note that during the parameterization stage, all the control panels are stopped. Rename… A name must be given to a control panel at the moment of its loading from an external file, or at its creation. This name is displayed in the window bar of the panel. You can change this name using this menu command. Export to File. Use this menu command in order to save a defined control panel on an external file. This will allow you to load and use this control panel in a different application. Edit Active Item… Choosing this menu command will open its specific parameterization dialog. This dialogue is automatically opened when a new object is defined. Align to | Use this menu command in order to align all the objects which are selected, at left, right, top or bottom. Note that the reference position is taken from the LAST selected object in the currently selected objects. Left - align the selected objects along their left side Right - align the selected objects along their right side Top - align the selected objects along their top edges Bottom - align the selected objects along their bottom edges Space evenly | Use this menu command in order to equally space all the objects which are selected, horizontally (across) or vertically (down). Note that the reference position is taken from the selected objects placed in the extremes of the currently selected objects. Across. Use this menu command to space objects evenly between the leftmost and the rightmost control selected. Down. Use this menu command to space objects evenly between the topmost and the bottommost object selected. Make same | You can manually resize an object by using the specific resize mouse cursors and the mouse left-button. If more objects are selected, this menu commands allows you to make the same width, height or size (both width and height) for all these objects. Note that there are some limits when trying to resize some of the objects. Note that the reference size is taken from the LAST selected object in the currently selected objects. Width - size objects with the same width as the dominant object; Height - size objects with the same height as the dominant object; Size - size objects with both the same height and the same width as the dominant object. Send to back. Use this menu command to send to back the selected items. Send to front. Use this menu command to send to front the selected items. © ElectroCraft 2013 38 MPD User Manual Add Control Panel… Use this menu command to define a new control panel. Add Control Panel from file… Use this menu command to add into your current application control panels defined in another application (e.g. associated with another setup file). Delete Control Panel | Use this menu command to delete a control panel. • 1_Motion Status • 2_Drive IO • 3_Drive Status • Other Control Panels created 3.1.9. Help Help Topics Getting Started About MotionPRO Developer… – The menu command opens a dialogue with information about MotionPRO Developer version Enter registration info… Check Updates – From this menu command you launch the PRO Update utility. © ElectroCraft 2013 39 MPD User Manual 3.2. Toolbar The buttons in the toolbar represent commonly used MotionPRO Developer commands. New. Use this icon to create a new project. The "New Project" menu dialog will open. Open. Use this icon to open an already defined motion project that was previously saved and closed. The "Open MotionPRO Developer project" dialogue will open, allowing you to select a project name. Save. In order to save the changes done to the current project use this icon. If the current project has not be named a “Save Project” window will open, allowing you to create a new folder where the project will be saved. Print. Use this icon in order to print the motion sequences from active window select some printing parameters such as the printer, the paper size and orientation. View Project. Use this icon to visualize the “Project Window” Command Interpreter. Use this icon to visualize the “Command Interpreter” View Logger. Use this icon to visualize the “Logger” window View Multi-Axis Logger. Use this icon to visualize the “Multi-Axis Logger” window View Control Panel. Use this icon to visualize the “Control Panel” windows. Check the windows you want to be open from the existing list. Edit/View Setup. Using this menu command will open the drive setup window and motor setup window. In these windows you can view or change the drive and motor settings. Import Setup from Drive/Motor. Use this icon to upload an existing setup from the drive/motor. Download Setup to Drive/Motor. Use this icon to download the setup to drive/motor. Run. Use this icon to download and run your application. © ElectroCraft 2013 40 MPD User Manual Axis On. Enable PWM signals. Axis Off. Disable PWM signals. Reset Active Drive/Motor. Send a reset command to the selected drive/motor. Start Logger. Use this toolbar icon to start storing data onto the drive/motor memory. The button is active only when the logger window is active. Upload Logger. Use this button to upload data from drive/motor. The button is active only when the logger is started. Stop Logger Upload. Use this button to stop the upload of data from drive/motor. The button is active only when data from the drive is uploaded. Start Control Panel. Use this button to start the selected control panels. Stop Control Panel. Use this button to stop the selected control panels. The button becomes active when the control panels are started. Refresh Communication. Use this button to reestablish communication with the drive/motor. Help. Opens the help page associated with the active window. © ElectroCraft 2013 41 MPD User Manual 4. Evaluation Tools 4.1. Data Logger 4.1.1. Data Logger The Data Logger is an advanced graphical analysis tool, allowing you to do data acquisitions on any variable of your drive / motor and plot the results. In order to set up / manage the data logger module, simply select the View | Logger menu command (alternatively, use the associated toolbar icon ). Once the Logger window is opened, you have access to its associated menu by clicking on the right mouse button when positioned in the logger window. This opens the Logger pop-up menu. This menu has the following menu sub-commands: Variables / Plot Setup... / Plot Options... / Arrange/ Zoom/ Start / Upload Data / Stop Data Upload / Import… / Export… / Export to WMF / Export to ASCII / Print… / Print Preview / Print Setup… Depending on the state of the Logger, some of these menu sub-commands will be enabled or not, hence you can execute only the allowed operations for a given situation. © ElectroCraft 2013 42 MPD User Manual 4.1.2. Data Logger L - Sta art Start the logger L | Starrt menu comm mand (or the associated to oolbar icon ) to start a d data acquisition for Use the Logger the selectted variables. Data is save ed in the driv ve/motor RA AM memory. IIn MotionPRO O Developer, if the logger win ndow is opened, the data acquisition a is started autom matically when you press tthe Run butto on. Each time e when you execute a Logger L | Sta art command , the data a acquisition is restarted an nd will overwrite the previously stored data a. Once the bu uffer is full, th he data storag ge process is stopped. D Upload Data Use the Logger L | Uplo oad Data me enu command d (or the asso ociated toolba ar icon the drive//motor memo ory and displa ay them in the e logger windo ow. ) to o get the data a from Stop Data a Upload Use the Logger L | Sto op Data Uplo oad menu co ommand (or tthe associate ed toolbar ico on logged da ata uploading process ) to sto op the See also: Data Logg ger Utility © ElectroC Craft 2013 43 3 MPD U User Manual 4.1.3. Data Logger - Plot Options The Logger | Plot Options… menu command allows you to set the graphical parameters of all the variables selected to be plotted in any of the four subplots of Logger View, as colors, line width and pattern, background, axes colors, grid options and measurement units. The list of variables that will be stored during the data logging must be defined using the Logger | Variables… menu command. Once this list defined, you may use the Logger | Plot Setup dialog in order to select the corresponding variables and distribute them on the graphics subplots for further visualization. With the plot variables selected in the Logger | Plot Setup dialog, you may open the Logger Plot Options dialog in order to examine / modify the predefined graphic attributes associated to the curves, axes, etc. The dialog contains the complete list of the variables selected to be stored for each of the possible four subplots that may be defined. For each subplot, any variable to be plotted on it may be selected from the list grouped under the title Curves. You may switch between the subplots using the corresponding tabs associated to each subplot. By default, each subplot tab is named as Subplot options if no name was given to the curve. Otherwise, if that name was defined, it is used as the tab name. (You may freely define each of the subplot names in the Logger | Plot Setup dialog). For each subplot, you may select any of the variables from the Curves list. Once a variable is selected (outlined) in the list, its graphical attributes are displayed and may be examined and/or modified by you. Thus, you may modify: • The curve color, using the Color drop-down list of available colors (up to 28 colors may be used); • The curve style, using the Style drop-down list of available line styles (up to 5 line styles may be used); • The curve width, using the Width drop-down list of available line widths (1 to 4 line widths may be used) © ElectroCraft 2013 44 MPD User Manual You can change in the Measure Units drop-down list the units in which to display the variables stored. The background color may be defined for each subplot, using the Background Color drop-down list (up to 28 colors may be used). The axis color may be defined for each subplot, using the Axis Color drop-down list (up to 28 colors may be used). The grid option for each subplot may be set/reset using the Grid check button. You may also define the X-axis label and measurement unit, by editing the X-Axis edit control field and respectively, by selecting the measurement unit from the associated drop-down list of possible units. Use the Default button to reset all the selected measurement units for the curves. Use the OK button to effectively apply the defined settings and exit back to the Logger View, by closing the Logger - Plot Options dialog. Use the Cancel button to cancel all the defined settings and exit back to the Logger View, by closing the Logger - Plot Options dialog. See also: Data Logger Utility © ElectroCraft 2013 45 MPD User Manual 4.1.4. Data Logger - Plot Setup The Logger | Plot Setup… menu command allows you to select and group on specific graphic subplots the variables which will be stored during the motion execution through the data logging procedure. Up to four subplots may be defined. The list of variables, which will be stored during the data logging, must be defined using the Logger | Variables… menu command. Once this list defined, you may accede the Logger - Plot Setup dialog in order to select the corresponding variables and distribute them on the graphics subplots for visualization. The dialog contains the complete list of the curves selected to be stored, in the top of it. For each subplot, the curves to be plotted on it may be chosen from the complete list of stored variables, grouped under the title Available Curves. You may switch between the subplots using the corresponding tabs associated to each subplot. By default, each subplot tab is named as Subplot setup. You may freely define each of the subplot names. The Subplot Title edit box contains the actual (if it was defined) subplot title. You may define or modify it at any time by editing this edit control. Each subplot has an associated list of the selected curves to be displayed on that subplot, grouped under the name of Subplot Axis. The list may be updated by you by adding to / removing from it curves from the Available Curves list. A variable may be added to the subplot curves list by selecting it in the Available Curves list, with a leftbutton mouse click (the selected variable becomes outlined), and by pressing on one of the Add to the © ElectroCraft 2013 46 MPD User Manual list button ns: press curve. to add it as the Y axis s curve, or pre ess the button to a add it as the X axis ding a new variable to the e subplot curv ves list, by ha aving at the ssame time a selected (outtlined) When add curve in the t Subplot Axis A list, the e added varia able will autom matically repllace the prevvious one from the Subplot Axis A list, corre esponding to the Y or X ax xis selected to o be replaced d. A curve may m be remov ved from the subplot s curve es list by sele ecting it in the e Subplot Ax xis list, with a rightbutton mo ouse click (th he selected curve c become es outlined), a and by presssing the Rem move from th he list button . Always, th he variable Acquisition A Tim me exists in the Available e Curves listt. Usually, yo ou will select some other variable to be ad dded to the Subplot Axis list. When th e first variablle is selected and added tto that m automatically inserts by default, as th he X-axis, the e Acquisition Time list as a Y axis curve, the program variable . The variables may be related to the e left or to the right vertica al axis of the e subplot. Usu ually, the variables are introd duced as rela ated to the left vertical axiis . If yyou want to change this ssetting to the e right vertical ax xis, you need d to double-c click the vertic cal axis symb bol, which wiill commute tto the right ve ertical axis symb bol . (A A similar double-click on this t symbol w will reverse ag gain the vertical axis to th he left one). s X-axis s coordinate, different thatt the time va ariable (in ord der to visualizze the If you want to use a special nce between two t variables s), you must select s the dessired X-axis va ariable in the Available Cu urves dependen list, and add a it to the Subplot Ax xis list using the Add to X axis button n variable will w replace the e time variablle as the X-ax xis coordinate e. . The newly sellected By default, the verticall axes do not have a name. You may ffreely define ffor each of th he subplots n names wo vertical axe es. The Labe els group con ntains the acttual (if it was defined) sub bplot Left axis and for the tw Right axis names. You u may define or modify the em at any time nding edit con ntrol. e by editing the correspon Use the OK O button to effectively ap pply the defined settings a and exit back to the Logge er View, by closing the Logge er - Plot Setu up dialog. Use the Cancel C button n to cancel all the defined settings and exit back to tthe Logger View, by closin ng the Logger - Plot Setup dialog. d See also: Data Logg ger Utility © ElectroC Craft 2013 47 7 MPD U User Manual 4.1.5. Data Logger - Variables Use this dialogue to select the variables to acquire for plotting. You can select any variable. All the variables selected will be saved into the drive/motor memory at some predefined moments. The total number of acquisitions points (“Acquisitions No” value) depends on the drive/motor memory available for data logging storage. Also in this dialog you can select the data logging moments. The data logging process may be: triggered by user, done in position/speed control loop (default), or into the current loop. You can select to acquire data at each sampling loop or from n to n samplings. From this dialogue you can: • Select where to perform the data logging (“Data logger active in” box): • Triggered by user (available only for some products) • in the Position/Speed control loop (slow sampling loop) - default • in the Current control loop (fast sampling loop). To be used with care, since it can impose to the processor a too big overhead, and thus can affect the behavior of the motion system. • See the location and size of the data acquisition buffer (“Acquisition Buffer” box), depending on the memory available in your system. The memory location and size can’t be changed directly, they result from the memory setting dialogue. • Define the number of points to store (“Acquisition Number” parameter). Note that the maximum value of this parameter is related to the size of the data acquisition buffer, as well as to the number of variables in the list. The “Free buffer space” value can be used to estimate the remaining amount of memory available for data logging. • Choose the interval of data logging (“Save logged data at every” box). You can select if the data logging will be performed at each x control loops. © ElectroCraft 2013 48 MPD User Manual • Manage the list of variables to be stored. You can: • add variables to the list. Select the variable from New Variable drop-down list and press “Add” button. • delete variables from the list. Select the variable and use the “Delete” button to delete a variable selected in the list, or the “Delete All” button to delete all the variables from the list. See also: Data Logger Utility Memory Settings © ElectroCraft 2013 49 MPD User Manual 4.1.6. Data Logger - Other Options Arrange (Auto, Horizontal, vertical) The Arrange menu command allows you to define the position of the subplots on the Logger View. The command is effective if more than one subplot are defined. The following options are available: • Auto: use a default disposal of the subplots, depending on their number (2, 3 or 4). • Horizontal: the plot window is divided in horizontal regions for sub-plotting. The subplots are displayed in a row, from left to right, on the graphic window. • Vertical: the plot window is divided in vertical regions for sub-plotting. The subplots are displayed one below the other. Zoom (In, Prev, Out) The Zoom menu command allows you to select fixed zoom areas of the selected subplot on the Logger View. The following options are available: • In: zoom-in the graphical image of the first subplot • Prev: zoom-out one step the graphical image of the first subplot • Out: zoom-out back to the initial graphical image of the first subplot In order to freely zoom any graphical image, you may use the mouse to select a part of the current subplot, allowing the zooming of the selected region. The selection is done by pressing the left mouse button and dragging the zoom cursor on the display surface (the movement is bound to the area of the subplot). On the release of the mouse button, the selected region is expanded to the dimension of the entire subplot. Successive zooms may be applied to any of the subplots. Note that, when moving the mouse cursor, you can see, at the bottom of the graphic window, the coordinates on the left and right axes of the current cursor position on the screen. Thus, measurements may be done on the plots. If no region is selected for zooming, the plot is unchanged. Double-click the left mouse button, with the mouse in the graphical area of a subplot, in order to zoom-out one level back from the currently displayed image. Import… Use the " Logger | Import…" menu command in order to load a pre-defined logger configuration into a special format file. Thus, all logger settings, including selected variables, pre-defined sub-plots contents, and other preferences (colors, etc), can be loaded, replacing the actual logger settings. This feature is useful in order to easily select a pre-defined preferred logger environment. Such files can be created by saving an already defined logger context, using the “Logger | Export…” menu command (see next paragraph). Note that the command also loads the plotted variables graphs, as existing when the .lgs file was saved. Use the “Logger | Upload Data” menu command to load from the drive the current values for the selected variables. © ElectroCraft 2013 50 MPD User Manual Export… Use the " Logger | Export…" menu command in order to save the actual logger configuration into a special format file. Thus, all logger settings, including selected variables, pre-defined sub-plots contents, and other preferences (colors, etc), can be saved on that file. This feature is useful in order to save predefined preferred logger environments. Such files can be latter-on loaded in order to re-create the same logger context, using the “Logger | Import…” menu command (see previous paragraph). Note that the command also saves the actual plotted variables graphs. Use the “Logger | Upload Data” menu command to load from the drive the current values for the selected variables. Export to ASCII The Export to ASCII menu command will be used to save the actual values of all the uploaded variables values, on a file on the system disk, into a standard ASCII text format. A special dialog is opened, similar to the Export… one, which asks you to indicate the name of the ASCII file (its default extension is “.txt”). The saved file may then be examined, and also read and imported in different other programs as Excel, Word, etc. The file will contain: • on the first line, the number n of saved curves, and the number m of saved points for each curve, separated by the TAB character • on the next m lines, n values for the saved curves on each line, separated by TAB characters. Each line contains variables values corresponding to a data logger X-axis instant (time sampling) Export to WMF The Export to WMF menu command will be used to save the actual graphic window contents to a file on the system disk, into a standard format, the Windows Metafile Format (or WMF). A special dialog is opened, similar to the Export… one, which asks the user to indicate the name of the metafile file (its default extension is “.WMF”). The saved file may then be imported in other Windows applications that have adequate graphic filters and recognize the metafile format. Thus, the graphics may be included in other documents; more text may be added to the plots, colors and other features may be changed. Print… The Print… menu command opens a dialogue which allows you to print the represented graphics. Print Preview The Print Preview menu command opens a new window allowing you to see how the graphics will look after the print. Print Setup The Print Setup command opens a dialogue with settings related to the printer, paper size and orientation. See also: Data Logger Utility © ElectroCraft 2013 51 MPD User Manual 4.2. Control Panel 4.2.1. Control Panel The Control Panel is a tool enabling you to define specific control panels where you can send commands and visualize status variables. Each ElectroCraft product comes with a set of pre-defined control panels. Using the “Customize” option, you can define new control panels or modify the existing ones according with your application specific. Handling the control panels Displaying the control panels Use the “View | Control Panel” command menu, in order to see the list of the currently defined control panels. Click on a list item in order to alternatively change its display status (show or hide). The “Control Panel” menu All of menu commands are displayed and can be used when you click the right-mouse button, while over a control panel window. Adding pre-defined control panels to an application Use the “Control Panel | Add Control Panel from file …” menu command to add into your current application control panels defined in another application (e.g. associated with another setup file). Adding new control panels to an application Use the “Control Panel | Add Control Panel” menu command to define a new control panel (see next paragraphs how to customize a control panel). © ElectroCraft 2013 52 MPD User Manual Deleting control panels from an application Use the “Control Panel | Delete Control Panel” menu command in order to delete a control panel. Activating the control panels of an application Use the “Start Control Panel” button or the “Control Panel | Start” menu command to start the control panels of an application. From this moment, all the contents of all the objects contained in the visible control panels of that application will be updated and displayed on the screen. Important notes: 1. The update rate depends on the communication speed between the PC and your drive/motor and on the number of different variables that must be read from the drive/motor in order to be displayed. In order to keep the update rate high, try to activate only those control panels, which are needed at one moment. Thus you’ll avoid over-charging this process and slowing down too much the update rate. 2. The display rate of the objects is individually selectable, at their definition (see next paragraphs, the customization procedure of control panels) Stopping the control panels of an application Use the “Stop Control Panel” button or the “Control Panel | Stop” menu command in order to stop the update of information on the control panels of the application. Note that this command will delete all the information associated to that control panel. If you want to preserve the control panel, use the “Control Panel | Export to File…” menu command, before deleting the control panel. The delete operation acts only at the level of the application, but does not affect the control panels saved on files. Customizing a control panel Use the “Control Panel | Customize” menu command in order to be able to customize a control panel. A special toolbar will be displayed, containing all the possible objects, which can be added in a control panel. You’ll be able to add, remove and parameterize all the objects of a control panel. Note that during the parameterization stage, all the control panels are stopped. See the “Control Panel Objects” paragraph for more details regarding the objects, which can be used in a control panel, and their parameter setting. Renaming a control panel A name must be given to a control panel at the moment of its loading from an external file, or at its creation. This name is displayed in the window bar of the panel. You can change this name using the “Control Panel | Rename” menu command. Note that this name is valid at the level of the application, and does not affect the name of the control panel file that was eventually used to load the control panel into the application. © ElectroCraft 2013 53 MPD User Manual Saving a control panel Use the “Control Panel | Export to File…” menu command in order to save a defined control panel on an external file. This will allow you to load and use this control panel in a different application. Deleting a control panel Use the “Control Panel | Delete” menu command in order to delete the currently selected control panel from the application. Note that if you previously saved this control panel using the “Control Panel | Export to File…” menu command, this command will only delete the control panel from the application, while the saved file will remain unchanged. This will allow you to re-load the control panel again, using the “Control Panel | Add Control Panel from file …” menu command. In case that you didn’t saved the control panel, using the “Control Panel | Delete” menu command will completely lose the information defined in it. Control Panel Customization A control panel can be freely defined and/or customized by you. Specific basic control panel templates can be saved and included in other MotionPRO Developer applications, as preferred by you. When you start creating a new control panel, using the “Control Panel | Add Control Panel” menu command, a new, empty control panel window is opened. At the same time, the specific control panel objects toolbar is also displayed. This toolbar is also displayed when you use the “Control Panel | Customize” menu command. While in the customization mode, all control panels are stopped and can be modified. Use again the “Control Panel | Customize” menu command to end the customization and return in the normal operation mode of the control panels. Several types of visualization or setting objects can be included in a control panel, and positioned / sized as preferred. Each object will be associated to one or more MPL variable(s) (for display-type objects) or MPL parameter (for setting objects). Depending on their types, specific parameters can be defined. Selecting objects in a control panel. Click on an object from the control panel in order to select it. Press the left-mouse button and drag the mouse in order to select more objects simultaneously. Currently selected object(s) are highlighted, and specific operations can be done related to them (see below). Alternatively, press the CTRL key and click the left-button of the mouse in order to select one by one the objects. Note that the LAST selected object is the dominant object, and alignments and resizing are referred to it. Editing an object in a control panel. Double-clicking an object, using the Control Panel | Edit Active Item… menu command, or the corresponding icon , will open its specific parameterization dialog. This dialogue is automatically opened when a new object is defined. See next paragraph for details related to the parameterization of each type of control panel object. Deleting an object in a control panel. Use the DEL key in order to delete the currently selected objects from a control panel. Duplicating objects in a control panel. Use the Control Panel | Duplicate Selected Items menu command in order to create a copy of all the objects which are selected in that moment. The newly created objects have the same characteristics and parameters as the original ones. © ElectroCraft 2013 54 MPD User Manual Moving objects in a control panel. Once one or more objects are selected in a control panel, drag them by pressing the mouse left-button and moving the mouse. The objects will move all together, keeping the same distance between them. Aligning objects in a control panel. Use the “Control Panel | Align to …” menu command or the corresponding icons, in order to align all the objects which are selected, at left, right, top or bottom. Note that the reference position is taken from the LAST selected object in the currently selected objects. To align objects: • Select the objects you want to align by holding down the CTRL key and clicking the mouse’s left button on the appropriate object window • Make sure the correct dominant object (the last selected object) is selected. • The final position of the group of objects depends on the position of the dominant object. Use Align Left button Use Align Right button Use Align Top button Use Align Bottom button from the toolbar to align the selected objects along their left side. from the toolbar to align the selected objects along their right side. from the toolbar to align the selected objects along their top edges. from the toolbar to align the selected objects along their bottom edges. Spacing objects in a control panel. Use the Control Panel | Space evenly… menu command or the corresponding icons, in order to equally space all the objects which are selected, horizontally (across) or vertically (down). Note that the reference position is taken from the selected objects placed in the extremes of the currently selected objects. from the local toolbar to space objects evenly between the Choose Space Evenly Across button leftmost and the rightmost control selected. from the local toolbar to space objects evenly between the Choose Space Evenly Down button topmost and the bottommost object selected. Resizing objects in a control panel. You can manually resize an object by using the specific resize mouse cursors and the mouse left-button. If more objects are selected, the Control Panel | Make Same… menu commands or the corresponding icons, allows you to make the same width, height or size (both width and height) for all these objects. Note that there are some limits when trying to resize some of the objects. Note that the reference size is taken from the LAST selected object in the currently selected objects. Choose Make Same Size Width button the dominant object; Choose Make Same Size Height button as the dominant object; from the local toolbar to size objects with the same width as from the local toolbar to size objects with the same height from the local toolbar to size objects with both the same Choose Make Same Size Both button height and the same width as the dominant object. © ElectroCraft 2013 55 MPD User Manual Superposing objects in a control panel. In order to create some special visual appearance effects, you can totally or partially superpose objects in a control panel. In this case, it is important to control the relative position of the objects. Use the Control Panel | Send to Back or Control Panel | Bring to Front menu commands or the corresponding icons. Choose Send to Back button from the local toolbar to send to back the selected items. Choose Send to Back button from the local toolbar to send to front the selected items. Control Panel Objects This section contains the description of the different objects that can be defined in a control panel. In the customization mode, you can freely add / remove objects to a control panel. Simply drag and drop an object from the toolbar containing the object symbols, and place it on the control panel area. Objects are user-resizable. For each of these objects, as already mentioned, there is associated a variable / parameter, I/O port number or data memory location or an expression can be defined, to be evaluated before being displayed. They can be selected at the moment when the control panel is defined. A data memory location must be specified with the following format: type@address where type represents the data type supported by MPL: integer, long or fixed and address is the memory location address expressed in hexadecimal form. Example: fixed@0x0903 the memory contents from addresses 0x0903 and 0x904 are interpreted as a fixed data. The Expression can be built using following operators: “+” - addition “-“ - subtraction “*” - multiply “/” - division “^” - power “(“ and “)” - parentheses The operands used for editing of an Expression are: variable_name [unit] variable_name type@address number Example: 100.5 + 5 * (Position_Command [rot] - 10.0) Note that for all the objects used to display the value of a variable, the variable can be selected from the current list of variables. In the “Axis ID” edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors © ElectroCraft 2013 56 MPD User Manual connected into a network. The default axis ID is as set in Comm Setup e.g. the axis ID set in Communication |Setup dialogue. Select the measurement unit in “Unit” section, corresponding to the selected variable type. Adjust the number of decimals by choosing in “Precision” section one of the values from the scroll list, for a convenient representation depending on values range. Note that if the selected measurement unit is “IU” (Internal Units), the decimals parameter is not used. Also for IU representations, hexadecimal format can be selected. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time intervals can be selected in the “Read value at every” field. Value Object Scope Object Dual Chanel Scope Object Y(X) Dual Chanel Scope Object Gauge Object Cursor Object Input Port Viewer Object Output Port Setting Tool Object Viewer of a Bit of a Variable Object User Defined MPL Sequence Object Label Object © ElectroCraft 2013 57 MPD User Manual 4.2.2. Control Panel - Show Value It’s used to visualize the value of one MPL variable or data memory contents. In the Variable field select the desired one from the current list of variables or insert a memory location. A data memory location must be specified with the following format: type@address where type represents a data type supported by MPL: integer, long or fixed and address is the memory location address expressed in hexadecimal form. Example: fixed@0x0903 the memory contents from addresses 0x0903 and 0x904 are interpreted as a fixed data. Select Expression to define a formula to be evaluated before being displayed. They can be selected at the moment when the control panel is defined. The Expression can be built using following operators: “+” - addition “-“ - subtraction “*” - multiply “/” - division “^” - power “(“ and “)” - parentheses The operands used for editing of an expression are: variable_name [unit] variable_name number © ElectroCraft 2013 58 MPD User Manual Example: 100.5 + 5 * (Position_Command [rot] - 10.0) In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. Select the measurement unit in “Unit” section, corresponding to the selected variable type. Adjust the number of decimals by choosing in “Precision” section one of the values from the scroll list, for a convenient representation depending on values range. Note that if the selected measurement unit is “IU” (Internal Units), the decimals parameter is not used. Also for IU representations, hexadecimal format can be selected. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time intervals can be selected in the “Read value at every” field. See also: Control Panel Utility © ElectroCraft 2013 59 MPD User Manual 4.2.3. Control Panel - Scope It’s used to visualize one variable. Note that, because the update rate of these values is somehow limited (depending on the communication speed between the PC and the drive, and on the functionality of the Windows environment), the evolution of fast changing variables cannot be correctly visualized. You cannot visualize AC currents or voltages, for example. Use this tool for slow varying or steady state regime analysis. Otherwise, use the Logger utility. … In the Variable field select the desired one from the current list of variables or insert a memory location. A data memory location must be specified with the following format: type@address where type represents the data type supported by MPL: integer, long or fixed and address is the memory location address expressed in hexadecimal form. Example: fixed@0x0903 the memory contents from addresses 0x0903 and 0x904 are interpreted as a fixed data. © ElectroCraft 2013 60 MPD User Manual Select Expression to define a formula to be evaluated before being displayed. They can be selected at the moment when the control panel is defined. The Expression can be built using following operators: “+” - addition “-“ - subtraction “*” - multiply “/” - division “^” - power “(“ and “)” - parentheses The operands used for editing of an expression are: variable_name [unit] variable_name number Example: 100.5 + 5 * (Position_Command [rot] - 10.0) In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. Select the measurement unit in “Unit” section, corresponding to the selected variable type. Adjust the number of decimals by choosing in “Precision” section one of the values from the scroll list, for a convenient representation depending on values range. Note that if the selected measurement unit is “IU” (Internal Units), the decimals parameter is not used. Also for IU representations, hexadecimal format can be selected. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time period can be set in the “Time period” field. See also: The Control Panel Utility © ElectroCraft 2013 61 MPD User Manual 4.2.4. Control Panel - Double Scope It’s used to visualize two variables on the same area. Note that, because the update rate of these values is somehow limited (depending on the communication speed between the PC and the axis, and on the functionality of the Windows environment), the evolution of fast changing variables cannot be correctly visualized. You cannot visualize AC currents or voltages, for example. Use this tool for slow varying or steady state regime analysis. Otherwise, use the Logger utility. In the Variable field select the desired one from the current list of variables or insert a memory location. A data memory location must be specified with the following format: type@address where type represents the data type supported by MPL: integer, long or fixed and address is the memory location address expressed in hexadecimal form. Example: fixed@0x0903 the memory contents from addresses 0x0903 and 0x904 are interpreted as a fixed data. Select Expression to define a formula to be evaluated before being displayed. They can be selected at the moment when the control panel is defined. The Expression can be built using following operators: “+” - addition “-“ - subtraction “*” - multiply © ElectroCraft 2013 62 MPD User Manual “/” - division “^” - power “(“ and “)” - parentheses The operands used for editing of an expression are: variable_name [unit] variable_name number Example: 100.5 + 5 * (Position_Command [rot] - 10.0) In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. Select the measurement unit in “Unit” section, corresponding to the selected variable type. Adjust the number of decimals by choosing in “Precision” section one of the values from the scroll list, for a convenient representation depending on values range. Note that if the selected measurement unit is “IU” (Internal Units), the decimals parameter is not used. Also for IU representations, hexadecimal format can be selected. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time period can be set in the “Time period” field. See also: The Control Panel Utility © ElectroCraft 2013 63 MPD User Manual 4.2.5. Control Panel - Y(X) Scope Object This object is similar to the Dual-channel scope (Double Scope Object) except that you visualize one variable as function of another variable on the same area. In the Variable field select the desired one from the current list of variables or insert a memory location. A data memory location must be specified with the following format: type@address where type represents the data type supported by MPL: integer, long or fixed and address is the memory location address expressed in hexadecimal form. Example: fixed@0x0903 the memory contents from addresses 0x0903 and 0x904 are interpreted as a fixed data. Select Expression to define a formula to be evaluated before being displayed. They can be selected at the moment when the control panel is defined. The Expression can be built using following operators: “+” - addition “-“ - subtraction “*” - multiply “/” - division “^” - power “(“ and “)” - parentheses The operands used for editing of an expression are: variable_name [unit] variable_name number Example: 100.5 + 5 * (Position_Command [rot] - 10.0) © ElectroCraft 2013 64 MPD User Manual In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. Select the measurement unit in “Unit” section, corresponding to the selected variable type. Adjust the number of decimals by choosing in “Precision” section one of the values from the scroll list, for a convenient representation depending on values range. Note that if the selected measurement unit is “IU” (Internal Units), the decimals parameter is not used. Also for IU representations, hexadecimal format can be selected. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time period can be set in the “Time period” field. See also: The Control Panel Utility © ElectroCraft 2013 65 MPD User Manual 4.2.6. Control Panel - Gauge Gauge is used to indicate the value of a variable and its variation in time Horizontal gauge: used to indicate the value of a variable and its variation in time. Disposed on horizontal direction. Vertical gauge: used to indicate the value of a variable and its variation in time. Disposed on vertical direction. In the Variable field select the desired one from the current list of variables or insert a memory location. A data memory location must be specified with the following format: type@address where type represents the data type supported by MPL: integer, long or fixed and address is the memory location address expressed in hexadecimal form. Example: fixed@0x0903 the memory contents from addresses 0x0903 and 0x904 are interpreted as a fixed data. Select Expression to define a formula to be evaluated before being displayed. They can be selected at the moment when the control panel is defined. © ElectroCraft 2013 66 MPD User Manual The Expression can be built using following operators: “+” - addition “-“ - subtraction “*” - multiply “/” - division “^” - power “(“ and “)” - parentheses The operands used for editing of an expression are: variable_name [unit] variable_name number Example: 100.5 + 5 * (Position_Command [rot] - 10.0) In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. Select the measurement unit in “Unit” section, corresponding to the selected variable type. Adjust the number of decimals by choosing in “Precision” section one of the values from the scroll list, for a convenient representation depending on values range. Note that if the selected measurement unit is “IU” (Internal Units), the decimals parameter is not used. Also for IU representations, hexadecimal format can be selected. In the Min and Max edit field you can specify the minimum and the maximum values you wish to visualize. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time intervals can be selected in the “Read value at every” field. See also: The Control Panel Utility © ElectroCraft 2013 67 MPD User Manual 4.2.7. Control Panel - Slider This cursor object is used to change the value of a parameter. Horizontal cursor: is disposed on horizontal direction. Vertical cursor: is disposed on vertical direction. In the Variable field select the desired one from the current list of variables or insert a memory location. A data memory location must be specified with the following format: type@address where type represents a data type supported by MPL: int, long or fixed and address is the memory location address expressed in hexadecimal form. Type is optional if it’s not specified data is interpreted as integer. Example: fixed@0x0903 the memory contents from addresses 0x0903 and 0x904 are interpreted as a fixed data. Select Expression to define a formula to be evaluated before being displayed. They can be selected at the moment when the control panel is defined. The Expression can be built using following operators: “+” - addition “-“ - subtraction “*” - multiply “/” - division “^” - power “(“ and “)” - parentheses © ElectroCraft 2013 68 MPD User Manual The operands used for editing of an expression are: variable_name [unit] variable_name number Example: 100.5 + 5 * (Position_Command [rot] - 10.0) In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. Select the measurement unit in “Unit” section, corresponding to the selected variable type. Adjust the number of decimals by choosing in “Precision” section one of the values from the scroll list, for a convenient representation depending on values range. Note that if the selected measurement unit is “IU” (Internal Units), the decimals parameter is not used. Also for IU representations, hexadecimal format can be selected. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time intervals can be selected in the “Read value at every” field. See also: The Control Panel Utility © ElectroCraft 2013 69 MPD User Manual 4.2.8. Control Panel - Input It’s used to display the status of an input port. In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. The input number (IN#) can be selected from the current list of input ports. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time intervals can be selected in the “Read value at every” field. See also: The Control Panel Utility © ElectroCraft 2013 70 MPD User Manual 4.2.9. Control Panel - Bit Value It’s used to display the status of a bit of one MPL variable or data memory contents. The variable can be selected from the current list of variables. In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. The bit number will be selected from Bit Position . The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time intervals can be selected in the “Read value at every” field. See also: The Control Panel Utility © ElectroCraft 2013 71 MPD User Manual 4.2.10. Contrrol Panel - User U Define ed MPL Seq quence Obje ect It’s a button ha aving associatted a MPL ins structions seq quence, user--defined. You can freely f define these t instructtions. Pressin ng the button will send the e associated M MPL comman nds to the ElectrroCraft drive. See also: The Contrrol Panel Utility © ElectroC Craft 2013 72 2 MPD U User Manual 4.2.11. Control Panel - Label It’s an object defining a text or a color-filled rectangle. Define a text the main edit field. Choose the font attributes (type, color, size, etc.) by pressing the Font… button. Check Border if you want that the text window to be bordered. You can check Filled and choose the background color by pressing the Background Color…. Use such objects in order to create more specific control panels, with a better graphical appearance. See also: The Control Panel Utility © ElectroCraft 2013 73 MPD User Manual 4.2.12. Control Panel - Output It’s used to set the status of an output port. In the Axis ID edit field of each object, you can select the Axis ID of the axis from where the variable will be read/set. This will allow you to visualize in one control panel variables from different drives / motors connected into a network. The default Axis ID is “as set in Comm Setup” e.g. the Axis ID selected in the Communicate with field from Communication | Setup dialogue. The output number (OUT#) can be selected from the current list of output ports. The title of the object window (displayed in the object window title bar) can be specified in Title section. By default, if you don’t specify a title, the variable name will be assumed instead. For display purposes, display time intervals can be selected in the “Read value at every” field. See also: The Control Panel Utility © ElectroCraft 2013 74 MPD User Manual 4.2.13. Contrrol Panel Properties Use this dialog d to defin ne / change th he name of th he current Con ntrol Panel. 4.3. Comman nd Interpre eter The Command Interp preter allows you to send on-line o MPL ccommands to o your drive/m motor. You ca an use o set/get MPL L data: registe ers, paramete ers and variab bles or to disp play memory locations. this tool to You can open o the Com mmand Interpreter using th he "View | Co ommand Inte erpreter" men nu command, or by selecting the associate ed toolbar icon n . onfig the MPL commands s are sent to the drive/mottor for which the setup is performed. T This is In PROco the drive/m motor selecte ed in Communication | Se etup to comm municate with.. In Motion nPRO Develo oper, the MPL commands are sent to tthe drive/moto or with the sa ame axis ID a as the axis numb ber of the sele ected application. To find the value of a MPL M data, typ pe in the que estion mark ch haracter "?" ffollowed by th he MPL data name c intterpreter disp plays the MP PL data type e and addresss as and press the [Enter]] key. The command dress and its value in decim mal and hexa adecimal form mat. type@add MPL> ?ap pos> APOS (lo ong@0x0228 8) = 134575 54 (0x0014 488DA) MPL> s method you u can find the e type and ad ddress of anyy MPL data, iincluding the userRemark: Through this v you create in an MotionPRO Developer a application. N Note that userr-defined vari riables defined variables are acces ssible only aftter you compiile your applic cation. To set the e value of a MPL M data, type e its name followed by equ ual and the va alue, then pre ess the [Enterr] key. MPL> var r_i1=0 © ElectroC Craft 2013 75 5 MPD U User Manual With Command Interpreter you can also perform the following operations related with the drive/motor EEPROM or RAM memory: • Fill with a value all the MPL program memory locations between a start address and stop address. MPL>fillmemory 0x4000, 0x4010, 0xABCD MPL> • Fill with a value all the MPL data memory locations between a start address and stop address. MPL>filldatamemory 0x8000, 0x8010, 0x0101 MPL> • Set a MPL program memory location with specified value MPL>setmemory 0x4000, 0x0001 MPL> • Set a MPL data memory location with specified value MPL>setdatamemory 0x8000, 0x0001 MPL> • Show all the MPL program memory locations contents between a start address and stop address MPL>showmemory 0x4000, 0x4010 4000: ABCD ABCD ABCD ABCD ABCD ABCD ABCD ABCD 4008: ABCD ABCD ABCD ABCD ABCD ABCD ABCD ABCD 4010: ABCD MPL> • Show all the MPL data memory locations contents between a start address and stop address MPL>showdatamemory 0x8000, 0x8010 8000: 0101 0101 0101 0101 0101 0101 0101 0101 8008: 0101 0101 0101 0101 0101 0101 0101 0101 8010: 0101 MPL> Remarks: • The Command Interpreter memory operations are intended mainly for test and debugging. Do not use then for normal operation. Note that uncontrolled change of memory locations may lead to unexpected results. • For MPL program or data memory addresses ranges see Memory Map. © ElectroCraft 2013 76 MPD User Manual The Command Interpreter keeps a history with all commands sent. You can navigate between them with arrow keys UP and DOWN and select one to execute again. When the Command Interpreter window is closed the commands history is reset. You can access the Command Interpreter menu, by clicking on the right button mouse inside its window. The menu options are: • Undo/Redo – reverses the last edit changes done on the current command line / reverses the Undo action • Cut/Copy/Paste – cuts selected text and puts it the on clipboard/copies selected text and puts it in the clipboard/inserts text from clipboard at the insertion point in the command line • Toggle Bookmark – activates/deactivates a bookmark at the insertion point. To navigate between bookmarks use key F2. See also: Memory Map © ElectroCraft 2013 77 MPD User Manual 4.4. Binary Code C Viewe er The Binary Code View wer offers yo ou a quick wa ay to program m your host fo or exchanging g messages w with a aft drive/moto or. Through this tool, you can find how w to encapsula ate a MPL co ommand for a all the ElectroCra communic cation types and a the supp ported protoco ols. You get the both the contents of tthe message es you have to se end and the expected e answ wers from the e drive/motor,, if it is the case. ct the commu unication Prottocol betwee en: serial RS 2 232, serial RS S 485, CAN-b bus with MPL LCAN, First selec CAN-bus with ElectroC CAN or no prrotocol, just th he binary code e of the MPL commands a and answers. er select the Axis A ID of the e message sender. In the e case of RS--232, the sender is alwayss your At Sende Host, as 2 drives/mottors may nott be connected between them using RS-232. If yo ou select RS S-485, AN, the sende er can be an Axis/Host (a another Axis or your Hostt) or None. O Option MPLCAN or ElectroCA eans non-requ uested messa ages sent by the drive/mottor, containing a specific M MPL data. Yo ou can None, me simulate these t messa ages with a ?? ? query follo owed by the returned MP PL data name e and by sele ecting None. If you y select MPL, you can find the bina ary code for M MPL comman nds sent from m both the Ho ost or another axis, which in the case of RS-232 R plays the role of an n Relay Axis (see Commu unication Prottocols s) for details Remark: Though theo oretically poss sible, activatiion of non-req quested messsages is nott recommende ed for 85 where the host must control the com mmunication to o avoid confliccts. the RS-48 At Destination choose e either an Ax xis of a Group of axes. In the first case e, set the axiss ID of the recceiver. In the sec cond case, se elect a group from f 1 to 8 orr set group nu umber to 0 forr a broadcastt message. In the case of query messages asking the driive/motor to return a MP PL data, you can introducce the v in hexa adecimal form mat in the Typ pe here (hexa a) edit box. T This helps you u to quickly id dentify returned value the positio on of the returned data in the t message received. © ElectroC Craft 2013 78 8 MPD U User Manual You can simulate 2 types of query or Type B messages (see Communication Protocols for details): • A “GiveMeData: request, by typing at Source Code a question mark ? followed by a MPL data name (for example ?apos to read the actual position). In this case the answer is a “TakeData” message • A “GiveMeData2” request, by typing at Source Code a double question mark ?? followed by a MPL data name (for example ??aspd to read the actual speed). In this case the answer is a “TakeData2” message On CAN-bus, a “GiveMeData2” request may be sent to a group of drives/motors. For the returned answer you can Select an axis from the group. Remarks: • If a “GiveMeData2” request is sent to a group, the “TakeData2” answers are prioritized function of the respondents’ axis ID: the drive/motor with the lowest axis ID has the highest priority. • The “GiveMeData” request is intended only for a single axis. If in a CAN-bus network, “GiveMeData” is sent to a group, all the returned answers have the same CAN identifier and therefore can’t be differentiated, causing an error. • On RS-485, the query messages can’t be sent to group, as the answers will overlap. For simulating Type A messages, which do not request to return a data, simply type the MPL instruction at Source code. For example to set a position command CPOS of 2000 encoder counts, type cpos=2000. After you have introduced one or more commands, press to arrow button “>” to generate the code. At Binary code sent you’ll see the binary code (in hexadecimal format), which must be sent by your host. When RS-232 and RS-485 are selected, the code displayed represents the bytes you have to send via the serial asynchronous port of your host. When MPLCAN is used, the first 8 hexadecimal numbers represent the 29-bit identifier of the CAN message (the 3MSB of the 32-bit value are zero) and the remaining bytes represent, the CAN message data: byte 0, byte 1, etc. When ElectroCAN protocol is chosen, the first 3 hexadecimal numbers represents the 11-bit identifier of the CAN message (the MSB of the 12-bit value is zero). At Binary code received you’ll see the answer sent by the drive/motor. Remark: On RS-232 and RS-485 each message sent to one axis is confirmed with an acknowledge byte 4Fh. Therefore, in a query message, you’ll see first the 4Fh byte as confirmation for the reception of the data request, followed by the contents of the answer message. On RS-485, the 4Fh acknowledge byte is not sent if the command is sent to a group. See also: Communication protocols © ElectroCraft 2013 79 MPD User Manual 4.5. Memory y View In Memorry window yo ou can view/modify the co ontents of th e ElectroCra aft drive’s/mottor’s memoryy from where the e MPL program runs. ow is opened d selecting the e View | Mem mory menu co ommand or th he associated d toolbar icon n. You The windo can refres sh the display yed data by se electing the menu m comman nd View | Re efresh button or F12 key. Remark: As this feature is a very lo ow level func ction, it is NO T recommend ded to modifyy memory con ntents edge of the us se made by the t ElectroCra raft drive/moto or of each me emory locatio on you without a deep knowle m intend to modify See also: Memory Settings S © ElectroC Craft 2013 80 0 MPD U User Manual 5. Com mmunicattion 5.1. Commun nication Se etup The comm munication settings from this dialogue e define how w MotionPRO O Developer is using you ur PC serial portt or a commu unication interrface board. The T dialogue allows you to o select the co ommunication n type between your y PC and your Electro oCraft drives//motors. You can choose between: se erial RS-232, serial RS-485, CAN-bus orr Ethernet and a setup in each case the communication para ameters. Witth the S-232, all the other opttions require a specific interface. F For CAN-buss, the exception of the RS cation setting gs depend on n the interface e used. There efore the Cha annel Type llist includes a all the communic CAN-bus interfaces supported. Remark: If your PC is equipped d with anothe er CAN-bus iinterface, con ntact ElectroCraft to checck for compatibiility with one of o the interfac ces supported d When sev veral drives/m motors are connected c in a CAN-bus network you have to spe ecify the CAN N-bus communic cation protoc col used. This s option is also available for serial RS-232 and E Ethernet, whe en the drive/moto or connected to the host acts a as retran nsmission rel ay (see Com mmunication P Protocols). Att CAN Protocol you can cho oose either MPLCAN M (CA AN 2.0B, 29-b bit identifierr) or CANope en or Electro oCAN A, 11-bit iden ntifier). (CAN2.0A Remark: When the CANopen C or ElectroCAN E (CAN2.0A, ( 11 1-bit identifierr) protocol is selected the e Axis e drives/moto ors and of the PC, are interrpreted as mo odulo 32. IDs, of the Through this t dialogue you also specify the Axis IDs for your PC or in the case of RS-2 232 or Ethernet the Axis ID of o the drive/m motor connec cted with your PC. Each time you clo ose MotionPR RO Develope er, the communic cation settings are saved. Next time wh hen you open n the MotionP PRO Develope er, the last se ettings you have set are restored. © ElectroC Craft 2013 81 1 MPD U User Manual Important Note: Only a part of the ElectroCraft products supports all communication types. Make sure you select a communication type supported by your product! Remark: If you get a communication error message, select “Communication | Refresh” command or press the associated button from the toolbar to restore the communication. Note that when using serial RS-232 or RS-485 communication, MotionPRO Developer automatically sets the drives/motors with the baud rate selected in this dialogue. If a drive/motor is reset (power supply is temporary turned off), the serial communication with your PC may no longer work. This happens if the drive/motor default baud rate after reset (9600 baud) differs from that set in MotionPRO Developer. Use “Communication | Refresh” command to restore the communication. This starts the automatic baud rate detection, followed by the baud rate change to the value set in MotionPRO Developer. See also: RS-232 Communication Setup RS-232 Communication Troubleshoots RS-485 Communication Setup RS-485 Communication Troubleshoots CAN-bus Communication Setup CAN-bus Communication Troubleshoots Ethernet Communication Setup Ethernet Communication Troubleshoots User Implemented Serial Driver Setup User Implemented Serial Driver Troubleshoots Advanced Communication Setup © ElectroCraft 2013 82 MPD User Manual 5.1.1. RS-23 32 Commun nication Setup Steps to o follow: 1. Setup p the drive/motor for RS-232 communic cation 2. Set MotionPRO M Developer D for communicatio c on via RS-232 2 with the drivve/motor Step 1 Se etup the driv ve/motor for RS-232 R comm munication 1. Powe er-Off your drrive/motor 2. In orrder to use the RS-232 communicatio c on, you need d to connect your PC witth the Electro oCraft drive/motor throug gh an RS-232 2 serial cable. If the drive/m motor is equip pped with a sstandard 9-pin n DB9 connector for seriial communic cation, use a 9-wire stand ard serial ca able: male-fem male, non-invverting he drive/moto or user manua al for cable co onnections. (e.g. one-to-one), else check th 3. If the e drive/motor supports als so RS-485 co ommunication n, set the RS S-232/RS-485 switch (or solderjoint) to the positio on RS-232. 4. Powe er-On the driv ve/motor Step 2 Se et MotionPRO O Developerr for commun nication via R RS-232 with the drive/mo otor 1. Selec ct menu comm mand “Comm munication | Setup” S 2. Selec ct at “Channe el Type” RS-2 232 (default). 3. Selec ct the “CAN Protocol” between b the drives/motorrs connected in the CAN N-bus networkk, the drive/motor conne ected to PC acting a as a re etransmission n relay (see C Communicatio on Protocols)). You can choose c eitherr MPLCAN (C CAN2.0B, 29 9-bit identifie er) or CANop pen or ElectrroCAN (CAN N2.0A, 11bitt identifier). 4. Selec ct at “Port” the t serial porrt of your PC, where you have conneccted the seria al cable. By d default the selected port is COM1 5. Selec ct the desired d baud rate fro om “Baud Ra ate” list 6. Set th he “Axis ID of o the drive/m motor connec cted to PC”. The default o option is auto odetected ena abling Motio onPRO Developer to detec ct automatica ally the axis ID D of the drive e connected tto the serial p port. If your drive/motor doesn’t d suppo ort this featurre (see remarrk below) sele ect its axis ID D from the listt. The s ID is set at power p on usin ng the followin ng algorithm: drives/motors axis a. With W the value read from the e EEPROM setup s table co ontaining all th he setup data a b. If the setup tab ble is invalid, with w the last axis a ID value read from a vvalid setup table © ElectroC Craft 2013 83 3 MPD U User Manual c. If there is no axis ID set by a valid setup table, with the value read from the hardware switches/jumpers for axis ID setting d. If the drive/motor has no hardware switches/jumpers for axis ID setting, with the default axis ID value which is 255. Remark: When the ElectroCAN communication protocol is used the Axis IDs, of the drives/motors and of the PC, are interpreted as modulo 32. 7. Press the OK button If the communication works properly, you’ll see displayed on the status bar (the bottom line) of the MotionPRO Developer the text “Online”, the axis ID of the drive/motor and the firmware version read from the drive/motor. Remark: If your drive/motor firmware number: • Starts with 1 – examples: F100A, F125C, F150G, etc., or • Starts with 0 or 9 and has a revision letter below H – examples: F000F, F005D, F900C you can’t use the axis ID autodetected option. See also: RS-232 Communication Troubleshoots Advanced Communication Setup Communication Setup © ElectroCraft 2013 84 MPD User Manual 5.1.2. RS-232 Communication Troubleshoots If the serial RS232 communication does not operate properly, MotionPRO Developer will issue an error message and you’ll see displayed on the status bar (the bottom line) of the MotionPRO Developer the text “Offline”. 1. If the error message is “Cannot open the selected serial port”, the serial port you have selected from “Port” does not exist or is used by another device of your PC (mouse, modem, etc.). Click “Cancel”, reopen Communication | Setup dialogue, select another serial port and try again. 2. If the error message is “Cannot synchronize the computer and drive/motor baud rates” click “Cancel”, then check the following: • Serial cable connections • Serial cable type, if you use a standard cable. Make sure that the cable is non-inverting (one-toone) • In “Communication | Setup” dialogue, the “Axis ID of the drive/motor connected to PC is” selection. If you use MotionPRO Developer with a previously bought drive/motor, this may not support the default option “autodetected”. Select the same axis ID with that of your drive/motor. The drives/motors axis ID is set at power on using the following algorithm: a. With the value read from the EEPROM setup table containing all the setup data b. If the setup table is invalid, with the last axis ID value read from a valid setup table c. If there is no axis ID set by a valid setup table, with the value read from the hardware switches/jumpers for axis ID setting d. If the drive/motor has no hardware switches/jumpers for axis ID setting, with the default axis ID value which is 255. • Drive hardware settings for RS-232 communication (see RS-232 Setup) 3. If the communication operates usually but gives communication errors from time to time, check the following: • If your PC has an earth connection. • If your drive/motor is linked to earth. For the drives/motors without an explicit earth point, connect the earth to the ground of the supply/supplies. • In “Communication | Setup” dialogue click on the Advanced… button and increase the “Read interval timeout”, “Timeout multiplier” and “Timeout constant” parameters. Note that these parameters are related to PC serial operation and usually the default values for these parameters do not need to be modified. After you fix the problem, execute menu command “Communication | Refresh” to restore the communication. See also: RS-232 Communication Setup Advanced Communication Setup Communication Setup © ElectroCraft 2013 85 MPD User Manual 5.1.3. CAN-bus Communication Setup Steps to follow: 1. Setup the drives/motors for CAN-bus communication 2. Mount on/connect to your PC a CAN-bus interface board 3. Install on your PC an CAN-bus software driver 4. Build the CAN-bus network 5. Set MotionPRO Developer for communication via CAN-bus with the drives/motors Step 1. Setup the drives/motors for CAN-bus communication 1. Power-Off the drive/motor 2. Choose a different axis ID for each drive/motor and also different from the axis ID of PC (which is set by default at 255). The drives/motors axis ID is set at power on using the following algorithm: a. With the value read from the EEPROM setup table containing all the setup data b. If the setup table is invalid, with the last axis ID value read from a valid setup table c. If there is no axis ID set by a valid setup table, with the value read from the hardware switches/jumpers for axis ID setting d. If the drive/motor has no hardware switches/jumpers for axis ID setting, with the default axis ID value which is 255. Remarks: • If your drive/motor has no hardware switches/jumpers for axis ID setting, you must program the desired axis ID in the drive/motor setup table. You can do this operation from MotionPRO Developer – the setup part of an application, where you can select the axis ID to be saved in the drive/motor setup table from the EEPROM. Use the RS-232 communication to download the setup data. • When the ElectroCAN communication protocol is used the Axis IDs, of the drives/motors and of the PC, are interpreted as modulo 32. Step 2. Mount on your PC a CAN-bus interface board MotionPRO Developer offers the possibility to choose one of the following PC to CAN-bus interfaces: • IxxAT PC to CAN interface • Sys Tec USB to CAN interface • ESD PC to CAN interface • LAWICEL CANUSB interface • PEAK System PCAN-PCI interface • PEAK System PCAN-ISA • PEAK System PC/104 • PEAK System PCAN-USB • PEAK System Dongle interfaces © ElectroCraft 2013 86 MPD User Manual o Dongle using SPP/EPP P protocol o Dongle witth SJA chipse et using SPP//EPP protocoll o Dongle Pro o with SJA ch hipset using SPP/EPP S prottocol Step 3. In nstall on you ur PC a CAN-BUS softwarre driver In order to use a CAN N-bus interfac ce you need to t install on yyour PC the CAN-bus drivver for the ch hosen C interface, the prroducer provvides the drivver as well as the installation interface. For each CAN-bus s. You can fin nd detailed in nformation reg garding the a above interfacces and theirr installation o on the guidelines following web pages: www.ixxat.c com, www.sy ystec-electron nic.de, www..peak-system m.com, www w.esdcs.com and ww ww.canusb.com (Lawicel interface). i electronic Remarks: For the CAN-bus interfa aces from PEA AK System yyou must cop py the DLL intterface provid ded in the folderr where Motion nPRO Develo oper was insttalled. B the CAN N-bus networrk Step 4. Build Each drive e/motor manu ual shows how w to do the co onnections in n order to buil d a CAN-buss network. Step 5. Set MotionPR RO Developerr for commu unication via CAN-bus wiith the drives s/motors 1. Selec ct menu comm mand “Comm munication | Setup” S 2. Selec ct at “Channe el Type” the CAN-bus C optiion correspon nding to yourr interface. Fo or IXXAT CAN N-bus interfa ace, PEAK PCAN-ISA, PCAN-PC/10 P 04 and PEA K PCAN-Dongle interfacces press “S Select Devic ce…” button to t choose the hardware mo odel correspo onding to your device. 3. Selec ct the “CAN Protocol” P use ed by the PC to communiccate with the drives/motorrs connected in the CAN-bus network.. You can ch hoose either MPLCAN (C AN2.0B, 29--bit identifierr) or CANopen or N2.0A, 11bit identifier). ElectroCAN (CAN 4. Depending on the CAN-bus inte erface used, you y have mo ore or less ports available. Select from ““Port” evice where you y have conn nected the CA AN-bus the de Rema ark: For Sys Tec USB to o CAN interfface the port number musst be the sam me with the d device numb ber set with the device conffiguration utiliity. 5. Selec ct the CAN-bu us interface ba aud rate from m “Baud Rate”” drop list Rema ark: The baud d rate selectio on refers ONL LY to the CAN N-bus interface on the PC C. It doesn’t ch hange the CAN C baud ratte on the driives/motors. The default b baud rate on n CAN-bus fo or the Electro oCraft drives s/motors is 50 00kbps. 6. Selec ct at “Axis ID of PC is” an address for the t PC. By de efault the value proposed is 255. Atten ntion! Make sure that all the drives/motors from the network ha ave a different address. W When the CAN Nopen © ElectroC Craft 2013 87 7 MPD U User Manual or ElectroCAN communication protocol is used the Axis IDs of the drives/motors and of the PC are interpreted as modulo 32. 7. Press the OK button If the CAN interface mounted on the PC works properly, you’ll see displayed on the status bar (the bottom line) of the MotionPRO Developer the text “Online” and the axis ID of the PC. See also: CAN-bus Communication Troubleshoots Advanced Communication Setup Communication Setup © ElectroCraft 2013 88 MPD User Manual 5.1.4. CAN-bus Communication Troubleshoots If the CAN-bus communication does not operate properly, MotionPRO Developer will issue an error message and you’ll see displayed on the status bar (the bottom line) of the MotionPRO Developer the text “Offline”. 1. If the error message is “Cannot find board with selected Axis ID”, click “Cancel” button, then check the following: • CAN Baud rate selected in the Communication | Setup dialogue for the CAN-bus interface. It should be the same with the drives/motors baud rate, which is set by default at power on at 500kbps. • CAN-bus cable connections and the presence of the 120 ohms terminal resistors at the two ends of the network • If the CAN-bus supply is on • In MotionPRO Developer project, the “Axis Number” of the selected application. This should match with the Axis ID of one of the drives from the network. As e general rule, the axis number of each application must correspond with the axis ID of one drive from the network. Each drive must have a different axis ID. No drive can have the same axis ID value as that set as Axis ID of PC. • The setup of the CAN-bus interface on your PC • Drive/motor hardware settings for CAN-bus communication (see CAN-bus Setup) 2. If the error message is “Cannot load interface with PEAK SYS xxxx devices (PCAN_XXXX.DLL)”, click “Cancel” button, and then copy the file “PCAN_XXXX.DLL” from the Peak System CD (or other storage media) in the folder where MotionPRO Developer was installed. 3. If the error message is “Invalid Parameter”, click “Cancel” and check the CAN-bus interface selected in the Communication | Setup dialogue. This message occurs when the selected interface is not installed and/or configured on your PC. 4. If the communication operates usually but gives communication errors from time to time, in “Communication | Setup” click on Advanced… button and increase the Send message timeout (when present) and Receive message timeout parameters. Note that for these parameters, usually, the default values do not need to be modified. After you fix the problem, execute menu command “Communication | Refresh” to restore the communication. See also: CAN-bus Communication Setup Advanced Communication Setup Communication Setup © ElectroCraft 2013 89 MPD User Manual 5.1.5. User implemented serial driver example // Defines the entry point for the DLL application. // Make sure that shdata is a shared section (e.g. for Microsoft linker you should use: /SECTION:shdata,RWS) // This way the s_nInstances applications using this DLL variable will be globally visible to all #pragma data_seg("shdata") static int s_nInstances = 0; #pragma data_seg() HANDLE g_hSerialPort = INVALID_HANDLE_VALUE; DWORD g_nBaudRate = 0; BOOL APIENTRY DllMain( HANDLE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/ ) { switch (ul_reason_for_call) case DLL_PROCESS_ATTACH: if (s_nInstances == 0) g_hSerialPort = CreateFile( "COM1", GENERIC_READ GENERIC_WRITE, 0, // exclusive access NULL, // no security attrs OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if (g_hSerialPort == INVALID_HANDLE_VALUE) return false; © ElectroCraft 2013 90 MPD User Manual | //Initialize serial parameters DCB dcb; if (!GetCommState(g_hSerialPort, &dcb)) return false; dcb.BaudRate = g_nBaudRate = CBR_9600; dcb.ByteSize = 8; dcb.Parity = NOPARITY; dcb.StopBits = TWOSTOPBITS; // Standard flow control // setup no hardware flow control dcb.fOutxDsrFlow = 0; dcb.fDtrControl = DTR_CONTROL_DISABLE; dcb.fOutxCtsFlow = 0; dcb.fRtsControl = RTS_CONTROL_DISABLE; dcb.fDsrSensitivity = false; // setup no software flow control dcb.fInX = dcb.fOutX = 0; dcb.fBinary = true ; if (!SetCommState(g_hSerialPort, &dcb)) return false; //Set serial timeouts. ReadData and WriteData must return //in a determined period of time COMMTIMEOUTS CommTimeOuts; CommTimeOuts.ReadIntervalTimeout = 1000; CommTimeOuts.WriteTotalTimeoutMultiplier CommTimeOuts.ReadTotalTimeoutMultiplier = 700 ; = CommTimeOuts.WriteTotalTimeoutConstant CommTimeOuts.ReadTotalTimeoutConstant = 500 ; = if(!SetCommTimeouts(g_hSerialPort, &CommTimeOuts)) return false; } else //This library does not support connection sharing between applications © ElectroCraft 2013 91 MPD User Manual //If you need it, you must duplicate file handler from one process to another return false; } s_nInstances++; break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: s_nInstances--; if (s_nInstances == 0) CloseHandle(g_hSerialPort); g_hSerialPort = INVALID_HANDLE_VALUE; } break; } return true; } //must have a timeout bool __stdcall ReadData(BYTE* pData, DWORD dwBufSize, DWORD* pdwBytesRead) return ReadFile(g_hSerialPort, pData, dwBufSize, pdwBytesRead, NULL) ? true : false; } //must have a timeout bool __stdcall pdwBytesWritten) WriteData(const BYTE* pData, DWORD dwBufSize, DWORD* return WriteFile(g_hSerialPort, pData, dwBufSize, pdwBytesWritten, NULL) ? true : false; } int __stdcall GetBytesCountInQueue() // should be non-blocking, < 0 means error COMSTAT comStat; © ElectroCraft 2013 92 MPD User Manual DWORD dwComErrors; if (!ClearCommError(g_hSerialPort, &dwComErrors, &comStat)) return -1; return comStat.cbInQue; } void __stdcall PurgeQueues() PurgeComm(g_hSerialPort, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR ); } DWORD __stdcall GetCommBaudRate() return g_nBaudRate; } bool __stdcall SetCommBaudRate(DWORD nNewBaudRate) if(nNewBaudRate != g_nBaudRate) DCB dcb; if (!GetCommState(g_hSerialPort, &dcb)) return false; dcb.BaudRate = g_nBaudRate = nNewBaudRate; if (!SetCommState(g_hSerialPort, &dcb)) return false; } return true; } © ElectroCraft 2013 93 MPD User Manual 5.1.6. User Implemented Serial Driver Setup Steps to follow: 1. Implement the serial driver accordingly with the MPLcomm.dll interface 2. Setup the drive/motor for RS-232 communication 3. Set MotionPRO Developer for communication via user implemented serial driver with the drive/motor Step 1 Implement the serial driver In the main function of the dll initialize the communication channel with the serial settings implemented on the ElectroCraft drives/motors: 8 data bits, 2 stop bits, no parity, no flow control and one of the following baud rates: 9600 (default after reset), 19200, 38400, 56600 and 115200. Implement the functions for interfacing your communication driver with MPLcomm. This functions are: bool __stdcall ReadData(BYTE* pData, DWORD dwBufSize, DWORD* pdwBytesRead) bool __stdcall WriteData(const pdwBytesWritten) BYTE* pData, DWORD dwBufSize, DWORD* int __stdcall GetBytesCountInQueue() void __stdcall PurgeQueues() DWORD __stdcall GetCommBaudRate() bool __stdcall SetCommBaudRate(DWORD nNewBaudRate) where: pData Pointer to buffer from/to the data is read/wrote dwBufsize Parameter specifying the number of bytes to be read/write from/to serial port pdwBytesRead Pointer to the variable that contains the number of bytes read pdwBytesWritten Pointer to the variable that contains the number of bytes written Variable that contains the new value for serial baud rate nNewBaudRate Export the functions from the communication driver using a module-definition (.DEF) file with the following content: LIBRARY "virtRS232" DESCRIPTION 'Example of a virtual serial driver for MPLcomm.dll' EXPORTS ; Explicit exports can go here ReadData WriteData © ElectroCraft 2013 94 MPD User Manual GetBy ytesCountI InQueue Purge eQueues GetCo ommBaudRat te SetCo ommBaudRat te Step 2 Se etup the driv ve/motor for RS-232 R comm munication 1. Power-Off your drive/motor 2. In n order to use e the RS-232 2 communica ation, you nee ed to connecct your PC with the Electro oCraft drrive/motor thrrough an RS--232 serial ca able. If the drrive/motor is equipped with a standard 9-pin DB9 D connecto or for serial co ommunication n, use a 9-wiire standard serial cable: male-female,, nonin nverting (e.g. one-to-one), else check th he drive/motorr user manua al for cable co onnections. 3. If the drive/motor supports s also RS-485 communiication, set tthe RS-232/R RS-485 switcch (or older-joint) to the position RS-232. so 4. Power-On the drive/motor Step 3 Se et MotionPR RO Develope er for commu unication via a user imple emented seriial driver witth the drive/motor ommunication | Setup” 1. Select menu command “Co 2. Select User im mplemented se erial driver at “Channel Ty ype”. 3. Select the “CA AN Protocol” ” between the drives/moto ors connecte ed in the CAN N-bus networrk, the drrive/motor co onnected to PC P acting as a retransmisssion relay (ssee Commun nication Proto ocols). You Y can choo ose either MPLCAN (CAN2.0B, 29-biit identifier) or CANope en or Electro oCAN (C CAN2.0A, 11bit identifier)). 4. Specify at “Po ort” the comm munication dll you impleme ented 5. Select the desired baud rate e from “Baud d Rate” list 6. Set the “Axis ID of the drive/motor d connected c to o PC”. The d default option n is autodete ected en nabling Motio onPRO Develloper to detec ct automatica ally the axis ID of the drive e connected to the se erial port. If your y drive/mo otor doesn’t support s this fe eature (see rremark below w) select its axxis ID from the list. The drives/motors axis ID is s set at powe r on using the e following alg gorithm: om the EEPR ROM setup tab ble containing g all the setup p data a. With the value read fro b. If the setu up table is inv valid, with the e last axis ID vvalue read fro om a valid settup table c. If there is no axis ID D set by a va alid setup tab ble, with the value read ffrom the hard dware a ID setting g switches//jumpers for axis © ElectroC Craft 2013 95 5 MPD U User Manual d. If the drive/motor has no hardware switches/jumpers for axis ID setting, with the default axis ID value which is 255. Remark: When the ElectroCAN communication protocol is used the Axis IDs, of the drives/motors and of the PC, are interpreted as modulo 32. 7. Press the OK button If the communication works properly, you’ll see displayed on the status bar (the bottom line) of the MotionPRO Developer the text “Online”, the axis ID of the drive/motor and the firmware version read from the drive/motor. Remark: If your drive/motor firmware number: • Starts with 1 – examples: F100A, F125C, F150G, etc., or • Starts with 0 or 9 and has a revision letter below H – examples: F000F, F005D, F900C you can’t use the axis ID autodetected option. See also: User Implemented Serial Driver Example User Implemented Serial Driver Troubleshoots Advanced Communication Setup Communication Setup © ElectroCraft 2013 96 MPD User Manual 5.1.7. User Implemented Serial Driver Troubleshoots If the serial communication does not operate properly, MotionPRO Developer will issue an error message and you’ll see displayed on the status bar (the bottom line) of the MotionPRO Developer the text “Offline”. 1. If the error message is “The specified module could not be found”, the serial driver you have specified at “Port” does not exist or its path is not properly set. Click “Cancel”, reopen Communication | Setup dialogue, check your environment variables and try again. 2. If the error message is “Cannot synchronize the computer and drive/motor baud rates” click “Cancel”, then check the following: • Serial cable connections • Serial cable type, if you use a standard cable. Make sure that the cable is non-inverting (one-toone) • In “Communication | Setup” dialogue, the “Axis ID of the drive/motor connected to PC is” selection. If you use MotionPRO Developer with a previously bought drive/motor, this may not support the default option “autodetected”. Select the same axis ID with that of your drive/motor. The drives/motors axis ID is set at power on using the following algorithm: a. With the value read from the EEPROM setup table containing all the setup data b. If the setup table is invalid, with the last axis ID value read from a valid setup table c. If there is no axis ID set by a valid setup table, with the value read from the hardware switches/jumpers for axis ID setting d. If the drive/motor has no hardware switches/jumpers for axis ID setting, with the default axis ID value which is 255. • Drive hardware settings for RS-232 communication (see User Implemented Serial Driver Setup) 3. If the communication operates usually but gives communication errors from time to time, check the following: • If your PC has an earth connection. • If your drive/motor is linked to earth. For the drives/motors without an explicit earth point, connect the earth to the ground of the supply/supplies. • In “Communication | Setup” dialogue click on the Advanced… button and increase the “Read interval timeout”, “Timeout multiplier” and “Timeout constant” parameters. Note that these parameters are related to PC serial operation and usually the default values for these parameters do not need to be modified. After you fix the problem, execute menu command “Communication | Refresh” to restore the communication. See also: User Implemented Serial Driver Setup Advanced Communication Setup Communication Setup © ElectroCraft 2013 97 MPD User Manual 5.1.8. Advanced Communication Setup The advanced communication parameters are related to the host/PC operation. Usually, the default values for these parameters do not need to be modified. You may try to increase these parameters only if the communication works but gives errors from time to time and you have already eliminated all the other possible sources of errors. When RS-232 or RS-485 communication is used, the dialogue displayed is and the parameters have the following significance: • Read Interval Timeout – specifies the maximum time, in milliseconds, allowed to elapse between the arrival of two characters on the communications line. During a read operation, the time period begins when the first character is received. If the interval between the arrivals of any two characters exceeds this amount, the read operation is completed and any buffered data is returned. A value of zero indicates that interval time-outs are not used. • Timeout Multiplier – specifies the multiplier, in milliseconds, used to calculate the total time-out period for read operations. For each read operation, the requested number of bytes to be read multiplies this value. • Timeout Constant – specifies the constant, in milliseconds, used to calculate the total time-out period for read operations. For each read operation, this value is added to the product of the Timeout Multiplier member and the requested number of bytes. Remark: A value of zero for both the Timeout Multiplier and the Timeout Constant members indicates that total time-outs are not used for read operations. • Wait after RUN – specifies the time interval, in milliseconds, during which the MotionPRO Developer will not communicate with a drive/motor, after it sends it a Run command from MotionPRO Developer. The default values are: Read interval timeout – 1000 ms, Timeout multiplier – 700 ms, Timeout constant – 400 ms, Wait after RUN – 0 ms. When CAN-bus communication is used, the dialogue displayed is © ElectroCraft 2013 98 MPD User Manual and the parameters have the same significance: • Send message timeout – specifies the maximum time interval, in milliseconds allowed to send a message. If this time interval elapses without sending the message PROconfig/MotionPRO Developer will issue a communication error message. This parameter is available for IxxAT and ESD PC to CAN interfaces. • Receive message timeout – specifies the maximum time, expressed in milliseconds, allowed for an expected message to be received. If this interval elapses without receiving the message PROconfig/MotionPRO Developer will issue a communication error message. • Wait after RUN – same as for RS-232/RS-485 The default values are: Send message timeout – 700 ms, Receive message timeout – 700 ms, Wait after RUN – 0 ms. When Ethernet communication is used, the dialogue displayed is and the parameters significance is similar with the serial RS-232 case. The default values are: Read interval timeout – 700 ms, Wait after RUN – 0 ms. Additional communication settings can be added directly in the configuration file kernel.cfg, from the folder where PROconfig/MotionPRO Developer is installed. The following options can be added: • SYNCHRONIZATION_SLEEP_MULTIPLIER – this parameter is multiplied with the time interval required for synchronization character to be received via RS-232/RS-485. Possible values for the parameter: between 2 and 2000. The Default value is 2. • NO_TRIES – specifies how many times PROconfig/MotionPRO Developer will try to establish the communication with your drive/motor before issuing error messages. The default value is 3. • RS485_DTR – determines PROconfig/MotionPRO Developer to enable/disable the Data Terminal Ready (DTR) line during communications. The Data Terminal Ready signal is sent by the PC to RS485 communication device to indicate that the PC is ready to accept incoming transmission. Possible values for the parameter: 0 (disabled) or 1 (enabled). The default value is 1 (enabled) © ElectroCraft 2013 99 MPD User Manual • RS485_RTS – determines PROconfig/MotionPRO Developer to enable/disable the Request To Send (RTS) line. The Request To Send signals that request permission to transmit data is sent from PC to RS485 communication device. Possible values for the parameter: 0 (disabled) or 1 (enabled). The default value is 1 (enabled). In order to add this parameters open the configuration file kernel.cfg with any text editor and at the end of the file add a new section named [MPLCOMM]. Bellow the section definition, add the desired parameters in the form parameter_name = parameter_value. Save the file and restart PROconfig/MotionPRO Developer. © ElectroCraft 2013 100 MPD User Manual 5.2. Communication Protocols This section describes the communication protocols supported by the ElectroCraft Programmable drives / motors. It presents how the MPL instructions are packed into messages, for each type of communication channel. This information is particularly useful for those applications where an external device like a host implements directly one of the ElectroCraft communication protocols. In this case, the host packs the binary code of each MPL command into a message which is sent, and unpacks each message received to extract from it the data provided. Remark: An alternate way to exchange data with the ElectroCraft drives/motors is via the MPL_LIB libraries. A MPL_LIB library is a collection of high-level functions for motion programming which you can integrate in the host/master application. If the host is an industrial PC, the MPL_LIB library may be integrated in C/C++, Delphi Pascal, Visual Basic or LabVIEW applications. If the host is a programmable logic controller (PLC), a version of the MPL_LIB, compatible with the PLCopen standard for motion programming, may be integrated in the PLC IEC 61131-3 application (see ElectroCraft web page www.ElectroCraft.com for details about the MPL_LIB libraries) Depending on the drive/motor, you can use two types of communication channels: • Serial RS-232 or RS-485 • CAN-bus The serial RS-232 communication channel can be used to connect a host with one drive/motor. The serial RS-485 and the CAN-bus communication channels can be used to connect up to 32 drives/motors with a host. Remark: The RS-485 and CAN-bus protocols accept up to 255 nodes. The limitation to 32 nodes is determined by the hardware, using a conservative approach. If your application has more than 32 axes, contact ElectroCraft. Depending on your drive/motor and network characteristics, we can provide you the exact maximum number of axes you may use. When CAN-bus communication is used, any drive/motor from the network may also be connected through RS-232 or Ethernet with a host. In this case, this drive/motor: • Executes the commands received from the host via the RS-232 link • Executes the commands received from other ElectroCraft drives via the CAN-bus link • Acts like a retransmission relay also called relay axis, which: • Receives via RS-232, commands from host for another axis and retransmits them to the destination via CAN-bus • Receives via CAN-bus data requested by host from another axis and retransmits them to the host via RS-232 © ElectroCraft 2013 101 MPD User Manual The relay y axis concep pt enables a host to com mmunicate witth all the Ele ectroCraft drivves/motors frrom a CAN-bus network, usin ng a single RS-232 R or Eth hernet connecction with one e drive/motorr. There is no need erface on the host, for whic ch the CAN-b bus protocol iss completely transparent. to have a CAN-bus inte Any drive e/motor acts as a a relay ax xis when it is s connected b both on RS-2 232 and CAN N-bus, withou ut any particular setup. The only o requirem ment is to settup the addre ess for the ho ost equal witth that of the drive d via RS-232 (see Messag ge structure. Axis A ID and G Group ID for d details) connected IMPORTA ANT! MotionP PRO Develop per includes a Binary Co ode Viewer, w which helps yyou to quicklly find how to se end MPL com mmands using g one of the communicatio c on channels a and protocolss supported b by the drives/mo otors. Using th his tool, you can c get the ex xact contents of the messa ages to send as well as of those expected to be receive ed as answers s. See also: Message structure. Ax xis ID and Gro oup ID Serial com mmunication. RS-232 and RS-485 proto ocols CAN-bus communication. MPLCAN N protocol CAN-bus communication. ElectroCA AN protocol © ElectroC Craft 2013 10 02 MPD U User Manual 5.2.1. Message Structure. Axis ID and Group ID The data exchange on any communication bus and protocol is done using messages. Each message contains one MPL instruction to be executed by the receiver of the message. Apart from the binary code of the MPL instruction attached, any message includes information about its destination: an axis (drive/motor) or group of axes. This information is grouped in the Axis/Group ID Code. Depending on the communication bus and the protocol used, the Axis/Group ID Code and the binary code of the MPL instruction attached are encapsulated in different ways. Information included in a communication message The first word Axis/Group ID Code identifies the destination axis or the group of axes that must receive the message. The next words represent the codification of the MPL instruction transmitted. The Axis/Group ID Code is a 16-bit word with the following structure: Where: Bit 0 – HOST bit. 0 – relay axis, 1 – host. When a host is connected with a drive using RS-232, the 2 devices must have the same axis ID (bits ID7-ID0 are identical). The HOST bit makes the difference between the host and the drive connected to the other end. On RS-485, the host and the drives have different axis ID, the HOST bit has as no significance and must be set to 0. Bits 11-4 – ID7-ID0: the 8-bit value of an axis ID or group ID Bit 12 – GROUP bit: 0 – ID7-ID0 value is an axis ID, 1 – ID7-ID0 value is a group ID Depending on the communication bus and protocol used, either the entire 16-bit Axis/Group ID code is included in a message or only a part of it. This part can be the 10 bits with useful information: HOST bit, ID7 – ID0 bits and the GROUP bit or a subset of those. Remark: In the following paragraphs, the terminology Axis ID Code or Group ID Code designates the above 16-bit word. The terminology Axis ID and Group ID designates the 8-bit value of an axis or group ID i.e. value of bits ID7 – ID0. The following example describes how the HOST bit is used: Let’s suppose that we have 2 drives with the axis ID=1 and axis ID=2 (values 1 and 2 represent the value of the bits ID7-ID0) connected between them via CAN-bus. The host is connected via RS-232 to the drive with axis ID=1 which acts as a relay axis. The host axis ID (host ID) must also be 1 but with the HOST bit set. The host sends a data request message to the drive with the axis ID=2. The axis ID code of this request message is 2 e.g. the destination axis. The message includes the sender axis ID code e.g. where the drive with ID=2 must send the data requested. The sender axis ID code is the host address (ID=1 and the HOST bit set). The request message is sent via RS-232 to drive with axis ID=1. This drive observes that the message destination is another axis (e.g. ID=2) and resends the message via CAN-bus. The drive with the axis ID=2, will receive the request message and send the answer via CAN-bus to the sender axis (e.g. host). © ElectroCraft 2013 103 MPD User Manual As the host has the same address as the relay axis, all the messages sent via CAN-bus and having as destination the host are received by the relay axis. The relay axis looks at the HOST bit: if the bit is set, then the message received is sent back via RS-232 to the host. If the HOST bit is not set, then the message received is executed (it’s destination is the relay axis). A message can be sent to an axis or to a group of axes. In the first case, the destination is specified via an Axis ID code. In the second case, the destination is specified via a Group ID code. Each drive/motor has its own 8-bit Axis ID and Group ID stored in the AAR MPL register. If the destination of a message is specified via an Axis ID code, the message is received only by the axis with the same 8-bit Axis ID (bits 11-4 from the 16-bit Axis ID code). If the destination of a message is specified via a Group ID code, each axis compares the 8-bit group ID from the message with its own group ID. If the two group IDs have at least one group (bit set to 1) in common, the message is accepted. In the group ID, each bit corresponds to one group: Definition of the groups A drive/motor can be programmed to be member of up to 8 groups. It will accept all the messages sent to any of the groups his is member. For example, if the drive is member of groups 1, 2 and 4, i.e. its 8-bit Group ID = 11 (00001011b), it will receive all the messages which have in their group ID value at least one of the bits 0,1 or 3 set to 1. Remarks: • A message with axis ID = 0 and will be accepted independently of the receiver axis ID • A broadcast message has the group ID = 0 and will be accepted by all the axes from the network, independently of their group ID On each drive/motor, the axis ID is initially set at power on using the following algorithm: a. With the value read from the EEPROM setup table containing all the setup data. b. If the setup table is invalid, with the last axis ID value read from a valid setup table c. If there is no axis ID set by a valid setup table, with the value read from the hardware switches/jumpers for axis ID setting d. If the drive/motor has no hardware switches/jumpers for axis ID setting, with the default axis ID value which is 255. Remark: If the axis ID read from a valid setup table is 0 (option H/W), the axis ID is set with the value read from the hardware switches/jumpers or in their absence with the default value 255 © ElectroCraft 2013 104 MPD User Manual On each drive/motor, at power on, the group ID is set to 1. group 1. For each drive/motor you can: i.e. all drives/motors are members of the • Set/change its group ID using the MPL instruction GROUPID • Add new groups to its group ID using the MPL instruction ADDGRID • Remove groups from its group ID using the MPL instruction REMGRID. Remark: You can read at any moment the actual values of the axis ID and group ID of a drive/motor from the Axis Address Register AAR The MPL instruction code can have 1 to 5 words. All the MPL instructions have at least one word – the Operation Code. Depending on the type of MPL instruction, the operation code may be followed by 0-4 Data words. Remark: Use Binary Code Viewer to get the binary code of MPL instructions See also: Communication protocols – Overview Serial communication. RS-232 and RS-485 protocols CAN-bus communication. MPLCAN protocol CAN-bus communication. ElectroCAN protocol © ElectroCraft 2013 105 MPD User Manual 5.2.2. Serial communication. RS-232 and RS-485 protocols All the ElectroCraft drives/motors can communicate via RS-232. Some of them also accept RS-485 as a substitute for RS-232. In the following paragraphs, the terminology serial communication refers to the features common to both RS-232 and RS-485. The terminology RS-232 communication or RS-485 communication is used to features that are specific for one or the other. The RS-232 communication is point-to point, full duplex, and enables you to link 2 devices. A typical example is when you connect your PC with a ElectroCraft drive/motor. Use the RS-232 communication if you want to: a) Setup and/or program the motion on one drive/motor using a ElectroCraft development platform like PROconfig or MotionPRO Developer, running on your PC b) Control a drive/motor, with commands sent via communication from your host c) Setup and/or program the motion on several drives/motors connected via CAN-bus, where one is also connected via RS-232 with your PC d) Control several drives/motors connected via CAN-bus, with commands sent from your host which is connected via RS-232 with one of them In cases c) and d), the ElectroCraft drive/motor connected to the host acts as a relay axis (see Communication protocols overview for details). The RS-485 communication is multi-point, half duplex, and enables you to link up to 32 drives/motors in a network. In an RS-485 network, at one moment only one device is allowed to send data. If two devices start by mistake to transmit in the same time, both transmissions are corrupted. Therefore for a correct operation, in an RS-485 network it is mandatory to have a master, which controls the transmission. Put in other words, only the master can initiate a transmission, while all the other devices from the network may transmit only when the master asks them to provide some data. Normally you should set as master your host. Use the RS-485 communication if you want to: a) Setup and/or program the motion on several drives/motors connected via RS-485 together with your PC (requires an RS-485 interface or an RS-232/RS-485 adapter on your PC) b) Control several drives/motors connected via RS-485, with commands sent from your host. The host is seen as one node of the RS-485 network, and in must act as a master. Remark: If the absence of a host, you can use any drive as master to control the RS-485 communication. This is possible due to the powerful set of MPL commands for multiple axes (see Motion – Data Transfer Between Axes) Serial communication settings and message encapsulation The ElectroCraft drives communicate serially using 8 data bits, 2 stop bits, no parity at the following baud rates: 9600 (default after reset), 19200, 38400, 56600 and 115200. The messages exchanged through serial communication are encapsulated in the following format: © ElectroCraft 2013 106 MPD User Manual Serial message structure – MPL Instruction encapsulation The message length byte contains the total number of bytes of the message minus 2. Put in other words, the length byte value is the number of bytes of the: Axis/group ID Code (2bytes), the Operation Code (2 bytes) and the Data words (variable from 0 to 8 bytes). The Checksum byte is the sum modulo 256 of all the bytes of the message except the checksum byte itself. Message types on serial communication The serial communication protocol is based on 3 types of messages imposed by the nature of the MPL commands encapsulated: • Type A: Messages that don’t require an answer (a return message). These messages can be sent either by a host or by another drive/motor and contain MPL instructions performing parameter settings, motion programming, motor commands, etc. • Type B: Messages that require an answer. These messages are sent by a host and contain one of the on line MPL commands. These commands ask to return data, for example the value of a MPL parameter, register, or variable. • Type C: Messages sent by a drive/motor to a host without being requested by the host. These messages may be sent either when a specific condition occurs or following the execution of the MPL command SEND (see Messages sent to the host for details) The next paragraphs present an example of each message type. © ElectroCraft 2013 107 MPD User Manual Example 1 – Type A Message: A host is connected to a drive/motor via RS-232 and sends the MPL instruction “KPP = 5” (set proportional part of the position controller with value 5). The axis ID of host and of the drive/motor are 255 = 0FFh. The Axis ID code and the MPL instruction binary code are: Axis ID code + Binary code of MPL Instruction KPP = 5 sent to axis 255 Remark: Use Binary Code Viewer to get the binary code of MPL instructions The host must send a serial message with the following contents: Serial message: MPL Instruction KPP = 5 sent to axis 255 The drive/motor will return a byte 0x4F as confirmation that the message was received OK. (See below the RS-232 and RS-485 protocols description for details) Remarks: a) If another drive with axis ID=1 is connected via CAN-bus with the drive having axis ID=255 and the host wants to sent the same MPL instruction “KPP = 5” to axis 1, the Axis ID Code becomes 0010h instead of 0FF0h. b) If the host is connected via RS-485 with a drive, the 2 devices must have different axis ID values. For example if the host axis ID = 255 and the drive ID = 1, the message is the same as in remark a) © ElectroCraft 2013 108 MPD User Manual Example 2 – Type B Message: M A host is conne ected to a drivve via RS-23 32 and wants to get the va alue of ( oller) parametter from the d drive. KPP ad ddress in MPL L data the KPP (proportional term of the position contro memory is 025Eh. The T ID of the host and the drive/mo otor are 255 5 = 0FFh. T The host sen nds a Data” reques st and the drive/motor ans swers with a “TakeData”” message. L Let’s suppose “GiveMeD e that the KPP value v returned d by the drive e/motor is 288 8 (120h). Remark: Use Comma and Interprete er to get MPL L data addressses. A “GiveM MeData” request message for a MPL da ata includes th he following information: “GiveMeData “ a” request forr a MPL data – Message d description The “TakeData” answ wer message includes the following f inforrmation: keData” answ wer - Messag ge description n “Tak In the parrticular case of o this example, the axis ID D code and th e binary code e of “GiveMe eData” are: Axis ID code e + Binary cod de of “GiveM MeData” requ est for KPP vvalue sent to a axis 255 The axis ID I code and the t binary cod de of ”TakeD Data” are: Axis ID D Code + Bina ary code of “TakeData” w with KPP valu ue from axis 2 255 © ElectroC Craft 2013 10 09 MPD U User Manual The host must send a “GiveMeData” request message with the following contents: Serial message: “GiveMeData” request for KPP value sent to axis 255 The drive/motor will return a byte 0x4F as confirmation that the message was received OK (See below the RS-232 and RS-485 protocols description for details), then the “TakeData” answer message with the following contents: Serial message: “TakeData” with KPP value from axis 255 Remarks: a) If another drive with axis ID=1 is connected via CAN-bus with the drive having axis ID=255 and the host wants to get KPP value from axis 1, the Axis ID Code becomes 0010h instead of 0FF0h in the “GiveMeData” message. The “Take Data” message also will have 0010h in instead of 0FF0h as Sender Axis ID Code. b) If the host is connected via RS-485 with a drive, the 2 devices must have different axis ID values. For example if the host has axis ID = 255 and the drive has axis ID = 1, the modifications compared with the above examples are: · “GiveMeData”: Axis ID Code – 0010h instead of 0FF0h and Sender Axis ID Code – 0FF0 instead of 0FF1h (Host bit = 0); · “TakeData”: Axis ID Code – 0FF0h instead of 0FF1h (Host bit = 0) and Sender Axis ID Code – 0010h instead of 0FF0h; © ElectroCraft 2013 110 MPD User Manual Example 3 – Type C Message: A host is connected to a drive via RS-232 and wants to be informed when the programmed motion is completed. The axis ID of the host and the drive/motor are 255 = 0FFh. A Type C message is a “TakeData2” message sent without a “GiveMeData2” request. It includes the following information: “TakeData2” - Message description The destination axis is provided by the MPL variable MASTERID, according with formula: MASTERID = host axis ID * 16 + 1. In this example, the 8-bit host axis ID = 255, hence MASTERID = 16 * 255 + 1 = 4081 (0xFF1). In the case of a Type C message, the “TakeData2” can return: • The 32-bit value of the 2 status registers SRL (bits 15-0) and SRH (bits 31-16), if one of their selected bits changes (the requested data address is the SRL address) • The 16-bit value of the error register MER, if one of its selected bits changes • The 16-bit value of the PVT/PT status PVTSTS, if PVT/PT buffer status changes • The 16-bit or 32-bit MPL data requested to be sent with the MPL command SEND. Remark: Use Command Interpreter to get the addresses for the above MPL data. Note that the SRL and SRH status registers may also be accessed as a single 32-bit variable named SR32. The bit selection is done via 3 masks, one for each register, set in MPL parameters: SRL_MASK, SRH_MASK, MER_MASK. A bit set in a mask, enables a message transmission when the same bit from the corresponding register changes. In this example, the motion complete condition is signaled by setting SRL.10 = 1. To activate automatic sending of a “TakeData2” whenever SRL.10 changes, set SRL_MASK = 0x0400. If SRH = 0x201 and SRL = 0x8400, after SRL.10 goes from 0 to 1, the host gets a “TakeData2” message with the following contents: © ElectroCraft 2013 111 MPD User Manual Serial message: “TakeData2” with status registers SRL and SRH from axis 255 Remark: A “TakeData2” message with SRL.10=1 signals that the last programmed motion is completed. A “TakeData2” message with SRL.10=0 signals that a new motion has started and may be used as a confirmation for the last motion command. RS-232 communication protocol The RS-232 protocol is full duplex, allowing simultaneous transmission in both directions. After each command (Type A or B) sent by the host, the drive will confirm the reception by sending one acknowledge-Ok byte. This byte is: ‘O’ (ASCII code of capital letter “o”, 0x4F). If the host receives the ‘O’ byte, this means that the drive has received correctly (checksum verification was passed) the last message sent, and now is ready to receive the next message. Remark: If the destination axis for the message is not the axis connected with the host via RS-232 (e.g. the relay axis), but another axis connected with the relay axis via CAN-bus, the reception of the acknowledge-Ok byte from the relay axis doesn’t mean that the message was received by the destination axis, but just by the relay axis. Depending on the CAN-bus baud rate and the amount of traffic on this bus, the host may need to consider introducing a delay before sending the next message to an axis connected on the CAN-bus. This delay must provide the relay axis the time necessary to retransmit the message via CAN-bus. If any error occurs during the message reception, for example the checksum computed by the drive axis doesn’t match with the one sent by the host, the drive will not send the acknowledge-Ok byte. If the host doesn’t receive any acknowledge byte for at least 2ms after the end of the checksum byte transmission, this means that at some point during the last message transmission, one byte was lost and the synchronization between the host and the relay axis is gone. In order to restore the synchronization the host should do the following: 1) Send a SYNC byte having value 0x0d (higher values are also accepted) 2) Wait a programmed timeout (typically 2ms) period for an answer; 3) If the drive sends back a SYNC byte having value 0x0d, the synchronization is restored and the host can send again the last message, else go to step 1 4) Repeat steps 1 to 3 until the drive answers with a SYNC byte or until 15 SYNC bytes are sent. If after 15 SYNC bytes the drive/motor still doesn’t answer, then there is a serious communication problem and the serial link must be checked © ElectroCraft 2013 112 MPD User Manual When a host sends a type A message through RS-232 it has to: a) Send the message (as in Example 1); b) Wait the acknowledge-OK byte ‘O’ from the drive; When a host sends a type B message through RS-232 it has to: a) Send the request message (as in Example 2 in case of a “Give Me Data” command) b) Wait the acknowledge-OK byte ‘O’ from the drive connected via RS-232 (relay axis); c) Wait the answer message from the drive/motor (as in Example 2, in case of a “Take Data” answer) When the relay axis returns an answer message it doesn’t expect to receive an acknowledge byte from the host. It is the host task to monitor the communication. If the host gets the response message with a wrong checksum, it is the host duty to send again the data request. RS-485 communication protocol The RS-485 protocol is half duplex. If two devices start by mistake to transmit in the same time, both transmissions are corrupted. Therefore for a correct operation, in an RS-485 network it is mandatory to have a master, which controls the transmission. This means that only the master can initiate a transmission, while all the other devices from the network may transmit only when the master asks them to provide some data. Usually you should set as master your host. After each command (Type A or B) sent by the host to one drive, the drive will confirm the reception by sending one acknowledge-Ok byte. This byte is: ‘O’ (ASCII code of capital letter “o”, 0x4F). If the host receives the ‘O’ byte, this means that the drive has received correctly (checksum verification was passed) the last message sent, and now is ready to receive the next message. The acknowledge-Ok byte is not sent when the host broadcasts a message to a group of drives. If any error occurs during the message reception, for example if the checksum computed by the drive axis doesn’t match with the one sent by the host, the drive will not send the acknowledge-Ok byte. If the host doesn’t receive any acknowledge byte for at least 2ms after the end of the checksum byte transmission, this means that at some point during the last message transmission, one byte was lost and the synchronization between the host and the relay axis is gone. In order to restore the synchronization the host should do the following: 1) Send 15 SYNC bytes having value 0x0d or any other bigger value up to 0xFF 2) Wait a programmed timeout (typically 2ms); 3) Send again the last command and wait for the drive answer 4) If the drive still doesn’t answer, then there is a serious communication problem and the serial link must be checked When a host sends a type A message through RS-485 it has to: a) Send the message (as in Example 1); b) Wait the acknowledge-OK byte ‘O’ from the drive, only if the message destination was a single drive; When a host sends a type B message through RS-485 it has to: a) Send the request message (as in Example 2 in case of a “Give Me Data” command) © ElectroCraft 2013 113 MPD User Manual b) Wait the acknowledge-OK byte ‘O’ from the drive; c) Wait the answer message from the drive/motor (as in Example 2, in case of a “Take Data” answer) Remarks: • When using the RS-485 protocol, do not send Type B request messages to a group of axes, because the answer messages will overlap • When using the RS-485 protocol, the Type C messages must be suppressed. Only the host/master is allowed to initiate a transmission When a drive returns an answer message it doesn’t expect to receive an acknowledge byte from the host. It is the host task to monitor the communication. If the host gets the response message with a wrong checksum, it is the host duty to send again the data request. See also: Communication protocols – Overview CAN-bus communication. MPLCAN protocol CAN-bus communication. ElectroCAN protocol Message structure. Axis ID and Group ID © ElectroCraft 2013 114 MPD User Manual 5.2.3. CAN-b bus commu unication. ElectroCAN E protocol ElectroCA AN is an alte ernate protoc col to MPLCA AN – the deffault CAN-bu us protocol fo or the Electro oCraft drives/mo otors without CANopen. ElectroCAN E was w specifica ally designed d to permit connection o of the ElectroCra aft drives/mo otors without CANopen on n a CANopen n network wh here messages are excha anged using CAN Nopen protoc col. ElectroCA AN and CANo open do not d disturb each o other and therefore can co o-exist on the sam me physical bus. b On request, the Electro oCraft drives//motors witho out CANopen may be delivvered with Ele ectroCAN pro otocol. en the drives/motors with MPLCAN M pro otocol and tho ose with ElecctroCAN proto ocol is The differrence betwee done only y through the firmware: all the ElectroC Craft products equipped with ElectroCA AN have a firm mware number starting s with 2 i.e. a firmw ware code is F2xxY, wherre 2xx is the firmware num mber and Y is the firmware revision. r ElectroCA AN is based on CAN2.0A A using 11 bits for the ide entifier. It acccepts the following baud rates: 125kb, 25 50kb, 500kb (default afte er reset), 80 00kb and 1M Mb. Like MP PLCAN, ElecttroCAN offerrs the possibility y to connect a PC via a serial RS-232 link to any d drive/motor frrom the CAN Nopen networrk and through itt to access all a the Electro oCraft drives/motors. In th his case, this drive/motor connected bo oth to CAN-bus and RS-232 becomes a re elay axis (see e Communica ation protocolss – Overview w for details) In ElectroCAN the MPL L instructions are split into 8 categories : a) Norm mal – includes s all the MPL instructions i addressed a to a single drive e/motor (axis) b) TakeD Data – includes the answe er “TakeData”” to the reque est “GiveMeDa ata” c) Group – includes all a the MPL in nstructions mu ulticast to a g group of drives/motors d) Host – includes the answers to all the other on line MPL ccommands exxcept “TakeD Data” e) PVT – includes the e instruction PVTP P (the ins struction is to long to be se ent as a normal message) f) Synchronization – includes the e synchroniza ation message e for the grou up 0 g) Broad dcast – inclu udes all the MPL instructtions addresssed to the grroup 0 (to the all drives in the system m) except the e request Give eMeData. h) TakeD Data2 – includes the answ wers “TakeData2” to the re quest “GiveM MeData2” Each cate egory is mapp ped in the folllowing range of COB-ID (C Communication Object Ide entifier – CAN Nopen terminolog gy for a CAN message ide entifier): © ElectroC Craft 2013 115 MPD U User Manual ElectroCA AN uses only COB-IDs outside of the ra ange used byy CANopen. Thus, Electro oCAN protoco ol and CANopen n protocol can n co-exist and d communicatte simultaneo ously on the ssame physical CAN bus, w without disturbing g each other. The next table t shows how h ElectroCAN COB-IDs are assigned d in relation w with the CANo open COB-IDss. © ElectroC Craft 2013 116 MPD U User Manual CANOpen C and d ElectroCAN N COB-IDs Remarks: In comparis son with MPLC CAN, TechoC CAN has the ffollowing resttrictions: • The e maximum number n of axe es is 31: poss sible Axis ID vvalues: 1 to 3 31 • The e maximum number n of gro oups is 5: pos ssible Group IID values: 1 to o5 © ElectroC Craft 2013 117 MPD U User Manual Normal messages encapsulation: COB-ID: 121h – 13Fh Host messages encapsulation: COB-ID: 141h – 15Fh Remark: Host messages occur only when a drive/master answers to a data request (other then “GiveMeData”) where the Sender Axis ID has the HOST bit set to 1. This happens for example when the host is a PC connected to one of the drives/motors via RS-232 and asks a data from another drive/motor. The answer will be sent to the relay axis as a Host message. The Host messages do not occur when the request is sent by a drive or by a host/master connected directly on the CAN bus. © ElectroCraft 2013 118 MPD User Manual Take Data messages encapsulation: COB-ID: 161h – 17Fh Remarks: In the Take Data messages, the 10-byte code of the Take Data MPL instruction is compacted to 8-bytes. This is done in the following way: • From the 16-bit Operation Code, only the first 10LSB are transmitted. The 6MSB are always constant: 0x2D (101101b) and are not transmitted. The receiver of a Take Data message must add 0x2D on the 6MSB of the Operation Code received in order to restore the full 16-bit code for TakeData instruction. • The HOST bit is transmitted in bit 2 of byte 1. There is no need to send the GROUP bit because the GiveMeData request can’t be sent to a group of drives/motors. • The first data word of the TakeData MPL instruction is the Sender Axis ID. As the maximum number of drives is limited to 31, only bits 8-4 are useful and are transmitted. © ElectroCraft 2013 119 MPD User Manual Group messages encapsulation: COB-ID: 001h – 01Fh PVT messages encapsulation: COB-ID: 041h – 05Fh Remarks: In the PVT messages, the 10-byte code of the PVT MPL instruction is compacted to 8-bytes. This is done in the following way: • The Operation Code is not transmitted. The receiver of a PVT message adds 0x6 on the 9MSB of the Operation Code received and the Counter value on the 7LSB in order to restore the full 16-bit code for PVT instruction. • The first data word of the PVT instruction contains the 15LSB of the 24 bits Position • The second data word of the PVT instruction contains the 8LSB of the 24 bits Speed value and the 8 MSB of the 24 bits Position value. • The third data word of the PVT instruction contains the 16MSB of the 24 bits Speed value. • The fourth data word of the PVT instruction contains the 9bits Time value. © ElectroCraft 2013 120 MPD User Manual Synchronization messages encapsulation: COB-ID: 020h Remarks: • The message has zero data bytes • The Operation Code is 0x1000 • The synchronization messages are broadcast messages; they are received by every drive connected to the network Broadcast messages encapsulation: COB-ID: 200h © ElectroCraft 2013 121 MPD User Manual Take Data 2 messages encapsulation: COB-ID: 101h – 11Fh Remarks: • The message will be never receive by one of the ElectroCraft drive, the message is dedicate for other drives. • The COB-ID contains the Expeditor Axis ID for the host to get the answers one by one, prioritized in the ascending order of the expeditors’ axis ID. • The VT bit specifies the data length (VT = 0 for 16bits or VT = 1 for 32 bits) and is transmitted in the first byte sent. • The P bit specifies if the message is TakeData2, in reply to a GiveMeData2 message, or a PONG, in reply to a PING message. The PING message is a broadcast message that requests the Axis ID and the firmware version of the drives in the network. For P=0 the message is Take Data2 and for P = 1 the message is a PONG (the VT bit is automatically reset and it has no meaning). Example 1: A host connected on a CANopen network sends to drive/motor with axis ID = 5 the MPL instruction “KPP = 0x1234” (set proportional part of the position controller with value 0x1234). The Axis ID Code and the MPL instruction binary code are: Binary code of MPL instruction KPP =0x1234 Remark: Use Binary Code Viewer to get the binary code of MPL instructions © ElectroCraft 2013 122 MPD User Manual The host must send a ElectroCAN message with the following contents: ElectroCAN message: MPL instruction KPP =0x1234 sent to axis 5 Remark: The last 4 bytes are not used and are not transmitted Example 2: A host connected on a CANopen network wants to get the value of the position error from the drive/motor with the axis ID=5. The host axis ID is 3. The position error is the 16-bit MPL variable named POSERR and its address in the MPL data memory is 0x022A. The host sends to axis 5 a “GiveMeData” request for the MPL variable POSERR and waits for the “TakeData” answer. The Axis ID Code and the binary code of “GiveMeData” request for POSERR are: Binary code of GiveMeData request for POSERR value sent to axis 5 © ElectroCraft 2013 123 MPD User Manual The host must send a ElectroCAN message with the following contents: ElectroCAN message: GiveMeData request for POSERR value sent to axis 5 Remark: The last 2 byes are not used and are not transmitted. Supposing that the drive/motor with Axis ID = 5 returns a position error POSERR = 2, the Axis ID Code and the binary code of the “TakeData” answer is: Binary code of TakeData with POSERR value from axis 5 © ElectroCraft 2013 124 MPD User Manual The host gets a ElectroCAN message with the following contents: ElectroCAN message: TakeData with POSERR value from axis 5 Remark: The last 2 byes are not used and are not transmitted. Example 3: A PVT command is sent to the drive with the axis ID 5 like following: pvtp -1000L, -10, 500U, 0 (set the coordinates for the next point the position at -1000 IU = 0,5 rot = FFFC18h, the speed at -10IU = 300 rpm = FFF600 and the time 500IU = 0,5s = 01F4 ). Binary code of PVT command sent to axis 5 © ElectroCraft 2013 125 MPD User Manual The ElectroCAN message sent has the following contents: ElectroCAN message: PVT command for axis 5 Example 4: If a ElectroCraft drive/motor receives the MPL instruction SETSYNC 20, it becomes the synchronization master and starts sending every 20ms a synchronization message and its time to the all drives connected in the CAN bus network. At a moment the master time has the value 0x246C46F and the code of MPL instruction is the following: Binary code of Set Master Time command sent to all axes The ElectroCAN messages are: • The synchronization message that when it is received by everybody specifics time variables are saved. ElectroCAN message: Synchronization command for all axes Remark: The last 8 bytes are not used and are not transmitted. • The master broadcast messages with the command to the slaves to set the master time © ElectroCraft 2013 126 MPD User Manual ElectroCAN message: Set Master Time command to all axes Example 5: If for example the axis 2 encounters a control error, the drive sends a message with the value of the error register MER (0x0008) with a TakeData2 instruction which has the following content: Binary code of TakeData 2 with MER register value from axis 2 Remark: The VT bit is set to zero The ElectroCAN message sent has the following contents: ElectroCAN message: TakeData2 command from axis 2 Remark: The last 3 byes are not used and are not transmitted. See also: Communication protocols – Overview Message structure. Axis ID and Group ID Serial communication. RS-232 and RS-485 protocols CAN-bus communication. MPLCAN protocol © ElectroCraft 2013 127 MPD User Manual 5.2.4. CAN-bus communication. MPLCAN protocol Most of the ElectroCraft drives/motors can communicate via CAN-bus. The CAN-bus communication is multi-point, half duplex, and enables you to link up to 32 drives/motors in a network. The major advantage of the CAN-bus is its capability to solve automatically the conflicts. On a CAN-bus network, if two devices start to transmit in the same time, one of them (having the higher priority) always wins the network access and completes the transmission. The other device, after losing the network access, commutes from transmission to reception, receives the message with the higher priority, then tries again to transmit its own message. All this procedure is done automatically by the hardware (CANbus controller) and it is transparent at higher levels. Put in other words, one can work with a CAN-bus network like being full duplex, knowing that if transmission conflicts occur, these are automatically solved. ElectroCraft drives/motors have been specifically designed to exploit the CAN-bus benefits. For example, in multi-axis applications you can really distribute the intelligence between the master and the drives/motors. Instead of trying to command each step of an axis movement, you can program the drives/motors using MPL to execute complex tasks and inform the master when these are done. Thus for each axis the master task may be reduced at: calling MPL functions (with possibility to abort their execution if needed) and waiting for a message, which confirms the execution. If needed, the drives/motors may also be programmed to send periodically information messages to the master so it can monitor a task progress. Depending on product, ElectroCraft drives/motors are delivered either with MPLCAN protocol or with CANopen. On request, the MPLCAN protocol, which is based on CAN2.0B, may be replaced with ElectroCAN protocol which is based on CAN2.0A. ElectroCAN was specifically designed to permit connection of the ElectroCraft drives/motors without CANopen on a CANopen network where messages are exchanged using CANopen protocol. ElectroCAN and CANopen do not disturb each other and therefore can co-exist on the same physical bus. Message encapsulation in MPLCAN protocol MPLCAN is based on CAN2.0B using 29 bits for the identifier. It accepts the following baud rates: 125kb, 250kb, 500kb (default after reset), 800kb and 1Mb. The message destination (an axis or a group of axes) and the MPL instruction binary code are encapsulated as follows: CAN message identifier of a message sent to: Axis Group Broadcast © ElectroCraft 2013 128 MPD User Manual CAN mes ssage data by ytes: Message types on CA AN-bus comm munication The CAN N-bus commu unication is based b on 3 types t of messsages impossed by the n nature of the MPL command ds encapsulatted: • Type T A: Mess sages that do on’t require an a answer (a return messsage). These messages ca an be sent s either by b a host orr by another drive/motor and contain n MPL instru uctions perfo orming parameter p setttings, motion n programming, motor com mmands, etc. • Type T B: Mess sages that req quire an answ wer. These m messages are sent by a host and contain one of o the on line MPL comma ands. These commands c assk to return d data, for exam mple the value of a MPL M paramete er, register, or o variable. • Type C: Messages sent by y a drive/moto or to a host w without being g requested b by the host. T These messages m may y be sent eith her when a specific s condittion occurs o or following th he execution of the MPL M command d SEND (see Messages sent s to the ho ost for detailss) p an exa ample of each h message tyype. The next paragraphs present © ElectroC Craft 2013 12 29 MPD U User Manual Example 1 – Type A Message: A host connected on CAN-bus sends to drive/motor with axis ID = 5 the MPL instruction “KPP = 0x1234” (set proportional part of the position controller with value 0x1234). The MPL instruction binary code are: Binary code of MPL instruction KPP =0x1234 Remark: Use Binary Code Viewer to get the binary code of MPL instructions The CAN message identifier is: CAN message identifier: MPL instruction KPP =0x1234 sent to axis 5 The host must send a CAN message with the following contents: CAN message: MPL instruction KPP =0x1234 sent to axis 5 Example 2 – Type B Message: A host wants to get the position error of 2 drives/motors, which are members of group 1. The host axis ID is 3 and the drives/motors axis ID are 5 and 7. The position error is the 16-bit MPL variable named POSERR and its address in the MPL data memory is 0x022A. The host sends to group 1 a “GiveMeData2” request for the MPL variable POSERR and waits for the “TakeData2” answers. The Group ID Code and the binary code of “GiveMeData2” request for POSERR are: Binary code of GiveMeData2 request for POSERR value sent to group 1 The CAN message identifier is: CAN message identifier: GiveMeData2 request for POSERR value sent to group 1 © ElectroCraft 2013 130 MPD User Manual The host must send a CAN message with the following contents: CAN message: GiveMeData2 request for POSERR value sent to group 1 Supposing that the drive/motor with Axis ID = 5 returns a position error POSERR = 2, the binary code of the “TakeData2” answer is: Binary code of TakeData2 with POSERR value from axis 5 The CAN message identifier is: CAN message identifier: TakeData2 with POSERR value from axis 5 The host gets a CAN message with the following contents: CAN message: TakeData2 with POSERR value from axis 5 Supposing that the drive/motor with Axis ID = 7 returns a position error POSERR = 1, the binary code of the “TakeData2” answer is: Binary code of TakeData2 with POSERR value from axis 7 © ElectroCraft 2013 131 MPD User Manual The CAN message identifier is: CAN message identifier: TakeData2 with POSERR value from axis 7 The host gets a CAN message with the following contents: CAN message: TakeData2 with POSERR value from axis 7 Example 3 – Type C Message: A host is connected to a drive via CAN-bus and wants to be informed when the programmed motion is completed. The host axis ID = 255 and the drive/motor axis ID = 1. A Type C message is a “TakeData2” message sent without a “GiveMeData2” request. It includes the following information: “TakeData2” – Message description The destination axis is provided by the MPL variable MASTERID, according with formula: MASTERID = host axis ID * 16 + 1. In this example, the 8-bit host axis ID = 255, hence MASTERID = 16 * 255 + 1 = 4081 (0xFF1). In the case of a Type C message, the “TakeData2” can return: • The 32-bit value of the 2 status registers SRL (bits 15-0) and SRH (bits 31-16), if one of their selected bits changes (the requested data address is the SRL address) • The 16-bit value of the error register MER, if one of its selected bits changes • The 16-bit value of the PVT/PT status PVTSTS, if PVT/PT buffer status changes • The 16-bit or 32-bit MPL data requested to be sent with the MPL command SEND. Remark: Use Command Interpreter to get the addresses for the above MPL data. Note that the SRL and SRH status registers may also be accessed as a single 32-bit variable named SR32. The bit selection is done via 3 masks, one for each register, set in MPL parameters: SRL_MASK, SRH_MASK, MER_MASK. A bit set in a mask, enables a message transmission when the same bit from the corresponding register changes. In this example, the motion complete condition is signaled by setting © ElectroCraft 2013 132 MPD User Manual SRL.10 = 1. To activate automatic sending of a “TakeData2” whenever SRL.10 changes, set SRL_MASK = 0x0400. Supposing that the drive/motor with Axis ID = 1 returns SRH = 0x201 and SRL = 0x8400, after SRL.10 goes from 0 to 1, the Axis ID Code and the binary code of the “TakeData2” message is: Axis ID Code + Binary code of TakeData2 with status registers SRL and SRH from axis 1 The CAN message identifier is: CAN message identifier: TakeData2 with status registers SRL and SRH from axis 1 The host gets a CAN message with the following contents: CAN message: TakeData2 with status registers SRL and SRH from axis 1 Remark: A “TakeData2” message with SRL.10=1 signals that the last programmed motion is completed. A “TakeData2” message with SRL.10=0 signals that a new motion has started and may be used as a confirmation for the last motion command. See also: Communication protocols – Overview CAN-bus communication. ElectroCAN protocol Message structure. Axis ID and Group ID Serial communication. RS-232 and RS-485 protocols © ElectroCraft 2013 133 MPD User Manual 6. Application Programming 6.1. Motion Programming – drives with built-in Motion Controller One of the key advantages of the ElectroCraft drives/motors is their capability to execute complex motions without requiring an external motion controller. This is possible because ElectroCraft drives offer in a single compact package both a state of art digital drive and a powerful motion controller. Programming motion on a ElectroCraft drive/motor means to create and download a MPL (ElectroCraft Motion Program Language) program into the drive/motor memory. The MPL allows you to: • Set various motion modes (profiles, PVT, PT, electronic gearing or camming, etc.) • Change the motion modes and/or the motion parameters • Execute homing sequences • Control the program flow through: o Conditional jumps and calls of MPL functions o MPL interrupts generated on pre-defined or programmable conditions (protections triggered, transitions on limit switch or capture inputs, etc.) o Waits for programmed events to occur • Handle digital I/O and analogue input signals • Execute arithmetic and logic operations • Perform data transfers between axes • Control motion of an axis from another one via motion commands sent between axes • Send commands to a group of axes (multicast). This includes the possibility to start simultaneously motion sequences on all the axes from the group • Synchronize all the axes from a network With MPL, you can really distribute the intelligence between the master and the drives/motors in complex multi-axis applications. Thus, instead of trying to command each step of an axis movement, you can program the drives/motors using MPL to execute complex tasks and inform the master when these are done. Thus for each axis the master task may be reduced at: calling MPL functions (with possibility to abort their execution if needed) and waiting for a message, which confirms the execution. If needed, the drives/motors may also be programmed to send periodically information messages to the master so it can monitor a task progress. A MPL program includes a main section, followed by the subroutines used: functions, interrupt service routines and homing procedures. The MPL program may also include cam tables used for electronic camming applications. When you select the “Motion” part of an application, you access the main section of your application MPL program. © ElectroCraft 2013 134 MPD User Manual You can select the other components of a MPL program too. Each has 2 types of access views: • Definition and/or selection view, with the following purposes: o Homing modes: select the homing procedure(s) to use from a list of already defined procedures. o Functions: create new MPL functions (initially void) and manipulate those defined: delete, rename, change their order in the program o Interrupts: choose the MPL interrupt service routines you want to view/change their default implementation o Cam Tables: create new cam tables loaded from other applications or imported from text files and manipulate those defined: select those to be downloaded and their order, delete or rename. • Edit view – for editing the contents. There is one edit view for each homing procedure and cam table selected, for each function defined and each interrupt chosen for view/edit. In order to help you create a MPL program, MotionPRO Developer includes a Motion Editor which is automatically activated when you select “M Motion” – the main section view or an edit view for a homing procedure, function or interrupt service routine. The Motion Editor adds a set of toolbar buttons in the project window just below the title bar. Each button opens a programming dialogue. When a programming dialogue is closed, the associated MPL instructions are automatically generated. Note that, the MPL instructions generated are not a simple text included in a file, but a motion object. Therefore with Motion Editor you define your motion program as a collection of motion objects. The major advantage of encapsulating programming instructions in motion objects is that you can very easily manipulate them. For example, you can: • Save and reuse a complete motion program or parts of it in other applications • Add, delete, move, copy, insert, enable or disable one or more motion objects • Group several motion objects and work with bigger objects that perform more complex functions The Motion Editor includes the following programming dialogues: Motion Programming and control Trapezoidal Profiles S-curve Profiles PT PVT External Electronic Gearing Electronic Camming Motor Commands Position Triggers Homing Contouring © ElectroCraft 2013 135 MPD User Manual Test © ElectroCraft 2013 136 MPD User Manual Events Programming Event Types When the actual motion is complete Function of motor or load position Function of motor or load speed After a wait time Function of reference Function of inputs status Function of a variable value Jumps and Function Calls I/O Handling Assignment & Data Transfer 16-bit Integer Data 32-bit Integer Data Arithmetic Operations Multiple Axis Data Transfer Send to Host Miscellaneous commands Interrupt Settings Free Text Editor See also: Motion View Homing Procedures View Functions View Interrupts View Cam Tables View © ElectroCraft 2013 137 MPD User Manual 6.1.1. Motion Programming Toolbars The top toolbar contains the buttons associated to motion programming dialogues. The “Motion – Trapezoidal Profiles“allows you to program a positioning path described through a series of points. Each point specifies the desired Position and Time, i.e. contains a PT data. Between the points the built-in reference generator performs a linear interpolation. The “Motion – S-curve Profiles” allows you to program a position profile with an S-curve shape of the speed. This shape is due to the jerk limitation, leading to a trapezoidal or triangular profile for the acceleration and an S-curve profile for the speed. The “Motion - PT” allows you to program an arbitrary profile whose contour is described by a succession of linear segments. The “Motion – PVT” allows you to program a positioning path described through a series of points. Each point specifies the desired Position, Velocity and Time, i.e. contains a PVT data. Between the points the built-in reference generator performs a 3rd order interpolation The “Motion – External” allows you to program the drives/motors to work with external reference provided by another device. The “Motion – Electronic Gearing” dialogue allows you to set the drives as master or a slave for electronic gearing mode. The “Motion – Electronic Camming” dialogue allows you to set the drives as master or a slave for electronic camming mode. The “Motor Commands” allows you to apply one of following commands to the motor: activate/deactivate the control loops and the power stage PWM output commands (AXISON / AXISOFF), stop the motor with acceleration/deceleration set, change the value of the motor position and position reference. The “Motion – Position Triggers” dialogue allows you to define 4 position trigger points. The “Motion – Homing” dialogue allows you choose a homing procedure and set its parameters. © ElectroCraft 2013 138 MPD User Manual The “Motion - Contouring” allows you to program an arbitrary contour via a series of points. Between the points, linear interpolation is performed, leading to a contour described by a succession of linear segments. The "Test" dialogue allows you to set the drives/motors in a special test configuration. The “Events” allows you to define an event to be monitored and to perform several actions. The “Jumps and Function Calls” allows you to control the MPL program flow through unconditional or conditional jumps and unconditional, conditional or cancelable calls of MPL functions. The “I/O” allows you program operations with the digital inputs and outputs of the drives/motors. The “16-bit Integer Data” helps you to program an assignment operation through which you can set the value of a 16-bit variable or set a memory location with a 16-bit immediate value or the value of a 16bit variable. The “32-bit Long or Fixed Data” helps you to program an assignment operation through which you can set the value of a 32-bit variable, set the low part (16LSB) or the high part (16MSB) of a 32-bit variable with a 16-bit value / variable value, set a memory location with a 32-bit immediate value or the value of a 32-bit variable. The “Arithmetic Operations” helps you to program one of the arithmetic operations accepted by the MPL (ElectroCraft Motion Program Language): addition, subtraction, product or shifting. The “Data Transfer Between Axis” helps you to program the data transfer operations between drives that are connected in a network. The “Send Data to Host” dialogue allows you to choose what information is sent by the drive automatically. You can send information about status register, error register or variables. The “Miscellaneous” dialogue allows you to declare new variables, reset FAULT status, insert a END instruction, insert an NOP instruction, set the baud rates for the Serial Communication Interface (SCI) used for RS-232 and RS-485, set the baud rates for the CAN communication. © ElectroCraft 2013 139 MPD User Manual The “MPL Interrupt Settings” allows you to activate and/or deactivate the MPL (ElectroCraft Motion Program Language) interrupts The “Free text” opens a dialogue where you can freely insert comments or MPL instructions in the current position. Once the parameters have been entered, a "motion sequence" is created. Such a sequence represents a macro-instruction to which one or more specific MPL instructions correspond. The MotionPRO Developer automatically generates the MPL code for these motion sequences. The right toolbar contains buttons used for the motion sequences management. Insert. Allows you choose a new motion sequence to be inserted. - Motion. Trapezoidal Profiles. This command allows you to program a position or speed profile with a trapezoidal shape of the speed, due to a limited acceleration. S-Curve Profiles. This command allows you to program a positioning with a limited jerk. In an S-curve mode, the acceleration profile is trapezoidal and the speed profile is like an S-curve. PT The command allows to program a positioning with path described through a set of points, for each point you specify PVT. This command allows you to program a positioning described through a series of points, each point includes the desired position, the speed and the time at which the position is to be reached. The user points are interpolated using third order polynomials. External. This command allows you to set the drives working with an external reference provided by another device. Electronic Gearing. This command dialogue allows you to set the drives as master or a slave for electronic gearing mode. Electronic Camming. This command dialogue allows you to set the drives as master or a slave for electronic camming mode. Motor Commands. This command allows you to apply one of following commands to the motor: activate/deactivate the control loops and the power stage PWM output commands (AXISON / AXISOFF), stop the motor with acceleration/deceleration set, change the value of the motor position and position reference Position Triggers. This command opens the dialogue where you define the triggering values for each trip point. Homing Contouring. This command allows you to program an arbitrary profile whose contour is described by a succession of linear segments © ElectroCraft 2013 140 MPD User Manual Test. This command dialogue allows you to set up the drives in a special test configuration. - Events. This command allows you to define an event (a condition) to be monitored and to perform several actions. - Jumps and Function Calls. This command allows you program the operations related with the control of the program flow. - I/O. This command allows you program operations with the digital inputs and outputs of the drives - Assignment & Data Transfer 16-bit Integer Data. This command helps you to program an assignment operation through which you can set the value of a 16-bit variable or set a memory location with a 16-bit immediate value or the value of a 16-bit variable. 32-bit Long or Fixed Data. This command helps you to program an assignment operation through which you can set the value of a 32-bit variable, set the low part (16LSB) or the high part (16MSB) of a 32-bit variable with a 16-bit value / variable value, set a memory location with a 32-bit immediate value or the value of a 32-bit variable. Arithmetic Operations. This command helps you to program one of the arithmetic operations accepted by the MPL (ElectroCraft Motion Program Language): addition, subtraction, product or shifting. Data Transfer Between Axes. This command helps you to program the data transfer operations between drives that are connected in a network. Send Data to Host. This command allows you to choose what information is sent by the drive automatically. You can send the status register (low part - SRL and high part - SRH), error register (MER) or the value of a variable. Miscellaneous. This command opens the dialogue from where you can declare new variables and insert FAULTR, END, NOP, SPI and SCI instructions. - Interrupt Settings. This command allows you to activate and/or deactivate the MPL interrupts. - Free text. This command opens a dialogue where you can freely insert a sequence of MPL instructions in the current position in the Motion Editor window. Edit. Pressing this button, the dialogue associated with the selected motion sequence opens, allowing changing the motion parameters. Duplicate. Duplicate the selected motion sequence. Move Down. Moves down the selected motion sequence. © ElectroCraft 2013 141 MPD User Manual Move Up. Moves up the selected motion sequence. Delete. Delete the selected motion sequence. Group. The button allows you to group the selected motion sequences in a new object containing all the selected motion objects. You can give a name or title to the grouped object. This embedding process can be performed in consecutive steps. Any grouped object is displayed with a leading [+] symbol. Click on the [+] symbol to expand the grouped object content to the next embedding level. The leading [+] symbol transforms into a leading [-] symbol. Click the [-] symbol to group back the expended object. Successive embedded levels are accepted. Ungroup. Use the “Ungroup” command to restore the motion objects list instead of the group object. Enable. For debugging, you have the possibility to remove motion sequences (one or more motion objects) from the motion program like commenting lines in a text program. Use the the “Enable” button to uncomment / enable motion sequences. Disable. For debugging, you have the possibility to remove motion sequences (one or more motion objects) from the motion program like commenting lines in a text program. Use the “Disable” button to comment / disable motion sequences. Import. Use the “Import” button to load/insert motion objects previously saved in *.msq files. These are appended below the current position e.g. the immediately after the selected motion object. Export. You can select a part of your program (one or more motion objects) and save it in a separate motion file, using the "Export" button. The operation saves the selected motion objects in a file with extension *.msq. See also: Motion programming Toolbars for Multi-axis motion controller © ElectroCraft 2013 142 MPD User Manual 6.1.2. Motion Trapezoidal Profile The “Motion – Trapezoidal Profiles” dialogue allows you to program a position or speed profile with a trapezoidal shape of the speed, due to a limited acceleration. In the position profile, the load/motor is controlled in position. You specify either a position to reach in absolute mode or a position increment in relative mode, plus the slew (maximum travel) speed and the acceleration/deceleration rate. In relative mode, the position to reach can be computed in 2 ways: standard (default) or additive. In standard relative mode, the position to reach is computed by adding the position increment to the instantaneous position in the moment when the command is executed. In the additive relative mode, the position to reach is computed by adding the position increment to the previous position to reach, independently of the moment when the command was issued. During motion, you can change on the fly the position command, the slew speed and the acceleration/deceleration rate. In the speed profile, the load/motor is controlled in speed. You specify the jog speed (speed sign specifies the direction) and the acceleration/deceleration rate. The load/motor accelerates until the jog speed is reached. During motion, you can change on the fly the slew speed and the acceleration/deceleration rate. You can switch at any moment between position and speed profiles or to any of these from another motion mode. IMPORTANT: Some setup configurations foresee a transmission ratio between the motor and the load. In these cases, the load position and speed are different from the motor position and speed. The motion parameters refer always to the load trajectory. Choose Position to program a position profile. Select positioning mode Relative or Absolute. For relative positioning, check Additive to add the position increment to the position to reach set by the previous motion command. Set the values of the Acceleration rate and the Slew speed. Select the measuring units from the lists on the right. In the absolute positioning mode, set the value of the Position to reach. In the relative positioning, set the value of the Position increment. Remark: The position profile option is available only if the drive/motor is setup to perform position control. © ElectroCraft 2013 143 MPD User Manual Choose Speed to program a speed profile. Set the values of the Acceleration rate and the Jog speed. Select the measuring units from the lists on the right. Remark: Speed profile option is active if the drive/motor is setup to perform speed control or position control with speed loop closed. Once set, the trapezoidal profile parameters are memorized. If you intend to use the same values as previously defined for the acceleration rate, the slew or jog speed, the position increment or position to reach you don’t need to set their values again in the following trapezoidal profiles. Use the checkboxes on the left to uncheck those parameters that remain unchanged. When a parameter is unchecked, you don’t need to give it a value. Remark: The additive mode for relative positioning is not memorized and must be set each time a new additive relative move is set. Select Generate new trajectory starting from actual values of position and speed reference if you want the reference generator to compute the motion profile starting from the actual values of the position and speed reference. Use this option for example if successive standard relative moves must be executed and the final target position should represent exactly the sum of the individual commands. Select Generate new trajectory starting from actual values of load/motor position and speed if you want the reference generator to compute the motion profile starting from the actual values of the load/motor position and speed. When this option is used, at the beginning of each new motion profile, the position and speed reference are updated with the actual values of the load/motor position and speed. Use this option for example if during a motion an external input triggers a stop on a precise position relative to the trigger point. Another situation to use this option is at recovery from an error or any other condition that disables the motor control while the motor is moving. Updating the reference values leads to a “glitch” free recovery because it eliminates the differences that may occur between the actual load/motor position/speed and the last computed position/speed reference (before disabling the motor control). Remark: In open loop control of steppers, this option is ignored because there is no position and/or speed feedback. Choose Execute Immediate to start the programmed motion immediately when the motion sequence is executed. Check Then wait until motion is completed if you want to postpone the start of the following motion until this programmed motion is completed. Remark: Verify the motion complete condition parameters. If these are incorrectly set, you may never reach the motion complete condition: • POSOKLIM – the settle band tolerance, expressed in internal position units • TONPOSOK – the stabilize time, expressed in internal time units • UPGRADE.11: 1 = uses the above parameters, 0 = sets motion complete when the reference generator has completed the trajectory and has arrived to the commanded position If these parameters have not been set previously, check their default value. Reset the drive/motor and using the command interpreter get their value. Choose Execute On event to start this new motion when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want only to set the motion parameters without starting the execution. © ElectroCraft 2013 144 MPD User Manual OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: Trapezoidal Position Profiles – MPL Programming Details Trapezoidal Speed Profiles – MPL Programming Details Trapezoidal Position Profiles – Related MPL Instructions and Data Trapezoidal Speed Profiles – Related MPL Instructions and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 145 MPD User Manual 6.1.3. Motion S-Curve Profile The “Motion – S-curve Profiles” dialogue allows you to program a position profile with an S-curve shape of the speed. This shape is due to the jerk limitation, leading to a trapezoidal or triangular profile for the acceleration and an S-curve profile for the speed. In the S-curve profile, the load/motor is controlled in position. You specify either a position to reach in absolute mode or a position increment in relative mode, plus the slew (maximum travel) speed, the maximum acceleration/deceleration rate and the jerk rate. An S-curve profile must begin when load/motor is not moving. During motion the parameters should not be changed. Therefore when executing successive S-curve commands, you should wait for the previous motion to end before setting the new motion parameters and starting next motion. During an S-curve execution, you can switch at any moment to another motion mode (except PVT and PT interpolated modes) or stop the motion with a STOP command. I IMPORTANT: Some setup configurations foresee a transmission ratio between the motor and the load. In these cases, the load position and speed are different from the motor position and speed. The motion parameters refer always to the load trajectory. Choose the option Relative to program a relative positioning or Absolute for an absolute positioning. Set the values of the Jerk, Acceleration rate and the Slew speed. Select the measuring units from the lists on the right. In the absolute positioning mode, set the value of the Position to reach. In the relative positioning, set the value of the Position increment. Remarks: • The reference generator actually uses the jerk time to compute the profile. This is computed as the ratio between the acceleration rate and the jerk rate you provided and must be a positive integer number, in internal time units. If the jerk value is too low, the jerk time may be zero. In this case you’ll get the error message “Jerk parameter must be greater than zero!” • The S-curve requires the drive/motor to be setup for position control. Otherwise, in the Motion view, the button opening this dialogue will not occur. © ElectroCraft 2013 146 MPD User Manual Select Decelerate at STOP command with a limited jerk if you want a smooth deceleration, using an S-curve speed profile in case of a STOP command. Select Decelerate at STOP command in shortest time if you want a faster deceleration, using a trapezoidal speed profile in case of a STOP command. Choose Execute Immediate to start the programmed motion immediately when the motion sequence is executed. Check Then wait until motion is completed if you want to postpone the start of the following motion until this programmed motion is completed. If the next motion is an S-curve too, checking this option is mandatory. Remark: Verify the motion complete condition parameters. If these are incorrectly set, you may never reach the motion complete condition: • POSOKLIM – the settle band tolerance, expressed in internal position units • TONPOSOK – the stabilize time, expressed in internal time units • UPGRADE.11: 1 = uses the above parameters, 0 = sets motion complete when the reference generator has completed the trajectory and has arrived to the commanded position If these parameters have not been set previously, check their default value. Reset the drive/motor and using the command interpreter get their value. Choose Execute On event to start this new motion when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want only to set the motion parameters without starting the execution. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: S-Curve Profiles – MPL Programming Details S-Curve Profiles – Related MPL Instructions and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 147 MPD User Manual 6.1.4. Motion PT The “Motion – PT” dialogue allows you to program a positioning path described through a series of points. Each point specifies the desired Position and Time, i.e. contains a PT data. Between the points the builtin reference generator performs a linear interpolation. In the PT mode the load/motor is controlled in position. A PT sequence must begin when load/motor is not moving. The PT mode is typically used together with a host, which sends PT points via a communication channel. Due to the interpolation, the PT mode offers the possibility to describe arbitrary position contours using a reduced number of points. It is particularly useful when the motion reference is computed on the fly by the host, like for example, in vision systems. By reducing the number of points, both the computation power and the communication bandwidth needed are substantially reduced optimizing the costs. When the PT motion mode is used simultaneously with several drives/motors having the time synchronization mechanism activated, the result is a very powerful multi-axis system that can execute complex synchronized moves. Upon reception, each PT point is stored in a reception buffer. The reference generator empties the buffer as the PT points are executed. The drive/motor automatically sends warning messages when the buffer is full, low or empty. The buffer full condition occurs when the number of PT points in the buffer is equal with the buffer size. The buffer low condition occurs when the number of PT points in the buffer is less or equal with a programmable value. The buffer empty condition occurs when the buffer is empty and the execution of the last PT point is over. Remarks: • The PT buffer size is programmable and if needed can be substantially increased. By default it is set to 7 PT points. • The buffer low condition is set by default when the last PT point from the buffer is read and starts to be executed • After the execution of the last PT point from a sequence the drive/motor keeps the last reference position, waiting for the next PT commands. • The PT mode requires the drive/motor to be setup for position control. Otherwise, in the Motion view, the button opening this dialogue will not occur. The “Motion – PT” dialogue was specifically created to help you quickly evaluate, in advance, a PT sequence of points. The included graphical plot shows you the interpolated trajectory allowing you to check the results. Moreover, you can execute the whole sequence of PT points and check your application behavior before implementing the PT handshake on your host. © ElectroCraft 2013 148 MPD User Manual You can introduce the PT points in 2 ways: • One by one, by setting for each point its Position and Time values. Both are relative to the beginning of the PT motion. Select the measuring units from the list on the right. The graphical tool included, will automatically update the evolution of the position after each point change. A red spot, indicates the active point. Use buttons: Remove, Update, Insert, << and >> to navigate between the PT points and modify them. • With Import From File to insert a set of PT points previously defined. The file format is a simple text with 2 columns separated by space or tabs representing from left to right: position and time values. The number of rows gives the number of PT points Check Host address and set your PC/host address if the drive/motor is connected via CANbus with your host. The host address is where the PT messages regarding buffer status are sent. Remark: By default, the host address is initialized with the same value as the drive/motor address, plus the host bit set. This causes to send the PT messages via RS-232 link. Check Clear PT Buffer to erase all the previously stored points from the PT buffer. Use this option each time when you initiate a new PT motion. Uncheck this option if the execution of the PT points was interrupted and you want to resume the execution of the remaining points. Select Generate new trajectory starting from actual values of position and speed reference if you want the reference generator to compute the PT motion path starting from the actual value of the position © ElectroCraft 2013 149 MPD User Manual reference (the speed reference is always considered zero). Select Generate new trajectory starting from actual values of load/motor position and speed if you want the reference generator to compute the PVT motion starting from the actual value of the load/motor position. When this option is used, the position and speed reference are updated with the actual values of the load/motor position and speed. Use this option for example at recovery from an error or any other condition that disables the motor control while the motor is moving. Updating the reference values leads to a “glitch” free recovery because it eliminates the differences that may occur between the actual load/motor position/speed and the last computed position/speed reference (before disabling the motor control). Remark: In open loop control of steppers, this option is ignored because there is no position and/or speed feedback. Choose Execute Immediate to start the programmed motion immediately when the motion sequence is executed. Check Then wait until motion is completed if you want to postpone the start of the following motion until this programmed motion is completed. Remark: Verify the motion complete condition parameters. If these are incorrectly set, you may never reach the motion complete condition: • POSOKLIM – the settle band tolerance, expressed in internal position units • TONPOSOK – the stabilize time, expressed in internal time units • UPGRADE.11: 1 = uses the above parameters, 0 = sets motion complete when the reference generator has completed the trajectory and has arrived to the commanded position If these parameters have not been set previously, check their default value. Reset the drive/motor and using the command interpreter get their value. Choose Execute On event to start this new motion when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: PT – MPL Programming Details PT – Related MPL Instructions and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 150 MPD User Manual 6.1.5. Motion PVT The “Motion – PVT” dialogue allows you to program a positioning path described through a series of points. Each point specifies the desired Position, Velocity and Time, i.e. contains a PVT data. Between the points the built-in reference generator performs a 3rd order interpolation. In the PVT mode the load/motor is controlled in position. A PVT sequence must begin when load/motor is not moving and must end with a last PVT point having velocity zero. The PVT mode is typically used together with a host, which sends PVT points via a communication channel. Due to the 3 rd order interpolation, the PVT mode offers the possibility to describe complex position contours using a reduced number of points. It is particularly useful when the motion reference is computed on the fly by the host, like for example, in vision systems. By reducing the number of points, both the computation power and the communication bandwidth needed are substantially reduced optimizing the costs. When the PVT motion mode is used simultaneously with several drives/motors having the time synchronization mechanism activated, the result is a very powerful multi-axis system that can execute complex synchronized moves. Upon reception, each PVT point is stored in a reception buffer. The reference generator empties the buffer as the PVT points are executed. The drive/motor automatically sends warning messages when the buffer is full, low or empty. The buffer full condition occurs when the number of PVT points in the buffer is equal with the buffer size. The buffer low condition occurs when the number of PVT points in the buffer is less or equal with a programmable value. The buffer empty condition occurs when the buffer is empty and the execution of the last PVT point is over. Remarks: • The PVT buffer size is programmable and if needed can be substantially increased. By default it is set to 7 PVT points. • The buffer low condition is set by default when the last PVT point from the buffer is read and starts to be executed • The normal end of a PVT sequence means: buffer empty condition and velocity zero of the last PVT point executed. If the velocity is not zero, the drive/motor enters in quick stop mode and stops using the quick stop deceleration rate. • The PVT mode requires the drive/motor to be setup for position control. Otherwise, in the Motion view, the button opening this dialogue will not occur. When PVT mode is used, a key factor for getting a correct positioning path is to set correctly the distance in time between the points. Typically this is 10-20ms, the shorter the better. If the distance in time between the PVT points is too big, the 3rd order interpolation may lead to important variations compared with the desired path. The “Motion – PVT” dialogue was specifically created to help you quickly evaluate, in advance, the results of the 3rd order interpolation applied to your data. The included graphical plot shows you the interpolation results for both position and speed reference allowing to check if with the data provided the results are correct. Moreover, you can execute the whole sequence of PVT points and check your application behavior before implementing the PVT handshake on your host. © ElectroCraft 2013 151 MPD User Manual You can introduce the PVT points in 2 ways: • One by one, by setting for each point its Position, Velocity and Time values. Both Position and Time values are relative to the beginning of the PVT motion. Select the measuring units from the list on the right. The graphical tool included, will automatically update the evolution of the position and speed after each point change. A red spot, indicates the active point. Use buttons: Remove, Update, Insert, << and >> to navigate between the PVT points and modify them. • With Import From File to insert a set of PVT points previously defined. The file format is a simple text with 3 columns separated by space or tabs representing from left to right: position, velocity and time values. The number of rows gives the number of PVT points Check Host address and set your PC/host address if the drive/motor is connected via CANbus with your host. The host address is where the PVT messages regarding buffer status are sent. Remark: By default, the host address is initialized with the same value as the drive/motor address, plus the host bit set. This causes to send the PVT messages via RS-232 link. Check Clear PVT Buffer to erase all the previously stored points from the PVT buffer. Use this option each time when you initiate a new PVT motion. Uncheck this option if the execution of the PVT points was interrupted and you want to resume the execution of the remaining points. Select Generate new trajectory starting from actual values of position and speed reference if you want the reference generator to compute the PVT motion path starting from the actual value of the © ElectroCraft 2013 152 MPD User Manual position reference (the speed reference is always considered zero). Select Generate new trajectory starting from actual values of load/motor position and speed if you want the reference generator to compute the PVT motion starting from the actual value of the load/motor position. When this option is used, the position and speed reference are updated with the actual values of the load/motor position and speed. Use this option for example at recovery from an error or any other condition that disables the motor control while the motor is moving. Updating the reference values leads to a “glitch” free recovery because it eliminates the differences that may occur between the actual load/motor position/speed and the last computed position/speed reference (before disabling the motor control). Remark: In open loop control of steppers, this option is ignored because there is no position and/or speed feedback. Choose Execute Immediate to start the programmed motion immediately when the motion sequence is executed. Check Then wait until motion is completed if you want to postpone the start of the following motion until this programmed motion is completed. Remark: Verify the motion complete condition parameters. If these are incorrectly set, you may never reach the motion complete condition: • POSOKLIM – the settle band tolerance, expressed in internal position units • TONPOSOK – the stabilize time, expressed in internal time units • UPGRADE.11 1 = uses the above parameters, 0 = sets motion complete when the reference generator has completed the trajectory and has arrived to the commanded position If these parameters have not been set previously, check their default value. Reset the drive/motor and using the command interpreter get their value. Choose Execute On event to start this new motion when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want only to set the motion parameters without starting the execution. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: PVT – MPL Programming Details PVT – Related MPL Instructions and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 153 MPD User Manual 6.1.6. Motion External The “Motion - External” dialogue allows you to program the drives/motors to work with an external reference provided by another device. There are 3 types of external references: • Analogue – read by the drive/motor via a dedicated analogue input (10-bit resolution) • Digital – computed by the drive/motor from: Pulse & direction signals Quadrature signals like A, B signals of an incremental encoder • Online – received online via a communication channel from a host and saved in a dedicated MPL variable Select Analogue if the external reference is an analogue signal. This signal is interpreted as a: • Position reference, if the drive/motor was setup for position control • Speed reference, if the drive/motor was setup for speed control • Current/torque reference, if the drive/motor was setup for torque control Remark: Check the drive/motor setup for the correspondence between the analogue input voltage and the reference values. In position control, check Limit maximum speed at and set a desired value, if you want to avoid mechanical shocks by limiting the maximum speed at sudden changes of the position reference. In speed © ElectroCraft 2013 154 MPD User Manual control, check Limit maximum acceleration at and set a desired value, if you want a smoother transition at sudden changes of the speed reference. In torque control, check Update torque in fast loop if you want to read the analogue input at each fast loop sampling period. When unchecked, the analogue input is read at each slow loop sampling period. Select Digital if the external reference is provided as pulse & direction or quadrature encoder signals. In either case, the drive/motor performs a position control with the reference computed from the external signals. Check Set/Change gear ratio if you want to follow the external position reference with a different ratio than 1:1. Set the desired Slave / Master ratio. Remarks: • A 1:3 ratio means that the actual position reference TPOS is 1/3 of the external reference. • Due to an automatic compensation procedure, the actual position reference is computed correctly without cumulating errors, even if the ratio is an irrational number like 1: 3 Select Online if an external device sends the reference via a communication channel. Depending on the Control Mode chosen, the external reference is saved in one of the MPL variables: • EREFP, which becomes the position reference if the Control Mode selected is Position • EREFS, which becomes the speed reference if the Control Mode selected is Speed • EREFT, which becomes the torque reference if the Control Mode selected is Torque • EREFV, which becomes voltage reference if the Control Mode selected is Voltage If the external device starts sending the reference AFTER the external online mode is activated, it may be necessary to initialize EREFP, EREFS, EREFT or EREFV. Check Set the initial value to set the desired starting value. Remarks: • The external online mode may also be used as a test mode in which you assign in EREFP, EREFS, EREFT or EREFV the desired reference • Use external online voltage mode with caution. If the motor is moving, an abrupt reduction of the voltage reference may lead to a high peak of regenerated energy injected into the DC supply. Without proper surging capacity, this may cause high over-voltages Choose Execute Immediate to activate the external reference mode immediately when the motion sequence is encountered. Choose Execute On Event to activate the external reference when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want to set the external reference mode parameters for a later use. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: External –MPL Programming Details External –MPL Instructions and Data Motion Programming © ElectroCraft 2013 155 MPD User Manual Internal Units and Scaling Factors © ElectroCraft 2013 156 MPD User Manual 6.1.7. Motion Electronic Gearing The “Motion – Electronic Gearing” dialogue allows you to set a drive/motor as master or a slave for electronic gearing mode. When set as master, a drive/motor sends its position via a multi-axis communication channel, like the CANbus. The master sends either the load position or the position reference once at each slow loop sampling time interval. When set as slave, a drive/motor follows the master position with a programmable ratio. The slaves can get the master position in two ways: 1. Via a communication channel, from a drive/motor set as master 2. Via an external digital reference of type pulse & direction or quadrature encoder. Both options have dedicated inputs. The pulse & direction signals are usually provided by an indexer and must be connected to the pulse & direction inputs of the drive/motor. The quadrature encoder signals are usually provided by an encoder on the master and must be connected to the 2nd encoder inputs. Remark: In case 2, you don’t need to program a drive/motor as master in electronic gearing Select Master tab to set a drive/motor as master in electronic gearing. © ElectroCraft 2013 157 MPD User Manual If the master sends its position to a single drive/motor, check the Axis ID and fill the associated field with the axis ID of the slave. If the master sends its position to more drives, indicate the Group ID of the slaves. Select one groups of drives (1 to 8) to which the master should send its position. Remark: You need to specify the Axis ID or the Group ID where master sends its position only the first time (after power on) when a drive is set as master. If the master mode is later on disabled, then enabled again, there is no need to set again the Axis ID or the Group ID, as long as they remain unchanged. In this case, just uncheck both the Axis ID and the Group ID. Select Feedback, to set the master sending its load position, or Reference, for sending its position reference. Remark: The feedback option is disabled if the master operates in open loop. It is meaningless if the master drive has no position sensor. Check Synchronization to activate the synchronization procedure between the master and the slave axes. Select Send synchronization messages and set the time interval between synchronization messages. Recommended starting value is 20ms. When synchronization procedure is active, the execution of the control loops on the slaves is synchronized with those of the master within a 10µs time interval. Due to this powerful feature, drifts between master and slave axes are eliminated. Select Don’t send synchronization to disable the synchronization procedure. If the master activation is done AFTER the slaves are set in electronic gearing mode, check Initialize slave(s) axis with master position. This determines the master to send an initialization message to the slaves. Check Enable operation to activate the master mode and start the sending of master position to the slaves. Check Disable operation to deactivate the master mode and stop sending of master position to the slaves. Note that enabling or disabling master operation has no effect on the motion executed by the master. Choose Execute Immediate to enable the slave operation mode immediately when the motion sequence is encountered. Choose Execute On Event to start the slave operation mode when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want to prepare the slave operation mode for a later execution. © ElectroCraft 2013 158 MPD User Manual Select Slave tab to set a drive/motor as slave in electronic gearing. Check Gear Ratio to set/change the gear ratio with which the slave follows the master position. The gear ratio is specified as a ratio of 2 integer values: Slave / Master. The slave value is signed, while the master one is unsigned. The sign indicates the direction of movement: positive – same as the master, negative – reversed to the master. Remarks: • Slave=1 and Master=3, means that slave does 1/3 of master displacement and its speed is 1/3 of the master speed • Due to an automatic compensation procedure, the slave reference is computed correctly without cumulating errors, even if the ratio is an irrational number like 1: 3 Check Master Resolution to specify the number of encoder counts per one revolution of the master motor. The slaves need the master resolution to compute correctly the master position and speed (i.e. position increment). Select Full range if master position is not cyclic (e.g. the resolution is equal with the whole 32-bit range of position). In this case the master resolution is set to value 0x80000001. Check Enable operation with master position and select how to get the master position: via communication or via an external reference. Leave unchecked if you want to set the slave parameters without enabling slave operation mode. © ElectroCraft 2013 159 MPD User Manual Check Superposition with other motions and select On or Off to enable or disable the superposition of the electronic gearing mode with a second motion mode. When this superposed mode activated, the position reference is computed as the sum of the position references for each of the 2 superposed motions. You may enable the superposed mode at any moment, independently of the activation/deactivation of the electronic gearing slave. If the superposed mode is activated during an electronic gearing motion, any subsequent motion mode change is treated as a second move to be superposed over the basic electronic gearing move, instead of replacing it. If the superposed mode is activated during another motion mode, a second electronic gearing mode will start using the motion parameters previously set. This move is superposed over the first one. After the first move ends, any other subsequent motion will be added to the electronic gearing. When you disable the superposed mode, the electronic gearing slave move is stopped and the drive/motor executes only the other motion. If you want to remain in the electronic gearing slave mode, set first the electronic gearing slave move and then disable the superposed mode. Check Limit maximum acceleration at, to smooth slave coupling with the master, when this operation is done with master running at high speed. This option limits the slave acceleration during coupling to the programmed value. Remark: Bit 12 from the Status Register High is set (SRH.12 = 1), when slave coupling with the master is complete. The same bit is reset to zero if the slave is decoupled from the master. The bit has no significance in other motion modes. Select Generate new trajectory starting from actual values of position and speed reference if you want the reference generator to compute the slave position starting from the actual values of the position and speed reference. Select Generate new trajectory starting from actual values of load/motor position and speed if you want the reference generator to compute the slave position starting from the actual values of the load/motor position and speed. Choose Execute Immediate to enable the slave operation mode immediately when the motion sequence is encountered. Choose Execute On Event to start the slave operation mode when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want to prepare the slave operation mode for a later execution. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page See also: Electronic Gearing – MPL Programming Details Electronic Gearing – MPL Instruction and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 160 MPD User Manual 6.1.8. Motion Electronic Camming The “Motion – Electronic Camming” dialogue allows you to set a drive/motor as master or slave for electronic camming mode. When set as master, a drive/motor sends its position via a multi-axis communication channel, like the CAN bus. The master sends either the load position or the position reference once at each slow loop sampling time interval. When set as slave, a drive/motor executes a cam profile function of the master position. The cam profile is defined by a cam table – a set of (X, Y) points, where X is cam table input i.e. the master position and Y is the cam table output i.e. the corresponding slave position. Between the points the drive/motor performs a linear interpolation. Using Cam Tables Selection selection you can associate cam tables to your application. These may be visualized and modified using the Cam Tables Edit. You may also import cam tables. The required format is: text file with 2 columns, one for X, and the other for Y, separated by space or tab. Data must be in internal units. The slaves can get the master position in two ways: 1. Via a communication channel, from a drive/motor set as master 2. Via an external digital reference of type pulse & direction or quadrature encoder. Both options have dedicated inputs. The pulse & direction signals are usually provided by an indexer and must be connected to the pulse & direction inputs of the drive/motor. The quadrature encoder signals are usually provided by an encoder on the master and must be connected to the 2nd encoder inputs. Remark: For 2nd option you don’t need to program a drive/motor as master in electronic camming © ElectroCraft 2013 161 MPD User Manual Select Master tab to set a drive/motor as master in electronic camming. If the master sends its position to a single drive/motor, check the Axis ID and fill the associated field with the axis ID of the slave. If the master sends its position to more drives, indicate the Group ID of the slaves. Select one group of drives (1 to 8) to which the master should send its position. Remark: You need to specify the Axis ID or the Group ID where master sends its position only the first time (after power on) when a drive is set as master. If the master mode is later on disabled, then enabled again, there is no need to set again the Axis ID or the Group ID, as long as they remain unchanged. In this case, just uncheck both the Axis ID and the Group ID. Select Feedback, to set the master sending its load position, or Reference, for sending its position reference. Remark: The feedback option is disabled if the master operates in open loop. It is meaningless if the master drive has no position sensor. Check Synchronization to activate the synchronization procedure between the master and the slave axes. Select Send synchronization messages and set the time interval between synchronization messages. Recommended starting value is 20ms. When synchronization procedure is active, the execution of the control loops on the slaves is synchronized with those of the master within a 10µs time interval. Due to this powerful feature, drifts between master and slave axes are eliminated. Select Don’t send synchronization to disable the synchronization procedure. © ElectroCraft 2013 162 MPD User Manual Check Enable operation to activate the master mode and start the sending of master position to the slaves. Check Disable operation to deactivate the master mode and stop sending of master position to the slaves. Note that enabling or disabling master operation has no effect on the motion executed by the master. Choose Execute Immediate to enable the slave operation mode immediately when the motion sequence is encountered. Choose Execute On Event to start the slave operation mode when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want to prepare the slave operation mode for a later execution. Select Slave tab to set a drive/motor as slave in electronic camming. Select the camming mode: • In Relative mode, the output of the cam table represents for the slave a position increment, which is added to its actual position • In Absolute mode, the output of the cam table represents for the slave the position to reach. © ElectroCraft 2013 163 MPD User Manual Remark: The absolute mode may generate abrupt variations on the slave position reference, mainly at entry in the camming mode. Check Limit maximum speed at to limit the speed of the slave during travel towards the position to reach. Check Use CAM table and choose between the selected cam tables which one to use. Remark: Note that at runtime, all the selected cam tables are loaded into the drive memory. If needed, you may switch between the cam tables loaded. This operation means just to change the value of the CAMSTART parameter which points towards the active cam table. Check Offset from master in IU to shift the cam profile versus the master position, by setting a cam offset for each slave. The cam table input is computed as the master position minus the cam offset. For example, if a cam table is defined between angles 100 to 250 degrees, a cam offset of 50 degrees will make the cam table to execute between master angles 150 and 300 degrees. Check Multiply table input with to compress/extend a cam table input. Specify the input correction factor by which the cam table input is multiplied. For example, an input correction factor of 2, combined with a cam offset of 180 degrees, will make possible to execute a cam table defined for 360 degrees of the master in the last 180 degrees. Check Multiply table output with in order to compress/extend a cam table output. Specify the output correction factor by which the cam table output is multiplied. This feature addresses the applications where the slaves must execute different position commands at each master cycle, all having the same profile defined through a cam table. In this case, the drive/motor is programmed with a unique normalized cam profile and the cam table output is multiplied with the relative position command updated at each master cycle. Check Enable operation with master position and select how to get the master position: via communication or via an external reference. Leave unchecked if you want to set the slave parameters without enabling slave operation mode. Check Master Resolution to specify the number of encoder counts per one revolution of the master motor. The slaves need the master resolution to compute correctly the master position and speed (i.e. position increment). Select Full range if master position is not cyclic (e.g. the resolution is equal with the whole 32-bit range of position). In this case the master resolution is set to value 0x80000001. Select Generate new trajectory starting from actual values of position and speed reference if you want the reference generator to compute the slave position starting from the actual values of the position and speed reference. Select Generate new trajectory starting from actual values of load/motor position and speed if you want the reference generator to compute the slave position starting from the actual values of the motor position and speed. Choose Execute Immediate to enable the slave operation mode immediately when the motion sequence is encountered. Choose Execute On Event to start the slave operation mode when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want to prepare the slave operation mode for a later execution. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page See also: Cam Tables Selection © ElectroCraft 2013 164 MPD User Manual Cam Tables Edit Electronic Camming – MPL Programming details Electronic Camming –MPL Instruction and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 165 MPD User Manual 6.1.9. Motor Commands The “Motion - Motor Commands” dialogue allows you to apply one of following commands to the motor: • Activate/deactivate the control loops and the power stage PWM output commands (AXISON / AXISOFF) • Stop the motor with deceleration set in MPL parameter CACC • Change the value of the motor position and position reference • Set deceleration rate for quick stops Select Activate the control loops and PWM outputs (AXISON) to restore normal drive operation after an AXISOFF command. Typically, this situation occurs at recovery from an error, following the fault reset command FAULTR, or after the drive/motor ENABLE input goes from status disabled to status enabled. Select Deactivate the control loops and PWM outputs (AXISOFF) when a fault condition is detected, for example when a protection is triggered. This command disables the motor control (all the control loops), all the PWM output commands for the power stage (all the switching devices are off) and also the reference generator. Fault conditions trigger MPL interrupts. Each drive/motor has a built-in set of MPL interrupt service routines (ISR) which are automatically activated after power-on. In these routines, the default action for fault conditions is an AXISOFF command. If needed, you may replace any built-in ISR with your own ISR and thus, adapt the fault treatment to your needs. After a fault condition, the actual values of the load position and speed (which continue to be measured during the AXISOFF condition) may differ quite a lot from the values of the target position and speed as were last computed by the reference generator before entering in the AXISOFF condition. Therefore, a correct fault recovery sequence involves the following steps: © ElectroCraft 2013 166 MPD User Manual • Set the motion mode, even if it is the same. Motion mode commands, automatically set the target update mode zero (TUM0), which updates the target position and speed with the actual measured values of the load position and speed • Execute update command UPD • Execute AXISON command Remark: • In the Drive Status control panel, SRL.15 shows the AXISON/AXISOFF condition and SRH.15 shows a fault condition • In MotionPRO Developer, ENDINIT and AXISON commands are automatically included in the MPL program, just before your first MPL command from the main section. Therefore you don’t need to include them in your motion program. Select STOP to stop the motor with the deceleration rate set in MPL parameter CACC. The drive/motor decelerates following a trapezoidal position or speed profile. If the STOP command is issued during the execution of an S-curve profile, the deceleration profile may be chosen between a trapezoidal or an Scurve profile (see S-curve dialogue settings). You can detect when the motor has stopped by setting a motion complete event and waiting until the event occurs. The STOP command can be used only when the drive/motor is controlled in position or speed. Remarks: • In order to restart after a STOP command, you need to set again the motion mode. This operation disables the stop mode and allows the motor to move • When STOP command is sent via a communication channel, it will automatically stop any MPL program execution, to avoid overwriting the STOP command from the MPL program Choose Immediate Update to generate an update command UPD. When this command is received, the last motion mode programmed together with the latest motion parameters are taken into consideration. The immediate update command is available in all the dialogues setting a motion mode and normally it is called from these dialogues. The immediate update command is useful when the motion mode is set in advance for a later execution, which is started with a separate update command. In a similar way you may use Update on event. You can set / change the referential for position measurement by changing simultaneously the load position APOS and the target position TPOS values, while keeping the same position error any moment during motion. Use the edit field from set actual position value to specify the new motor position value. Remark: In the case of steppers controlled in open loop, this command changes only the target position TPOS to the desired value. The deceleration rate for quick stops can be set/change selecting the option Set quick stop deceleration rates. To assign an immediate value select option value and fill the associated field, if you want to assign the value of a variable select then variable and in the associated field write the name of the variable. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: © ElectroCraft 2013 167 MPD User Manual Motor Commands – MPL Programming Details Motor Commands – MPL Instructions and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 168 MPD User Manual 6.1.10. Motion Position Triggers The “Motion - Position Triggers” dialogue allows you to define 4 position trigger points. A position trigger is a position value with which the actual position is continuously compared. The compare result is shown in the Status Register High (SRH). If the actual position is below a position trigger, the corresponding bit from SRH is set to 0, else it is set to 1. You can change at any moment the value of a position trigger. The actual position that is compared with the position triggers is: • The Load position feedback (MPL variable APOS_LD) for configurations with position sensor • The position reference (MPL variable TPOS – Target position) in the case of steppers controlled in open-loop Remark: The position triggers can be used to monitor the motion progress. If this operation is done from a host, you may program the drive/motor to automatically issue a message towards the host, each time when the status of a position trigger is changed. See also: Position Triggers – MPL Programming Details Position Triggers – Related MPL Instructions and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 169 MPD User Manual 6.1.11. Motion Homing The “Motion – Homing” dialogue allows you choose a homing procedure and set its parameters. The homing is a sequence of motions, usually executed after power-on, through which the load is positioned into a well-defined point – the home position. Typically, the home position is the starting point for normal operation. The search for the home position can be done in numerous ways. Therefore, a lot of homing procedures are possible. ElectroCraft provides for each programmable drive/motor a collection of up to 32 homing procedures. These are predefined MPL functions, which you may call after setting the homing parameters. You may use these homing procedures as they are, or you may modify them according with your application needs. From the list with all the defined homing procedures you can choose one or several to be used in your application. This represents the list of selected homing procedures. Check Select homing parameters to set the following values: • Acceleration/deceleration rate for the position or speed profiles done during homing • Deceleration rate for quick stop when a limit switch is reached • High/normal speed for the position or speed profiles done during homing • Low speed for the final approach towards the home position • New home position set at the end of the homing procedure Check Execute homing mode and choose a homing procedure from the list of the selected homing procedures. During the execution of a homing sequence SRL.8 = 1. Hence you can find when a homing sequence ends, either by monitoring bit 8 from SRL or by programming the drive/motor to send a message to your host when SRL.8 changes. As long as a homing sequence is in execution, you should not start another one. If this happens, the last homing is aborted and a warning is generated by setting SRL.7 = 1. © ElectroCraft 2013 170 MPD User Manual Remark: You can abort a homing sequence execution at any moment using MPL command ABORT (see Decisions). You can also use this dialogue to read the status of the home input. The home input is one of the drive/motor inputs, which is used by the homing procedures. The home input is specific for each product and based on the setup data, MotionPRO Developer automatically generates the MPL code for reading the correct input. Check Read home input in the variable and fill the associated field with the name of the variable. After execution, the value of the variable will be 0 if the home input is zero (low) or 1 if the home input is 1 (high). Remark: The source of the motion sequence for reading the home input is general and independent. The particular value of the home input, specific for each product, occurs only in the compiled version of this motion sequence, in the MPL code generated. Therefore, you can safely import the source code of this motion sequence into other applications where the target products have different home inputs. OK: Close this dialogue and save the settings in your motion sequence list. Cancel: Close this dialogue without saving the settings in your motion sequence list. Help: Open this help page. See also: Homing – MPL Programming Details Homing – Related MPL Instructions and data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 171 MPD User Manual 6.1.12. Motion Contouring The “Motion - Contouring” dialogue allows you to program an arbitrary contour via a series of points. Between the points, linear interpolation is performed, leading to a contour described by a succession of linear segments. The contouring mode may be executed only from a MPL program. You can’t send contouring points from a host via a communication channel, like in the case of the PT mode. Depending on the control mode chosen, four options are available: • Position contouring – the load/motor is controlled in position. The path represents a position reference • Speed contouring – the load/motor is controlled in speed. The path represents a speed reference. • Torque contouring – the motor is controlled in torque. The path represents a current reference. • Voltage contouring – the motor is controlled in voltage. The path represents a voltage reference. Each contour point is defined by 2 values: the reference and the time. The contouring mode has been foreseen mainly for setup tests. However, you can also use the position contouring and the speed contouring for normal operation, as part of your motion application. You can switch at any moment to and from these 2 modes. The torque contouring and the voltage contouring have been foreseen only for setup tests. The torque contouring may be used, for example, to check the response of the current controllers to different input signals. Similarly, the voltage contouring may be used, for example, to check the motors behavior under a constant voltage or any other voltage shape. © ElectroCraft 2013 172 MPD User Manual © ElectroCraft 2013 173 MPD User Manual Choose Position for a position contouring, Speed for a speed contouring, Torque for a torque contouring Voltage for a voltage contouring. Remarks: • Position contouring option is disabled if the drive/motor is not setup for position control • Speed contouring option is disabled if the drive/motor is not setup for speed control. This includes the case when position control is performed without closing the speed loop • Torque contouring option is disabled for stepper drives working in open loop In the position contouring and the speed contouring the starting point has always the coordinates (0,0) and corresponds to the moment when the contouring mode is activated. Therefore all the segments values (time and reference) are relative to the starting point of the contouring. For example, lets suppose that a position contouring sequence has one segment with coordinates (1s, 10 rot) and the absolute position is 20 revolutions (initial position when the position contouring is activated). During the contour segment execution, the motor moves 10 revolutions in 1 second and stops on absolute position 30 revolutions. In the torque contouring and voltage contouring the starting point has by default the initial value 0. However, you can also start with a different value, by setting in the first point a non-zero reference at time = 0. You can introduce the contouring points in 2 ways: • One by one, by setting for each point its Time and Reference values. Select the measuring units from the list on the right. The graphical tool included, will automatically update the contour as you introduce each point. A red spot, indicates the active point. Use buttons: Remove, Update, Insert, << and >> to navigate between the points and modify them. • With Import From File to insert a set of contouring points previously defined. The file format is a simple text with 2 columns separated by space or tabs representing from left to right: time and reference values. The number of rows gives the number of points Select Generate new trajectory starting from actual values of position and speed reference if you want the reference generator to compute the contour profile starting from the actual values of the position and speed reference. Select Generate new trajectory starting from actual values of load/motor position and speed if you want the reference generator to compute the contour profile starting from the actual values of the load/motor position and speed. When this option is used, at the beginning of each new contour profile the position and speed reference is updated with the values of the load/motor position and speed. Use this option for example at recovery from an error or any other condition that disables the motor control while the motor is moving. Updating the reference values leads to a “glitch” free recovery because it eliminates the differences that may occur between the actual load/motor position/speed and the last computed position/speed reference (before disabling the motor control). Remark: In open loop control of steppers, this option is ignored because there is no position and/or speed feedback. Choose Execute Immediate to start the contour profile immediately when the motion sequence is encountered. Choose Execute On event to start the motion when a programmable event occurs. Click © ElectroCraft 2013 174 MPD User Manual Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: Contouring – MPL Programming details Contouring – MPL Instructions and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 175 MPD User Manual 6.1.13. Motion Test The “Motion – Test” dialogue allows you to set the drives/motors in a special test configuration. This configuration is not supposed to be used during normal operation, but only during drive/motor setup. In the test mode, either a voltage or a torque (current) command can be set using a test reference consisting of a limited ramp. For AC motors (like for example the brushless motors), the test mode offers also the possibility to rotate a voltage or current reference vector with a programmable speed. As a result, these motors can be moved in an “open-loop” mode without using the position sensor. The main advantage of this test mode is the possibility to conduct in a safe way a series of tests, which can offer important information about the motor parameters, drive status and the integrity of the its connections. Select Voltage for voltage reference or Torque for torque reference. Insert the appropriate values for reference amplitude and reference increment in the corresponding fields and select the measurement unit. For AC motors, check the option AC motor only. Insert the appropriate values for the reference vector initial position and the electrical angle increment in the corresponding fields and select the measurement unit. Choose Execute Immediate to activate the external reference mode immediately when the motion sequence is encountered. Choose Execute On Event to activate the external reference when a programmable event occurs. Click Change Event to select the event type or Edit Event to modify the parameters of the selected event (see Events for details). Select Setup motion data, but don’t start execution if you want to prepare the external reference mode for a later use. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: © ElectroCraft 2013 176 MPD User Manual Motion Test –MPL Programming details Motion Test – Related MPL Instructions and Data Motion Programming Internal Units and Scaling Factors © ElectroCraft 2013 177 MPD User Manual 6.1.14. Events Dialogue The “Events” dialogue allows you to define events. An event is a programmable condition, which once set, is monitored for occurrence. You can do the following actions in relation with an event: 1) Change the motion mode and/or the motion parameters, when the event occurs 2) Stop the motion when the event occurs 3) Wait for the programmed event to occur Remark: The programmed event is automatically erased if the event is reached, if the timeout for the wait is reached or if a new event is programmed. Only a single event can be programmed at a time. This can be: 1) When the actual motion is completed 2) When motor absolute position is equal or under a value or the value of a variable 3) When motor absolute position is equal or over a value or the value of a variable 4) When load absolute position is equal or under a value or the value of a variable 5) When load absolute position is equal or over a value or the value of a variable 6) When load/motor relative position is equal or under a value or the value of a variable 7) When load/motor relative position is equal or over a value or the value of a variable 8) When motor speed is equal or under a value or the value of a variable 9) When motor speed is equal or over a value or the value of a variable 10) When load speed is equal or under a value or the value of a variable 11) When load speed is equal or over a value or the value of a variable 12) After a wait time equal with a value or the value of a variable 13) When position reference is equal or under a value or the value of a variable 14) When position reference is equal or over a value or the value of a variable 15) When speed reference is equal or under a value or the value of a variable © ElectroCraft 2013 178 MPD User Manual 16) When speed reference is equal or over a value or the value of a variable 17) When torque reference is equal or under a value or the value of a variable 18) When torque reference is equal or over a value or the value of a variable 19) When 1st or 2nd encoder index goes low or high 20) When the positive limit switch goes low or high 21) When the negative limit switch goes low or high 22) When a digital input goes low 23) When a digital input goes high 24) When a 32-bit variable is equal or under a 32-bit value or the value of another 32-bit variable 25) When a 32-bit variable is equal or over a 32-bit value or the value of another 32-bit variable Remark: The load/motor relative position is computed starting from the beginning of the current movement. You can also program events in the following motion dialogues: Trapezoidal Profiles, S-curve Profiles, PT, PVT, External, Electronic Gearing, Electronic Camming, Contouring, Test. Set events in these dialogues, if you want to activate the programmed motion mode and/or its motion parameters, when the programmed event occurs. The event programming is done in the same way when it is done from a motion dialogue or from this dialogue. Press Change Event to open the Event Selection dialog which allows you to define the event / condition to be monitored. If you have already defined an event, use Edit Event button to modify its parameters or conditions. When you set an event using one of the motion dialogues, you program the following operations: • Definition of an event • Programming of a new motion mode and/or new motion parameters • Definition of the moment when the new motion mode and/or motion parameters must be updated (e.g. enabled) as the moment when the programmed event will occur Remark: After you have programmed a new motion mode and/or new motion parameters with update on event, you need to introduce a wait until the programmed event occurs. Otherwise, the program will continue with the next instructions that may override the event monitoring. In order to introduce a wait until the programmed event occurs, open this dialogue, select as event None and check Wait until the event occurs. © ElectroCraft 2013 179 MPD User Manual In this dialogue, apart from programming an event, you can Stop motion when the event occurs and Wait until the event occurs by checking these options. You can also define a time limit for an event to occur. Check Exit from the wait loop after a time equal with and specify the time limit. If the monitored event doesn’t occur in this time limit, the wait loop is interrupted and the MPL program passes to the next instruction. Remarks: • By default, the option Wait until the event occurs is checked. Typically, you define an event, than wait for the event to occur. • If the option Wait until the event occurs is checked without a time limit, and the programmed event doesn’t occur, the MPL program will remain in a loop. In order to exit from this loop, send via a communication channel a GOTO command, which moves the program execution outside the loop OK: Close this dialogue and save the event programming in your motion sequence list. Cancel: Close this dialogue without saving or updating the event programming in the motion sequence list. Help: Open this help page. See also: Events – MPL Programming Details Event Selection Motion Programming © ElectroCraft 2013 180 MPD User Manual 6.1.14.1. Event Type Selection The “Event Type” dialogue allows you to select an event. An event is a programmable condition, which once set, is monitored for occurrence. The “Event Type” dialogue may be opened from: • Events dialogue: Event Type – called from Events dialogue • One of the following motion dialogues: Trapezoidal Profiles, S-curve Profiles, PT, PVT, External, Electronic Gearing, Electronic Camming, Contouring, Test: Event Type – called from a motion dialogue The events are grouped into 8 categories: None/ When a previously defined event occurs. The meaning of this case depends from where the “Event Type” dialogue was opened: • None – appears when the dialogue is opened from the “Events” dialogue. Check this item if you have already defined an event and now you want to: a) program a stop when the event occurs and/or b) wait for the programmed event to occur. • When a previously defined event occurs – appears when the dialogue is opened from one of the motion dialogues (see above). Check this item if you have already defined an event (in a previous motion sequence) and now you want to start the actual motion sequence when this event occurs. When actual motion is completed – for programming the event: when the actual motion is completed. © ElectroCraft 2013 181 MPD User Manual Function of motor or load position – for programming the events: when the absolute or relative motor or load position is equal or over/under a value or the value of a variable. Function of motor or load speed – for programming the events: when the motor or load speed is equal or over/under a value or the value of a variable. After a wait time – for programming a time delay, using a time event. The monitored event is: when the relative time is equal with a value or the value of a variable Function of reference – for programming the events: when the position or speed or torque reference is equal or over/under a value or the value of a variable. Function of inputs status – for programming the events: when capture inputs or limit switch inputs or general purpose inputs change status: low to high or high to low. Function of a variable value – for programming the events: when a selected variable is equal or over/under a value or the value of another variable. OK: Close this dialogue and save selected event Cancel: Close this dialogue without saving the selected event Help: Open this help page. See also: Events Motion Programming © ElectroCraft 2013 182 MPD User Manual 6.1.14.2. Event - When the actual motion is completed This dialogue allows you to set the event: when a motion is completed. You can use, for example, this event to start the next move only after the actual one is finalized. The motion complete condition is set in the following conditions: • During position control: With position feedback – when the position reference arrives at the position to reach (commanded position) and the position error remains inside a settle band for a preset stabilize time interval Without position feedback (open-loop systems) – when the position reference arrives at the position to reach (commanded position) • During speed control, when the speed reference arrives at the commanded speed The motion complete condition is reset when a new motion is started. In position control, choose In position control when the actual position remains inside a settle band for the first option. Check Set motion complete parameters if you want to modify the Settle band tolerance and the Stabilize time values. Select the measuring units from the list on the right. Leave Set motion complete parameters unchecked if you want to keep the motion complete parameters unchanged. Choose In position control when the position arrives at the position to reach or in speed control when speed command & reference are equal in: © ElectroCraft 2013 183 MPD User Manual • Speed control • Position control with open-loop configurations or if you do not want to use first option OK: Close this dialogue and save the event set Cancel: Close this dialogue without saving the event set. Help: Open this help page. See also: Events – When actual motion is completed– MPL Programming details Event Selection Events Motion Programming © ElectroCraft 2013 184 MPD User Manual 6.1.14.3. Event - Function of motor or load position This dialogue allows you to program an event function of the motor or load position. The events can be: when the absolute or relative motor or load position is equal or over/under a value or the value of a variable The absolute load or motor position is the measured position of the load or motor. The relative position is the load displacement from the beginning of the actual movement. For example if a position profile was started with the absolute load position 50 revolutions, when the absolute load position reaches 60 revolutions, the relative motor position is 10 revolutions. Select motor or load position, its type: absolute or relative, the event condition: over (or equal) or under (or equal) and the comparison data: a value or the value of a variable. OK: Close this dialogue and save the event set Cancel: Close this dialogue without saving the event set. Help: Open this help page. See also: Event – Function of motor or load position–MPL Programming Details Event Selection Motion Programming © ElectroCraft 2013 185 MPD User Manual 6.1.14.4. Event - Function of motor or load speed This dialogue allows you to program an event function of the motor or load speed. The events can be: when the motor or load speed is equal or over/under a value or the value of a variable. Select motor or load speed, the event condition: over (or equal) or under (or equal) and the comparison data: a value or the value of a variable. OK: Close this dialogue and save the event set Cancel: Close this dialogue without saving the event set. Help: Open this help page. See also: Event – Function of motor or load speed–MPL Programming Details Event Selection Events Motion Programming © ElectroCraft 2013 186 MPD User Manual 6.1.14.5. Event– After a Wait Time This dialogue allows you to introduce a programmable delay in the motion program execution of the motion controller/drive, using a time event. When you set this event, the motion controller/drive relative time is reset and it starts counting from zero and the monitored condition is: when the relative time is equal with a value or the value of a variable. Remarks: • The event on time can be programmed only for the local axis. • In order to effectively execute the time delay, you need to follow this command by a Wait until the event occurs command e.g. until the programmed relative time has elapsed. Select the comparison data: a value or the value of a variable. OK: Close this dialogue and save the event set Cancel: Close this dialogue without saving the event set. Help: Open this help page. See also: Event– After a Wait Time –MPL Programming Details Event Selection Events Motion Programming © ElectroCraft 2013 187 MPD User Manual 6.1.14.6. Event - Function of reference This dialogue allows you to program an event function of the position or speed or torque reference. The events can be: when the position/speed/torque reference is equal or over/under a value or the value of a variable. Use: • Position reference events, only when position control is performed • Speed reference events, only when speed control is performed • Torque reference events, only when torque control is performed Remark: Setting an event based on the position or speed reference is particularly useful for open loop operation where feedback position and speed is not available Select the reference type: position, speed or torque, the event condition: over (or equal) or under (or equal) and the comparison data: a value or the value of a variable. OK: Close this dialogue and save the event set Cancel: Close this dialogue without saving the event set. Help: Open this help page. See also: Event – Function of reference –MPL Programming Details Event Selection Events Motion Programming © ElectroCraft 2013 188 MPD User Manual 6.1.14.7. Event - Function of inputs status This dialogue allows you to program one of the following events: • When a transition occurs on one of the 2 capture inputs, where are connected the 1st and 2nd encoder index signals (if available) • When a transition occurs on one of the 2 limit switch inputs • When a general purpose digital input changes its status • When the home input changes its status The capture inputs and the limit switch inputs can be programmed to sense either a low to high or high to low transition. When the programmed transition occurs on either of these inputs, the following happens: • Motor position is captured and memorized in the MPL variable CAPPOS, except the case of openloop systems, where the reference position is captured instead • Master or load position is captured and memorized in the MPL variable CAPPOS2, except the case of steppers controlled open-loop with an encoder on the load, when load position is captured in CAPPOS. The selection between master and load position is done as follows: load position is saved in CAPPOS2 only for the setup configurations which use different sensors for load and motor and foresee a transmission ratio between them. For all the other setup configurations, the master position is saved in CAPPOS2. The master position is automatically computed when pulse and direction signals or quadrature encoder signals are connected to their dedicated inputs. Select: • encoder index to detect a transition on 1st capture/encoder index input • 2nd encoder index to detect a transition on 2nd capture/encoder index • positive limit switch to detect a transition on limit switch input for positive direction • negative limit switch to detect a transition on limit switch input for negative direction and choose the transition type: low -> high or high -> low Select digital input to set an event on one of the general-purpose digital input available. The event can be set when the input goes high or low. Select home input in order to set an event on the general purpose digital input assigned as home input. The home input is specific for each product and based on the setup data, MotionPRO Developer automatically generates the MPL code for reading the correct input. © ElectroCraft 2013 189 MPD User Manual OK: Close this dialogue and save the event set Cancel: Close this dialogue without saving the event set. Help: Open this help page. See also: Events – Function of inputs status–MPL Programming Details Event Selection Events Motion Programming © ElectroCraft 2013 190 MPD User Manual 6.1.14.8. Event - Function of a variable value This dialogue allows you to program an event function of the value of a selected variable. The events can be: when the selected variable is equal or over/under a value or the value of another variable. You may select any 32-bit MPL variable or parameter, long or fixed, for this event. Introduce the variable name, the event condition: over (or equal) or under (or equal) and the comparison data: a value or the value of a variable. Remark: If you choose a predefined MPL parameter or variable and as comparison a value, you’ll see on the right list the measurement units associated with the selected variable. OK: Close this dialogue and save the event set Cancel: Close this dialogue without saving the event set. Help: Open this help page. See also: Event – Function of a variable value –MPL Programming Details Event Type Dialogue Events Motion Programming © ElectroCraft 2013 191 MPD User Manual 6.1.15. Jumps and Function Calls The “Jumps and Function Calls” dialogue allows you to control the MPL program flow through unconditional or conditional jumps and unconditional, conditional or cancelable calls of MPL functions. Select Goto and indicate the jump address in address, label or address set in variable. The jump address can be set directly as a numerical value (if it is known) or indirectly via: • A label. Use Insert label name to place the label in the desired location. The label name can be any string of up to 32 characters, which starts with an alphanumeric character or with underscore. • A 16-bit MPL variable whose value represents the jump address. Remark: You may assign a label to a 16-bit integer variable. The variable takes the value of the label i.e. the address of the next instruction after label. Example: user_var = jump_label; Leave if variable unchecked to execute an unconditional jump. Check if variable to execute a conditional jump and specify a test variable and a condition. The test variable is always compared with zero. The possible conditions are: < 0, <= 0, >0, >=0, =0, ≠ 0. If the condition is true the jump is executed, else the next MPL command is carried out. Select Call and indicate the name of a MPL function in address, label or address set in variable. A MPL function starts with a label and ends with the RET instruction. The label gives the MPL function address and name. You can create, rename or delete MPL functions using the Functions View. Remark: The MPL functions are placed after the end of the main program Similarly with the jump address, the MPL function address can be set directly, as a numerical value (if it is known), or indirectly via: • The MPL function starting label (i.e. the function name) • A 16-bit MPL variable whose value represents the MPL function address. Leave if variable unchecked to execute an unconditional call. Check if variable to execute a conditional call and specify a test variable and a condition. The test variable is always compared with zero. The possible conditions are: < 0, <= 0, >0, >=0, =0, ≠ 0. If the condition is true the call is executed, else the next MPL command is carried out. © ElectroCraft 2013 192 MPD User Manual Choose Cancelable Call and indicate the MPL function address if the exit from the called function depends on conditions that may not be reached. In this case, using Abort cancelable call you can terminate the function execution and return to the next instruction after the call. Select RETurn from function to insert the RET instruction, which ends a MPL function. When RET instruction is executed, the MPL program returns to the next instruction (motion sequence) after the MPL function call. Select RETurn from interrupt to insert the RETI instruction, which ends a MPL interrupt. When RETI instruction is executed, the MPL program returns to the point where it was before the MPL interrupt occurrence. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving the motion sequence in your motion sequence list. Help: Open this help page. See also: Jumps and Function Calls – MPL Programming Details Functions View. Motion Programming © ElectroCraft 2013 193 MPD User Manual 6.1.16. I/O General I/O (Firmware FAxx) The “I/O” dialogue allows you to program the following operations with the digital inputs and outputs: • Read and save the status of a digital input into a variable • Set low or high a digital output • Read and save the status of multiple digital inputs into a variable • Set multiple digital outputs according with the value of variable The digital inputs and outputs are numbered: #0 to #39. Each programmable drive/motor has a specific number of inputs and outputs, therefore only a part of the 40 I/Os is used. The I/O numbering is common for all the products; hence each product has its own list of available I/Os. This is not an ordered list. For example, a product with 4 inputs and 4 outputs can use the inputs: #36, #37, #38 and #39 and the outputs #28, #29, #30 and #31. If you want to read the status of an input: 1. Select Single I/O, Read input line, choose the desired input from the list of available inputs and provide the name of an integer variable where to save the input status 2. Check Set as input if the input selected may also be used as an output (i.e. the input line number occurs in the outputs list too). Do this operation only once, first time when you use the input. Omit this check if the drive/motor has the inputs separated from the outputs (i.e. all have different line numbers) 3. Press OK © ElectroCraft 2013 194 MPD User Manual When this MPL command is executed, the variable where the input line status is saved, becomes: • Zero if the input line was low • Non-zero if the input line was high Remark: Check the drive/motor user manual to find if the input line you are reading is directly connected or is inverted inside the drive/motor. If an input line is inverted, the variable where the input line is saved is inverted too: zero if the input is high (at connectors level), non-zero if the input is low (at connectors level). If you want to set an output low or high: 1. Select Single I/O, choose Set output line, select the desired output from the list of available outputs and choose the output level: low or high 2. Check Set as output if the output selected may also be used as an input (i.e. the output line number occurs in the inputs list too). Do this operation only once, first time when you use the output. Omit this check if the drive/motor has the inputs separated from the outputs (i.e. all have different line numbers) 3. Press OK Remark: The MPL code generated takes into account the possibility to have outputs inverted inside the drive/motor. This information, provided by the setup data, is used to inverse the output command logic: getting the output high (at connectors level) means setting the output low and to getting the output low (at connectors level) means setting the output high Check Read inputs in variable to read simultaneously more inputs and specify the name of an integer variable where to save their status. The inputs are: • Enable input – saved in bit 15 • Limit switch input for negative direction (LSN) - saved in bit 14 • Limit switch input for positive direction (LSP) - saved in bit 13 • General-purpose inputs #39, #38, #37 and #36 – save din bits 3, 2, 1 and 0 The bits corresponding to these inputs are set as follows: 0 if the input is low and 1 if the input is high. The other bits of the variable are set to 0. Remark: If one of these inputs is inverted inside the drive/motor, the corresponding bit from the variable is inverted too. Hence, these bits always show the inputs status at connectors level ( 0 if input is low and 1 if input is high) even when the inputs are inverted. Check Set multiple outputs to a value of variable to set simultaneously more outputs with the value of the specified variable. The outputs are: • Ready output – set by bit 15 • Error output – set by bit 14 • General-purpose outputs: #31, #30, #29, #28 – set by bits 3, 2, 1, and 0 The outputs are set as follows: low if the corresponding bit in the variable is 0 and high if the corresponding bit in the variable is 1. The other bits of the variable are not used. Remark: If one of these outputs is inverted inside the drive/motor, its command is inverted too. Hence, the outputs are always set at connectors level according with the bits values (low if bit is 0 and high if bit is 1) even when the outputs are inverted. © ElectroCraft 2013 195 MPD User Manual CAUTION: Do not use Set multiple outputs to a value of variable if any of the 6 outputs mentioned is not on the list of available outputs of your drive/motor. There are products that use some of these outputs internally for other purposes. Attempting to change these lines status may harm your product. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving anything in your motion sequence list. Help: Open this help page. See also: General-purpose I/O – MPL Programming Details Motion Programming © ElectroCraft 2013 196 MPD User Manual 6.1.17. I/O General I/O (Firmware FBxx) The “I/O” dialogue allows you to program the following operations with the digital inputs and outputs: • Read and save the status of a digital input into a variable • Set low or high a digital output • Read and save the status of multiple digital inputs into a variable • Set multiple digital outputs according with an immediate value or the value of 16-bit variable The digital inputs and outputs are numbered: 0 to 15. Each programmable drive/motor has a specific number of inputs and outputs, therefore only a part of the 16 inputs or outputs is used. The I/O numbering is common for all the products; hence each product has its own list of available I/Os. This is an ordered list. For example, a product with 4 inputs and 4 outputs can use the inputs: IN0, IN1, IN2 and IN3 and the outputs OUT0, OUT1, OUT2 and OUT3. If you want to read the status of an input: 1. Select Single I/O, Read input line, choose the desired input from the list of available inputs and provide the name of an integer variable where to save the input status 2. Check Set as input if the input selected may also be used as an output. Do this operation only once, first time when you use the input. Omit this check if the drive/motor has the inputs separated from the outputs (i.e. all have different line numbers) 3. Press OK © ElectroCraft 2013 197 MPD User Manual When this MPL command is executed, the variable where the input line status is saved, becomes: • Zero if the input line was low • Non-zero if the input line was high Remark: Check the drive/motor user manual to find if the input line you are reading is directly connected or is inverted inside the drive/motor. If an input line is inverted, the variable where the input line is saved is inverted too: zero if the input is high (at connectors’ level), non-zero if the input is low (at connectors’ level). If you want to set an output low or high: 1. Select Single I/O, choose Set output line, select the desired output from the list of available outputs and choose the output level: low or high 2. Check Set as output if the output selected may also be used as an input. Do this operation only once, first time when you use the output. Omit this check if the drive/motor has the inputs separated from the outputs. 3. Press OK Remark: The MPL code generated takes into account the possibility to have outputs inverted inside the drive/motor. This information, provided by the setup data, is used to inverse the output command logic: getting the output high (at connectors’ level) means setting the output low and to getting the output low (at connectors’ level) means setting the output high Check Read inputs in variable to read simultaneously more inputs and specify the name of an integer variable where to save their status. The bits corresponding to these inputs are set as follows: 0 if the input is low and 1 if the input is high. The other bits of the variable are set to 0. Remark: If one of these inputs is inverted inside the drive/motor, the corresponding bit from the variable is inverted too. Hence, these bits always show the inputs status at connectors level (0 if input is low and 1 if input is high) even when the inputs are inverted. Check Set outputs to set simultaneously more outputs with the value of 16-bit mask or variable. Select the outputs you want to command and specify how they are set: • with the mask generated after setting as High or Low each of the selected outputs • with the value of the specified 16-bit variable. The outputs are set as follows: low if the corresponding bit in the mask or variable is 0 and high if the corresponding bit in the mask or variable is 1. The other bits of the mask or variable are not used. Remark: If one of these outputs is inverted inside the drive/motor, its command is inverted too. Hence, the outputs are always set at connectors level according with the bits values (low if bit is 0 and high if bit is 1) even when the outputs are inverted. OK: Close this dialogue and save the motion sequence in your motion sequence list. Cancel: Close this dialogue without saving anything in your motion sequence list. Help: Open this help page. See also: General-purpose I/O – MPL Programming Details Motion Programming © ElectroCraft 2013 198 MPD User Manual 6.1.18. Assignment & Data Transfer - Setup 16-bit variable The “Assignment and Data Transfer – 16 bit Integer Data” dialogue helps you to: 1. Assign a value to a 16-bit integer MPL parameter/variable 2. Transfer in a memory location, a 16-bit value or the value of a 16-bit integer MPL parameter or variable Select Set 16-bit variable to assign a value to a 16-bit integer MPL parameter or variable. Introduce its name and choose one of the possible sources: • With value / 16 bit variable / label: A 16-bit value or the value of a 16-bit variable or the value of a label. Introduce in the associated field the value or the variable/label name. • With data / program / E2ROM memory contents located at address set in pointer variable: The value of a memory location whose address is set in another 16-bit (pointer) variable. Introduce in the associated field the pointer variable name. Check then increment the pointer variable to automatically increment by one the pointer value, after the assignment is done. This option is particularly useful for repetitive assign operations where source is placed in successive memory locations. The memory type is split into 3 categories: data – for the RAM area for MPL data, program – for the RAM area for MPL programs and E2ROM – for the EEPROM area for MPL programs. Remark: The data memory may be used to extend the number of user-defined variables. By data exchanges with MPL variables, the data memory locations may be used as a temporary © ElectroCraft 2013 199 MPD User Manual buffer. Work for example for these operations with the RAM locations reserved but not used by the cam tables. • With low / high part of a 32-bit variable: The low or high 16-bit part of a 32-bit MPL parameter or variable. Introduce in the associated field the variable name. • With inverse (-) of variable: The inverse (negate) value of a 16-bit MPL parameter or variable. Introduce in the associated field the variable name • Using AND mask…and OR mask …: The result of a logical operations: AND between the selected variable and the AND mask value OR between the above result and the OR mask value • With checksum of data located in data / program / E2ROM memory between address … and …: The result of a checksum performed with all the locations situated between the 2 specified memory addresses. The memory type is split into 3 categories like in the case of indirect addressing: data – for the RAM area for MPL data, program – for the RAM area for MPL programs and E2ROM – for the EEPROM area for MPL programs. Remark: The checksum is the sum modulo 65536 of all the memory values, including those from the limits. The address limits are hexadecimal values. Select Set data / program / E2ROM memory contents located at address set in the pointer variable to transfer in a memory location, a 16-bit value or the value of a 16-bit integer MPL parameter or variable. The memory location address is provided by another 16-bit (pointer) variable. Introduce in the associated fields the pointer variable name and the 16-bit value or the variable name. Check then increment the pointer variable to automatically increment by one the pointer value, after the assignment is done. This option is particularly useful for repetitive assign operations where destination is placed in successive memory locations. The memory type is split into 3 categories: data – for the RAM area for MPL data, program – for the RAM area for MPL programs and E2ROM – for the EEPROM area for MPL programs. OK: Close this dialogue and save the assignment or data transfer in your motion sequence list. Cancel: Close this dialogue without anything in your motion sequence list. Help: Open this help page. See also: Assignment and Data Transfer: 16-bit data – MPL Programming Details Motion Programming 6.1.19. Assignment & Data Transfer - Setup 32-bit variable The “Assignment and Data Transfer – 32-bit Long or Fixed Data” dialogue helps you: 1. Assign a value to a 32-bit long or fixed MPL parameter/variable 2. Assign a value to the high (16MSB) or low (16LSB) part of a 32-bit long or fixed data 3. Transfer in 2 consecutive memory locations, a 32-bit value or the value of a 32-bit long or fixed MPL parameter or variable © ElectroCraft 2013 200 MPD User Manual Select Set 32-bit variable to assign a value to a 32-bit long or fixed MPL parameter or variable. Introduce its name and choose one of the possible sources: • With value / 32 bit variable: A 32-bit value or the value of a 32-bit variable. Introduce in the associated field the value or the variable name. • With data / program / E2ROM memory contents located at address set in pointer variable: The value of 2 consecutive memory locations. The first memory address (the lowest) is provided by another 16-bit (pointer) variable. Introduce in the associated field the pointer variable name. Check then increment the pointer variable to automatically increment by two the pointer value, after the assignment is done. This option is particularly useful for repetitive assign operations where source is placed in successive memory locations. The memory type is split into 3 categories: data – for the RAM area for MPL data, program – for the RAM area for MPL programs and E2ROM – for the EEPROM area for MPL programs. Remark: The data memory may be used to extend the number of user-defined variables. By data exchanges with MPL variables, the data memory locations may be used as a temporary buffer. Work for example for these operations with the RAM locations reserved but not used by the cam tables. • With inverse (-) of variable: The inverse (negate) value of a 32-bit MPL parameter or variable. Introduce in the associated field the variable name • With 16-bit value of variable…left shifted with: The value of a 16-bit MPL data, left shifted with 0 to 16 bits. Introduce in the associated fields the variable name and the shift value. Select Set low / high part of 32-bit variable… with value/16-bit variable…to copy a 16-bit data into the higher or lower 16-bits or a 32-bit MPL data. The 16-bit data can be either an immediate value or a 16-bit MPL data. Choose low or high part and introduce in the associated field the value or the variable name. © ElectroCraft 2013 201 MPD User Manual Remarks: • The left shift operation is done with sign extension. If you intend to copy the value of an integer MPL data into a long MPL data preserving the sign use this operation with left shift 0 • If you intend to copy the value of a 16-bit unsigned data into a 32-bit long variable, assign the 16-bit data in low part of the long variable and set the high part with zero. Select Set data / program / E2ROM memory contents located at address set in the pointer variable to transfer in 2 consecutive memory locations, a 32-bit value or the value of a 32-bit integer MPL parameter or variable. The first memory address (the lowest) is provided by another 16-bit (pointer) variable. Introduce in the associated field the pointer variable name and the 16-bit value or the variable name. Check then increment the pointer variable to automatically increment by two the pointer value, after the assignment is done. This option is particularly useful for repetitive assign operations where destination is placed in successive memory locations. The memory type is split into 3 categories: data – for the RAM area for MPL data, program – for the RAM area for MPL programs and E2ROM – for the EEPROM area for MPL programs. Remark: When this operation is performed having as source an immediate value, the MPL compiler checks the type and the dimension of the immediate value and based on this generates the binary code for a 16-bit or a 32-bit data transfer. Therefore if the immediate value has a decimal point, it is automatically considered as a fixed value. If the immediate value is outside the 16-bit integer range (32768 to +32767), it is automatically considered as a long value. However, if the immediate value is inside the integer range, in order to execute a 32-bit data transfer it is necessary to add the suffix L after the value, for example: 200L or –1L. OK: Close this dialogue and save the assignment or data transfer in your motion sequence list. Cancel: Close this dialogue without anything in your motion sequence list. Help: Open this help page. See also: Assignment and Data Transfer: 32-bit data – MPL Programming Details Motion Programming © ElectroCraft 2013 202 MPD User Manual 6.1.20. Assignment & Data Transfer - Arithmetic Operations The “Arithmetic Operations” dialogue allows you to program the following arithmetic operations: addition, subtraction, multiplication and division, plus the left and right shifting. All these operations are signed i.e. the operands are treated as signed numbers. Except the multiplication, the result is saved in the left operand. For multiplication, the result is saved in the dedicated product register. Select Add to variable and introduce the name of the left operand to perform an addition. Indicate the right operand in the value/variable field. The left operand may be a 16-bit or 32-bit MPL data. The right operand may be an immediate value or another MPL data, of the same type as the left operand. Remark: When the left operand is a 32-bit long or fixed MPL data and the right operand is a 16-bit integer value, it is treated as follows: • Sign extended to a 32-bit long value, if the left operand is a 32-bit long • Set as the integer part of a fixed value, if the left operand is a 32-bit fixed Select Subtract from variable and introduce the name of the left operand to perform a subtraction. Indicate the right operand in the value/variable field. The left operand may be a 16-bit or 32-bit MPL data. The right operand may be an immediate value or another MPL data, of the same type as the left operand. Remark: When the left operand is a 32-bit long or fixed MPL data and the right operand is a 16-bit integer value, it is treated as follows: • Sign extended to a 32-bit long value, if the left operand is a 32-bit long • Set as the integer part of a fixed value, if the left operand is a 32-bit fixed Select Set PROD register with the product of variable and introduce the name of the first operand to perform a multiplication. Indicate the second operand in with value / 16 bit variable field. The first © ElectroCraft 2013 203 MPD User Manual operand may be a 16-bit or 32-bit MPL data. The second operand may be a 16-bit value or a 16-bit MPL data. The multiplication result is saved left or right shifted in a dedicated 48-bit product register. Choose the shift type Left or Right and number of shift bits: 0 to 15. Use 0 to perform no shift. Remark: The result is placed in the product register function of the left operand. When shift is 0: • In the 32 least significant bits, when the left operand is a 16-bit integer. The result is a 32-bit long integer • In all the 48 bits, when the left operand is a 32-bit fixed. The result has the integer part in the 32 most significant bits and the fractional part in the 16 least significant bits • In all the 48 bits, when the left operand is a 32-bit long. The result is a 48-bit integer The MPL variable PRODH contains the 32 most significant bits of the product register. The MPL variable PROD contains the 32 least significant bits of the product register. Select Divide variable and introduce the name of the left operand: the dividend, to perform a division. Indicate the right operand: the divisor, in the by the value of variable field. The dividend is a 32-bit MPL data. The divisor is 16-bit MPL data. Remark: The result, saved in first operand, is a fixed value with the integer part in the 16 most significant bits and the fractional part in the 16 least significant bits. Choose Shift Left / Right and introduce the name of the MPL data to be shifted left or right in the variable field, followed by the number of shift bits: 0 to 15. The MPL data can be any 16-bit or 32-bit MPL data. Choose Shift Left / Right product register by and introduce the number of shift bits: 0 to 15, to perform a left or right shift of the 48-bit product register. Remark: At right shifts, high order bits are sign-extended and the low order bits are lost. At left shifts, high order bits are lost and the low order bits are zeroed. OK: Close this dialogue and save the arithmetic or logic operation in your motion sequence list. Cancel: Close this dialogue without anything in your motion sequence list. Help: Open this help page. See also: Arithmetic and logic operations. MPL Programming Details Motion Programming © ElectroCraft 2013 204 MPD User Manual 6.1.21. Assig gnment & Data D Transfe er - Data Tra ansfer Betw ween Axes The “Data a Transfer Between B Axes” dialog allo ows you to program data a transfer op perations bettween drives/mo otors connectted in a nettwork. From this dialog, you can alsso change th he axis ID – the drive/moto or network address, a and d the groups s it belongs for multicasst transmissio ons as well as to activate/deactivate the synchronizattion between axes. Check Se et axis ID if yo ou want to ch hange the axis ID and set a new value. The axis ID is a value bettween 1 and 255 5. It is initially set at power on using the following alg orithm: a. With th he value read from the EEPROM setup p table contain ning all the setup data. If this value is 0, the axis ID D is set with the t value read from the hardware swittches/jumperss or in their a absence acco ording with d) b. If the se etup table is invalid, with th he last axis ID D value read ffrom a valid ssetup table c. If there is no axis ID D set by a valid d setup table, with the valu ue read from the hardware e switches/jum mpers s ID setting for axis d. If the drive/motor d ha as no hardwa are switches/jumpers for a axis ID setting g, with the de efault axis ID value which is 255. e axis ID is ke ept constant during d operatition at the vallue establishe ed during the setup Remark: Typically, the phase. Ho owever, if ne eeded, you can change th he axis ID to o any of the 255 possible e values, usin ng the above com mmand In MotionPRO Develop per, each app plication has associated a an Axis Numb ber, set in Ap pplication Ge eneral n application is selected, all a the data e exchange ope erations are p performed with the Information. When an or having the e same axis ID as the ap pplication Ax is Number. A An axis ID ch hange may ccreate drive/moto communic cation problems, if this is performed du uring operatio on i.e. if the d drive/motor starts with one e axis ID and latter on switche es to another axis ID. © ElectroC Craft 2013 20 05 MPD U User Manual Check Set group if you want set the groups to which a drive/motor belongs. A group is way to identify a number of drives, for a multicast transmission. Each drive can be programmed to be member of one or several of the 8 possible groups (up to all). A drive will accept all the messages sent to any of the groups it belongs. Push the buttons for the groups the drive/motor will belong. Use Add groups or Remove groups to add or remove your drive/motor from one or several groups. Remark: A message can be: • Sent to an axis defined by an Axis ID • Multicast to one group of axes defined by a Group ID. The Group ID is an 8-bit value, where each bit set represents a group. For example, a multicast to Group ID = 4 (100b) will be received by all drives from group 3. • Broadcast to all nodes, if the Group ID = 0. Check Synchronization group to activate/deactivate the synchronization procedure. This procedure requires activating one axis as a synchronization master. The other axes are deactivated and are synchronization slaves. Select Send synchronization messages every… and set the time interval between synchronization messages, to activate the synchronization master. Recommended starting value for the time interval is 20ms. When synchronization procedure is active, the execution of the control loops on the slaves is synchronized with those of the master within a 10µs time interval. Due to this powerful feature, drifts between master and slave axes are eliminated. Deactivate the synchronization procedure by choosing Stop sending synchronization messages. This will disable the synchronization master and set the axis as a synchronization slave. In the absence of a master, the synchronization process is stopped. The data transfer operations may be split into three categories: 1. Read data from a remote axis. A variable or a memory location from the remote axis is saved into a local variable 2. Write data to a remote axis or group of axes. A variable or a memory location of a remote axis or group of axes is written with the value of a local variable 3. Send MPL commands from local drive to a remote drive or group of drives Check data transfer commands, and select From axis to read from the remote axis specified, the value of a variable or the data / program / E2ROM memory contents located at an address set in a pointer variable. The data is saved in the local MPL variable indicated in to local variable field. The local variable can be either a 16-bit or a 32-bit MPL data. Its type, dictates the data transfer size. Check then increment the pointer variable to automatically increment the pointer by one or two function of the local variable type, after the transfer is performed. The memory type is split into 3 categories: data – for the RAM area for MPL data, program – for the RAM area for MPL programs and E2ROM – for the EEPROM area for MPL programs. Select Send the local variable to copy on a remote axis or group of axes, the value of the local variable specified. The data is saved either in an external/remote variable or in the data / program / E2ROM memory location(s) from address set in the pointer variable indicated. The local variable can be either a 16-bit or a 32-bit MPL data. Its type, dictates the data transfer size. Check then increment the pointer variable to automatically increment the pointer by one or two function of the local variable type, after the transfer is performed. The memory type is split into 3 categories: data – for the RAM area for MPL data, program – for the RAM area for MPL programs and E2ROM – for the EEPROM area for MPL programs. The destination specified at axis/group can be: • An axis ID set with a number between 1 and 255 • A group set with letter G followed by a number between 1 and 8. Examples: G1, G7 • A broadcast to all axes set with letter B © ElectroCraft 2013 206 MPD User Manual Select Send MPL command to program the local axis to transmit the MPL command(s) you type in the associated field towards the destination specified in the axis/group field. The transmission is done when the command is executed. Remarks: • This command offers a very powerful tool through which one drive/motor may control other drives/motors from the network. For example it can start or stop the other drives motion or check their status • You may type multiple MPL commands separated by semicolon (;). These will be sent one by one in the order of occurrence in the edit. • Via this type of messages, you can send all the MPL instructions having an instruction code of maximum 4 words. In this category enter most of the MPL commands (see MPL Instruction Coding and the detailed description of the MPL Instructions). OK: Close this dialogue and save the operations selected in your motion sequence list. Cancel: Close this dialogue without saving anything in your motion sequence list. Help: Open this help page. See also: Axis Identification Data Transfer Between Axes – MPL Programming Details Remote Control Motion Programming © ElectroCraft 2013 207 MPD User Manual 6.1.22. Send data to host The “Send Data to Host” dialogue allows you to program when the drive/motor will send messages to your host. The message transmission can be triggered by: • Conditions which change the status or error registers • The execution of a dedicated MPL command from your MPL program. Through this command you can send to your host the contents of any MPL data In the first case, you can select the status or the error register bits, which will trigger a message when are changed. The selection is done via masks, one for each register, where for each bit you can choose if to trigger or not a transmission when it is changed. When the transmission is triggered by a bit change in a status register SRH (high part) or SRL (low part), the message sent contains these 2 registers grouped together as a single 32-bit register/data. When the transmission is triggered by a bit change in the error register MER, the message sent contains this register. In the Host address write the axis ID of the host. Check Status Register to enable transmission on status register bit changes. From the right list, select a bit whose change you want to trigger a message transmission and press the [ < ] button. The selected bit will appear on the left list. Repeat the operation for the other bits. Use the button [<<] to select all the bits. Choose a bit from the left list and press the [ > ] button to move it back to the right list. Use the [>>] button to remove all the bits from the left list. © ElectroCraft 2013 208 MPD User Manual Check Error Register to enable transmission on error register bit changes. From the right list, select a bit whose change you want to trigger a message transmission and press the [ < ] button. The selected bit will appear on the left list. Repeat the operation for the other bits. Use the button [<<] to select all the bits. Choose a bit from the left list and press the [ > ] button to move it back to the right list. Use the [>>] button to remove all the bits from the left list. Remark: After power on, the 2 masks are empty i.e. none of the status or error bits is selected to trigger a transmission on change. Check Send contents of variable and indicate the name of the MPL data to be sent when this MPL command is executed. The MPL data can be any 16-bit or 32-bit data: MPL registers, parameters, variable or user variables. Remark: By default, at power on, the host address is set equal with the drive/motor axis ID. Therefore, the messages will be sent via RS-232 serial communication. If the host address is different from the drive/motor axis ID, the messages are sent via the other communication channels: CAN bus, RS485, etc. See also: Messages sent to the host – MPL Programming Details Motion Programming © ElectroCraft 2013 209 MPD User Manual 6.1.23. Assignment & Data Transfer - Miscellaneous The “Miscellaneous” dialogue allows you to: • Declare user variables • Reset/exit the drive/motor from the FAULT status • Execute less frequently used MPL commands like: END, NOP, ENDINIT • Change the CAN bus and serial RS232 / RS485 communication settings • Save actual setup data from RAM into the EEPROM in the setup table Select Define variable named if you want to define a new variable. Specify the variable name in the next field and choose the variable type from the list. The options are: int, fixed or long. A variable of type int is a 16-bit signed integer. A variable of type long is a 32-bit signed integer. A variable of type fixed is 32bit wide and is used for signed fixed-point representations with 16MSB the integer part and 16LSB the factionary part. Select Reset FAULT status to exit a drive/motor from the FAULT status in which it has entered due to an error. After a fault reset command, most of the bits from error register MER are cleared (set to 0), ready output is set to ready level, error output is set to no error level and drive/motor returns to normal operation. Remarks: • The FAULT reset command does not change the status of MER.15 (enable input on disabled level), MER.7 (negative limit switch input active), MER.6 (positive limit switch input active) and MER.2 (invalid setup table) • The drive/motor will return to FAULT status if there are errors when the FAULTR command is executed © ElectroCraft 2013 210 MPD User Manual Select Insert END instruction to introduce in your MPL program the instruction END. When END is executed, the MPL program execution is stopped. Remark: It is mandatory to end the main section of a MPL program with an END command. All the MPL functions and the MPL interrupt service routines must follow after the END command. MotionPRO Developer automatically handles these requirements, when it generates the MPL program to be compiled and downloaded into the drive. Select Insert NOP instruction to introduce a NOP (No operation) instruction. It can be used as a delay between two motion sequences / instructions. In the Serial communication section, choose Change baudrate to if you want to change the drive baud rate for RS-232 and RS-485 communication. Choose from the drop list one of the available baud rates: 9600, 19200, 38400, 56000 and 115200. Remarks: 1. The drives/motors default serial baud rate after power on is 9600 baud, unless another value was saved in the setup table. When you start MotionPRO Developer, the drives/motors serial baud rate is automatically adjusted to the last value selected at Communication | Setup in the Baud Rate field. 2. Use this command when a drive/motor operates in AUTORUN (after power on starts to execute the MPL program from the EEPROM) and it must communicate with a host at a baud rate different from the default value. In this case, the MPL program must start with a serial baud rate change. 3. An alternate solution to the above case is to set via MotionPRO Developer the desired baud rate and then to save it the EEPROM, with command SAVE. After a reset, the drive/motor starts directly with the new baud rate, if the setup table was valid. Once set, the new default baud rate is preserved, even if the setup table is later on disabled, because the default serial baud rate is stored in a separate area of the EEPROM. In the CAN communication section, choose Select Set CAN baudrate to if you want to change the baud rate for CAN-bus communication. Choose from the drop list one of the available CAN baud rates: 125kb, 250kb, 500kb, 800kb, 1Mb. Remarks: 1. The drives/motors default CAN baud rate after power on is 500kb, unless another value was saved in the setup table. In MotionPRO Developer, at Communication | Setup, in the Baud Rate field, you must choose the same value as the default CAN baud rate of the drives/motors value. This selection refers ONLY to the CAN bus interface of your PC 2. Use this command when a drive/motor operates in AUTORUN (after power on starts to execute the MPL program from the EEPROM) and it must communicate with a host at a baud rate different from the default value. In this case, the MPL program must start with a CAN baud rate change. 3. An alternate solution to the above case is to set via MPL command CANBR the desired CAN baud rate and then to save it the EEPROM, with command SAVE. After a reset, the drive/motor starts directly with the new CAN baud rate, if the setup table was valid. Once set, the new default CAN baud rate is preserved, even if the setup table is later on disabled, because the default CAN baud rate is stored in a separate area of the EEPROM. Select Insert ENDINIT instruction to introduce an ENDINT (end of initialization) instruction. This command uses the available setup data to perform key initializations, but does not activate the controllers or the PWM outputs. These are activated with the AXISON command Remarks: © ElectroCraft 2013 211 MPD User Manual 1. After power on, the ENDINIT command may be executed only once. Subsequent ENDINIT commands are ignored. 2. The AXISON command must be executed after the ENDINIT command 3. Typically, the ENDINIT command is executed at the beginning of a MPL program and may be followed by the AXISON command even if no motion mode was set. In the absence of any programmed motion, the drive applies zero voltage to the motor. 4. In MotionPRO Developer, ENDINIT and AXISON commands are automatically included when a MPL program is generated. Hence you can start directly with the motion programming Select Save actual setup data in the EEPROM to insert a SAVE instruction in the MPL program. When SAVE instruction is executed, the actual values of the MPL parameters are copied from the RAM memory into the EEPROM memory, in the setup table. Through this command, you can save all the setup modifications done, after power on initialization. OK: Close this dialogue and save the MPL commands in your motion sequence list. Cancel: Close this dialogue without saving anything in your motion sequence list. Help: Open this help page See also: Miscellaneous commands – MPL Programming Details Motion Programming © ElectroCraft 2013 212 MPD User Manual 6.1.24. MPL Interrupt Se ettings The “Interrrupt Settings s” dialogue allows you to activate and//or deactivate e the MPL (E ElectroCraft M Motion Program Language) in nterrupts. Wh hen a MPL interrupt occu urs, the norm mal MPL program executtion is ed to execute a MPL functiion associate ed with the intterrupt, called d Interrupt Se ervice Routine (in suspende short ISR). The MPL in nterrupt mech hanism is the following: • Th he drive conttinuously monitors 12 con nditions that may genera ate MPL inte errupts. In ca ase of mo otion controlle er applications there is a 13th condition related to sla ave error status. • Th he motion controller has an a additional condition tha at triggered interrupt whe en an error o on the sla aves occurs • When an interru upt condition occurs, a flag g (bit) is set in n the ISR (Inte errupt Status Register) • If the interrupt is unmasked d e.g. the same bit (as p position) is se et in the ICR R (Interrupt C Control Re egister) and also if the in nterrupts are globally ena abled (EINT instruction w was executed d), the intterrupt conditiion is qualified d and it generates a MPL interrupt • Th he interrupt causes a jump p to the asso ociated interru upt service ro outine. On en ntry in this ro outine, the e MPL interru upts are globa ally disabled (DINT) and th he interrupt fla ag is reset • Th he interrupt service s routine e must end with w the MPL L instruction RETI, which returns to n normal pro ogram executtion and in the same time globally enab bles the MPL interrupts. Interrrupt settings dialog d for driv ve/motor © ElectroC Craft 2013 213 MPD U User Manual The 12 conditions are: 1. Int0 – Enable input has changed: either transition sets the interrupt flag 2. Int1 – Short-circuit: when the drive/motor hardware protection for short-circuit is triggered 3. Int2 – Software protections: when any of the following protections is triggered: a) Over current b) I2t motor c) I2t drive d) Over temperature motor e) Over temperature drive f) Over voltage g) Under voltage 4. Int3 – Control error: when the control error protection is triggered 5. Int4 – Communication error: when a communication error occurs 6. Int5 – Wrap around: when the target position computed by the reference generator wraps around because it bypasses the limit of the 32-bit long integer representation 7. Int6 – LSP programmed transition detected: when the programmed transition is detected on the limit switch input for positive direction (LSP) 8. Int7 – LSN programmed transition detected: when the programmed transition is detected on the limit switch input for negative direction (LSN) 9. Int8 – Capture input transition detected: when the programmed transition is detected on the 1st capture/encoder index input or on the 2nd capture/encoder index input 10. Int9 – Motion is completed: in position control, when motion complete condition is set and in speed control when target speed reaches zero. 11. Int10 – Time period has elapsed: periodic time interrupt with a programmable time period 12. Int11 – Event set has occurred: when last defined event has been occurred After power-on, the MPL interrupts are globally enabled together with the first 4 interrupts: Int 0 to Int 3. For Int 2, all the protections are activated, except over temperature motor, which depends on the presence or not of a temperature sensor on the motor; hence this protection may or may not be activated. For each of these 4 interrupts there is a default ISR which is executed when the corresponding interrupt occurs. You can view the contents of the default ISR in the MPL Interrupt Service Routines view. From this view you may also modify the default ISR for these interrupts and/or define ISR for the other MPL interrupts. Before using other MPL interrupts, you need to enable them from this dialogue. Keep in mind that the interrupt flags are set independently of the activation or not of the MPL interrupts. Therefore, as a general rule, before enabling an interrupt, reset the corresponding flag. This operation will avoid triggering an interrupt immediately after activation, due to an interrupt flag set in the past. Remarks: • On entry in an ISR, the MPL interrupts are globally disabled. If you want to enable during the ISR execution ant of the other interrupts, set accordingly the interrupt mask in the ICR register and insert the EINT instruction that globally enables the interrupts © ElectroCraft 2013 214 MPD User Manual • The interrupt service routines are similar with the MPL functions, except for the return instruction: RETI (RETurn from Interrupt) instead of RET (RETurn from subroutine). Like the MPL functions, the MPL interrupt service routines must be positioned after the end of the main program. MotionPRO Developer handles automatically this aspect. Check Globally Enable MPL interrupts to globally enable the MPL interrupts. Check Globally Disable MPL interrupts to globally disable the MPL interrupts. At Enable/Disable MPL interrupt choose one or several interrupts and select either Enable or Disable to activate or deactivate them. The status of the other interrupts remains unchanged. For the interrupts enables, check also Reset previous MPL interrupt request to reset the corresponding interrupt flag(s) set in the past. For Int2 – Software protections, select Enable and press Details to modify the status (enabled or disabled) of the protections triggering this interrupt. © ElectroCraft 2013 215 MPD User Manual For Int 6 - LSP programmed transition detected and Int 7 - LSN programmed transition detected select Enable and press Details to select the monitored transition: high to low or low to high. For Int8 – Capture input transition detected select Enable and press Details to select the monitored transition: high to low or low to high and the capture/encoder input to use: 1st or 2nd © ElectroCraft 2013 216 MPD User Manual For Int10 – Time period has elapsed select Enable and press Details to set the time period. Remark: Some of the drive/motor protections may not work properly if the MPL Interrupts are handled incorrectly. In order to avoid this situation keep in mind the following rules: • The MPL interrupts must be kept globally enabled to allow execution of the ISR for those MPL interrupts triggered by protections. As during a MPL interrupt execution, the MPL interrupts are globally disabled, you should keep the ISR as short as possible, without waiting loops. If this is not possible, you must globally enable the interrupts with EINT command during your ISR execution. • If you modify the interrupt service routines for Int 0 to Int 4, make sure that you keep the original MPL commands from the default ISR. Put in other words, you may add your own commands, but these should not interfere with the original MPL commands. Moreover, the original MPL commands must be present in all the ISR execution paths. OK: Close this dialogue and save the interrupt settings in your motion sequence list. Cancel: Close this dialogue without saving anything in your motion sequence list. Help: Open this help page. See also: MPL Interrupts – MPL Programming Details MPL Interrupt Service Routines Motion Programming © ElectroCraft 2013 217 MPD User Manual 6.1.25. Free text The “Free Text” dialogue allows you to add comments to your MPL programs in order to improve their readability and therefore make them easier to understand and debug. A comment can include any characters. A multi line comment must start with “ /* ” and finish with “ */ “. A single line comment can be preceded by “ // ”. Through this dialogue you can also insert directly MPL commands, if you know their syntax. Note that all the MPL commands must ended with a semicolon “;”. Labels must start from the first column of a new line and end with a colon “:”. For readability, leave at least one space before starting a MPL command in a new line. This way you can quickly distinguish them from the labels. Remark: The motion dialogues cover all the MPL commands you typically need in an application. There is however a small number of MPL instructions that can’t be generated from the motion dialogues and which may be used in some special cases. If ever needed, you can set these MPL commands via this dialogue. OK: Close this dialogue and add the comments / MPL commands in your motion sequence list. Cancel: Close this dialogue without saving anything. Help: Open this help page. See also: Motion Programming © ElectroCraft 2013 218 MPD User Manual 6.2. ElectroCraft Motion Language 6.2.1. Basic Concepts 6.2.1.1. Overview The ElectroCraft Motion Program Language (MPL) is a high-level language allowing you to: • Setup a ElectroCraft Programmable drive/motor for a given application • Program and execute motion sequences The setup part consists in assigning the right values for the MPL registers and parameters. Through this process you can: • Describe your application configuration (as motor and sensors type) • Select specific operation settings (as motor start mode, PWM mode, sampling rates, etc.) • Setup the controllers’ parameters (current, speed, position), etc. The output of the setup process is a set of values – the setup data – to be written in the MPL registers and parameters. The setup data can be: a) Stored in the drive/motor non-volatile EEPROM, from where it is automatically loaded into the MPL registers and parameters at power-on, if the data integrity check is passed b) Included at the beginning of a MPL program as a set of assignment instructions through which the MPL registers and parameters are initialized with the desired values Remark: PROconfig – the latest generation setup tool for ElectroCraft Programmable drives/motors – handles the setup process according with option a). The motion programming part allows you to: • Set various motion modes (profiles, PVT, PT, electronic gearing or camming, etc.) • Change the motion modes and/or the motion parameters • Execute homing sequences • Control the program flow through: o Conditional jumps and calls of MPL functions o MPL interrupts generated on pre-defined or programmable conditions (protections triggered, transitions on limit switch or capture inputs, etc.) o Waits for programmed events to occur • Handle digital I/O and analogue input signals • Execute arithmetic and logic operations • Perform data transfers between axes • Control motion of an axis from another one via motion commands sent between axes © ElectroCraft 2013 219 MPD User Manual • Send commands to a group of axes (multicast). This includes the possibility to start simultaneously motion sequences on all the axes from the group • Synchronize all the axes from a network Due to a powerful instruction set, the motion programming in MPL is quick and easy even for complex motion applications. The result is a high-level motor-independent program which once conceived may be used in other applications too. Basic Concepts next topics: MPL Environment Program Execution MPL Program Structure MPL Instruction Coding MPL Data Memory Map – Firmware version FAxx Memory Map – Firmware version FBxx AUTORUN mode See also: MPL Description © ElectroCraft 2013 220 MPD User Manual 6.2.1.2. MPL Environment The MPL environment includes three basic components: 1. “MPL processor” 2. Trajectory generator 3. Motor control kernel The software-implemented “MPL processor” represents the core of the MPL environment. It decodes and executes the MPL commands. Like any processor, it includes specific elements as program counter, stack, ALU, interrupt management and registers. The trajectory generator computes the position, speed, torque or voltage reference at each sampling step, depending on the selected motion mode. The motor-control kernel implements the control loops including: the acquisition of the feedback sensors, the controllers, the PWM commands, the protections, etc. When the “motion processor” executes a motion command, it translates them into actions upon the trajectory generator and/or the motor control kernel. Basic Concepts next topics: Program Execution MPL Program Structure MPL Instruction Coding MPL Data Memory Map– Firmware FAxx Memory Map – Firmware FBxx AUTORUN mode See also: Basic Concepts MPL Description © ElectroCraft 2013 221 MPD User Manual 6.2.1.3. Program Execution The MPL programs are executed sequentially, one o instructio on after the otther. A 16-bit instruction p pointer ols the progra am flow. As th he binary cod de of a MPL in nstruction ma ay have up to 5 words, during its (IP) contro execution the IP is inc creased accorrdingly. When n the executio on of a MPL instruction ends, the IP a always t next MPL instruction, or o more exacttly to the first word of its binary code. points to the The seque ential execution may be interrupted by one of the fol lowing cause es: • A MPL comma and received through t a com mmunication channel (on-lline command ds); • A branch to the e interrupt service routine (ISR) when a MPL interrup pt occurs; • The need to se end the maste er position to the slave axe es when the current axis is set as mastter for ellectronic gearring or camming • A GOTO, CAL LL or CALL LS instruction; • A return from a MPL functio on – RET or fro om a MPL intterrupt – RET TI; • During D the exe ecution of the e instructions: WAIT! (waitt event), SEG G (new contou ur segment), PVTP orr PT (new PVT P or PT point) p if the buffer b is full, and data trransfers betw ween axes off type lo ocal_varia able = [x]r remote_var riable, whicch all keep the e IP unchanged (i.e. loop o on the sa ame instructio on) until a spe ecific conditio on is achieved d • After A execution n of the END instruction. The on-lin ne command ds have the highest h prioritty and act likke interrupts:: when an on n-line comma and is received through t any communicatio c on channel, itt starts to be executed imm mediately afte er the currentt MPL instruction n is completed d. If an on-line command is received during d a wait loop, the waitt loop is temp porary suspen nded, to perm mit the e command. execution of the on-line mmands, prese ented in table e below. The MPL works with 3 types of com ediate comma ands may be sent via a co ommunication n channel, orr can reside in a MPL program. The imme These commands don n’t require any y wait loops to t complete. Their executtion is straigh htforward and d can’t ands. be interrupted by otherr MPL comma ands require a wait loop to o complete i. e. will not pe ermit the IP to o advance un ntil the The sequential comma s true. In this category entter commandss like: wait condition becomes AIT!; // Wait a programme ed event to oc ccur WA SE EG Time, Increment; ; // Set a contour c segm ent with para ameters Time and //Increm ment to be exe ecuted when the previous one ends lo ocal_variable = [x]r remote_vari iable; © ElectroC Craft 2013 22 22 ue of remote_ _variable from m // Get valu MPD U User Manual //axis x and put it in local_variable The sequential commands can reside only in a MPL program saved in the local memory. Remark: If a sequential command is sent via a communication channel, it is immediately executed as if the wait loop condition is always true. The on-line commands may be sent only via a communication channel. These commands can’t be included in a MPL program. The on-line commands do not have an associated mnemonic and syntax rules as they are do not need to be recognized by the MPL compiler. Their code is known only by the “MPL processor”. Remark: Some of the on-line commands are implemented in debugging tools like the Command Interpreter, which was specifically designed to allow sending commands via a communication channel. These commands are presented with a “mnemonic” like that used in the Command Interpreter. The Command Interpreter is a component present in all the ElectroCraft applications for drives/motors setup and MPL Programming: PROconfig, MotionPRO Developer. Basic Concepts next topics: MPL Program Structure MPL Instruction Coding MPL Data Memory Map – Firmware version FAxx Memory Map – Firmware version FBxx AUTORUN mode See also: Basic Concepts MPL Description © ElectroCraft 2013 223 MPD User Manual 6.2.1.4. MPL Program Structure The main section of a MPL program starts with the instruction BEGIN and ends with the instruction END. It is divided into two parts: • • Setup part Motion programming part The setup part starts after BEGIN and lasts until the ENDINIT instruction, meaning “END of INITitialization”. This part of the MPL program consists mainly of assignment instructions, which shall set the MPL registers and the MPL parameters in accordance with your application data. When the ENDINIT command is executed, key features of the MPL environment are initialized according with the setup data. After the ENDINIT execution, the basic configuration involving the motor and sensors types or the sampling rates cannot be changed unless a reset is performed. Remark: The setup part can be void when setup data is saved in the EEPROM. In this case, the setup data is automatically loaded into the MPL registers and parameters, at power-on. However, even in this case in some situations it may still be necessary to perform some setup operations like: • Copy of cam tables from the drive/motor EEPROM into the working RAM memory • Copy of the whole MPL program into the RAM in special cases where the EEPROM memory can’t be used during run time The motion programming part starts after the ENDINIT instruction until the END instruction. All the MPL programs (the main section) should end with the MPL instruction END. When END instruction is encountered, the sequential execution of a MPL program is stopped. Apart from the main section, a MPL program also includes the MPL interrupt vectors table, the interrupt service routines (ISRs) for the MPL interrupts and the MPL functions. A typical structure for a MPL program is presented in figure below. © ElectroCraft 2013 224 MPD User Manual Typical stru ucture of a MP PL Program Basic Con ncepts next to opics: MPL Instrruction Coding g MPL Data a Memory Map M – Firmwa are version FA Axx Memory Map M – Firmwa are version FB Bxx AUTORUN mode See also: ncepts Basic Con MPL Desc cription © ElectroC Craft 2013 22 25 MPD User Manual 6.2.1.5. MPL Instruction Coding The MPL instruction code consists of 1 to 5, 16-bit words. The first word is the operation code. The rest of words (if present) represent the instruction data words. The operation code is divided into two fields: Bits 15-9 represent the code for the operation category. For example all MPL instructions that perform addition of two integer variables share the same operation category code. The remaining bits 8-0 represent the operand ID that is specific for each instruction. Basic Concepts next topics: MPL Data Memory Map – Firmware version FAxx Memory Map – Firmware version FBxx AUTORUN mode See also: Basic Concepts MPL Description © ElectroCraft 2013 226 MPD User Manual 6.2.1.6. MPL Data The MPL works with the following categories of data: • MPL Registers • MPL Parameters • MPL Variables • User Variables All MPL data are identified by their name. The names of the MPL registers, parameters or variables are predefined and do not require to be declared. The names of the user variables are at your choice. You need to declare the user variables before using them. The MPL uses the following data types: • int 16-bit signed integer • uint 16-bit unsigned integer • fixed 32-bit fixed-point data with the 16MSB for the integer part and the 16LSB for the factionary part. • long 32-bit signed integer • ulong 32-bit unsigned integer The data type uint or ulong are reserved for the MPL predefined data. The user-defined variables are always signed. Hence you may declare them of type: int, fixed or long. Remark: An unsigned MPL data means that in the firmware its value is interpreted as unsigned. Typical examples: register values, time-related variables, protection limits for signals that may have only positive values like temperature or supply voltage, etc. However, the same data will interpreted as signed if it is used in a MPL instruction whose operands are treated as signed values. Each MPL data has an associated address. This represents the address of the data memory location where the MPL data exists. Address ranges for MPL registers, variables and parameters are from 0x0200 to 0x03AF and from 0x0800 to 0x09FF. For user-defined variables the address range is between 0x03B0 and 0x03FF. In MPL the data components may be addressed in several ways: • direct, using their name in the MPL instruction mnemonic Example: CPOS = 2000; // write 2000 in CPOS parameter (command position) • indirect, using a pointer variable. The pointer value is the address of the data component to work with Example: user_var = 0x29E; // write hexadecimal value 0x29E representing CPOS address in // the user-defined pointer variable user_var (user_var),dm = 2000; // write 2000 in the data memory address pointed by // user_var i.e. in the CPOS parameter © ElectroCraft 2013 227 MPD User Manual • direct with extended address, using the MPL data name Example: CPOS,dm = 2000; // write 2000 in CPOS using direct mode with extended address In the MPL instructions the operands (variables) are grouped into 2 categories: • V16. In this category enter all the 16-bit data from all the categories: MPL registers, MPL parameters, MPL variables, and user parameters. From the execution point of view, the MPL makes no difference between them. • V32. In this category enter all the 32-bit data either long or fixed from all the categories: MPL registers, MPL parameters, MPL variables, and user parameters. From the execution point of view, the MPL makes no difference between them. Remarks: • It is possible to address only the high or low part of a 32-bit data, using the suffix (H) or (L) after the variable name. Examples: CPOS(L) = 0x4321; // write hexadecimal value 0x4321 in low part of CPOS CPOS(H) = 0x8765; // write hexadecimal value 0x8765 in high part of CPOS // following the last 2 commands, CPOS = 0x87654321 • The MPL compiler always checks the data type. It returns an error if an operand has an incompatible data type or if the operands are not of the same type • A write operation using indirect addressing is performed on one or two words function of the data type. If the data is a 16-bit integer, the write is done at the specified address. If the data is fixed or long the write is performed at the specified address and the next one. A fixed data is recognized by the presence of the dot, for example: 2. or 1.5. A long variable is automatically recognized when its size is outside the 16-bit integer range or in case of smaller values by the presence of the suffix L, for example: 200L or –1L. Examples: user_var = 0x29E; // write CPOS address in pointer variable user_var (user_var),dm = 1000000;// write 1000000 (0xF4240) in the CPOS parameter i.e. // 0x4240 at address 0x29E and 0xF at next address 0x29F (user_var),dm = -1;// write -1 (0xFFFF) in CPOS(L). CPOS(H) remains unchanged (user_var),dm = -1L;// write –1 seen as a long variable (0xFFFFFFFF) in CPOS i.e. // CPOS(L) = 0xFFFF and CPOS(H) = 0xFFFF user_var = 0x2A0; // write CSPD address in pointer variable user_var (user_var),dm = 1.5; // write 1.5 (0x18000) in the CSPD parameter i.e. // 0x8000 at address 0x2A0 and 0x1 at next address 0x2A1 • In an indirect addressing, if the pointer variable if followed by + sign, it is automatically incremented by 1 or 2 depending on the data type: 1 for integer, 2 for fixed or long data. © ElectroCraft 2013 228 MPD User Manual Examples: user_var = 0x29E; // write CPOS address in pointer variable user_var (user_var+),dm = 1000L; // write 1000 seen as long in CPOS, then increment // user_var by 2 (user_var+),dm = 1000; // write 1000 seen as int at address 0x29A (0x29E+2) , // then increment user_var by 1 MPL Data categories: MPL Registers MPL Parameters MPL Variables User Variables Basic Concepts next topics: Memory Map – Firmware version FAxx Memory Map – Firmware version FBxx AUTORUN mode See also: Basic Concepts MPL Description © ElectroCraft 2013 229 MPD User Manual 6.2.1.6.1. MPL Registers There are 3 categories of MPL registers: • Configuration registers • Command registers • Status registers The configuration registers contain essential configuration information like motor and sensors type, or basic operation settings like PWM mode, motor start method, etc. The configuration registers must be set up during the setup part before the ENDINIT instruction The command registers hold configuration settings that may be changed during motion. These settings refer to the activation/deactivation of software protections, to the use of MPL interrupts and to communication options. The status registers provide information about drive/motor condition: errors and protections triggered, communication, active motion mode and control loops, MPL interrupts. The status registers can be used to detect events and to make decisions in a MPL program. Configuration registers (R/W): ACR – Auxiliary Control Register. Defines extra settings like: the configuration for automatic start and the external reference, operation options for the S-curve and the electronic camming modes. OSR – Operating Settings Register. Defines some specific operating settings regarding motor control and data acquisition SCR – System Configuration Register. Defines the basic application configuration regarding the motor type and the feedback sensors used UPGRADE – Upgrade Register. Defines new options and extended features which are activated when their corresponding bits are set to 1 Command registers (R/W): CCR – Communication Control Register. Contains settings for the SPI link with the EEPROM ICR – Interrupt Control Register. Enables/disables MPL interrupts MCR – Motion Command Register. Configures the motion modes: reference mode, active control loops, positioning type - absolute or relative, etc. PCR.7-0 – Protections Control Register. Activates different drive/motor protections like: over-current, I2t drive and motor, over- and under-voltage and over-temperature. Status registers (RO): AAR – Axis Address Register. Contains the Axis ID and the group ID of the drive/motor. CBR – CAN Baud rate Register. Contains the current settings for CANbus baud-rate. CER – Communication Error Register. Contains error flags for the communication channels. CSR – Communication Status Register. Contains status flags for the communication channels. ISR – Interrupt Status Register. Contains interrupt flags set by the MPL interrupt conditions. © ElectroCraft 2013 230 MPD User Manual MER – Motion Error Register. Groups all the errors conditions. MSR – Motion Status Register. Gives indications about the motion status and some specific events like: control error condition, position wrap-around, limit switches and captures triggered by programmed transitions, etc. PCR.14-8 – Protections Control Register. Contains flags set by the protections set in PCR.7-0. SRL – Status Register Low. Low part of a 32-bit register grouping together all the key status information concerning the drive/motor SRH – Status Register High. High part of a 32-bit register grouping together all the key status information concerning the drive/motor SSR – Slave Status Register. Groups initialization information related to slave axes commanded by the motion controller The MPL registers are treated like any other MPL parameter or variable in the MPL program. The configuration and command registers may be read or written. The status registers may only be read. Remark: The setup tools set automatically the configuration and command registers. The most important status information is grouped in 2 registers: MER - the Motion Error Register and SRL, SRH – the Status Register Low and High part. They have been specifically designed to provide you all the key information about the drive/motor status. See also: MPL Data MPL Parameters MPL Variables User Variables © ElectroCraft 2013 231 MPD User Manual 6.2.1.6.2. MPL Parameters The MPL parameters allow you to setup the parameters of the MPL environment according with your application data. Though most of the MPL parameters have their own address, there are some that share the same memory address. They are used in application configurations that exclude each other, and thus are not needed at the same time. Some MPL parameters must be setup during the initialization phase. They are used to define the realtime kernel, including the PWM frequency and the control loops sampling periods, and should not be changed after the execution of the ENDINIT command. The other parameters can be initialized, used and changed any time, before or after the ENDINIT command. See also: MPL Data MPL Registers MPL Variables User Variables 6.2.1.6.3. MPL Variables The MPL variables provide you status information about the MPL environment like the motor position, speed and current, the position, speed and current commands, etc. These values may be used to take decisions in the motion program or for analysis and debug. The MPL variables are read-only (RO). Modifying their value during motion execution may cause an improper operation of the drive/motor. There are however, specific situations when some MPL variables may also be written (R/W variables). Most of the MPL variables are internally initialized after power-on, or during the setup phase up to the execution of the ENDINIT command. Activating the on-chip logger module, real-time data tracking can also be implemented for any of these variables. See also: MPL Data MPL Registers MPL Parameters User Variables © ElectroCraft 2013 232 MPD User Manual 6.2 2.1.6.4. MPL User Variables Besides the MPL pre-d defined variables, you can n also define your own usser variables. You can use e your nstruction acc cepting variab bles of the sa me type. variables in any MPL in e can be: inte eger, fixed (po oint) or long (iinteger) (see table below).. The user variables type ess of the us ser variables is automatically set in the e order of de eclaration sta arting with 0x03B0. The addre First integ ger variable takes t addres ss 0x3B0, next one 0x3B1 1, etc. An in nt variable takes one me emory location. A long or fixed f variab ble takes 2 consecutive c m memory locattions. In this case the va ariable address is s the lowest one. o Example:: in nt user_va ar1; lo ong user_v var2; // user_v var1 address iis 0x3B0 // us ser_var2 address is 0x3B1 1 fi ixed user_ _var3; // us ser_var3 address is 0c3B3 3 in nt user_va ar4; // user_v var4 address iis 0x3B5 Remark: you have to declare d a use er variable beffore using it fifirst time. See also: MPL Data a MPL Registers MPL Para ameters MPL Varia ables © ElectroC Craft 2013 23 33 MPD U User Manual 6.2.1.7. Memory Map - Firmware FAxx ElectroCraft drives/motors work with 2 separate address spaces: one for MPL programs and the other for data. Each space accommodates a total of 64K 16-bit word. The first 16K of the MPL program space (0 to 3FFFh) is reserved and can’t be used. The next 16K, from 4000h to 7FFFh are mapped to a serial SPI-connected EEPROM with the maximum size 32K bytes (seen as 16K 16-bit words). The exact amount of EEPROM memory is specific for each drive/motor. This space is used to store MPL programs, cam tables, the setup data and the product ID. The recommended way to use the EEPROM memory space is: • MPL programs from the beginning of the EEPROM, starting with first address 4000h • Cam tables, after the MPL program, until the beginning of the setup data • Setup data and product ID. Other data until the end of the EEPROM Remarks: • The space needed for the setup data and the product ID is automatically computed by PROconfig • The overall dimension of a MPL program includes apart from the main section, the MPL interrupt vectors table, the interrupt service routines (ISRs) for the MPL interrupts and the MPL functions For most of the ElectroCraft drives/motors, the next 2K of the MPL program space from 8000h to 87FFh represent the drive/motor internal RAM memory. From it, the first 270h, from 8000h to 826Fh are reserved for the internal use. The rest from 8270h to 87FFh may be used to temporary store MPL programs. The remaining MPL program space from 8800h to FFFFh is invalid. Some ElectroCraft drives have an extended internal RAM going from 8000h to FFFFh. From it, the first 270h are reserved for the internal use. In this case, the MPL programs space goes from 8270h to FFFFh. The data memory space is used to store the MPL data (registers, parameters, variables), the cam tables during runtime (after being copied from the EEPROM memory) and for data acquisitions. The MPL data are stored in a reserved area, while the others are using the same internal RAM memory used for MPL programs. Though physically the RAM memory is the same for both, the MPL programs and data, the first 2K are mapped at different address ranges: The MPL program space from 8000h to 87FFh is seen in the data space from 800h to 9FFh. As the first 270h from it are reserved, the effective data memory space goes from A70h to FFFh. Apart from this space, the drives with extended internal RAM have another 32k of data memory, from 0x8000 to 0xFFFF. Remark: As the same RAM memory is used both for MPL programs and for data, it is the user responsibility to decide how to split these spaces in order to avoid their overlap. The recommended way to use the RAM memory (both for MPL programs and data) is: • MPL programs from the beginning of the SRAM memory • Data acquisitions, after the MPL programs • Cam tables, after data acquisitions, until the end of the RAM In the case of the drives/motors with normal RAM memory, you should start by checking if or how much space you need to reserve for cam tables, and use the rest of the SRAM for data acquisitions. As concerns the MPL programs, it is highly preferable to store them in the EEPROM. Remark: In configurations with feedback devices like the SSI or EnDat encoders, the MPL programs must execute from SRAM memory. This is because these feedback devices are using the same SPI interface to read the feedback position like the EEPROM, which is disabled after the execution of © ElectroCraft 2013 234 MPD User Manual ENDINIT command. Therefore, T at power-on, th he MPL progrram needs to o be copied ffrom the EEP PROM R where it is i executed into the RAM Basic Con ncepts next to opics: AUTORUN mode See also: Basic Con ncepts MPL Desc cription © ElectroC Craft 2013 23 35 MPD U User Manual 6.2.1.8. Memory Map - Firmware FBxx ElectroCraft drives/motors work with 2 separate address spaces: one for MPL programs and the other for data. Each space accommodates a total of 64K 16-bit word. The first 16K of the MPL program space (0 to 3FFFh) is reserved and can’t be used. The next 16K, from 4000h to 7FFFh are mapped to a serial SPI-connected EEPROM with the maximum size 32K bytes (seen as 16K 16-bit words). The exact amount of EEPROM memory is specific for each drive/motor. This space is used to store MPL programs, cam tables, the setup data and the product ID. The recommended way to use the EEPROM memory space is: • MPL programs from the beginning of the EEPROM, starting with first address 4000h • Cam tables, after the MPL program, until the beginning of the setup data • Setup data and product ID. Other data until the end of the EEPROM Remarks: • The space needed for the setup data and the product ID is automatically computed by MotionPRO Developer • The overall dimension of a MPL program includes apart from the main section, the MPL interrupt vectors table, the interrupt service routines (ISRs) for the MPL interrupts and the MPL functions For most of the ElectroCraft drives/motors, the next 4K of the MPL program space, from 9000h to 9FFFh, represents the drive/motor internal RAM memory. The memory space may be used to temporary store MPL programs. The data memory space is used to store the PVT buffer, the cam tables during runtime (after being copied from the EEPROM memory) and for data acquisitions. The MPL data are stored in a reserved area, while the others are using the same internal RAM memory used for MPL programs. Remark: As the same RAM memory is used both for MPL programs and for data, it is the user responsibility to decide how to split these spaces in order to avoid their overlap. The recommended way to use the RAM memory (both for MPL programs and data) is: • MPL programs from the beginning of the SRAM memory • Data acquisitions, after the MPL programs • Cam tables, after data acquisitions, until the end of the RAM You should start by checking if or how much space you need to reserve for cam tables, and use the rest of the SRAM for data acquisitions. As concerns the MPL programs, it is highly preferable to store them in the EEPROM. Remark: In configurations with feedback devices like the SSI or EnDat encoders, the MPL programs must execute from SRAM memory. This is because these feedback devices are using the same SPI interface to read the feedback position like the EEPROM, which is disabled after the execution of ENDINIT command. Therefore, at power-on, the MPL program needs to be copied from the EEPROM into the RAM where it is executed © ElectroCraft 2013 236 MPD User Manual Basic Con ncepts next to opics: AUTORUN mode See also: Basic Con ncepts MPL Desc cription © ElectroC Craft 2013 23 37 MPD User Manual 6.2.1.9. AUTORUN Mode The ElectroCraft drives/motors have 2 startup modes, at power on: AUTORUN and slave In the AUTO(matic) RUN(ning) mode, the drive/motor reads the first EEPROM memory location at address 0x4000 and checks if the binary code is 0x649C corresponding to the MPL instruction BEGIN. If this condition is true, the MPL program saved in the EEPROM memory is executed starting with the next instruction after BEGIN. If the condition is false, the drive/motor enters in the slave mode and waits to receive commands from a host via a communication channel. The AUTORUN mode, offers the possibility to execute automatically after power-on a MPL program saved into the drive/motor EEPROM memory. In the slave mode, even if there is a valid MPL program in the EEPROM, this is not executed, because the drive/motor forces the execution of the END command which stops the MPL program execution. Some of the ElectroCraft drives/motors are automatically set in the AUTORUN mode. Others have a dedicated switch or jumper through which you can set either the AUTORUN mode or the slave mode. During a MPL program execution, a drive/motor can enter in the slave mode and stop the MPL program execution in the following cases: • After the execution of the END command • After receiving a STOP command from an external device, via a communication channel • After an entering in FAULT status, due to a protection triggered Remark: When a drive/motor is set in AUTORUN mode, to change the MPL program you have to do to the following operations: Send via a communication channel the MPL command END, to stop the current program execution, followed by AXISOFF to disable the drive power stage Download the new MPL program Reset the drive. The new MPL program will start to execute. See also: Basic Concepts MPL Description © ElectroCraft 2013 238 MPD User Manual 6.2.2. MPL Description 6.2.2.1. Overview The MPL provides instructions for the following categories of operations: • Motion programming and control. These instructions allow you to program ElectroCraft motion controllers or programmable drives/motors in order to set different motion modes and trajectories. These are divided into 2 categories function of how the motion reference is generated: • Motion modes with reference provided by an external device via an analog input, pulse & direction signals, a master encoder or via a communication channel • Motion modes with reference computed by the internal reference generator. In this category enter all the other motion modes You can program one of the following motion modes: • Trapezoidal Position Profile • Trapezoidal Speed Profile • S-Curve Profile • Position-Time (PT) Interpolated • Position-Velocity-Time (PVT) Interpolated • External • Electronic Gearing (alone or superposed with another motion mode) • Electronic Camming • Homing • Contouring • Test • Linear Interpolation • Vector Mode and control their execution via a set of Motor Commands. Remark: The Linear Interpolation and Vector Mode are coordinated motion modes available in applications developed for ElectroCraft Motion Controller. • • Program flow control. In the MPL you can control the program execution in 3 ways: • By setting an event to be monitored and waiting the event occurrence • Through jumps and MPL function calls • Through the MPL interrupts which can be triggered in certain conditions I/O handling © ElectroCraft 2013 239 MPD User Manual Firmware FAxx • General-purpose I/O • Special I/O: enable, capture and limit switch inputs Firmware FBxx • • General-purpose I/O • Special I/O MC3: enable, capture and limit switch inputs Assignment and data transfer • Setup 16 bit variable • Setup 32 bit variable • Arithmetic and logic manipulation • Multi axis control • • • • Axis identification • Axis synchronization • Data transfer between axes • Remote control Monitoring. You can check the motion progress as well as the drive/motor status via • Position Triggers • Status Register • Error Register • Messages sent to the host Slaves Management. From the motion controller application you can perform: • Slaves Initialization • Program events on slave axes and wait for their occurrence • Homing and Function Calls from slave axes • Slave Error Handling Miscellaneous including: • Declare user variable • Reset FAULT status © ElectroCraft 2013 240 MPD User Manual • Save actual setup data from RAM into EEPROM in the setup table • Change the CAN bus and serial RS232 / RS485 communication settings See also: Basic Concepts © ElectroCraft 2013 241 MPD User Manual 6.2.2.2. Motion programming – drives with built-in Motion Controller 6.2.2.2.1. Trapezoidal Position Profiles - MPL Programming Details In the trapezoidal position profile, the load/motor is controlled in position. The built-in reference generator computes a position profile with a trapezoidal shape of the speed, due to a limited acceleration. You specify either a position to reach in absolute mode or a position increment in relative mode, plus the slew (maximum travel) speed and the acceleration/deceleration rate. In relative mode, the position to reach can be computed in 2 ways: standard (default) or additive. In standard relative mode, the position to reach is computed by adding the position increment to the instantaneous position in the moment when the command is executed. In the additive relative mode, the position to reach is computed by adding the position increment to the previous position to reach, independently of the moment when the command was issued. The additive relative mode is activated by setting ACR.11 = 1. Remarks: • The motion mode and its parameters become effective after the execution of the update command UPD • The additive relative mode is automatically disabled after an the update command UPD, which sets ACR.11 = 0 restoring the standard relative mode You can switch at any moment, including during motion, from another motion mode to the trapezoidal position profile. This operation is possible due to the target update mode 0 TUM0 which is automatically activated when a new motion mode is set. During motion, you can change on the fly the position command, the slew speed and the acceleration/deceleration rate. These changes become effective at next update command UPD. Position profile with trapezoidal shape of the speed Once set, the motion parameters are memorized. If you intend to use the same values as previously defined for the acceleration rate, the slew speed, the position increment or the position to reach, you don’t need to set their values again in the following trapezoidal profiles. Remark: The additive mode for relative positioning is not memorized and must be set each time a new additive relative move is set. © ElectroCraft 2013 242 MPD User Manual See also: Trapezoidal Position Profiles – Related MPL Instruction and Data Trapezoidal Position Profiles – On the fly change of the motion parameters Trapezoidal Position Profiles – Automatic elimination of round-off errors MPL Description © ElectroCraft 2013 243 MPD User Manual 6.2.2.2.2. Trapezoidal Position Profiles - Related MPL Instructions and Data Parameters CPOS Command position – desired position (absolute or relative) for the load. Measured in position units. CSPD Command speed – desired slew speed for the load. The command speed can have only positive values. Measured in speed units. CACC Command acceleration – desired acceleration / deceleration for the load. The command acceleration can have only positive values. Measured in acceleration units ACR Auxiliary Control Register – includes several MPL Programming options Variables TPOS Target load position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units TSPD Target load speed – speed reference computed by the reference generator at each slow loop sampling period. Measured in speed units TACC Target load acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period. Measured in acceleration units APOS_LD Actual load position. Measured in position units. Alternate name: APOS ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units ASPD_MT Actual motor speed. Measured in motor speed units Alternate name: ASPD Instructions CPR Command position is relative CPA Command position is absolute MODE PP Set position profile mode TUM1 Target Update Mode 1 (TUM1). Generates new trajectory starting from the actual values of position and speed reference (i.e. don’t update the reference values with load/motor position and speed) TUM0 Target Update Mode 0 (TUM0). Generates new trajectory starting from the actual values of load/motor position and speed (i.e. update the reference values with load/motor position and speed) UPD Update motion parameters and start new motion mode STOP Stop the motion SRB Set/reset bits from a MPL data © ElectroCraft 2013 244 MPD User Manual Remarks: • CSPD and CACC must be positive. Negative values are taken in modulus • The difference between CPOS and TPOS values in modulus must be maximum 231-1. • The sum between CSPD and CACC values must be maximum 32767.99998 (0x7FFF.FFFF) i.e. the maximum value for fixed number • Once a position profile is started, you can find when the motion is completed, by setting an event on motion complete and waiting until this event occurs. • In order to activate the TUM1 mode, execute the MPL instruction TUM1 AFTER the MODE PP command and BEFORE the UPD command. When MODE PP is executed, it automatically sets TUM0 mode. However, as the new motion mode becomes effective only after the UPD command, a TUM1 command will overwrite the TUM0 mode • Under TUM0 mode, at the UPD command TPOS=APOS_LD and TSPD=ASPD_LD. In open loop control of steppers, TUM0 is ignored as there is no position and/or speed feedback • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD Programming Example // Position profile. Position feedback: 500 lines incremental // encoder (2000 counts/rev) CACC = 0.3183; //acceleration rate = 1000[rad/s^2] CSPD = 33.3333; //slew speed = 1000[rpm] CPOS = 6000; //position command = 3[rot] CPR; //position command is relative SRB ACR 0xFFFF, 0x800; // and additive MODE PP; // set trapezoidal position profile mode TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; WAIT!; //wait for completion See also: Trapezoidal Position Profiles – MPL Programming Details Trapezoidal Position Profiles – On the fly change of the motion parameters Trapezoidal Position Profiles – Automatic elimination of round-off errors MPL Description © ElectroCraft 2013 245 MPD User Manual 6.2.2.2.3. Trapezoidal Position Profiles - On the fly change of the motion parameters In the trapezoidal position profile mode, the motion parameters CPOS, CSPD, CACC can be changed any time during motion. The reference generator automatically re-computes the position trajectory in order to reach the new commanded position, using the new values for slew speed and acceleration. The figure below shows an example where slew speed and acceleration rate are changed, while the commanded position is kept the same. 172 CSP D = 8 CACC = 2 UPD CPO S = 172 CSP D = 4 CACC = 1 UPD Trapezoidal position profile. On-the-fly change of motion parameters Programming Example // Position profile already set. CACC and CSPD // are changed during motion CACC = 2; //acceleration rate = 2 [internal units] CSPD = 8; //slew speed = 8 [internal units] UPD; //execute immediate If the trapezoidal position profile is already set and you intend to change only the motion parameters, you don’t need to set again neither the motion mode with MPL instruction MODE PP, nor the target update mode 1 (when required) with MPL instruction TUM1. If during motion, a new position command is issued that requires reversing the motor movement, the reference generator does automatically the following operations: • stops the motor with the programmed deceleration rate • accelerates the motor in the opposite direction till the slew speed is reached, or till the motor has to decelerate • stops the motor on the commanded position See also: Trapezoidal Position Profiles – MPL Programming Details Trapezoidal Position Profiles – Related MPL Instruction and Data Trapezoidal Position Profiles – Automatic elimination of round-off errors © ElectroCraft 2013 246 MPD User Manual MPL Description © ElectroCraft 2013 247 MPD User Manual 6.2.2.2.4. Trapezoidal Position Profiles - Automatic elimination of round-off errors In trapezoidal position profile mode, the reference generator automatically eliminates the round-off errors, which may occur when the commanded position cannot be reached with the programmed slew speed and acceleration/deceleration rate. This situation is illustrated by the example below, where the position feedback is an incremental encoder. Therefore, the internal units for position are [encoder counts], for speed are [encoder counts / slow loop sampling], for acceleration are [encoder counts / square of slow loop sampling] Example: The commanded position is 258 counts, with the slew speed 18 counts/sampling and the acceleration rate 4 counts/sampling2. To reach the slew speed, two options are available: • Accelerate to 16 in 4 steps, then from 16 to 18 in a 5th step. Acceleration space is 49 counts • Accelerate from 0 to 2 in 1st step, then from 2 to 18 in 4 steps. Acceleration space is 41 counts For the deceleration phase, the options and spaces are the same. But, no matter which option is used for the acceleration and deceleration phases, the space that remains to be done at constant speed is not a multiple of 18, i.e. the position increment at each step. So, when to start the deceleration phase? Table below presents the possible options, and the expected errors. MPL comes with a different approach. It monitors the round-off errors and automatically eliminates them by introducing, during deceleration phase, short periods where the target speed is kept constant. Hence, the target position is always reached precisely, without any errors. © ElectroCraft 2013 248 MPD User Manual CPO S=258 CSP D=18 CACC=4 Trapezoidal Position profile. Automatic elimination of round-off errors The figure above shows the target speed generated by MPL for the above example. During the deceleration phase, the target speed: • decelerates from 18 to 6 in 3 steps (target position advances by 36 counts) • is kept constant for 1 step (target position advances by 6 counts) • decelerates from 6 to 2 in one step (target position advances by 4 counts) • decelerates from 2 to 0 in the last step (target position advances by 1 count) Hence the deceleration space is 47 counts, which, added to 49 counts for acceleration phase and to the 162 counts for constant speed, gives exactly the 258-count commanded position. See also: Trapezoidal Position Profiles – MPL Programming Details Trapezoidal Position Profiles – Related MPL Instruction and Data Trapezoidal Position Profiles – On the fly change of the motion parameters MPL Description © ElectroCraft 2013 249 MPD User Manual 6.2.2.2.5. Trapezoidal Speed Profiles - MPL Programming Details In the speed profile, the load/motor is controlled in speed. The built-in reference generator computes a speed profile with a trapezoidal shape, due to a limited acceleration. You specify the jog speed (speed sign specifies the direction) and the acceleration/deceleration rate. The load/motor accelerates until the jog speed is reached. During motion, you can change on the fly the slew speed and/or the acceleration/deceleration rate. The motion will continue until a STOP command. An alternate way to stop motion is to set the jog speed to zero. Speed profile with trapezoidal shape Remark: The motion mode and its parameters become effective after the execution of the update command UPD. Changes of the slew speed and/or acceleration/deceleration rate also become effective at next update command. You can switch at any moment, including during motion, from another motion mode to the trapezoidal speed profile. This operation is possible due to the target update mode 0 TUM0 which is automatically activated when a new motion mode is set. Once set, the motion parameters are memorized. If you intend to use the same values as previously defined for the acceleration rate and the jog speed, you don’t need to set their values again in the following trapezoidal profiles. See also: Trapezoidal Speed Profiles – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 250 MPD User Manual 6.2.2.2.6. Trapezoidal Speed Profiles - Related MPL Instructions and Data Parameters CSPD Command speed – desired slew speed for the load. The sign specifies the direction. Measured in speed units CACC Command acceleration – desired acceleration / deceleration for the load. The command acceleration can have only positive values. Measured in acceleration units. Variables TPOS Target load position – position reference computed by the reference generator at each slow loop sampling period. TPOS is computed by integrating the target speed TSPD.Measured in position units TSPD Target load speed – speed reference computed by the reference generator at each slow loop sampling period. Measured in speed units TACC Target load acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period. Measured in acceleration units APOS_LD Actual load position. Measured in position units. Alternate name: APOS. ASPD_LD Actual load speed – measured in speed units. APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD Instructions MODE SP Set speed profile mode TUM1 Target Update Mode 1 (TUM1). Generates new trajectory starting from the actual values of position and speed reference (i.e. don’t update the reference values with load/motor position and speed) TUM0 Target Update Mode 0 (TUM0). Generates new trajectory starting from the actual values of load/motor position and speed (i.e. update the reference values with load/motor position and speed) UPD Update motion parameters and start new motion mode STOP STOP the motion. Remarks: • The sum between CSPD and CACC values must be maximum 32767.99998 (0x7FFF.FFFF) i.e. the maximum value for fixed number. • After a STOP command or after setting jog speed command to zero, you can find when the motion is completed, by setting an event on motion complete and waiting until this event occurs. • In order to activate the TUM1 mode, execute the MPL instruction TUM1 AFTER the MODE SP command and BEFORE the UPD command. When MODE SP is executed, it automatically sets TUM0 mode. However, as the new motion mode becomes effective only after the UPD command, a TUM1 command will overwrite the TUM0 mode © ElectroCraft 2013 251 MPD User Manual • Under TUM0 mode, at the UPD command TPOS=APOS_LD and TSPD=ASPD_LD. In open loop control of steppers, TUM0 is ignored as there is no position and/or speed feedback • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD Programming Example // Speed profile with position feedback on motor: 500 lines // incremental encoder (2000 counts/rev) CACC = 0.1591;//acceleration rate = 500[rad/s^2] CSPD = 40;//jog speed = 1200[rpm] MODE SP; // set trapezoidal speed profile mode TUM1; //set Target Update Mode 1 UPD; //execute immediate See also: Trapezoidal Speed Profiles – MPL Programming Details MPL Description © ElectroCraft 2013 252 MPD User Manual 6.2.2.2.7. S-curve Profiles - MPL Programming Details In the S-curve profile, the load/motor is controlled in position. The built-in reference generator computes a position profile with an S-curve shape of the speed. This shape is due to the jerk limitation, leading to a trapezoidal or triangular profile for the acceleration and an S-curve profile for the speed. You specify either a position to reach in absolute mode or a position increment in relative mode, plus the slew (maximum travel) speed, the maximum acceleration/deceleration rate and the jerk rate. The jerk rate is set indirectly via the jerk time, which represents the time needed to reach the maximum acceleration starting from zero. Remarks: • The motion mode and its parameters become effective after the execution of the update command UPD • The jerk rate results by dividing the maximum acceleration rate to the jerk time. An S-curve profile must begin when load/motor is not moving. During motion the parameters should not be changed. Therefore when executing successive S-curve commands, you should wait for the previous motion to end before setting the new motion parameters and starting next motion. During an S-curve execution, you can switch at any moment to another motion mode (except PVT and PT interpolated modes) or stop the motion with a STOP command. Following a STOP command, the deceleration phase can be done in 2 ways: • Smooth, using an S-curve speed profile, when ACR.1 = 0 (default), or • Fast using a trapezoidal speed profile, when ACR.1 = 1 Position profile with S-curve shape of the speed © ElectroCraft 2013 253 MPD User Manual Once set, the motion parameters are memorized. If you intend to use the same values as previously defined for the acceleration rate, the slew speed, the position increment or the position to reach, you don’t need to set their values again in the following trapezoidal profiles. See also: S Curve Profile – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 254 MPD User Manual 6.2.2.2.8. S Curve Profile - Related MPL Instructions and Data Parameters CPOS Command position – desired position (absolute or relative) for the load. Measured in position units CSPD Command speed – desired slew speed for the load. Measured in speed units CACC Command acceleration – maximum desired acceleration / deceleration for the load. Measured in acceleration units CDEC Command deceleration for quick stop mode. Measured in acceleration units TJERK Jerk time needed to accelerate from zero up to the CACC value. Measured in time units ACR Auxiliary Control Register – includes several MPL Programming options Variables TPOS Target load position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units TSPD Target load speed – speed reference computed by the reference generator at each slow loop sampling period. Measured in speed units TACC Target load acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period. Measured in acceleration units APOS_LD Actual load position. Measured in position units. Alternate name: APOS ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD Instructions CPR Command position is relative CPA Command position is absolute MODE PSC Set S-curve mode. UPD Update motion parameters and start new motion mode STOP Stop the motion SRB Set/reset bits from a MPL data Remarks: • CSPD, CACC and TJERK must be positive • The difference between CPOS and TPOS values in modulus must be maximum 231-1. • The sum between CSPD and CACC values must be maximum 32767.99998 (0x7FFF.FFFF) i.e. the maximum value for fixed number © ElectroCraft 2013 255 MPD User Manual • Once a position profile is started, you can find when the motion is completed, by setting an event on motion complete and waiting until this event occurs. • The S-curve profile uses always TUM1 mode, i.e. preserves the values of TPOS and TSPD. If these values don’t match with the actual feedback values, precede the S-curve command with another motion command accepting TUM0 to update TPOS and TSPD. This command may be for example a trapezoidal profile that keeps position unchanged • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD Programming Example // S-curve profile. Position feedback: 500 lines incremental // encoder (2000 counts/rev) TJERK = 50;//jerk = 2e+004[rad/s^3] CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 33.3333;//slew speed = 1000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PSC; // set S-curve profile mode SRB ACR, 0xFFFE, 0x0000; //Stop using an S-curve profile UPD; //execute immediate !MC; WAIT!; //wait for completion See also: S Curve Profile – MPL Programming Details MPL Description © ElectroCraft 2013 256 MPD User Manual 6.2.2.2.9. Position-Time (PT) Interpolated - MPL Programming Details In the PT motion mode the load/motor is controlled in position. The built-in reference generator computes a positioning path using a series of points. Each point specifies the desired Position, and Time, i.e. contains a PT data. Between the PT points the reference generator performs a linear interpolation. The PT Interpolated mode is typically used together with a host, which sends PT points via a communication channel. Due to the interpolation, the PT mode offers the possibility to describe an arbitrary position contour using a reduced number of points. It is particularly useful when the motion reference is computed on the fly by the host like for example in vision systems. By reducing the number of points, both the computation power and the communication bandwidth needed are substantially reduced optimizing the costs. When the PT motion mode is used simultaneously with several drives/motors having the time synchronization mechanism activated, the result is a very powerful multiaxis system that can execute complex synchronized moves. The PT motion mode can be started only when the previous motion is complete. However, you can switch at any moment to another motion mode. The PT mode can be relative (following a CPR command) or absolute (following a CPA command). In the absolute mode, each PT point specifies the position to reach. The initial position may be either the current position reference TPOS or a preset value read from the MPL parameter PVTPOS0. In the relative mode, each PT point specifies the position increment relative to the previous point. In both cases, the time is relative to the previous point i.e. represents the duration of a PT segment. For the first PT point, the time is measured from the starting of the PT mode. Each time when a new PT point is read from a MPL program or received via a communication channel, it is saved into the PT buffer. The reference generator empties the buffer as the PT points are executed. The PT buffer is of type FIFO (first in, first out). The default length of the PT buffer is 7 PT points. The drive/motor automatically sends messages to the host when the buffer is full, low or empty. The messages contain the PT status (MPL variable PVTSTS). The host address is taken from the MPL parameter MASTERID. The buffer full condition occurs when the number of PT points in the buffer is equal with the buffer size. The buffer low condition occurs when the number of PT points in the buffer is less or equal with a programmable value – the low level. The buffer empty condition occurs when the buffer is empty and the execution of the last PT point is over. When the PT buffer becomes empty the drive/motor keeps the position reference unchanged. Remarks: • The PVT and PT modes share the same buffer. Therefore the MPL parameters and variables associated with the buffer management are the same. • Before activating the PT mode, you must place at least one PT point in the buffer • The buffer low condition is set by default when the last PT point from the buffer is read and starts to be executed • Both the PT buffer size and its start address are programmable via MPL parameters PVTBUFBEGIN and PVTBUFLEN. Therefore if needed, the PT buffer size can be substantially increased. Each PT point also includes a 7-bit integrity counter. The integrity counter value must be incremented by the host by one, each time a new PT point is sent to the drive/motor. If the integrity counter error checking is activated, the drive compares its internally computed integrity counter value with the one sent with the PT point (i.e. with the PTP command). This comparison is done every time a PTP instruction is received. If the values of the two integrity counters do not match, the integrity check error is triggered, the drive/motor sends the PVTSTS to the host with PVTSTS.12 =1 and the received PT point is discarded. Each time a PT point is accepted (the integrity counters match or the integrity counter error checking is disabled), the drive automatically increments its internal integrity counter. The default value of the internal © ElectroCraft 2013 257 MPD User Manual integrity counter after power up is 0. Its current value can be read from the MPL variable PVTSTS (bits 6..0). The integrity counter can also be set to any value using MPL command SETPT. See also: PT – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 258 MPD User Manual 6.2.2.2.10. Position-Velocity-Time(PVT) Programming Details Interpolated - MPL In the PVT motion mode the load/motor is controlled in position. The built-in reference generator computes a positioning path using a series of points. Each point specifies the desired Position, Velocity and Time, i.e. contains a PVT data. Between the PVT points the reference generator performs a 3rd order interpolation. The PVT Interpolated mode is typically used together with a host, which sends PVT points via a communication channel. Due to the 3rd order interpolation, the PVT mode offers the possibility to describe complex position contours using a reduced number of points. It is particularly useful when the motion reference is computed on the fly by the host like for example in vision systems. By reducing the number of points, both the computation power and the communication bandwidth needed are substantially reduced optimizing the costs. When the PVT motion mode is used simultaneously with several drives/motors having the time synchronization mechanism activated, the result is a very powerful multi-axis system that can execute complex synchronized moves. A key factor for getting a correct positioning path in PVT mode is to set correctly the distance in time between the points. Typically this is 10-20ms, the shorter the better. If the distance in time between the PVT points is too big, the 3rd order interpolation may lead to important variations compared with the desired path. The PVT motion mode can be started only when the previous motion is complete. However, you can switch at any moment to another motion mode. The PVT mode can be relative (following a CPR command) or absolute (following a CPA command). In the absolute mode, each PVT point specifies the position to reach. The initial position may be either the current position reference TPOS or a preset value read from the MPL parameter PVTPOS0. In the relative mode, each PVT point specifies the position increment relative to the previous point. In both cases, the time is relative to the previous point i.e. represents the duration of a PVT segment. For the first PVT point, the time is measured from the starting of the PVT mode. Each time when a new PVT point is read from a MPL program or received via a communication channel, it is saved into the PVT buffer. The reference generator empties the buffer as the PVT points are executed. The PVT buffer is of type FIFO (first in, first out). The default length of the PVT buffer is 7 PVT points. Each entry in the buffer is made up of 9 words, so the default length of the PVT buffer in terms of how much memory space is reserved is 63 (3Fh) words. The drive/motor automatically sends messages to the host when the buffer is full, low or empty. The messages contain the PVT status (MPL variable PVTSTS). The host address is taken from the MPL parameter MASTERID. The buffer full condition occurs when the number of PVT points in the buffer is equal with the buffer size. The buffer low condition occurs when the number of PVT points in the buffer is less or equal with a programmable value – the low level. The buffer empty condition occurs when the buffer is empty and the execution of the last PVT point is over. When the PVT buffer becomes empty the drive/motor: • Remains in PVT mode if the velocity of last PVT point executed is zero and waits for new points to receive • Enters in quick stop mode if the velocity of last PVT point executed is not zero Therefore, a correct PVT sequence must always end with a last PVT point having velocity zero. Remarks: • The PVT and PT modes share the same buffer. Therefore the MPL parameters and variables associated with the buffer management are the same. • Before activating the PVT mode, you must place at least one PVT point in the buffer © ElectroCraft 2013 259 MPD User Manual • The buffer low condition is set by default when the last PVT point from the buffer is read and starts to be executed • Both the PVT buffer size and its start address are programmable via MPL parameters PVTBUFBEGIN and PVTBUFLEN. Therefore if needed, the PVT buffer size can be substantially increased. Each PVT point also includes a 7-bit integrity counter. The integrity counter value must be incremented by the host by one, each time a new PVT point is sent to the drive/motor. If the integrity counter error checking is activated, the drive compares its internally computed integrity counter value with the one sent with the PVT point (i.e. with the PVTP command). This comparison is done every time a PVTP instruction is received. If the values of the two integrity counters do not match, the integrity check error is triggered, the drive/motor sends the PVTSTS to the host with PVTSTS.12 =1 and the received PVT point is discarded. Each time a PVT point is accepted (the integrity counters match or the integrity counter error checking is disabled), the drive automatically increments its internal integrity counter. The default value of the internal integrity counter after power up is 0. Its current value can be read from the MPL variable PVTSTS (bits 6..0). The integrity counter can also be set to any value using MPL command SETPVT. See also: PVT – Related MPL Instructions and Data MPL Description 6.2.2.2.11. Motion PT - MPL Instructions and Data Parameters MASTERID Contains the axis ID of the host/master where the drive/motor must send the PT messages. It must be set before starting the PT mode. The MASTERID value must be set as: host ID << 4 + 1, where host ID is a number between 1 and 255 representing the host ID. By default, after power-on the host ID is set equal with the drive address causing all the PT messages to be sent via RS-232 PVTBUFBEGIN Specifies the start address of the PT buffer PVTBUFLEN Specifies the PT buffer length expressed in PT points PVTPOS0 Specifies for absolute mode, the initial position from which to start computing the distance to move up to the first PT point. An alternate option is to consider TPOS as initial position. Selection between these 2 options is done at PT initialization via MPL command SETPT. The default value of PVTPOS0 is 0. PVTSENDOFF When set to 1, disables transmission of messages during PT mode. By default is set to 0 and the transmission is enabled Variables PVTSTS Contains the PT motion mode status. © ElectroCraft 2013 260 MPD User Manual PVTSTS bit description PVTMODE PVT operation mode as was set with the SETPT command TPOS Target load position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units TSPD Target load speed – speed reference computed by the reference generator at each slow loop sampling period. Measured in speed units TACC Target load acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period. Measured in acceleration units APOS_LD Actual load position. Measured in position units. Alternate name: APOS ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD © ElectroCraft 2013 261 MPD User Manual Instructio ons SETPT va alue Set PT T operation as s specified by y value: PT P operation mode m (a copy y of value is saved s in the M MPL variable PVTMODE) CPR PT mode is relative CPA PT mode is absolute e MODE PT T Set PT T motion mode e. TUM1 Target Upda ate Mode 1 (T TUM1). Gene erates new ttrajectory starting from the actual valu ues of position and speed refere ence (i.e. don n’t update the oad/motor po osition e reference vvalues with lo and speed) TUM0 ate Mode 0 (T TUM0). Gene erates new ttrajectory starting from the actual valu ues of Target Upda load/motor position and speed s (i.e. up pdate the refference value es with load/m motor position n and speed) PTP Posiition, Time, Counter C Deffines a PT poiint, where: Position – is the PT poin nt position, measured m in p position unitts. In absolu ute mode, it is the osition to rea ach. In relativ ve mode, it is the position increment frrom the previious PT pointt. The po po osition value is a 32-bit lon ng integer. Time – is the PT P point time measured in time units. T The time valu ue is a 16-bit u unsigned inte eger Counter C – is the t PVT pointt integrity cou unter. It is a 7 7-bit unsigned d integer with h values betw ween 0 an nd 127. UPD Update motion n parameters and start new w motion mod de STOP Sttop motion © ElectroC Craft 2013 26 62 MPD U User Manual Remarks: • When a PT sequence of points is executed from a MPL program, the first PTP commands are processed one after the other, until the PT buffer fills up. At this point the MPL program stops until the PT buffer starts to empty. Therefore, the next PTP commands are processed in the cadence of the PT points execution. At the end of the sequence, the PT buffer starts to empty and next MPL instructions start to execute. This may lead to incorrect operation if for example a new motion mode is set while there are still points in the PT buffer waiting to be executed. In order to avoid this situation, it is mandatory to end the PVT sequence with an event on motion complete and wait until this event occurs. • In order to activate the TUM1 mode, execute the MPL instruction TUM1 AFTER the MODE PT command and BEFORE the UPD command. When MODE PT is executed, it automatically sets TUM0 mode. However, as the new motion mode becomes effective only after the UPD command, a TUM1 command will overwrite the TUM0 mode • Under TUM0 mode, at the UPD command TPOS=APOS_LD and TSPD=ASPD_LD. In open loop control of steppers, TUM0 is ignored as there is no position and/or speed feedback • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD Programming Example // PT sequence. Position feedback: 500 lines incremental // encoder (2000 counts/rev) SETPVT 0xC000; //Clear PT buffer, disable counter check //Don’t change counter & buffer low condition MODE PT; // Set PT Mode TUM1;//Start from actual value of position reference CPR; PTP 2000L, 100U, 0; //PT(1[rot], 0.1[s]) UPD; //Execute immediate PTP 0L, 100U, 0; //PT(1[rot],0.2[s]) PTP -2000L, 100U, 0; //PT(0[rot],0.3[s]) !MC; WAIT!; //wait for completion See also: PT – MPL Programming Details MPL Description © ElectroCraft 2013 263 MPD User Manual 6.2.2.2.12. Mode PVT - Related MPL Instructions and Data Parameters MASTERID Contains the axis ID of the host/master where the drive/motor must send the PVT messages. It must be set before starting the PVT mode. The MASTERID value must be set as: host ID << 4 + 1, where host ID is a number between 1 and 255 representing the host ID. By default, after power-on the host ID is set equal with the drive address causing all the PVT messages to be sent via RS-232 PVTBUFBEGIN Specifies the start address of the PVT buffer PVTBUFLEN Specifies the PVT buffer length expressed in PVT points PVTPOS0 Specifies for absolute mode, the initial position from which to start computing the distance to move up to the first PVT point. An alternate option is to consider TPOS as initial position. Selection between these 2 options is done at PVT initialization via MPL command SETPVT. The default value of PVTPOS0 is 0. PVTSENDOFF When set to 1, disables transmission of messages during PVT mode. By default is set to 0 and the transmission is enabled © ElectroCraft 2013 264 MPD User Manual Variables PVTSTS Contains the PVT motion mode status. PVTSTS bit description PVTMODE PVT operation mode as was set with the SETPVT command TPOS Target load position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units TSPD Target load speed – speed reference computed by the reference generator at each slow loop sampling period. Measured in speed units TACC Target load acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period. Measured in acceleration units APOS_LD Actual load position. Measured in position units. Alternate name: APOS ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD © ElectroCraft 2013 265 MPD User Manual Instructio ons SETPVT value Set PVT operation as specified by vallue: PVT P operation n mode (a cop py of value is s saved in the e MPL variablle PVTMODE E) CPR PV VT mode is re elative CPA PV VT mode is absolute a MODE PV VT Set PV VT motion mode. TUM1 Target Upda ate Mode 1 (T TUM1). Gene erates new ttrajectory starting from the actual valu ues of position and speed refere ence (i.e. don n’t update the oad/motor po osition e reference vvalues with lo and speed) TUM0 ate Mode 0 (T TUM0). Gene erates new ttrajectory starting from the actual valu ues of Target Upda load/motor position and speed s (i.e. up pdate the refference value es with load/m motor position n and speed) PVTP Pos sition, Veloc city, Time, Co ounter Defines D a PVT T point, wherre: Position – is s the PVT po oint position, measured in position un nits. In absolute mode, it is the position to re each. In relativ ve mode, it is s the position increment fro om the previo ous PVT point. The position valu ue is a signe ed long integer limited to 24 bits, i.e. in the range e – 8388608 8 to + 8388607. Values outside this t range are e truncated ca ausing unpred dictable results. Velocity – is the PVT poin nt velocity, measured in sp peed units. T The velocity is a fixed valu ue like command sp peed CSPD an nd target speed TSPD Time – is the e PVT point time measured d in time uni ts The time vvalue is a 9-b bit unsigned in nteger having values s between 1 and a 511. Counter – is the PVT poin nt integrity co ounter. It is a 7 7-bit unsigned d integer with h values betw ween 0 and 127. UPD Update motion n parameters and start new w motion mod de © ElectroC Craft 2013 26 66 MPD U User Manual STOP Stop the motion Remarks: • When a PVT sequence of points is executed from a MPL program, the first PVTP commands are processed one after the other, until the PVT buffer fills up. At this point the MPL program stops until the PVT buffer starts to empty. Therefore, the next PVTP commands are processed in the cadence of the PVT points execution. At the end of the sequence, the PVT buffer starts to empty and next MPL instructions start to execute. This may lead to incorrect operation if for example a new motion mode is set while there are still points in the PVT buffer waiting to be executed. In order to avoid this situation, it is mandatory to end the PVT sequence with an event on motion complete and wait until this event occurs. • In order to activate the TUM1 mode, execute the MPL instruction TUM1 AFTER the MODE PVT command and BEFORE the UPD command. When MODE PVT is executed, it automatically sets TUM0 mode. However, as the new motion mode becomes effective only after the UPD command, a TUM1 command will overwrite the TUM0 mode • Under TUM0 mode, at the UPD command TPOS=APOS_LD and TSPD=ASPD_LD. In open loop control of steppers, TUM0 is ignored as there is no position and/or speed feedback • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD Programming Example // PVT sequence. Position feedback: 500 lines incremental // encoder (2000 counts/rev) MASTERID = 4081; // Set host address to 255 (255<<4+1) SETPVT 0xC000; //Clear PVT buffer, disable counter check //Don’t change counter & buffer low condition MODE PVT; // Set PVT Mode TUM1;//Start from actual value of position reference CPR; // Relative mode PVTP 400L, 60, 10U, 0;//PVT(0.2[rot], 1800[rpm], 0.01[s]) UPD; //Execute immediate PVTP 400L, 0, 10U, 0;//PVT(0.4[rot], 0[rpm], 0.02[s]) !MC; WAIT!; //wait for completion See also: PVT – MPL Programming Details MPL Description © ElectroCraft 2013 267 MPD User Manual 6.2.2.2.13. External - MPL Programming Details In the external modes, you program the drives/motors to work with an external reference provided by another device. There are 3 types of external references: • Analogue – read by the drive/motor via a dedicated analogue input (10-bit resolution) • Digital – computed by the drive/motor from: • Pulse & direction signals • Quadrature signals like A, B signals of an incremental encoder • Online – received online via a communication channel from a host and saved in a dedicated MPL variable When the reference is analogue or online, you can set a: • Position external mode, where the motor is controlled in position and the external reference is interpreted as a position reference • Speed external mode, where the motor is controlled in speed and the external reference is interpreted as a speed reference • Torque external mode, where the motor is controlled in torque and the external reference is interpreted as a current reference. • Voltage external mode, where the motor is controlled in voltage and the external reference is interpreted as a voltage reference. When the external reference is digital, the option for the input signals: pulse & direction or quadrature encoder is established during the drive/motor setup. The drive/motor performs only position control having as goal to follow the position reference computed from the input signals with a preset gear ratio. In this case, the drive/motor actually works in electronic gearing mode, where you can find further details. In position external mode with analogue or online reference, you can limit the maximum speed at sudden changes of the position reference and thus to reduce the mechanical shocks. This feature is activated by setting UPGRADE.2=1 and the maximum speed value in CSPD. In speed external mode with analogue or online reference, you can limit the maximum acceleration at sudden changes of the speed reference and thus to get a smoother transition. This feature is activated by setting UPGRADE.2=1 and the maximum acceleration value in CACC. In torque or voltage external mode with analogue reference, you can choose how often to read the analogue input: at each slow loop sampling period or at each fast loop sampling period. When using the analogue reference, during the setup phase, you specify the reference values corresponding to the upper and lower limits of the analogue input. Depending on the control mode selected, these values may be position or speed or torque or voltage references. You may also select a dead-band symmetrical interval and it’s center point inside the analogue input range. While the analogue signal is inside the dead-band interval, the output reference is kept constant and equal with value corresponding to the dead-band center point. This option is especially useful when you need to set a precise reference, which doesn’t change in the presence of some noise on the analogue input signal. If dead-band width is set to zero, the dead-band is disabled. Remark: Setup tools like PROconfig, automatically compute the value of the MPL parameters needed to convert the analogue input range into the desired reference range. © ElectroCraft 2013 268 MPD User Manual See also: External – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 269 MPD User Manual 6.2.2.2.14. External - MPL Instructions and Data Parameters CADIN Half of the reference range expressed in internal units, divided by 2SFTADIN. The division result should lead to a value less than 32767. Depending on control mode selected, the reference range can be a: • Position range expressed in position units • Speed range expressed in speed units • Torque range expressed in current units • Voltage range expressed in voltage command units SFTADIN The smallest power of 2 for which: (Half of the reference range in internal units) / 2STFADIN < 32767 AD5OFF Reference value expressed in internal units, corresponding to the lower limit of the analogue input. Depending on control mode selected, the reference value can be a: • Position value expressed in position units • Speed value expressed in speed units • Torque value expressed in current units • Voltage value expressed in voltage command units FILTER1 Cutoff frequency for the low-pass filter on analogue input, computed with: FILTER1 = 32767 * (1 - exp(-fc*T)), where fc is the cutoff frequency in radians/s T is the slow loop sampling period in seconds. Remark: For the external torque mode with analogue input read in fast loop, T is the fast loop sampling period in seconds. LEVEL_AD5 Dead-band point in internal units computed with: LEVEL_AD5=(DB_Point–InputLow)*65472/InputRange where DB_Point – is the dead band point expressed in V InputLowLimit – is the low limit of the drive/motor analogue input expressed in V InputRange – s the drive/motor analogue input range expressed in V. E_LEVEL_AD5 Dead-band range in internal units computed with formula: E_LEVEL_AD5 = DB_Range * 65472 / InputRange, where DB_Range – is the desired dead-band range expressed in V InputRange – is the drive/motor analogue input range expressed in V. UPGRADE MPL register. When UPGRADE.2=1, a speed limitation may be set in position external mode and an acceleration limitation in speed external mode. When UPGRADE.2=0, speed or acceleration limitation is disabled © ElectroCraft 2013 270 MPD User Manual CSPD Maximum speed in position external when UPGRADE.2=1 CACC Maximum acceleration in speed external when UPGRADE.2=1 Variables AD5 16-bit unsigned integer value representing the value read from the analogue input. The output of the 10-bit A/D converter is set in the 10 MSB (most significant bits) of the AD5 EREFP MPL variable where an external device writes the position reference in external mode on-line. Measured in position units EREFS MPL variable where an external device writes the speed reference in external mode on-line. Measured in speed units EREFT MPL variable where an external device writes the torque reference in external mode on-line. Measured in current units EREFV MPL variable where an external device writes the voltage reference in external mode on-line. Measured in voltage command units TPOS Target load position – position reference computed by the reference generator at each slow loop sampling period, when position external mode is performed. TPOS is set function of the analogue input value, with analogue reference or with the EREFP value with online reference. Measured in position units TSPD Target load speed – speed reference computed by the reference generator at each slow loop sampling period, when position or speed external mode is performed. In speed control, TSPD is set function of the analogue input value, with analogue reference or with the EREFS value with online reference. Measured in speed units In position control, TSPD is computed as the position variation over a slow loop sampling period. Measured in speed units TACC Target load acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period, when position or speed external mode is performed. Measured in acceleration units IQREF Current reference – updated at each fast or slow loop function of the analogue input value or set with EREFT value, when torque external mode is performed. Measured in current units UQREF Voltage reference – updated at each fast or slow loop function of the analogue input value or set with EREFV value, when voltage external mode is performed. Measured in voltage command units APOS_LD Actual load position. Measured in position units. Alternate name: APOS ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD IQ Motor current – measured in current units Instructions MODE PE Set position external mode © ElectroCraft 2013 271 MPD User Manual MODE GS Set position external mode with digital reference MODE SE Set speed external mode MODE TES Set torque external mode with reference read in slow loop MODE TEF Set torque external mode with reference read in fast loop MODE VES Set voltage external mode with reference read in slow loop EXTREF 0 Set external reference type on-line EXTREF 1 Set external reference type analogue EXTREF 2 Set external reference type digital UPD Update motion parameters and start new motion mode STOP Stop motion Remarks: • In the absence of an external device, EREFP, EREFS, EREFT, EREFV may also be used as MPL parameters through which you can set a position, speed, torque or voltage reference in the external mode online. This is a simple way to impose step references • The MPL variables EREFP, EREFS, EREFT, EREFV are alternate ways to address the MPL variable EREF in which the external devices must place the reference. The new mnemonics have been added to clearly differentiate how EREF is interpreted function of control mode selected: o Position control: EREFP = EREF. EREFP is a 32-bit long integer o Speed control: EREFS=EREF. EREF is a 32-bit fixed o Torque control: EREFT = EREF(H). EREFT is a 16-bit integer o Voltage control: EREFV = EREF(H). EREFV is a 16-bit integer • CSPD and CACC must be positive • The sum between CSPD and CACC values must be maximum 32767.99998 (0x7FFF.FFFF) i.e. the maximum value for fixed number • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD © ElectroCraft 2013 272 MPD User Manual Programming Example 1 // External mode. Read position reference from the analogue input // Position feedback: 500 lines incremental // encoder (2000 counts/rev) MODE PE; //External position CSPD = 100;// Limit = 3000[rpm] SRB UPGRADE, 0xFFFF, 0x0004; //UPGRADE.2 = 1 UPD; //execute immediate Programming Example 2 // External mode online. Read speed reference from variable EREFS // Position feedback: 500 lines incremental // encoder (2000 counts/rev) EREFS = 33.3333;// EREFS initial = 1000[rpm] EXTREF 0; MODE SE; //External speed CACC = 0.3183;// Limit = 1000[rad/s^2] SRB UPGRADE, 0xFFFF, 0x0004; //UPGRADE.2 = 1 UPD; //execute immediate See also: External – MPL Programming Details MPL Description © ElectroCraft 2013 273 MPD User Manual 6.2.3. Electronic Gearing - MPL Programming Details In the electronic gearing a drive/motor may operate as master or as slave. When set as master, the drive/motor sends its position via a multi-axis communication channel, like the CANbus. When set as slave, the drive/motor follows the master position with a programmable gear ratio. Master operation The master operation can be enabled with the MPL command SGM followed by an UPD (update) and can be disabled by the MPL command RGM followed by an UPD. In both cases, these operations have no effect on the motion executed by the master. Once at each slow loop sampling time interval, the master sends either its load position APOS (if OSR.15 = 0) or its position reference TPOS (if OSR.15 = 1) to the axis or the group of axes specified in the MPL parameter SLAVEID. The SLAVEID contains either the axis ID of one slave or the value of a group ID+256 i.e. the group of slaves to which the master should send its data. Remark: The group ID is an 8-bit unsigned value. Each bit set to 1 represents a group: bit 0 – group 1, bit 1 – group 2, etc. In total there are 8 groups. For example, if the master sends its position to group 3, the group ID = 4 (00000100b) and the SLAVEID is 4+256 = 260. The master operation can be synchronized with that of the slaves. The synchronization process is performed in two steps. First, the master sends a synchronization message to all axes, including to itself. When this message is received, all the axes read their own internal time. Next, the master sends its internal time to all the slaves, which compare it with their own internal time. If there are differences, the slaves correct slightly their sampling periods in order to keep them synchronized with those of the master. As effect, when synchronization procedure is active, the execution of the control loops on the slaves is synchronized with those of the master within a 10μs time interval. Due to this powerful feature, drifts between master and slave axes are eliminated. The synchronization procedure is activated with the MPL command SETSYNC value where value represents the time interval in internal units between the synchronization messages sent by the master. Recommended value is 20ms. If the master is going to be activated with slaves already set in electronic gearing, an initialization is necessary before enabling the master operation: the master must set the MPL parameter MPOS0 on all the slaves with a non-zero value, for example 1. Slave operation The slaves can get the master position in two ways: 1. Via a communication channel, from a drive/motor set as master 2. Via an external digital reference of type pulse & direction (if ACR.2=1) or quadrature encoder (if ACR.2 = 0). Both options have dedicated inputs. The pulse & direction signals are usually provided by an indexer and must be connected to the pulse & direction inputs of the drive/motor. The quadrature encoder signals are usually provided by an encoder on the master and must be connected to the 2nd encoder inputs. You can activate the first option with the MPL command: EXTREF 0 and the second option with the MPL command EXTREF 2. Both become effective at the next UPD command. In slave mode the drive/motor performs a position control. At each slow loop sampling period, the slave computes the master position increment and multiplies it with its programmed gear ratio. The result is the slave position reference increment, which added to the previous slave position reference gives the new slave position reference. Remark: The slave executes a relative move, which starts from its actual position © ElectroCraft 2013 274 MPD User Manual The gear ratio is specified via 3 MPL parameters: GEAR, GEARSLAVE and GEARMASTER. GEARSLAVE and GEARMASTER represent the numerator and denominator of the Slave / Master ratio. GEARSLAVE is a signed integer, while GEARMASTER is an unsigned integer. GEARSLAVE sign indicates the direction of movement: positive – same as the master, negative – reversed to the master. GEAR is a fixed value containing the result of the ratio i.e. the result of the division GEARSLAVE / GEARMASTER. GEAR is used to compute the slave reference increment, while GEARSLAVE and GEARMASTER are used by an automatic compensation procedure which eliminates the round off errors which occur when the gear ratio is an irrational number like: 1/3 (Slave = 1, Master = 3). The MPL parameter MASTERRES provides the master resolution which is needed to compute correctly the master position and speed (i.e. the position increment). MASTERRES is a 32-bit long integer value, expressed in the master position units. If master position is not cyclic (i.e. the resolution is equal with the whole 32-bit range of position), set master resolution to 0x80000001. When master position is provided via the external digital interface, the slave computes the master position by counting the pulse & direction or quadrature encoder signals. The initial value of the master position is set by default to 0. It may be changed to a different value by writing the desired value in the MPL variable APOS2. MPL commands REG_ON/REG_OFF enable/disable the superposition of the electronic gearing mode with a second motion mode. When this superposed mode activated, the position reference is computed as the sum of the position references for each of the 2 superposed motions. You may enable the superposed mode at any moment, independently of the activation/deactivation of the electronic gearing slave. If the superposed mode is activated during an electronic gearing motion, any subsequent motion mode change is treated as a second move to be superposed over the basic electronic gearing move, instead of replacing it. If the superposed mode is activated during another motion mode, a second electronic gearing mode will start using the motion parameters previously set. This move is superposed over the first one. After the first move ends, any other subsequent motion will be added to the electronic gearing. When you disable the superposed mode, the electronic gearing slave move is stopped and the drive/motor executes only the other motion. If you want to remain in the electronic gearing slave mode, set first the electronic gearing slave move and then disable the superposed mode. You can smooth the slave coupling with the master, by limiting the maximum acceleration on the slave. This is particularly useful when the slave is must couple with a master running at high speed. The feature is activated by setting UPGRADE.2=1 and the maximum acceleration value in CACC. Remark: When slave coupling with the master is complete SRH.12 = 1. The same bit is reset to zero if the slave is decoupled from the master. The bit has no significance in other motion modes. See also: Electronic Gearing – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 275 MPD User Manual 6.2.3.1.1. Electronic Gearing - Related MPL Instructions and Data Parameters CACC Maximum acceleration in slave mode when UPGRADE.2=1 SLAVEID The axis or group ID to which the master sends its position. When group ID is used, the SLAVEID is set with group ID value + 256. GEAR Slave(s) gear ratio value. Negative values means opposite direction compared with the master GEARMASTER Denominator of gear ratio GEARSLAVE Numerator of gear ratio. Negative values means opposite direction compared with the master MASTERRES Master resolution used by slave(s) Measured in master position units MPOS0 Initialization parameter. Must be set by the master with a non-zero value before enabling the master mode, if the slaves are already set in electronic gearing. OSR MPL register. When OSR.15=1, the master sends the position reference. When OSR.15=0, the master sends the actual load position UPGRADE ACR MPL register. When UPGRADE.2=1, an acceleration limitation may be set on slave. When UPGRADE.2=0, the acceleration limitation is disabled Auxiliary Control Register – includes several MPL Programming options. When ACR.2 = 0, the external reference is quadrature encoder. When ACR.2 = 1, the external reference is pulse & direction Variables MREF Master position received or computed by the slave(s). Measured in master position units MSPD Master speed computed by the slaves. Measured in master speed units APOS2 Master position computed by the slaves from pulse & direction or quadrature encoder inputs. At power-on it is set to 0. May be set to a different value, before starting the master. Measured in master position units TPOS Target position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units TSPD Target speed – speed reference computed by the reference generator at each slow loop sampling period. Measured in speed units TACC Target acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period. Measured in acceleration units APOS_LD Actual load position. Measured in position units. Alternate name: APOS ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD © ElectroCraft 2013 276 MPD User Manual Instructions EXTREF 0 Get master position via a communication channel EXTREF 2 Compute master position from pulse & direction or quadrature encoder signals MODE GS Set electronic gear slave mode SGM Set electronic gear master mode RGM Reset electronic gear master mode REG_ON Enable superposed mode REG_OFF Disable superposed mode SETSYNC value Send synchronization messages at the time interval indicated by the 16-bit value. Measured in time units TUM1 Target Update Mode 1 (TUM1). Generates new trajectory starting from the actual values of position and speed reference (i.e. don’t update the reference values with load/motor position and speed) TUM0 Target Update Mode 0 (TUM0). Generates new trajectory starting from the actual values of load/motor position and speed (i.e. updates the reference values with load/motor position and speed) UPD Update motion parameters and start new motion mode STOP Stop the motion SRB Set/reset bits from a MPL data Remarks: • Do not change GEAR, GEARSLAVE and GEARMASTER during slave operation • CACC must be positive • In order to activate the TUM1 mode, execute the MPL instruction TUM1 AFTER the MODE GS command and BEFORE the UPD command. When MODE GS is executed, it automatically sets TUM0 mode. However, as the new motion mode becomes effective only after the UPD command, a TUM1 command will overwrite the TUM0 mode • Under TUM0 mode, at the UPD command TPOS=APOS_LD and TSPD=ASPD_LD. In open loop control of steppers, TUM0 is ignored as there is no position and/or speed feedback • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD © ElectroCraft 2013 277 MPD User Manual Programming Example //Electronic gearing. Master position is received via //communication channel inputs. //Master resolution: 2000 counts/rev // On slave axis (Axis ID = 1): GEAR = 0.3333; // gear ratio GEARMASTER = 3; //gear ratio denominator GEARSLAVE = 1; //gear ratio numerator EXTREF 0; // master position got via communication channel MASTERRES = 2000; // master resolution REG_ON; //Enable superposition MODE GS; //Set as slave, position mode TUM1; //Set Target Update Mode 1 SRB UPGRADE, 0xFFFF, 0x0004; //UPGRADE.2 = 1 CACC = 0.9549; //Limit maximum acceleration at 3000[rad/s^2] UPD; //execute immediate // On master axis: SLAVEID = 1; SGM; //Enable Master in Electronic Gearing mode SRB OSR, 0xFFFF, 0x8000; // OSR.15=1 -> Send Position Reference [1]MPOS0 = TPOS; UPD; //execute immediate SETSYNC 20; //Send synchronization messages every 20[ms] See also: Electronic Gearing – MPL Programming Details MPL Description © ElectroCraft 2013 278 MPD User Manual 6.2.3.1.2. Electronic Camming - MPL Programming Details In the electronic camming a drive/motor may operate as master or as slave. When set as master, the drive/motor sends its position via a multi-axis communication channel, like the CAN bus. When set as slave, the drive/motor executes a cam profile function of the master position. The cam profile is defined by a cam table – a set of (X, Y) points, where X is cam table input i.e. the master position and Y is the cam table output i.e. the corresponding slave position. Between the points the drive/motor performs a linear interpolation. Master operation The master operation can be enabled with the MPL command SGM followed by an UPD (update) and can be disabled by the MPL command RGM followed by an UPD. In both cases, these operations have no effect on the motion executed by the master. Once at each slow loop sampling time interval, the master sends either its load position APOS (if OSR.15 = 0) or its position reference TPOS (if OSR.15 = 1) to the axis or the group of axes specified in the MPL parameter SLAVEID. The SLAVEID contains the axis ID of one slave or the value of a group ID+256 i.e. the group of slaves to which the master should send its data. Remark: The group ID is an 8-bit unsigned value. Each bit set to 1 represents a group: bit 0 – group 1, bit 1 – group 2, etc. In total there are 8 groups. For example, if the master sends its position to group 3, the group ID = 4 (00000100b) and the SLAVEID is 4+256 = 260. The master operation can be synchronized with that of the slaves. The synchronization process is performed in two steps. First, the master sends a synchronization message to all axes, including to itself. When this message is received, all the axes read their own internal time. Next, the master sends its internal time to all the slaves, which compare it with their own internal time. If there are differences, the slaves correct slightly their sampling periods in order to keep them synchronized with those of the master. As effect, when synchronization procedure is active, the execution of the control loops on the slaves is synchronized with those of the master within a 10μs time interval. Due to this powerful feature, drifts between master and slave axes are eliminated. The synchronization procedure is activated with the MPL command SETSYNC value where value represents the time interval in internal units between the synchronization messages sent by the master. Recommended value is 20ms. Slave operation The slaves can get the master position in two ways: 1. Via a communication channel, from a drive/motor set as master 2. Via an external digital reference of type pulse & direction (if ACR.2=1) or quadrature encoder (if ACR.2 = 0). Both options have dedicated inputs. The pulse & direction signals are usually provided by an indexer and must be connected to the pulse & direction inputs of the drive/motor. The quadrature encoder signals are usually provided by an encoder on the master and must be connected to the 2nd encoder inputs. You can activate the first option with the MPL command: EXTREF 0 and the second option with the MPL command EXTREF 2. Both become effective at the next UPD command. The MPL parameter MASTERRES provides the master resolution which is needed to compute correctly the master position and speed (i.e. the position increment). MASTERRES is a 32-bit long integer value, expressed in the master position units. If master position is not cyclic (i.e. the resolution is equal with the whole 32-bit range of position), set master resolution to 0x80000001. When master position is provided via the external digital interface, the slave computes the master position by counting the pulse & direction or quadrature encoder signals. The initial value of the master © ElectroCraft 2013 279 MPD User Manual position is set by default to 0. It may be changed to a different value by writing the desired value in the MPL variable APOS2. Through the MPL parameter CAMOFF you can shift the cam profile versus the master position, by setting an offset for each slave. The cam table input is computed as the master position minus the cam offset. For example, if a cam table is defined between angles 100 to 250 degrees, a cam offset of 50 degrees will make the cam table to execute between master angles 150 and 300 degrees. In slave mode the drive/motor performs a position control. Based on the master position X, it calculates the cam table output Y = f(X). It is not mandatory to define the cam table for 360 degrees of the master. You may also define shorter cam tables, with a start angle Xmin > 0 and an end angle Xmax < 360 degrees. In this case, the cam table output remains unchanged outside the active area of the cam, being computed as follows: • Y = Ymin = f(Xmin), if 0 < X < Xmin • Y = f(X), if Xmin ≤ X ≤ Xmax • Y = Ymax = f(Xmax), if Xmax < X < 360 The electronic camming can be: relative (if ACR.12 = 0) or absolute (if ACR.12 = 1). In the relative mode, the output of the cam table is added to the slave actual position. At each slow loop sampling period the slave computes a position increment dY = Y – Yold. This is the difference between the actual cam table output Y and the previous one Yold. The position increment dY is added to the old target position to get a new target position: TPOS = TPOS + dY. The slave detects when the master position rolls over, from 360 degrees to 0 or vice-versa and automatically compensates in dY the difference between Ymax and Ymin. Therefore, in relative mode, you can continuously run the master in one direction and the slaves will execute the cam profile once at each 360 degrees with a glitch free transition when the cam profile is restarted. When electronic camming is activated in relative mode, the slave initializes Yold with the first cam output computed: Yold = Y = f(X). The slave will keep its position until the master starts to move and then it will execute the remaining part of the cam. For example if the master moves from X to Xmax, the slave moves with Ymax – Y. In the absolute mode, the output of the cam table Y is the target position to reach: TPOS = Y. Remark: The absolute mode must be used with great care because it may generate abrupt variations on the slave target position if: • Slave position is different from Y at entry in the camming model • Master rolls over and Ymax ≠ Ymin In the absolute mode, you can introduce a maximum speed limit to protect against accidental sudden changes of the positions to reach. The feature is activated by setting UPGRADE.2=1 and the maximum speed value in CSPD. Remark: When the slave can’t reach the target position corresponding to the cam profile due to the speed limitation, SRH.14 = 1. The same bit is reset to zero when the slave returns to normal operation following the cam profile with a speed below the maximum limit. The bit has no significance in other motion modes. One way to avoid abrupt variations at activation of absolute mode is to move the slave(s) in the position corresponding to the master actual value, before enabling the camming slave mode. This approach requires finding the cam table output before entering in the camming mode. You can get this information in the following way: © ElectroCraft 2013 280 MPD User Manual 1. Set the slave(s) in trapezoidal position profile mode, for example to keep its actual position 2. Set MPL parameter GEAR (also used as gear ratio in electronic gearing) at 0. 3. Introduce an wait of 1ms (more exactly one slow-loop sampling period) 4. Read the cam table output for the actual master position from MPL variable EREF Remark: Before executing point 2, make sure that the cam table is present in the RAM memory and CAMSTART is initialized accordingly (see below for details). The cam tables are arrays of X, Y points, where X is the cam input i.e. the master position and Y is the cam output i.e. the slave position. The X points are expressed in the master internal position units, while the Y points are expressed in the slave internal position units. Both X and Y points 32-bit long integer values. The X points must be positive (including 0) and equally spaced at: 1, 2, 4, 8, 16, 32, 64 or 128 i.e. having the interpolation step a power of 2 between 0 and 7. The maximum number of points for one cam table is 8192. As cam table X points are equally spaced, they are completely defined by two data: the Master start value or the first X point and the Interpolation step providing the distance between the X points. This offers the possibility to minimize the cam size, which is saved in the drive/motor in the following format: • 1st word (1 word = 16-bit data): Bits 15-13 – the power of 2 of the interpolation step. For example, if these bits have the binary value 010 (2), the interpolation step is The link ed image cannot be display ed. The file may hav e been mov ed, renamed, or deleted. Verify that the link points to the correct file and location. = 4, hence the master X values are spaced 2 from 4 to 4: 0, 4, 8, 12, etc. Bits 12-0 – the length -1 of the table. The length represents the number of points • 2nd and 3rd words: the Master start value (long), expressed in master position units. 2nd word contains the low part, 3rd word the high part • 4th and 5th words: Reserved. Must be set to 0 • Next pairs of 2 words: the slave Y positions (long), expressed in position units. The 1st word from the pair contains the low part and the 2nd word from the pair the high part • Last word: the cam table checksum, representing the sum modulo 65536 of all the cam table data except the checksum word itself © ElectroCraft 2013 281 MPD User Manual Before enabling electronic camming slave mode, the cam table must be downloaded into the drive/motor RAM memory and the MPL variable CAMSTART must be set with the value of the cam start address. It is possible to download more than one cam table in the drive/motor RAM memory and through CAMSTART to select which one to use at one moment. Typically, the cam tables are first downloaded into the EEPROM memory of the drive, together with the rest of the MPL program. Then using the MPL command (included in the MPL program): INITCAM LoadAddress, RunAddress the cam tables are copied from the EEPROM memory into the drive/motor RAM memory. The LoadAddress is the EEPROM memory address where the cam table was loaded and RunAddress is the RAM memory address where to copy the cam table. After the execution of this command the MPL variable CAMSTART takes the value of the RunAddress. Remarks: • Motion programming tool MotionPRO Developer automatically computes the start addresses in RAM and EEPROM of the selected cam tables and for each cam generates an INITCAM command. The INITCAM commands are included in the MPL application before ENDINIT. Therefore when this command is executed, all the selected cams are already copied from the EEPROM into the RAM. • During electronic camming slave mode, only one cam table can be active at time You can compress/extend the cam table input. Specify through MPL parameter CAMX, an input correction factor by which the cam table input is multiplied. For example, an input correction factor of 2, combined with a cam offset of 180 degrees, will make possible to execute a cam table defined for 360 degrees of the master in the last 180 degrees. You can also compress/extend the cam table output. Specify through the MPL parameter CAMY, an output correction factor by which the cam table output is multiplied. This feature addresses the applications where the slaves must execute different position commands at each master cycle, all having the same profile defined through a cam table. In this case, the drive/motor is programmed with a unique normalized cam profile and the cam table output is multiplied with the relative position command updated at each master cycle. See also: Electronic Camming – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 282 MPD User Manual 6.2.3.1.3. Electronic Camming - Related MPL Instructions and Data Parameters CSPD Maximum speed in slave mode when UPGRADE.2=1 CAMOFF Cam offset. The input in the cam table before applying the scaling MPOS0 is computed by subtracting cam offset from the master position. Measured in master position units CAMSTART Pointer to cam table start address in RAM memory. When several cam tables are loaded in RAM, CAMSTART indicates which one is used. You can switch between cam tables by setting CAMSTART to the start address of another cam table. CAMSTART is automatically set by the INITCAM command, which copies the cam table from the EEPROM to the RAM memory CAMX Cam input correction factor. Cam input X (MPL variable CAMINPUT) is: X = CAMINPUT = MPOS0 * CAMX where MPOS0 = MREF - CAMOFF CAMY Cam output correction factor. Cam table output Y is: Y = f(X) * CAMY MASTERRES Master resolution used by slave(s) (long) Measured in master position units. SLAVEID The axis or group ID to which the master sends its position. When group ID is used, the SLAVEID is set with group ID value + 256. OSR MPL register. When OSR.15=1, the master sends the position reference. When OSR.15=0, the master sends the actual load position UPGRADE MPL register. When UPGRADE.2=1, a speed limitation may be set on slave. When UPGRADE.2=0, the speed limitation is disabled ACR Auxiliary Control Register – includes several MPL Programming options. When ACR.12 = 0, the camming is relative. When ACR.12 = 1, the camming is absolute. When ACR.2 = 0, the external reference is quadrature encoder. When ACR.2 = 1, the external reference is pulse & direction Variables MREF Master position received or computed by the slave(s). Measured in master position units MSPD Master speed computed by the slaves. Measured in master speed units MPOS0 Master position on the slave(s) after subtracting cam offset CAMOFF. Measured in master position units CAMINPUT Cam table input APOS2 Master position computed by the slaves from pulse & direction or quadrature encoder inputs. At power-on it is set to 0. May be set to a different value, before starting the master. Measured in master position units TPOS Target position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units © ElectroCraft 2013 283 MPD User Manual TSPD Target speed – speed reference computed by the reference generator at each slow loop sampling period. Measured in speed units TACC Target acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period. Measured in acceleration units APOS_LD Actual load position. Measured in position units. Alternate name: APOS ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD Instructions EXTREF 0 Get master position via a communication channel EXTREF 2 Compute master position from pulse & direction or quadrature encoder signals MODE CS Set electronic camming slave mode SGM Set electronic gearing/camming master mode RGM Reset electronic gearing/camming master mode SETSYNC value Send synchronization messages at the time interval indicated by the 16-bit value. Measured in time units INITCAM LoadAddress, RunAddress Copy a cam table from EEPROM starting with LoadAddress to RAM starting with RunAddress. Both values are unsigned integers TUM1 Target Update Mode 1 (TUM1). Generates new trajectory starting from the actual values of position and speed reference (i.e. don’t update the reference values with load/motor position and speed) TUM0 Target Update Mode 0 (TUM0). Generates new trajectory starting from the actual values of load/motor position and speed (i.e. updates the reference values with load/motor position and speed) UPD Update motion parameters and start new motion mode STOP Stop the motion SRB Set/reset bits from a MPL data Remarks: • CSPD must be positive • In order to activate the TUM1 mode, execute the MPL instruction TUM1 AFTER the MODE CS command and BEFORE the UPD command. When MODE CS is executed, it automatically sets TUM0 mode. However, as the new motion mode becomes effective only after the UPD command, a TUM1 command will overwrite the TUM0 mode • Under TUM0 mode, at the UPD command TPOS=APOS_LD and TSPD=ASPD_LD. In open loop control of steppers, TUM0 is ignored as there is no position and/or speed feedback • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD © ElectroCraft 2013 284 MPD User Manual Programming Example // Electronic camming slave. Master position is read from 2nd // encoder inputs. Master resolution : 2000 counts/rev CAMSTART = 0xF000; //Initialize CAM table start address EXTREF 2; // master position read from P&D or 2nd encoder CAMOFF = 200; //Cam offset from master CAMX = 0.5; //Cam input correction factor CAMY = 1.5; //Cam output correction factor MASTERRES = 2000; // master resolution MODE CS; //Set electronic camming slave mode TUM1; //Set Target Update Mode 1 SRB ACR, 0xEFFF, 0x0000; //Camming mode: Relative UPD; //execute immediate See also: Electronic Camming – MPL Programming Details MPL Description 6.2.3.1.4. Homing and Function Calls ElectroCraft Motion Controller is able to start the execution of homing routines and MPL functions stored in the slaves’ non-volatile memory. A maximum of 10 homing/functions can be called access from Motion Controller Once the homing/function execution starts the Motion Controller application can be halted by using an event on function complete. The Motion complete resumes the application execution when the event occurs or it time outs. See also: MPL Description © ElectroCraft 2013 285 MPD User Manual 6.2.3.1.5. Homing - MPL Programming Details The homing is a sequence of motions, usually executed after power-on, through which the load is positioned into a well-defined point – the home position. Typically, the home position is the starting point for normal operation. The search for the home position can be done in numerous ways. In order to offer maximum flexibility, the MPL does not impose the homing procedures but lets you define your own, according with your application needs. Basically a homing procedure is a MPL function and by calling it you start executing the homing procedure. The call must be done using the MPL command CALLS – a cancelable call. This command offers the possibility to abort at any moment the homing sequence execution (with MPL command ABORT) and return to the point where the call was initiated. Therefore, if the homing procedure can’t find the home position, you have the option to cancel it. During the execution of a homing procedure SRL.8 = 1. Hence you can find when a homing sequence ends, either by monitoring bit 8 from SRL or by programming the drive/motor to send a message to your host when SRL.8 changes. As long as a homing sequence is in execution, you should not start another one. If this happens, the last homing is aborted and a warning is generated by setting SRL.7 = 1. Remark: In motion programming tools like MotionPRO Developer, ElectroCraft provides for each programmable drive/motor a collection of up to 32 homing procedures. These are predefined MPL functions, which you may call after setting the homing parameters. You may use any of these homing procedures as they are, or use them as a starting point for your own homing routines. Typically a homing function requires setting the following parameters before calling it: • CACC – acceleration/deceleration rate for the position / speed profiles during homing • CDEC – deceleration rate for quick stop when a limit switch is reached • CSPD – High/normal speed for the position / speed profiles done during homing • HOMESPD – Low speed for the final approach towards the home position • HOMEPOS – New home position set at the end of the homing procedure See also: Homing – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 286 MPD User Manual 6.2.3.1.6. Homing - Related MPL Instructions and Data Parameters CACC Acceleration/deceleration command for the position / speed profiles during homing. Measured in acceleration units CDEC Deceleration rate during quick stop. Measured in acceleration units CSPD speed units High/normal speed command for the position / speed profiles during homing. Measured in HOMEPOS New home position set at the end of the homing procedure. Measured in position units HOMESPD speed units Low speed command for the final approach towards the home position. Measured in Instructions CALLS Cancelable call of a MPL function ABORT Abort execution of a function called with CALLS SAP V32 Set actual position equal with the value or a 32-bit long variable V32. The value is measured in position units Programming Example // Position feedback: 500 lines incremental // encoder (2000 counts/rev) //Select homing parameters CACC = 0.3183;//Acceleration rate = 1000[rad/s^2] CDEC = 0.3183;//Deceleration rate = 1000[rad/s^2] CSPD = 33.3333;//High speed = 1000[rpm] HOMESPD = 3;//Low speed = 90[rpm] HOMEPOS = 0;//Home position = 0[rot] //Execute homing mode 1 CALLS HomeMode1; // call HomeMode1 function WaitHomingEnd: user_var = SRL; SRB user_var, 0x100, 0; // isolate SRL.8 GOTO WaitHomingEnd, user_var, NEQ; // wait as long as SRL.8=1 HomingEnded: ... © ElectroCraft 2013 287 MPD User Manual HomeMode1: // this function implements the homing procedure ... SAP HOMEPOS; // Set home position = HOMEPOS value RET; See also: Homing – MPL Programming Details MPL Description © ElectroCraft 2013 288 MPD User Manual 6.2.3.1.7. Contouring In the contouring mode, you can program an arbitrary path via a series of points. Between the points, linear interpolation is performed, leading to a contour described by a succession of linear segments. The contouring mode may be executed only from a MPL program. You can’t send contouring points from a host via a communication channel, like in the case of the PT mode. Depending on the control mode chosen, four options are available: • Position contouring – the load/motor is controlled in position. The path represents a position reference • Speed contouring – the load/motor is controlled in speed. The path represents a speed reference. • Torque contouring – the motor is controlled in torque. The path represents a current reference. • Voltage contouring – the motor is controlled in voltage. The path represents a voltage reference. A contouring segment is described via the MPL command SEG, which has 2 parameters: time and reference increment. The time represents the segment duration expressed in time units i.e. in number of slow loop sampling periods. The reference increment represents the amount of reference variation per time unit i.e. per slow loop sampling period. The contouring mode has been foreseen mainly for setup tests. However, you can also use the position contouring and the speed contouring for normal operation, as part of your motion application. You can switch at any moment to and from these 2 modes. The torque contouring and the voltage contouring have been foreseen only for setup tests. The torque contouring may be used, for example, to check the response of the current controllers to different input signals. Similarly, the voltage contouring may be used, for example, to check the motors behavior under a constant voltage or any other voltage shape. 24 20 16 12 8 4 0 0 2 4 6 8 10 12 14 Reference generation in contouring modes In position contouring or speed contouring, the starting point is either the current value of the target position/speed (if TUM1 command is set between the motion mode setting and the UPD command), or the actual value of the load position/speed (if TUM1 is omitted). Therefore the contour is relative to the starting point. In torque/voltage contouring, the starting point may be set by the user in REF0(H). After reset, the default value of REF0(H) is zero. In the MPL program, first the contouring mode must be set, followed by the first point. Then the contouring mode can be activated with the UPD command, followed by the next points. The sequence of points must end with a final point having the time interval 0. © ElectroCraft 2013 289 MPD User Manual Remarks: • When the last segment execution ends, the reference is kept constant at the last computed value. • When a contouring sequence ends without having time value set to 0 on the last segment, the drive/motor remains in contouring mode waiting for new points. When the last segment has time value set to 0, the drive gets out from contouring mode. In order to execute other segments, the contouring mode must be set again. When a sequence of contour points is executed, the MPL instruction pointer IP advances as the segments described by the points are executed. When the reference generator starts working with a new segment, at MPL program level the IP advances to the execution of the SEG instruction. The execution of a MPL instruction for a contour segment means to copy the segment data into a local buffer and then wait (i.e. loop on the same instruction) until the previous segment, currently under execution at reference generator level will end. This procedure permits to immediately start the execution of the next contour segment when the current one ends because the next segment data are already available in a local buffer. Each time the reference generator starts to execute a new segment, the IP advances to the next contour segment and its data are transferred into the local buffer. See also: Contouring – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 290 MPD User Manual 6.2.3.1.8. Contouring - MPL Instructions and Data Parameters REF0(H) Starting value for torque or voltage contouring. Measured in current units or voltage command units Variables TPOS Target load position – position reference computed by the reference generator at each slow loop sampling period in position or speed contouring. In speed contouring, TPOS is computed by integrating the target speed TSPD.Measured in position units TSPD Target load speed – speed reference computed by the reference generator at each slow loop sampling period in position or speed contouring. Measured in speed units TACC Target load acceleration – acceleration/deceleration reference computed by the reference generator at each slow loop sampling period in position and speed contouring. Measured in acceleration units IQREF Current reference – computed by the reference generator at each slow loop sampling period in torque contouring. Measured in current units UQREF Voltage reference – computed by the reference generator at each slow loop sampling period in voltage contouring. Measured in voltage command units APOS_LD Actual load position. Measured in position units. Alternate name: APOS. ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD IQ Motor current. Measured in current units Instructions MODE PC Set position contouring mode MODE SC Set speed contouring mode MODE TC Set torque contouring mode MODE VC Set voltage contouring. SEG Time, Increment Set a contour segment where: Time – is the segment time. It is an unsigned integer measured in time units Increment – is the segment reference increment per time unit. It is 32-bit fixed value measured in: © ElectroCraft 2013 291 MPD User Manual speed units for position contouring acceleration units for speed contouring current units / time units for torque contouring voltage units / time units for voltage contouring TUM1 Target Update Mode 1 (TUM1). Generates new trajectory starting from the actual values of position and speed reference (i.e. don’t update the reference values with load/motor position and speed) TUM0 Target Update Mode 0 (TUM0). Generates new trajectory starting from the actual values of load/motor position and speed (i.e. updates the reference values with load/motor position and speed) UPD Update motion parameters and start new motion mode STOP Stop the motion. Remarks: • In order to activate the TUM1 mode, execute the MPL instruction TUM1 AFTER setting one of the contouring modes and BEFORE the UPD command. When the MPL command setting a contouring mode is executed, it automatically sets TUM0 mode. However, as the new motion mode becomes effective only after the UPD command, a TUM1 command will overwrite the TUM0 mode • Under TUM0 mode, at the UPD command TPOS=APOS_LD and TSPD=ASPD_LD. In open loop control of steppers, TUM0 is ignored as there is no position and/or speed feedback • In setup configurations where there is no transmission ratio between the motor and the load, it is supposed that these are directly connected. In these cases: APOS_MT=APOS_LD and ASPD_MT=ASPD_LD Programming Example // Position contouring with position feedback on motor: 500 lines // incremental encoder (2000 counts/rev) MODE PC;//Set Position Contouring TUM1;//Start from actual value of position reference SEG 100U, 20.00000;// 1st point UPD; //Execute immediate SEG 100U, 0.00000; // 2nd point SEG 0, 0.0; //End of contouring See also: Contouring – MPL Programming Details MPL Description © ElectroCraft 2013 292 MPD User Manual 6.2.3.1.9. Test Mode - MPL Programming Details The torque and voltage test modes have been designed to facilitate the testing during the setup phase. In these test modes, either a voltage or a torque (current) command can be set using a test reference consisting of a limited ramp (see figure below). Reference profile in test modes For AC motors (like for example the brushless motors), the test mode offers also the possibility to rotate a voltage or current reference vector with a programmable speed. As a result, these motors can be moved in an “open-loop” mode without using the position sensor. The main advantage of this test mode is the possibility to conduct in a safe way a series of tests, which can offer important information about the motor parameters, drive status and the integrity of the its connections. Electrical angle setup in test modes with brushless AC motors Remark: The Motion test is a special test mode to be used only in some special cases for drives setup. The Motion Test mode is not supposed to be used during normal operation See also: Test Mode – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 293 MPD User Manual 6.2.3.1.10. Test Mode - MPL Instructions and Data Parameters REFTST_V Maximum voltage reference. Measured in voltage units REFTST_A Maximum current reference. Measured in current units RINCTST_V Voltage reference increment at each slow-loop sampling period. Measured in voltage units / time units RINCTST_A Current reference increment at each slow-loop sampling period. Measured in current units / time units THTST Initial value for the electrical angle. Measured in electrical angle units TINCTST Electrical angle increment at each fast-loop sampling period. Measured in electrical angle increments units. Instructions MODE VT Set voltage test mode MODE TT Set torque test mode UPD Update motion mode and parameters. Start motion Programming Example //Torque test mode, brushless AC motor. Drive IDM640-8EI //with peak current 16.5A -> 32736 internal current units //360° electric angle -> 65536 internal units // fast loop sampling period = 0.1ms. Motor has 2 pole pairs MODE TT; //Torque Test Mode REFTST_A = 1984;//Reference saturation = 1[A] RINCTST_A = 20;//Reference increment = 10[A/s] THTST = 0;//Electric angle = 0[deg] TINCTST = 7;//Electric angle increment ~= 2e+002[deg/s] UPD; //update immediate See also: Test Mode – MPL Programming Details MPL Description © ElectroCraft 2013 294 MPD User Manual 6.2.3.1.11. Motor Commands You can apply one of following commands to the motor: • Activate/deactivate the control loops and the power stage PWM output commands (AXISON / AXISOFF) • Stop the motor with deceleration set in MPL parameter CACC • Issue an update command, immediate (UPD) or when a previously programmed event occurs (UPD!) • Change the value of the motor position and position reference The AXISON command activates the control loops and the PWM output commands. After power on, the AXISON command has to be executed after the ENDINIT (end of initialization) command. Remark: You may set the first motion mode either before or after the AXISON command. If the first AXISON is executed before setting the motion mode, the drive/motor enters in the default motion mode: voltage external online with voltage reference zero. Therefore, the drive gets zero voltage commands, until you’ll set a new motion mode. If you first set a motion mode, followed by update UPD and then activate control with AXISON, the drive/motor enters directly in the desired motion mode. The AXISON command may be used to restore the normal drive operation following an AXISOFF command. Typically, this situation occurs at recovery from an error, following the fault reset command FAULTR, or after the drive/motor ENABLE input goes from status disabled to status enabled. When AXISON is set after an AXISOFF command, the reference generator resumes its calculations from the same conditions left when the AXISOFF command was executed. As consequence, the values of the target position and speed provided by the reference generator may differ quite a lot from the actual values of the load position and speed which continue to be measured during the AXISOFF condition. In order to eliminate these differences: • Set the motion mode, even if it is the same. The motion mode commands, automatically set the target update mode zero (TUM0), which updates the target position and speed with the actual measured values of the load position and speed • Execute update command UPD • Execute AXISON command Example: A motor controlled in speed with a trapezoidal profile, was stopped with an AXISOFF command. In order to resume the normal operation, with the same parameters, the MPL program can be: // Resume speed profile operation from AXISOFF MODE SP; // set speed profile mode UPD; // update immediate AXISON; // motion starts. //The initial value for target speed is 0 because was //updated with the actual motor speed which is 0 //because the motor is still The AXISOFF command deactivates the control loops, the reference generator and the PWM output commands (all the switching devices are off). However, all the measurements remain active and therefore the motor currents, speed, position as well as the supply voltage continue to be updated and monitored. If the AXISOFF command is applied during motion, it leaves the motor free running. Typically, © ElectroCraft 2013 295 MPD User Manual the AXISOFF command is used when a fault condition is detected, for example when a protection is triggered. Fault conditions trigger MPL interrupts. Each drive/motor has a built-in set of MPL interrupt service routines (ISR), which are automatically activated after power-on. In these routines, the default action for fault conditions is an AXISOFF command. If needed, you may replace any built-in ISR with your own ISR and thus, adapt the fault treatment to your needs. Remark: The AXISOFF command is automatically generated when the Enable input goes from enabled to disabled status. If the Enable input returns to the enabled status, the AXISON command is automatically generated if • ACR.3 =1, or • ACR.1 = 1 i.e. the drive/motor is set to start automatically after power-on with an external Remark: SRL.15 shows the AXISON/AXISOFF condition and SRH.15 shows a fault condition The STOP command stops the motor with the deceleration rate set in MPL parameter CACC. The drive/motor decelerates following a trapezoidal position or speed profile. If the STOP command is issued during the execution of an S-curve profile, the deceleration profile may be chosen between a trapezoidal or an S-curve profile (see S-curve dialogue settings). You can detect when the motor has stopped by setting a motion complete event ( !MC )and waiting until the event occurs ( WAIT! ). The STOP command can be used only when the drive/motor is controlled in position or speed. Remarks: • In order to restart after a STOP command, you need to set again the motion mode. This operation disables the stop mode and allows the motor to move • When STOP command is sent via a communication channel, it will automatically stop any MPL program execution, to avoid overwriting the STOP command from the MPL program If an error requiring the immediate stop of the motion occurs (like triggering a limit switch or following a command error), the drive/motor enters automatically in the quick stop mode. This mode stops the motor with a trapezoidal profile, using the deceleration rate set in the MPL parameter CDEC. When an immediate update command UPD is executed, the last motion mode programmed together with the latest motion parameters are taken into consideration. During motion execution, you can freely change the motion mode and/or its parameters. These changes will have no effect until an update command is executed. If you intend to perform an update when a specific condition occurs, you can set an event which monitors the condition, followed by an update on event command UPD!. When the monitored condition occurs, the update will be automatically performed. Once you have set an update on event UPD!, you can either wait for the monitored event to occur, or perform other operations. The MPL command SAP offers you the possibility to set / change the referential for position measurement by changing simultaneously the load position APOS and the target position TPOS values, while keeping the same position error. © ElectroCraft 2013 296 MPD User Manual You can specify the new position either as an immediate value or via a 32-bit long variable. SAP command can be executed at any moment during motion. When SAP command is executed, the following operations are performed: • Under TUM1, i.e. if TUM1 command has been executed after the last motion mode setting and before the last UPD, the target/reference position TPOS is set equal with the new position value and the actual motor position APOS is set equal with the new position reference minus the position error (POSERR) TPOS = new_value; APOS = TPOS – POSERR; • Under TUM0, i.e. if TUM1 command has not been executed after the last motion mode setting and before the last UPD, the actual load position APOS is set equal with the new position value and the target/reference position TPOS is set equal with the new position plus the position error (POSERR) APOS = new_value; TPOS = APOS + POSERR; The MPL command STA sets the target position equal with the actual position: TPOS = APOS. See also: Motor Commands – Related MPL Instructions and Data MPL Description 6.2.3.1.12. Motor Commands - Related MPL Instructions and Data Parameters CACC Deceleration rate following a STOP command CDEC Deceleration rate during quick stop MPL Variables APOS_LD Actual load position. Measured in position units. Alternate name: APOS TPOS Target position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units POSERR Represents the value of load position error, computed as the difference between the target position and the measured position of the load Instructions AXISON Set axis ON. Activate control loops and PWM commands AXISOFF Set axis OFF. Deactivate control loops and PWM commands STOP Stop motion with the acceleration/deceleration set in CACC © ElectroCraft 2013 297 MPD User Manual UPD Update immediate motion mode and parameters. Start motion UPD! Update the motion mode and parameters when the programmed event occurs SAP V32 Set V32 in the actual or target position. V32 is either a 32-bit immediate value or a long MPL data (user variable) containing the value to set STA Set target position TPOS equal with the actual position APOS Programming Example // Position profile. Position feedback: 500 lines incremental // encoder (2000 counts/rev) CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 33.3333;//slew speed = 1000[rpm] CPOS = 6000;//position command = 3[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate ... STOP; // stop motion before reaching the final position //Define event: When actual position remains inside //a settle band around the position to reach SRB UPGRADE, 0xFFFF, 0x0800; !MC; WAIT!;//Wait until the event occurs i.e. motor stops SAP 0; // Set actual position value to 0[rot] ... MODE PP; UPD; //execute immediate – restart motion after a STOP command See also: Motor Commands – MPL Programming Details MPL Description © ElectroCraft 2013 298 MPD User Manual 6.2.3.2. Program flow control 6.2.3.2.1. Events on drives with built-in Motion Controller 6.2.3.2.1.1. List of Events An event is a programmable condition, which once set, is monitored for occurrence. You can do the following actions in relation with an event: A) Change the motion mode and/or the motion parameters, when the event occurs B) Stop the motion when the event occurs C) Wait for the programmed event to occur Remark: The programmed event is automatically erased if the event is reached, if the timeout for the wait is reached or if a new event is programmed. Only a single event can be programmed at a time. The Table below presents all the events with their mnemonic and a short description. © ElectroCraft 2013 299 MPD User Manual If you want to change the motion mode and/or the motion parameters when an event occurs, you must do the following: • Program/define one of the above events • Set the new motion mode and/or the motion parameters © ElectroCraft 2013 300 MPD User Manual • Set one of the MPL commands: UPD! (Update on event) or STOP! (Stop on event), which will become effective when the programmed event occurs Remark: After you have programmed a new motion mode and/or new motion parameters with update on event, you need to wait until the programmed event occurs, using the MPL command WAIT!. Otherwise, the program will continue with the next instructions that may override the event monitoring. The instruction WAIT!, stops the MPL program further execution, until the programmed event occurs. During this period, only the MPL commands received via a communication channel are processed. You may also specify the time limit for the wait, by adding a time value after the WAIT! command: WAIT! time_limit. If the monitored event doesn’t occur in the time limit set, the wait loop is interrupted, the event checking is reset and the MPL program passes to the next instruction. See also: Events – When the actual motion is completed. Related MPL Instructions and Data Events – Function of motor or load position Related MPL Instructions and Data Events – Function of motor or load speed Related MPL Instructions and Data Events – After a wait time Related MPL Instructions and Data Events – Function of reference Related MPL Instructions and Data Events – Function of inputs status Related MPL Instructions and Data Events – Function of 32-bit variable value Related MPL Instructions and Data 6.2.3.2.1.2. When the actual motion is completed Setting this event allows you to detect when a motion is completed. You can use, for example, this event to start your next move only after the actual move is finalized. The motion complete condition is set in the following conditions: • During position control: If UPGRADE.11=1, when the position reference arrives at the position to reach (commanded position) and the position error remains inside a settle band for a preset stabilize time interval If UPGRADE.11=0, when the position reference arrives at the position to reach (commanded position) • During speed control, when the speed reference arrives at the commanded speed The motion complete condition is reset when a new motion is started i.e. when the update command – UPD is executed. Remark: In case of steppers controlled open-loop, the motion complete condition for positioning is always set when the position reference arrives at the position to reach independently of the UPGRADE.11 status. Parameters POSOKLIM Specifies the settle band when UPGRADE.11=1. Measured in position units TONPOSOK Specifies the stabilize time UPGRADE.11=1. Measured in time units © ElectroCraft 2013 301 MPD User Manual UPGRADE MPL register. When UPGRADE.11=1, the motion complete is set when commanded/target position is reached and the position error is inside a settle band for a preset stabilize time. When UPGRADE.11=0, the motion complete is set when commanded/target position speed is reached Instructions !MC Set event when the actual position is completed UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units Programming Example 1 //Execute successive position profiles //Position feedback: 500 lines encoder (2000 counts/rev) CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; WAIT!; // set event and wait for motion complete // start here next move Programming Example 2 //Execute successive position profiles // Position feedback: 500 lines encoder (2000 counts/rev) // First move CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD; //start first move © ElectroCraft 2013 302 MPD User Manual // set motion complete parameters POSOKLIM = 20; //Set settle band to 0.01[rot] TONPOSOK = 10; //Set stabilize time to 10[ms] SRB UPGRADE, 0xFFFF, 0x0800; !MC; // set event when motion is complete // Prepare data for second move CPOS = 10000;//new position command = 5[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD!; //execute on event WAIT!;//Wait until the event occurs. When the event // occurs the second move will start See also: Events – Function of motor or load position. Related MPL Instructions and Data Events – Function of motor or load speed. Related MPL Instructions and Data Events – After a wait time. Related MPL Instructions and Data Events – Function of reference. Related MPL Instructions and Data Events – Function of inputs status. Related MPL Instructions and Data Events – Function of 32-bit variable value. Related MPL Instructions and Data Events – MPL Programming Details © ElectroCraft 2013 303 MPD User Manual 6.2.3.2.1.3. Function of motor or load position Setting any of these events allows you to detect when the load or motor absolute or the relative position is equal or over/under a value or the value of a variable. The absolute load or motor position is the measured position of the load or motor. The relative position is the load displacement from the beginning of the actual movement. For example if a position profile was started with the absolute load position 50 revolutions, when the absolute load position reaches 60 revolutions, the relative motor position is 10 revolutions. Remark: The origin for the relative position measurement (MPL variable POS0) is set function of the target update mode. Under TUM1, POS0 = TPOS. Under TUM0, POS0=APOS_LD. Variables POS0 Origin for the relative position measurement for the position events. Measured in position units RPOS Relative load position for the position events. It is computed with formula: RPOS = APOS_LD – POS0. Measured in position units TPOS Target position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units APOS_LD Actual load position. Measured in position units. Alternate name: APOS APOS_MT Actual motor position. Measured in motor position units. Instructions !AMPOvalue32 Set event when motor absolute position is equal or over value32. Value32 is a long integer. Measured in motor position units !AMPOvar32 Set event when motor absolute position is equal or over var32. Var32 is a long integer MPL parameter or variable. Measured in motor position units !ALPOvalue32 Set event when load absolute position is equal or over integer. Measured in position units value32. Value32 is a long !ALPOvar32 Set event when load absolute position is equal or over var32. Var32 is a long integer MPL parameter or variable. Measured in position units !AMPUvalue32 Set event when motor absolute position is equal or under value32. Value32 is a long integer. Measured in motor position units !AMPUvar32 Set event when motor absolute position is equal or under var32. Var32 is a long integer MPL parameter or variable. Measured in motor position units !ALPUvalue32 Set event when load absolute position is equal or under value32. Value32 is a long integer. Measured in position units !ALPUvar32 Set event when load absolute position is equal or under var32. Var32 is a long integer MPL parameter or variable. Measured in position units © ElectroCraft 2013 304 MPD User Manual !RPOvalue32 Set event when load relative position is equal or over value32. Value32 is a long integer. Measured in position units !RPOvar32 Set event when load relative position is equal or over var32. Var32 is a long integer MPL parameter or variable. Measured in position units !RPUvalue32 Set event when load relative position is equal or under value32. Value32 is a long integer. Measured in position units !RPUvar32 Set event when load relative position is equal or under var32. Var32 is a long integer MPL parameter or variable. Measured in position units UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units Programming Example //Stop motion when motor position > 3 rev //Position feedback: 500 lines encoder (2000 counts/rev) !AMPO 6000; //Set event: when motor absolute position is >= 3 rev STOP!;//Stop the motion when the event occurs WAIT!;//Wait until the event occurs See also: Events – When the actual motion is completed. Related MPL Instructions and Data Events – Function of motor or load speed Related MPL Instructions and Data Events – After a wait time Related MPL Instructions and Data Events – Function of reference Related MPL Instructions and Data Events – Function of inputs status Related MPL Instructions and Data Events – Function of 32-bit variable value Related MPL Instructions and Data Events – MPL Programming Details © ElectroCraft 2013 305 MPD User Manual 6.2.3.2.1.4. Function of motor or load speed Setting any of these events allows you to detect when the load or motor speed is equal or over/under a value or the value of a variable. Variables ASPD_LD Actual load speed – measured in speed units APOS_MT Actual motor position. Measured in motor position units. ASPD_MT Actual motor speed. Measured in motor speed units. Alternate name: ASPD Instructions !MSOvalue32 Set event when motor speed is equal or over value32. Value32 is a fixed value. Measured in motor speed units !MSOvar32 Set event when motor speed is equal or over var2. Var32 is a fixed MPL parameter or variable. Measured in motor speed units !LSOvalue32 Set event when load speed is equal or over value32. Value32 is a fixed value. Measured in speed units !LSOvar32 Set event when load speed is equal or over var2. Var32 is a fixed MPL parameter or variable. Measured in speed units !MSUvalue32 Set event when motor speed is equal or under value32. Value32 is a fixed value. Measured in motor speed units !MSUvar32 Set event when motor speed is equal or under var2. Var32 is a fixed MPL parameter or variable. Measured in motor speed units !LSUvalue32 Set event when load speed is equal or under value32. Value32 is a fixed value. Measured in speed units !LSUvar32 Set event when load speed is equal or under var2. Var32 is a fixed MPL parameter or variable. Measured in speed units UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units © ElectroCraft 2013 306 MPD User Manual Programming Example //Motor is decelerating. Start a position profile when motor //speed <= 600 rpm //Position feedback: 500 lines encoder (2000 counts/rev) !MSU 20; //Set event: when motor speed is <= 600 rpm // prepare new motion mode CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD!; //execute on event WAIT!;//Wait until the event occurs See also: Events – When the actual motion is completed. Related MPL Instructions and Data Events – Function of motor or load position Related MPL Instructions and Data Events – After a wait time Related MPL Instructions and Data Events – Function of reference Related MPL Instructions and Data Events – Function of inputs status Related MPL Instructions and Data Events – Function of 32-bit variable value Related MPL Instructions and Data Events – MPL Programming Details 6.2.3.2.1.5. After a wait time Setting this event allows you to introduce a delay in the execution of the MPL program. The monitored event is: when relative time (MPL variable RTIME) is equal or over a value or the value of a variable. The relative time RTIME is computed with formula: RTIME = ATIME – TIME0, where ATIME is a 32-bit absolute time counter, incremented by 1 at each slow loop sampling period and TIME0 is the ATIME value when the wait event was set. After power on, TIME0 is set to 0. RTIME is updated together with ATIME, at each slow loop sampling period. Remark: • ATIME and RTIME start ONLY after the execution of the ENDINIT (end of initialization) command. Therefore you should not set wait events before executing this command • After setting a wait time event, in order to effectively execute the time delay, you need to wait for the event to occur, using WAIT! © ElectroCraft 2013 307 MPD User Manual Variables ATIME Absolute time counter. Incremented at each slow loop sampling period. Starts after execution of ENDINIT command. Measured in time units RTIME Relative time. RTIME = ATIME – TIME0. Measured in time units TIME0 Absolute time when last wait event was set. Measured in time units Instructions !RT value32 Introduce a time delay equal with value32. Value32 is a 32-bit long number. Measured in time units integer !RT var32 Introduce a time delay equal with value of var32. Var32 is a 32-bit long integer MPL variable or parameter. Measured in time units UPD! occurs Update the motion mode and/or the motion parameters when the programmed event STOP! occurs Stop motion with the acceleration/deceleration set in CACC, when the programmed event WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units Programming Example //Introduce a 100 ms delay !RT 100; // set event: After a wait of 100 slow-loop periods // 1 slow-loop period = 1ms WAIT!; // wait the event to occur See also: Events – When the actual motion is completed. Related MPL Instructions and Data Events – Function of motor or load position Related MPL Instructions and Data Events – Function of motor or load speed Related MPL Instructions and Data Events – Function of reference Related MPL Instructions and Data Events – Function of inputs status Related MPL Instructions and Data Events – Function of 32-bit variable value Related MPL Instructions and Data Events – MPL Programming Details © ElectroCraft 2013 308 MPD User Manual 6.2.3.2.1.6. Function of reference Setting any of these events allows you to detect when the position or speed or torque reference is equal or over/under a value or the value of a variable. Use: • Position reference events, only when position control is performed • Speed reference events, only when speed control is performed • Torque reference events, only when torque control is performed Remark: Setting an event based on the position or speed reference is particularly useful for open loop operation where motor position and speed is not available Variables TPOS Target load position – position reference computed by the reference generator at each slow loop sampling period, when position or speed control is performed. Measured in position units TSPD Target load speed – speed reference computed by the reference generator at each slow loop sampling period, when position or speed control is performed. Measured in speed units IQREF Current reference – Measured in current units TREF Target reference. It is a: Position reference, when position control is performed Speed reference, when speed control is performed Current/torque reference, when torque control is performed Voltage reference, when voltage control is performed Function of the control mode, it is measured in position units or speed units or current units or voltage command units Instructions !PROvalue32 Set event if position reference is equal or over value32. Value32 is a long integer value. Measured in position units !PROvar32 Set event if position reference is equal or over var32. Var32 is a long integer MPL parameter or variable. Measured in position units !PRUvalue32 Set event if position reference is equal or under value32. Value32 is a long integer value. Measured in position units !PRUvar32 Set event if position reference is equal or under var32. Var32 is a long integer MPL parameter or variable. Measured in position units !SROvalue32 Set event when speed reference is equal or over value32. Value32 is a fixed value. Measured in speed units !SROvar32 Set event when speed reference is equal or over var32. Var32 is a fixed MPL parameter or variable. Measured in speed units © ElectroCraft 2013 309 MPD User Manual !SRUvalue32 Set event when speed reference is equal or under value32. Value32 is a fixed value. Measured in speed units !SRUvar32 Set event when torque reference is equal or under var32. Var32 is a fixed MPL parameter or variable. Measured in speed units !TROvalue32 Set event when torque reference is equal or over value32. Value32 is a fixed value. Measured in current units !TROvar32 Set event when speed reference is equal or over var32. Var32 is a fixed MPL parameter or variable. Measured in current units !TRUvalue32 Set event when torque reference is equal or under value32. Value32 is a fixed value. Measured in current units !TRUvar32 Set event when speed reference is equal or under var32. Var32 is a fixed MPL parameter or variable. Measured in current units UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units Programming Example // Motor will reach a hard stop. Disable control when torque // reference > 1 A = 1984 internal current units !TRO 1984.0; // set event when torque reference > 1 A WAIT!;//Wait until the event occurs AXISOFF; // disable control See also: Events – When the actual motion is completed. Related MPL Instructions and Data Events – Function of motor or load position Related MPL Instructions and Data Events – Function of motor or load speed Related MPL Instructions and Data Events – After a wait time Related MPL Instructions and Data Events – Function of inputs status Related MPL Instructions and Data Events – Function of 32-bit variable value Related MPL Instructions and Data Events – MPL Programming Details © ElectroCraft 2013 310 MPD User Manual 6.2.3.2.1.7. Function of inputs status Setting any of these events allows you to detect when: • A transition occurs on one of the 2 capture inputs. On these inputs, are usually connected the 1st and 2nd encoder index signals • A transition occurs on one of the 2 limit switch inputs • A general purpose digital input changes its status Capture and limit switch inputs events The capture inputs and the limit switch inputs can be programmed to sense either a low to high or high to low transition. When the programmed transition occurs on either of these inputs, the following happens: • Motor position APOS_MT is captured and memorized in the MPL variable CAPPOS, except the case of open-loop systems, where reference position TPOS is captured instead • Master position APOS2 or load position APOS_LD is captured and memorized in the MPL variable CAPPOS2, except the case of steppers controlled open loop with an encoder on the load, when load position is captured in CAPPOS. The selection between master and load position is done as follows: load position is saved in CAPPOS2 only for the setup configurations which use different sensors for load and motor and foresee a transmission ratio between them. For all the other setup configurations, the master position is saved in CAPPOS2. The master position is automatically computed when pulse and direction signals or quadrature encoder signals are connected to their dedicated inputs. More details about the capture process are presented at Special I/O – MPL Programming Details Remarks: • If both capture inputs are activated in the same time, the capture event is set by the capture input that is triggered first. The capture event makes no difference between the two capture inputs. • If the drive/motor accepts CANopen protocol, the home input is the same with the 2nd encoder index. Therefore, the home input can be programmed like a capture input to sense transitions and to memorize the load and master position when the transition occurs. In order to set an event on a capture input, you need to: 1) Enable the capture input for the detection of a low->high or a high-> low transition, using one of the MPL instructions: ENCAPI0, ENCAPI1, EN2CAPI0, EN2CAPI1 2) Set a capture event, with the MPL instruction: !CAP 3) Wait for the event to occur, with the MPL instruction: WAIT! Remarks: • When the programmed transition is detected, the capture input is automatically disabled. In order to use it again, you need to enable it again for the desired transition • You may also disable a capture input (i.e. its capability to detect a programmed transition) previously enabled, using the MPL commands: DISCAPI, DIS2CAPI In order to set an event on a limit switch input, you need to: 1) Enable the limit switch input for the detection of a low->high or a high-> low transition, using one of the MPL instructions: ENLSP0, ENLSP1, ENLSN0, ENLSNI1 © ElectroCraft 2013 311 MPD User Manual 2) Set a limit switch event with one of the MPL instructions: !LSP, !LSN 3) Wait for the event to occur, with the MPL instruction: WAIT! Remarks: • When the programmed transition is detected, the limit switch input is automatically disabled (for sensing transitions). In order to use it again, you need to enable it again for the desired transition • You may also disable a limit switch input (i.e. its capability to detect a programmed transition) previously enabled, using the MPL commands: DISLSP, DISLSN Variables CAPPOS Position captured when programmed transition occurs on 1st capture/encoder index input. Measured in motor position units, except the case of stepper motors, when it is measured in position units CAPPOS2 Position captured when programmed transition occurs on 2nd capture/encoder index input. Measured in position units when load position is captured, or in master position units when master position is captured APOS2 Master position computed by the slaves from pulse & direction or quadrature encoder inputs. Measured in master position units TPOS Target position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units APOS_LD Actual load position. Measured in position units. Alternate name: APOS APOS_MT Actual motor position. Measured in motor position units. Instructions: !CAP Set event on capture inputs ENCAPI0 Enable 1st capture/encoder index input to detect a high to low transition EN2CAPI0 Enable 2nd capture/encoder index input to detect a high to low transition ENCAPI1 Enable 1st capture/encoder index input to detect a low to high transition EN2CAPI1 Enable 2nd capture/encoder index input to detect a low to high transition !LSN Set event on negative limit switch input !LSP Set event on positive limit switch input ENLSP0 Enable positive limit switch input to detect a high to low transition ENLSN0 Enable negative limit switch input to detect a high to low transition ENLSP1 Enable positive limit switch input to detect a low to high transition ENLSN1 Enable negative limit switch input to detect a low to high transition DISCAPI Disable 1st capture/encoder index input to detect transitions DIS2CAPI Disable 2nd capture/encoder index input to detect transitions © ElectroCraft 2013 312 MPD User Manual DISLSP Disable positive limit switch input to detect transitions DISLSN Disable negative limit switch input to detect transitions UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units Programming Example //Stop motion on next encoder index ENCAPI1; //Set event: When the encoder index goes low->high !CAP; STOP!;//Stop the motion when event occurs WAIT!;//Wait until the event occurs // now load/motor is in deceleration CPOS = CAPPOS; // new command position = captured position CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; WAIT!; //wait for completion General purpose digital inputs events You can program an event on any general-purpose digital input. The event can be set when the input is high (after a low to high transition) or low (after a high to low transition). A general purpose input event is checked at each slow loop sampling period, when the status of the selected input is compared with the one set in the event. A match triggers the event. Instructions !IN#n 1 Set event when the Input #n is high !IN#n 0 Set event when input #n is low UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs © ElectroCraft 2013 313 MPD User Manual WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units Programming Example // Start motion when digital input #36 is high !IN#36 1; // set event when input #36 is high //Position profile. Position feedback: 500-lines encoder CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD!; //execute on event WAIT!;//Wait until the event occurs See also: Events – When the actual motion is completed. Related MPL Instructions and Data Events – Function of motor or load position Related MPL Instructions and Data Events – Function of motor or load speed Related MPL Instructions and Data Events – After a wait time Related MPL Instructions and Data Events – Function of reference Related MPL Instructions and Data Events – Function of 32-bit variable value Related MPL Instructions and Data Events – MPL Programming Details Special I/O – MPL Programming Details © ElectroCraft 2013 314 MPD User Manual 6.2.3.2.1.8. Function of variable value Setting any of these events allows you to detect when a selected variable is equal or over/under a value or the value of a variable. The selected variable can be any 32-bit MPL variable, long or fixed. Instructions !VO var32, value32 Set event when 32-bit MPL parameter or variable var32 is equal or over value32. Value32 is either a long or a fixed, depending on var32 type. !VO var32, var32c Set event when 32-bit MPL parameter or variable var32 is equal or over var32c. Var32c is a 32-bit MPL parameter of variable of the same type like var32. !VU var32, value32 Set event when 32-bit MPL parameter or variable var32 is equal or under value32. Value32 is either a long or a fixed, depending on var32 type. !VU var32, var32c Set event when 32-bit MPL parameter or variable var32 is equal or under var32c. Var32c is a 32-bit MPL parameter of variable of the same type like var32. UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units Programming Example //Wait until master position MREF > 500 counts, then activate //electronic gearing slave mode !VO MREF, 500; //Set event when variable MREF is <= 500 GEAR = 1; // gear ratio GEARMASTER = 1; // Gear ratio denominator GEARSLAVE = 1; // Gear ratio numerator EXTREF 2; // read master from 2nd encoder or pulse & dir MASTERRES = 2000; // master resolution MODE GS; //Set as slave, position mode TUM1; //Set Target Update Mode 1 SRB UPGRADE, 0xFFFF, 0x0004;//UPGRADE.2=1 enables CACC limitation CACC = 0.3183; //Limit maximum acceleration at 1000[rad/s^2] UPD!; //execute on event See also: Events – When the actual motion is completed. Related MPL Instructions and Data Events – Function of motor or load position Related MPL Instructions and Data Events – Function of motor or load speed Related MPL Instructions and Data © ElectroCraft 2013 315 MPD User Manual Events – After a wait time Related MPL Instructions and Data Events – Function of reference Related MPL Instructions and Data Events – Function of inputs status Related MPL Instructions and Data Events – MPL Programming Details 6.2.3.2.2. Jumps and Function Calls The MPL offers the possibility to make unconditional or conditional jumps and calls of functions. The jumps are executed with MPL command GOTO, followed by a jump address. The jump address may be specified with an immediate value, through a label or via 16-bit MPL variable containing it. A label can be any user-defined string of up to 32 characters starting with an alphanumeric character or with underscore. A label starts from the first column of a text line and ends with a colon (:). It contains the MPL program address of the next MPL instruction. Using an assignment instruction of type: user_var = label; you can set a jump address in an integer MPL variable. In a conditional jump, a condition is tested. If the condition is true the jump is executed, else the next MPL command is carried out. The condition is specified by a test variable and a test condition both added after the jump address. The test variable is always compared with zero. The possible test conditions are: < 0, <= 0, >0, >=0, =0, ≠ 0. The calls are executed with MPL command CALL, followed by a MPL function address. A MPL function is a set of MPL commands which starts with a label and ends with the RET instruction. The label gives the MPL function address and name. Like the jump address, the MPL function address may be specified with an immediate value, through a label or via 16-bit MPL variable containing it. In a conditional call, a condition is tested. If the condition is true the MPL function is executed, else the next MPL command is carried out. The condition is specified by a test variable and a test condition added after the MPL function address. The test variable is always compared with zero. The possible test conditions are: < 0, <= 0, >0, >=0, =0, ≠ 0. Using MPL command CALLS, you can do a cancelable call. Use this command if the exit from the called function depends on conditions that may not be reached. In this case, using MPL command ABORT you can terminate the function execution and return to the next instruction after the call. See also: Jumps and Function Calls – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 316 MPD User Manual 6.2.3.2.3. Jumps and Function Calls - Related MPL Instructions and Data Instructions GOTO label Unconditional jump to the address indicated by the label. GOTO value16 Unconditional jump to the address set in value16. Value16 is a 16-bit unsigned integer. GOTO var16 Unconditional jump to the address indicated by var16. Var16 is a 16-bit MPL variable whose value is the jump address GOTO label, var, cond Conditional jump to the address indicated by the label. Var is a 16 or 32-bit MPL variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ GOTO value16, var, cond Conditional jump to the address set in value16. Var is a 16 or 32-bit MPL variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ GOTO var16, var, cond Conditional jump to the address indicated by var16. Var is a 16 or 32-bit MPL variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ CALL label Unconditional call from the address indicated by the function starting label (i.e. function name) CALL value16 Unconditional call from the address set in value16. Value16 is a 16-bit unsigned integer. CALL var16 Unconditional call from the address indicated by var16. Var16 is a 16-bit MPL variable whose value is the MPL function address CALL label, var, cond Conditional call from the address indicated by the function starting label. Var is a 16 or 32-bit MPL variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ CALL value16, var, cond Conditional call from the address set in value16. Var is a 16 or 32-bit MPL variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ CALL var16, var, cond Conditional call from the address indicated by var16. Var is a 16 or 32-bit MPL variable compared with 0. Test condition is: EQ, NEQ, GT, GEQ, LT, LEQ CALLS label Cancelable call from the address indicated by the function starting label. CALLS value16 Cancelable call from the address set in value16. Value16 is a 16-bit unsigned integer. CALLS var16 Cancelable call from the address indicated by var16. Var16 is a 16-bit MPL variable whose value is the MPL function address ABORT Abort the execution of a MPL function called with CALLS RET Return from a MPL function Remarks: • All labels mentioned in the GOTO or CALL instructions must exist i.e. must be defined somewhere in the MPL program. • The label values are assigned after MPL program compilation © ElectroCraft 2013 317 MPD User Manual • When you call a MPL function, the return address pointed by the IP (instruction pointer) is saved into the MPL stack. When RET is executed, the IP is set with the last value from the MPL stack, hence the MPL program execution continues with the next instruction after the call. The MPL stack dimension is 12 words. Each function call and MPL interrupt service routine call uses one word of the MPL stack • The body of the MPL subroutines must be placed outside the main MPL program, for example, after the END instruction. Programming Examples GOTO label1, var1, LT; // jump to label1 if var1 < 0 GOTO label2, var1, LEQ; // jump to label2 if var1 <= 0 GOTO label3, var1, GT; // jump to label3 if var1 > 0 GOTO label4; CALL fct1, var2, GEQ; CALL fct1, var2, EQ; // unconditional jump to label4 // call function fct1, if var2 >= 0 // call function fct1, if var2 = 0 CALL fct1, var2, NEQ; // call function fct1, if var2 != 0 CALL fct1; // unconditional call of function fct1 CALLS fct2; // unconditional cancelable call of fct1 ... END; // end of main program fct1: ... ... RET; fct2: ... ABORT; // abort function, return to next MPL // command after the CALLS RET; See also: Jumps and Function Calls - MPL Programming Details MPL Description © ElectroCraft 2013 318 MPD User Manual 6.2.3.2.4. MPL Interrupts In MPL, you can monitor simultaneously up to 13 conditions. Each condition triggers a MPL interrupt. When a MPL interrupt occurs, the normal MPL program execution is suspended to execute a MPL function associated with the interrupt, called the interrupt service routine (in short ISR). The MPL interrupt mechanism is the following: • The programmable drive continuously monitors 12 conditions that may generate MPL interrupts. The motion controller has an additional condition that triggers the MPL interrupt Int12 when an error on the slaves occurs • When an interrupt condition occurs, a flag (bit) is set in the ISR (Interrupt Status Register) • If the interrupt is enabled e.g. the same bit (as position) is set in the ICR (Interrupt Control Register) and also if the interrupts are globally enabled (EINT instruction was executed), the interrupt condition is qualified and it generates a MPL interrupt • The interrupt causes a jump to the associated interrupt service routine. On entry in this routine, the MPL interrupts are globally disabled (DINT) and the interrupt flag is reset • The interrupt service routine must end with the MPL instruction RETI, which returns to normal program execution and in the same time globally enables the MPL interrupts The 13 monitored conditions are: 1. Int0 – Enable input has changed: either transition of the Enable input sets the interrupt flag 2. Int1 – Short-circuit: when the drive/motor hardware protection for short-circuit is triggered 3. Int2 – Software protections: when any of the following protections is triggered: a. Over current b. I2t motor c. I2t drive d. Over temperature motor e. Over temperature drive f. Over voltage g. Under voltage 4. Int3 – Control error: when the control error protection is triggered 5. Int4 – Communication error: when a communication error occurs 6. Int5 – Wrap around: when the target position computed by the reference generator wraps around because it bypasses the limit of the 32-bit long integer representation 7. Int6 – LSP programmed transition detected: when the programmed transition (low to high or high to low) is detected on the limit switch input for positive direction (LSP) 8. Int7 – LSN programmed transition detected: when the programmed transition (low to high or high to low) is detected on the limit switch input for negative direction (LSN) 9. Int8 – Capture input transition detected: when the programmed transition (low to high or high to low) is detected on the 1st capture / encoder index input or on the 2nd capture / encoder index input © ElectroCraft 2013 319 MPD User Manual 10. Int9 – Motion is completed: in position control, when motion complete condition is set and in speed control when target speed reaches zero. 11. Int10 – Time period has elapsed: periodic time interrupt with a programmable time period set in the MPL parameter TMLINTPER 12. Int11 – Event set has occurred: when last defined event has been occurred 13. Int12 – Error on slave occurred: when a slave reports an error. The interrupt service routines (ISR) of the MPL interrupts are similar with the MPL functions: the starting point is a label and the ending point is the MPL instruction RETI (return from interrupt). When a MPL interrupt occurs, the MPL instruction pointer (IP) jumps to the start address of the associated ISR. This information is read from an interrupt table, which contains the values of the starting labels for all the ISR. The beginning of the interrupt table is pointed by the MPL parameter INTTABLE. Like the MPL functions, the interrupt table and the interrupt service routines must be positioned outside the main section of the MPL program (see the programming example below). At power-on, each drive/motor starts with a built-in interrupt table and a set of default ISR. The MPL interrupts are globally enabled together with the first 4 interrupts: Int 0 to Int 3. For Int 2, all the protections are activated, except over temperature motor, which depends on the presence or not of a temperature sensor on the motor; hence this protection may or may not be activated. For each of these 4 interrupts there is a default ISR which is executed when the corresponding interrupt occurs. Remark: A basic description of these defaults ISR is presented below. Their exact content is product dependent and can be seen using MPL development platforms like MotionPRO Developer which include the possibility to view and/or modify the contents of the default ISR for each type of drive/motor. If you intend to enable other MPL interrupts or to modify the default ISR for the first 4 MPL interrupts, you need to create another MPL interrupt table which will point towards your own ISR. In this new interrupt table, put the starting labels for your ISR and use the global symbols: default_intx (x=0 to 11) as labels for those ISR you don’t want to change. These global symbols contain the start addresses of the default ISR. Remark: Some of the drive/motor protections may not work properly if the MPL Interrupts are handled incorrectly. In order to avoid this situation keep in mind the following rules: • The MPL interrupts must be kept globally enabled to allow execution of the ISR for those MPL interrupts triggered by protections. As during a MPL interrupt execution, the MPL interrupts are globally disabled, you should keep the ISR as short as possible, without waiting loops. If this is not possible, you must globally enable the interrupts with EINT command during your ISR execution. • If you modify the interrupt service routines for Int 0 to Int 4, make sure that you keep the original MPL commands from the default ISR. Put in other words, you may add your own commands, but these should not interfere with the original MPL commands. Moreover, the original MPL commands must be present in all the ISR execution paths. The interrupt flags are set independently of the activation or not of the MPL interrupts. Therefore, as a general rule, before enabling an interrupt, reset the corresponding flag. This operation will avoid triggering an interrupt immediately after activation, due to an interrupt flag set in the past. To summarize, in order to work with a MPL interrupt, you need to: • Edit your own ISR or decide to use the default ISR. • Create your own interrupt table, and set the MPL parameter INTTABLE equal with your interrupt table start address. Exception: if you use only default ISR • Reset the interrupt flag to avoid entering in an interrupt due to a flag set in the past © ElectroCraft 2013 320 MPD User Manual • Enable the MPL interrupt. As the MPL interrupts must be globally enabled, the MPL interrupt is now activated and your ISR will execute when the interrupt flag will be set. Default ISR Description ISR for Int0 – Enable input has changed: When enable input goes from disable to enable status, executes AXISON if ACR.1 = 1 (i.e. the drive/motor is set to start automatically after power-on with an external reference) or if ACR.3 = 1 (i.e. specific request to execute AXISON at recover from disable status). Before executing AXISON, if the drive/motor is set in electronic gearing slave mode, the motion mode is set again (followed by an update command – UPD) to force a re-initialization for smooth recoupling with the master. ISR for Int1 – Short-circuit: Set Ready output (if present) to not ready status and turn off the green led (if present). Set Error output (if present) to error status and turn on the red led (if present). Execute AXISOFF and set SRL.3 =1 to set the drive/motor into the FAULT condition. ISR for Int2 – Software protections: Same as ISR for Int1 ISR for Int3 – Control error: Same as ISR for Int1 See also: MPL Interrupts – Related MPL Instructions and Data MPL Description 6.2.3.2.5. MPL Interrupts - Related MPL Instructions and Data Parameters INTTABLE Pointer to the start address of the interrupt table TMLINTPER Time period for the periodic time interrupt Int10. Measured in time_units Instructions EINT Globally enables the MPL interrupts. Sets ICR.15 = 1 DINT Globally disables the MPL interrupts. Sets ICR.15 = 0 SRB ICR, ANDm, ORm Individually enable/disable MPL interrupts, by setting/resetting bits from ICR register according with AND mask ANDm and OR mask ORm SRB ISR, ANDm, 0; Reset interrupt flags in the ISR register according with AND mask ANDm RETI Return from a MPL interrupt service routine Programming Example Set MPL Int10 to generate a time interrupt at each 0.5s. In the ISR, switch the status of output #25/Ready to signal that the drive/motor is in standby. Leave the other MPL interrupts with their default ISR. BEGIN; // MPL program start INTTABLE = InterruptTable; ENDINIT; // set start address for the new interrupt table // end of initialization ... © ElectroCraft 2013 321 MPD User Manual int Ready_status; // Define integer variable Ready_status Ready_status = 0; // initialize Ready_status TMLINTPER = 500; //Set a time interrupt at every 0.5[s] SRB ICR, 0x8FFF, 0x0400; // Set ICR.10 to enable Int10 ... END; InterruptTable: // end of the main section // start of the interrupt table @default_int0; @default_int1; @default_int2; @default_int3; @default_int4; @default_int5; @default_int6; @default_int7; @default_int8; @default_int9; @int10; @default_int11; int10: GOTO Turn_on, Ready_status, EQ; // Branch to Turn_on if Ready_status == 0 SOUT#25; //Set Low to I/O line #25 Ready_status = 0; // set Ready_status = 0 RETI; // return from interrupt Turn_on: //Define label Turn_on ROUT#25; //Set High to I/O line #25 Ready_status = 1; // set Ready_status = 1 RETI; See also: MPL Interrupts – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 322 MPD User Manual 6.2.3.3. I/O Programming 6.2.3.3.1. General I/O (Firmware FAxx) In MPL you can access up to 40 digital I/O lines, numbered: #0 to #39. Each programmable drive/motor has a specific number of inputs and outputs, therefore only a part of the 40 I/Os is used. The I/O numbering is common for all the products; hence each product has its own list of available I/Os. This is not an ordered list. For example, a product with 4 inputs and 4 outputs can use the inputs: #36, #37, #38 and #39 and the outputs #28, #29, #30 and #31. Remark: Read carefully the drive/motor user manual to find which I/O lines are available. Do not attempt to use the other I/Os. This may harm your drive/motor. Some drives/motors include I/O lines that may be used either as inputs or as outputs. In these cases, the same I/O number occurs both in the list of available inputs and in the list of available outputs. Before using these lines, you need to specify how you want to use them, with the MPL commands: SETIO#n OUT; //Set the I/O line #n as an output SETIO#n IN; //Set the I/O line #n as an input Remarks: • Check the drive/motor user manual to find how are set, after power-on, the I/O lines that may be used either as inputs or as outputs • You need to set an I/O line as input or output, only once, after power on You can read and save the status of an input with the MPL command: user_var = IN#n; // read input #n in the user variable user_var where user_var is a 16-bit integer variable and n is the input number. If the input line is low (0 logic), user_var is set to 0, else user_var is set to a non-zero value. You can set an output high (1 logic) or low (0 logic) with the following commands: ROUT#n; // Set low the output line #n SOUT#n; // Set high the output line #n Remark: Check the drive/motor user manual to find if the I/O lines you are using are passed directly or are inverted inside the drive/motor. If an I/O line is inverted, you need to switch high with low in the examples above, which refer to the I/O line status at the drive/motor connector level. Using MPL command: user_var = INPORT, 0xE00F; // read inputs in variable user_var you can read simultaneously and save in a 16-bit integer variable the status of the following inputs: • Enable input (#16/ENABLE) – saved in bit 15 • Limit switch input for negative direction (#24/LSN) - saved in bit 14 • Limit switch input for positive direction (#2/LSP) - saved in bit 13 • General-purpose inputs #39, #38, #37 and #36 – save din bits 3, 2, 1 and 0 The bits corresponding to these inputs are set as follows: 0 if the input is low and 1 if the input is high. The other bits of the variable are set to 0. © ElectroCraft 2013 323 MPD User Manual Remark: Each drive/motor contains in the MPL parameter DIGIN_INVERSION_MASK an inversion mask for these inputs. A bit set to 1 in this mask, means that the corresponding input is inverted. The value set in user_var is obtained after a logical XOR between the inputs status and the inversion mask. As result, the bits in user_var always show correctly the inputs status at connectors level (0 if the input is low and 1 if the input is high) even when the inputs are inverted. Using MPL command: OUTPORT user_var; // Send variable user_var to external output port you can set simultaneously with the command value specified by a 16-bit integer variable, the following outputs: • Ready output (#25/READY) – set by bit 15 • Error output (#12/ERROR) – set by bit 14 • General-purpose outputs: #31, #30, #29, #28 – set by bits 3, 2, 1, and 0 The outputs are set as follows: low if the corresponding bit in the variable is 0 and high if the corresponding bit in the variable is 1. The other bits of the variable are not used. Remark: Each drive/motor contains in the MPL parameter DIGOUT_INVERSION_MASK an inversion mask for these outputs. A bit set to 1 in this mask, means that the corresponding output is inverted. The commands effectively sent to the outputs are obtained after a logical XOR between the user_var value and the inversion mask. As result, the outputs at connectors level always correspond to the user_var command values (low if the bit is 0 and high if the bit is 1), even when the outputs are inverted. General-purpose I/O – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 324 MPD User Manual 6.2.3.3.2. General I/O (Firmware FAxx) - Related MPL Instructions and Data Parameters DIGIN_INVERSION_MASK Inversion mask for the following digital inputs: • Enable input (#16/ENABLE) – bit 15 • Limit switch input for negative direction (#24/LSN) - bit 14 • Limit switch input for positive direction (#2/LSP) - bit 13 • General-purpose inputs #39, #38, #37 and #36 – bits 3, 2, 1 and 0 A bit set signals that the corresponding input is inverted. The MPL variable INSTATUS as well as the MPL command INPORT are considering this inversion mask to switch the status of inverted inputs. As result, in INSTATUS and in the MPL variable set by INPORT, the above bits always show correctly the inputs status at connectors level (0 if the input is low and 1 if the input is high) even when the inputs are inverted DIGOUT_INVERSION_MASK Inversion mask for the following digital outputs: • Ready output (#25/READY) – set by bit 15 • Error output (#12/ERROR) – set by bit 14 • General-purpose outputs: #31, #30, #29, #28 – set by bits 3, 2, 1, and 0 A bit set signals that the corresponding output is inverted. The MPL command OUTPORT uses this inversion mask to switch the command for the inverted outputs. As result, the outputs at connectors level are always set as specified by the above bits in the MPL variable of the OUTPORT command (low if the bit is 0 and high if the bit is 1), even when the outputs are inverted. Variables INSTATUS Provides status of the following digital inputs: • Enable input (#16/ENABLE) – in bit 15 • Limit switch input for negative direction (#24/LSN) - in bit 14 • Limit switch input for positive direction (#2/LSP) - in bit 13 • General-purpose inputs #39, #38, #37 and #36 – in bits 3, 2, 1 and 0 The above bits are set to 0 if the input is low (at connectors level) and 1 if the input is high (at connectors level). The information is automatically corrected in the case of inverted inputs. The other bits INSTATUS have no significance. Instructions user_var = IN#n Read input #n in the user variable user_var OUTPORTvalue16 Set simultaneously the output lines as specified by value16 ROUT#n Set low the output line #n SOUT#n Set high the output line #n SETIO#n OUT; Set the I/O line #n as an input © ElectroCraft 2013 325 MPD User Manual SETIO #n IN; Set the I/O line #n as an output Programming Example user_var = IN#36; // read input #36 in user_var GOTO label1, user_var, NEQ; // go to label1 if input #36 is 1 // input #36 is 0 user_var = IN#39; // read input #39 in user_var GOTO label2, user_var, EQ; // go to label2 if input #39 is 0 // input #39 is 1 ... Label1: // input #36 is 1 ... Label2: // input #39 is 0 ... See also: General-purpose I/O – MPL Programming Details MPL Description © ElectroCraft 2013 326 MPD User Manual 6.2.3.3.3. Special I/O (Firmware FAxx) In MPL, there are 5 inputs and 2 outputs that have dedicated functions. These are: • Enable input: #16/ENABLE • 2 limit switch inputs: #2/LSP and #24/LSN • 2 capture inputs: #5/CAPI and #34/2CAPI • Ready output: #25/READY • Error output: #12/ERROR Remark: On some drives/motors only a part if these special I/O is available. When present, the capture and limit switch inputs and always connected to the same I/O numbers. However, the Enable input as well as the Ready and Error outputs may be assigned to other I/O lines. Their I/O number allocation is specific for each product. The enable input is a safety input, and can be: active or inactive. On the active level, it enables normal operation. On the inactive level it disables the drive/motor similarly with the AXISOFF command. When the enable input goes from inactive to active level and AXISON command is automatically performed if ACR.1 = 1 or ACR.3 = 1. The active level is programmable: low or high via MPL parameter DIGIN_ACTIVE_LEVEL as follows: • If DIGIN_ACTIVE_LEVEL.15 = 1, #16/ENABLE is active when the input is high • If DIGIN_ACTIVE_LEVEL.15 = 0, #16/ENABLE is active when the input is low Remark: The enable input high/low refers to the input level at drive/motor connector. After power on, the active level is set to enable normal operation with nothing connected on the input The limit switch inputs main goal is to protect against accidental moves outside a defined working area. The protection involves connecting limit switches to: • #2/LSP to stop movement in positive direction • #24/LSN to stop movement in negative direction A limit switch input can be: active or inactive. The active level is programmable: low or high via MPL parameter DIGIN_ACTIVE_LEVEL as follows: • If DIGIN_ACTIVE_LEVEL.14 = 1, #24/LSN is active when the input is high • If DIGIN_ACTIVE_LEVEL.14 = 0, #24/LSN is active when the input is low • If DIGIN_ACTIVE_LEVEL.13 = 1, #2/LSP is active when the input is high • If DIGIN_ACTIVE_LEVEL.13 = 0, #2/LSP is active when the input is low Remark: The limit switch inputs high/low refers to the inputs level at drive/motor connector. After power on, the active level is set to have both limit switches inactive with nothing connected on these inputs When positive limit switch #2/LSP input is active, movement is possible only in the negative direction. Any attempt to move in the positive direction will set the drive/motor in quick stop mode, and this will stop the move with the deceleration rate set in MPL parameters CDEC. When negative limit switch #24/LSN input is active, movement is possible only in the positive direction. Any attempt to move in the negative direction will set the drive/motor in quick stop mode, and this will stop the move with the deceleration rate set in MPL parameters CDEC. © ElectroCraft 2013 327 MPD User Manual Remark: The drive/motor exits from quick stop mode only by setting a new motion mode. The limit switch inputs may also be used as capture inputs due to their capability to sense low to high or high to low transitions and to capture the motor, load or master position when these transitions occur. The limit switch inputs capturing behavior is identical with that of the capture inputs #5/CAPI and #34/2CAPI and therefore is presented below together with the capture inputs. You can set either an event or a MPL interrupt, for each limit switch input, to detect when a programmed transition has occurred. In both cases you need to: 1. Enable limit switch input capability to detect a low->high or a high-> low transition with one of the following MPL instructions: ENLSP0; //Enable #2/LSP to detect a high->low transition ENLSP1; //Enable #2/LSP to detect a low->high transition ENLSN0; //Enable #24/LSN to detect a high->low transition ENLSN1; //Enable #24/LSN to detect a low->high transition 2. Set: • A limit switch event with !LSP or !LSN, then wait until the event occurs with WAIT!;, or • Enable the LSP or LSN MPL interrupt with the MPL commands: SRB ICR 0xFFFF,0x0040;// Set ICR.6 = 1 to enable LSP interrupt SRB ICR 0xFFFF,0x0080;// Set ICR.7 = 1 to enable LSN interrupt Remarks: • The main task of the limit switches i.e. to protect against accidental moves outside the working area is performed independently of the fact that limit switches may be enabled or not to detect transitions • A limit switch input capability to detect transitions is automatically disabled, after the programmed transition was detected. In order to reuse it, you need to enable it again. • You may also disable a limit switch input capability to detect transitions, using the MPL commands: DISLSP, DISLSN You can also use the limit switch inputs as general-purpose inputs by disabling their capability to protect against accidental moves outside a defined working area. For this you need to set MPL parameter LSACTIVE = 1. This command, doesn’t affect the limit switch inputs capability to detect transitions. Remark: After power on, LSACTIVE = 0 and the limit switches are active. You can read the limit switches inputs, at any moment, independently of LSACTIVE value, like any other inputs using the MPL instructions: var = IN#2; // read status of the positive limit switch input var = IN#24; // read status of the negative limit switch input The capture inputs are special inputs that can be programmed to sense either a low to high or high to low transition and capture the motor, load or master position with very high accuracy when these transitions occur. Typically, the 1st encoder index is connected to the 1st capture input – #5/CAPI, and the 2nd encoder index is connected to the 2nd capture input – #34/2CAPI. © ElectroCraft 2013 328 MPD User Manual When an incremental encoder provides the motor position, its signals are always connected to the 1st encoder interface. When an incremental encoder provides the master position, its signals are always connected to the 2nd encoder interface. When an incremental encoder provides the load position, its signals are connected to: • 2nd encoder interface, if there is another sensor on the motor (for example DC motor with encoder on load and tachometer on the motor) • 1st encoder interface, if there is no other sensor on the motor (for example steppers controlled open-loop with an encoder on the load) When the programmed transition occurs on any capture or limit switch input, the following happens: • Motor position APOS_MT is captured and memorized in the MPL variable CAPPOS, except the case of open-loop systems, where reference position TPOS is captured instead • Master position APOS2 or load position APOS_LD is captured and memorized in the MPL variable CAPPOS2, except the case of steppers controlled open loop with an encoder on the load, when load position is captured in CAPPOS. The selection between master and load position is done as follows: load position is saved in CAPPOS2 only for the setup configurations which use different sensors for load and motor and foresee a transmission ratio between them. For all the other setup configurations, the master position is saved in CAPPOS2. The master position is automatically computed when pulse and direction signals or quadrature encoder signals are connected to their dedicated inputs. When an incremental encoder is connected to the 1st encoder interface and 1st capture/encoder index detects the programmed transition, the position captured in CAPPOS is very accurate, being read in less than 200 ns after the input transition. The position captured in CAPPOS2 is also accurate being read with a maximum delay of 5μs. When an incremental encoder is connected to the 2nd encoder interface or when master position is set via pulse & direction signals and 2nd capture/encoder index detects the programmed transition, the position captured in CAPPOS2 is very accurate, being read in less than 200 ns, after the input transition. The position captured in CAPPOS2 is read with a maximum delay of 5μs. When any of the 2 limit switch inputs detects the programmed transition, the positions captured in CAPPOS and CAPPOS2 are accurate, both being read with a maximum delay of 5μs. You can set either an event or a MPL interrupt on a capture input. In both cases you need to: 1. Enable the capture input for the detection of a low->high or a high-> low transition with one of the following MPL instructions: ENCAPI0; //Enable #5/CAPI to detect a high->low transition ENCAPI1; //Enable #5/CAPI to detect a low->high transition EN2CAPI0; //Enable #34/2CAPI to detect a high->low transition EN2CAPI1; //Enable #34/2CAPI to detect a low->high transition 2. Set: • A capture event with !CAP, then wait until the event occurs with WAIT!;, or • Enable the MPL capture interrupt with the MPL command: SRB ICR 0xFFFF,0x0100; //Set ICR.8 = 1 Remarks: © ElectroCraft 2013 329 MPD User Manual • If both capture inputs are activated in the same time, the capture event and the MPL capture interrupt flag is set by the capture input that is triggered first. The capture event or the MPL capture interrupt makes no difference between the two capture inputs. • When the programmed transition is detected, the capture input is automatically disabled. In order to reuse it, you need to enable it again for the desired transition • You may also disable a capture input (i.e. its capability to detect a programmed transition) previously enabled, using the MPL commands: DISCAPI, DIS2CAPI See also: Special I/O – Related MPL Instructions and Data MPL Description 6.2.3.3.4. Special I/O (Firmware FAxx) - Related MPL Instructions and Data Parameters DIGIN_ACTIVE_LEVEL Sets active levels for enable and limit switch inputs as follows: • Enable input (#16/ENABLE) – bit 15: 0 – low, 1 – high • Limit switch input for negative direction (#24/LSN) - on bit 14: 0 – low, 1 – high • Limit switch input for positive direction (#2/LSP) - on bit 13: 0 – low, 1 – high LSACTIVE When set to a non-zero value, disables limit switch inputs capability to protect against accidental moves outside a defined working area. In this case, the limit switch inputs are treated like 2 extra general-purpose inputs CDEC Command deceleration for quick stop mode. Measured in acceleration units ICR Interrupt Control Register. The MPL interrupts can be enabled or disabled by setting or resetting the corresponding bits from this register ACR Auxiliary Control Register. If ACR.1 = 1 the drive/motor is set to start automatically after power-on with an external reference. If ACR.3 = 1 there is a specific request to execute AXISON at recover from disable status. In both cases, an AXISON is executed when enable input goes from inactive to active status. Variables CAPPOS Position captured when programmed transition occurs on 1st capture/encoder index input. Measured in motor position units, except the case of stepper motors, when it is measured in position units CAPPOS2 Position captured when programmed transition occurs on 2nd capture/encoder index input. Measured in position units when load position is captured, or in master position units when master position is captured APOS2 Master position computed by the slaves from pulse & direction or quadrature encoder inputs. Measured in master position units © ElectroCraft 2013 330 MPD User Manual TPOS Target position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units APOS_LD Actual load position. Measured in position units. Alternate name: APOS APOS_MT Actual motor position. Measured in motor position units. Instructions !CAP Set event on capture inputs ENCAPI0 Enable 1st capture/encoder index input to detect a high to low transition EN2CAPI0 Enable 2nd capture/encoder index input to detect a high to low transition ENCAPI1 Enable 1st capture/encoder index input to detect a low to high transition EN2CAPI1 Enable 2nd capture/encoder index input to detect a low to high transition !LSN Set event on negative limit switch input !LSP Set event on positive limit switch input ENLSP0 Enable positive limit switch input to detect a high to low transition ENLSN0 Enable negative limit switch input to detect a high to low transition ENLSP1 Enable positive limit switch input to detect a low to high transition ENLSN1 Enable negative limit switch input to detect a low to high transition DISCAPI Disable 1st capture/encoder index input to detect transitions DIS2CAPI Disable 2nd capture/encoder index input to detect transitions DISLSP Disable positive limit switch input to detect transitions DISLSN Disable negative limit switch input to detect transitions UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units SRB Set/reset bits from a MPL data © ElectroCraft 2013 331 MPD User Manual Programming Example //Stop motion on next encoder index ENCAPI1; //Set event: When the encoder index goes low->high !CAP; STOP!;//Stop the motion when event occurs WAIT!;//Wait until the event occurs CPOS = CAPPOS; // new command position = captured position CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; WAIT!; //wait for completion See also: Special I/O – MPL Programming Details MPL Description 6.2.3.3.5. General-purpose I/O (Firmware FBxx) In MPL you can access up to 16 digital input and 16 digital output lines, numbered: 0 to 15. Each programmable drive/motor has a specific number of inputs and outputs, therefore only a part of the 16 inputs or 16 outputs is used. The I/O numbering is common for all the products; hence each product has its own list of available I/Os. This is an ordered list. For example, a product with 4 inputs and 4 outputs can use the inputs: 0, 1, 2 and 3 and the outputs 0, 1, 2 and 3. Remark: Read carefully the drive/motor user manual to find which I/O lines are available. Do not attempt to use the other I/Os. This may harm your drive/motor. Some drives/motors include I/O lines that may be used either as inputs or as outputs. Before using these lines, you need to specify how you want to use them, with the MPL commands: SetAsInput(n); //Set the IO line n as an input SetAsOutput(n); //Set the IO line n as an output Remarks: • Check the drive/motor user manual to find how are set, after power-on, the I/O lines that may be used either as inputs or as outputs • You need to set an I/O line as input or output, only once, after power on You can read and save the status of an input with the MPL command: user_var = IN(n); //Read IO line n data into variable user_var where user_var is a 16-bit integer variable and n is the input number. If the input line is low (0 logic), user_var is set to 0, else user_var is set to a non-zero value. © ElectroCraft 2013 332 MPD User Manual You can set an output high (1 logic) or low (0 logic) with the following commands: OUT(n)=value16; // corresponding bit from value16 Set IO line n according with its Remark: Check the drive/motor user manual to find if the I/O lines you are using are passed directly or are inverted inside the drive/motor. If an I/O line is inverted, you need to switch high with low in the examples above, which refer to the I/O line status at the drive/motor connector level. Using MPL command: user_var = IN(n1,n2,n3,…); // Set corresponding bits from a according with selected inputs status you can read simultaneously and save in a 16-bit integer variable the status of the selected inputs. The bits corresponding to these inputs are set as follows: 0 if the input is low and 1 if the input is high. The other bits of the variable are set to 0. Remark: Each drive/motor contains in the MPL parameter DIGIN_INVERSION_MASK an inversion mask for these inputs. A bit set to 1 in this mask, means that the corresponding input is inverted. The value set in user_var is obtained after a logical XOR between the inputs status and the inversion mask. As result, the bits in user_var always show correctly the inputs status at connectors level (0 if the input is low and 1 if the input is high) even when the inputs are inverted. Using MPL command: OUT(n1, n2, n3,…) = value16; // with corresponding bits from value16 Set outputs n1, n2, n3, … according you can set simultaneously with the command value specified by a 16-bit integer variable, the selected outputs. The outputs are set as follows: low if the corresponding bit in the variable is 0 and high if the corresponding bit in the variable is 1. The other bits of the variable are not used. Remark: Each drive/motor contains in the MPL parameter DIGOUT_INVERSION_MASK an inversion mask for these outputs. A bit set to 1 in this mask, means that the corresponding output is inverted. The commands effectively sent to the outputs are obtained after a logical XOR between the immediate or user_var value and the inversion mask. As result, the outputs at connectors level always correspond to the immediate or user_var command values (low if the bit is 0 and high if the bit is 1), even when the outputs are inverted. General-purpose I/O – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 333 MPD User Manual 6.2.3.3.6. General-purpose I/O – Related MPL Instructions and Data (Firmware FBxx) Variables INSTATUS Provides status of the following digital inputs: The above bits are set to 0 if the input is low (at connectors level) and 1 if the input is high (at connectors level). The information is automatically corrected in the case of inverted inputs. The other bits INSTATUS have no significance. Instructions user_var = IN(n) Read input n in the user variable user_var user_var = IN(n1, n2, n3, …) Read inputs n1, n2, n3,… in the user variable user_var OUT(n) =value16 Set the output line as specified by value16 OUT(n1, n2, n3, …) =value16 Set the output lines n1 n2, n3 as specified by value16 SetAsInput(n); Set the I/O line #n as an input SetAsOutput(n); Set the I/O line #n as an output Programming Example user_var = IN#36; // read input #36 in user_var GOTO label1, user_var, NEQ; // go to label1 if input #36 is 1 // input #36 is 0 user_var = IN#39; // read input #39 in user_var GOTO label2, user_var, EQ; // go to label2 if input #39 is 0 // input #39 is 1 ... Label1: // input #36 is 1 ... Label2: // input #39 is 0 ... See also: General-purpose I/O – MPL Programming Details MPL Description © ElectroCraft 2013 334 MPD User Manual 6.2.3.3.7. Special I/O - MPL Programming Details (Firmware FBxx) In MPL, there are 5 inputs and 2 outputs that have dedicated functions. These are: • Enable input • 2 limit switch inputs • 2 capture inputs • Ready output • Error output Remark: On some drives/motors only a part if these special I/O is available. When present, the capture and limit switch inputs and always connected to the same I/O numbers. However, the Enable input as well as the Ready and Error outputs may be assigned to other I/O lines. Their I/O number allocation is specific for each product. The enable input is a safety input, and can be: active or inactive. On the active level, it enables normal operation. On the inactive level it disables the drive/motor similarly with the AXISOFF command. When the enable input goes from inactive to active level and AXISON command is automatically performed if ACR.1 = 1 or ACR.3 = 1. The active level is programmable: low or high via MPL parameter DIGIN_ACTIVE_LEVEL as follows: • If DIGIN_ACTIVE_LEVEL.15 = 1, Enable is active when the input is high • If DIGIN_ACTIVE_LEVEL.15 = 0, Enable is active when the input is low Remark: The enable input high/low refers to the input level at drive/motor connector. After power on, the active level is set to enable normal operation with nothing connected on the input The limit switch inputs main goal is to protect against accidental moves outside a defined working area. The protection involves connecting limit switches to: • LSP input to stop movement in positive direction • LSN input to stop movement in negative direction A limit switch input can be: active or inactive. The active level is programmable: low or high via MPL parameter DIGIN_ACTIVE_LEVEL as follows: • If DIGIN_ACTIVE_LEVEL.14 = 1, Limit Switch Negative is active when the input is high • If DIGIN_ACTIVE_LEVEL.14 = 0, Limit Switch Negative is active when the input is low • If DIGIN_ACTIVE_LEVEL.13 = 1, Limit Switch Positive is active when the input is high • If DIGIN_ACTIVE_LEVEL.13 = 1, Limit Switch Positive is active when the input is low Remark: The limit switch inputs high/low refers to the inputs level at drive/motor connector. After power on, the active level is set to have both limit switches inactive with nothing connected on these inputs When positive limit switch input is active, movement is possible only in the negative direction. Any attempt to move in the positive direction will set the drive/motor in quick stop mode, and this will stop the move with the deceleration rate set in MPL parameters CDEC. When negative limit switch input is active, movement is possible only in the positive direction. Any attempt to move in the negative direction will set the drive/motor in quick stop mode, and this will stop the move with the deceleration rate set in MPL parameters CDEC. © ElectroCraft 2013 335 MPD User Manual Remark: The drive/motor exits from quick stop mode only by setting a new motion mode. The limit switch inputs may also be used as capture inputs due to their capability to sense low to high or high to low transitions and to capture the motor, load or master position when these transitions occur. The limit switch inputs capturing behavior is identical with that of the capture inputs and therefore is presented below together with the capture inputs. You can set either an event or a MPL interrupt, for each limit switch input, to detect when a programmed transition has occurred. In both cases you need to: 1. Enable limit switch input capability to detect a low->high or a high-> low transition with one of the following MPL instructions: ENLSP0; transition //Enable Positive Limit Switch to detect a high->low ENLSP1; transition //Enable Positive Limit Switch to detect a low->high ENLSN0; transition //Enable Negative Limit Switch to detect a high->low ENLSN1; transition //Enable Negative Limit Switch to detect a low->high 2. Set: • A limit switch event with !LSP or !LSN, then wait until the event occurs with WAIT!;, or • Enable the LSP or LSN MPL interrupt with the MPL commands: SRB ICR 0xFFFF,0x0040; //Set/Reset Bits of Interrupt Control Register SRB ICR 0xFFFF,0x0080; //Set/Reset Bits of Interrupt Control Register Remarks: • The main task of the limit switches i.e. to protect against accidental moves outside the working area is performed independently of the fact that limit switches may be enabled or not to detect transitions • A limit switch input capability to detect transitions is automatically disabled, after the programmed transition was detected. In order to reuse it, you need to enable it again. • You may also disable a limit switch input capability to detect transitions, using the MPL commands: DISLSP, DISLSN You can also use the limit switch inputs as general-purpose inputs by disabling their capability to protect against accidental moves outside a defined working area. For this you need to set MPL parameter LSACTIVE = 1. This command, doesn’t affect the limit switch inputs capability to detect transitions. Remark: After power on, LSACTIVE = 0 and the limit switches are active. You can read the limit switches inputs, at any moment, independently of LSACTIVE value, like any other inputs using the MPL instructions: var = IN#2; // read status of the positive limit switch input var = IN#24; // read status of the negative limit switch input The capture inputs are special inputs that can be programmed to sense either a low to high or high to low transition and capture the motor, load or master position with very high accuracy when these transitions occur. © ElectroCraft 2013 336 MPD User Manual Typically, the 1st encoder index is connected to the 1st capture input – #5/CAPI, and the 2nd encoder index is connected to the 2nd capture input – #34/2CAPI. When an incremental encoder provides the motor position, its signals are always connected to the 1st encoder interface. When an incremental encoder provides the master position, its signals are always connected to the 2nd encoder interface. When an incremental encoder provides the load position, its signals are connected to: • 2nd encoder interface, if there is another sensor on the motor (for example DC motor with encoder on load and tachometer on the motor) • 1st encoder interface, if there is no other sensor on the motor (for example steppers controlled open-loop with an encoder on the load) When the programmed transition occurs on any capture or limit switch input, the following happens: • Motor position APOS_MT is captured and memorized in the MPL variable CAPPOS, except the case of open-loop systems, where reference position TPOS is captured instead • Master position APOS2 or load position APOS_LD is captured and memorized in the MPL variable CAPPOS2, except the case of steppers controlled open loop with an encoder on the load, when load position is captured in CAPPOS. The selection between master and load position is done as follows: load position is saved in CAPPOS2 only for the setup configurations which use different sensors for load and motor and foresee a transmission ratio between them. For all the other setup configurations, the master position is saved in CAPPOS2. The master position is automatically computed when pulse and direction signals or quadrature encoder signals are connected to their dedicated inputs. When an incremental encoder is connected to the 1st encoder interface and 1st capture/encoder index detects the programmed transition, the position captured in CAPPOS is very accurate, being read in less than 200 ns after the input transition. The position captured in CAPPOS2 is also accurate being read with a maximum delay of 5μs. When an incremental encoder is connected to the 2nd encoder interface or when master position is set via pulse & direction signals and 2nd capture/encoder index detects the programmed transition, the position captured in CAPPOS2 is very accurate, being read in less than 200 ns, after the input transition. The position captured in CAPPOS2 is read with a maximum delay of 5μs. When any of the 2 limit switch inputs detects the programmed transition, the positions captured in CAPPOS and CAPPOS2 are accurate, both being read with a maximum delay of 5μs. You can set either an event or a MPL interrupt on a capture input. In both cases you need to: 1. Enable the capture input for the detection of a low->high or a high-> low transition with one of the following MPL instructions: ENCAPI0; //Activate CAPI input to trigger a rising transitions ENCAPI1; //Activate CAPI input to trigger a falling transitions EN2CAPI0; //Activate CAPI input to trigger a rising transitions EN2CAPI1; //Activate CAPI input to trigger a falling transitions 2. Set: • A capture event with !CAP, then wait until the event occurs with WAIT!;, or • Enable the MPL capture interrupt with the MPL command: SRB ICR 0xFFFF,0x0100; //Set/Reset Bits of Interrupt Control Register © ElectroCraft 2013 337 MPD User Manual Remarks: • If both capture inputs are activated in the same time, the capture event and the MPL capture interrupt flag is set by the capture input that is triggered first. The capture event or the MPL capture interrupt makes no difference between the two capture inputs. • When the programmed transition is detected, the capture input is automatically disabled. In order to reuse it, you need to enable it again for the desired transition • You may also disable a capture input (i.e. its capability to detect a programmed transition) previously enabled, using the MPL commands: DISCAPI, DIS2CAPI See also: Special I/O – Related MPL Instructions and Data MPL Description 6.2.3.3.8. Special I/O - Related MPL Instructions and Data (Firmware FBxx) Parameters DIGIN_ACTIVE_LEVEL Sets active levels for enable and limit switch inputs as follows: • Enable input – on bit 15: 0 – low, 1 – high • Limit switch input for negative direction – on bit 14: 0 – low, 1 – high • Limit switch input for positive direction – on bit 13: 0 – low, 1 – high LSACTIVE When set to a non-zero value, disables limit switch inputs capability to protect against accidental moves outside a defined working area. In this case, the limit switch inputs are treated like 2 extra general-purpose inputs CDEC Command deceleration for quick stop mode. Measured in acceleration units ICR Interrupt Control Register. The MPL interrupts can be enabled or disabled by setting or resetting the corresponding bits from this register ACR Auxiliary Control Register. If ACR.1 = 1 the drive/motor is set to start automatically after power-on with an external reference. If ACR.3 = 1 there is a specific request to execute AXISON at recover from disable status. In both cases, an AXISON is executed when enable input goes from inactive to active status. Variables CAPPOS Position captured when programmed transition occurs on 1st capture/encoder index input. Measured in motor position units, except the case of stepper motors, when it is measured in position units CAPPOS2 Position captured when programmed transition occurs on 2nd capture/encoder index input. Measured in position units when load position is captured, or in master position units when master position is captured APOS2 Master position computed by the slaves from pulse & direction or quadrature encoder inputs. Measured in master position units © ElectroCraft 2013 338 MPD User Manual TPOS Target position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units APOS_LD Actual load position. Measured in position units. Alternate name: APOS APOS_MT Actual motor position. Measured in motor position units. Instructions !CAP Set event on capture inputs ENCAPI0 Enable 1st capture/encoder index input to detect a high to low transition EN2CAPI0 Enable 2nd capture/encoder index input to detect a high to low transition ENCAPI1 Enable 1st capture/encoder index input to detect a low to high transition EN2CAPI1 Enable 2nd capture/encoder index input to detect a low to high transition !LSN Set event on negative limit switch input !LSP Set event on positive limit switch input ENLSP0 Enable positive limit switch input to detect a high to low transition ENLSN0 Enable negative limit switch input to detect a high to low transition ENLSP1 Enable positive limit switch input to detect a low to high transition ENLSN1 Enable negative limit switch input to detect a low to high transition DISCAPI Disable 1st capture/encoder index input to detect transitions DIS2CAPI Disable 2nd capture/encoder index input to detect transitions DISLSP Disable positive limit switch input to detect transitions DISLSN Disable negative limit switch input to detect transitions UPD! Update the motion mode and/or the motion parameters when the programmed event occurs STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs WAIT! value16 Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units SRB Set/reset bits from a MPL data © ElectroCraft 2013 339 MPD User Manual Programming Example //Stop motion on next encoder index ENCAPI1; //Set event: When the encoder index goes low->high !CAP; STOP!;//Stop the motion when event occurs WAIT!;//Wait until the event occurs CPOS = CAPPOS; // new command position = captured position CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; WAIT!; //wait for completion See also: Special I/O – MPL Programming Details MPL Description 6.2.3.4. Assignment and Data Transfer 6.2.3.4.1. Setup 16-bit variable The MPL instructions presented in this paragraph show you the options you have to: 1. Assign a value to a 16-bit integer MPL data 2. Transfer in a memory location, a 16-bit value or the value of a 16-bit integer MPL data In the first case, the destination is a 16-bit MPL data: MPL register, MPL parameter or user variable and the source can be: • A 16-bit immediate value or a label • A 16-bit MPL data: MPL register, parameter, variable or user variable (direct or negated) • The high or low part of a 32-bit MPL data: MPL parameter, variable or user variable • A memory location indicated through a pointer variable • The result of the checksum performed with all locations situated between 2 memory addresses specified either as immediate values or via 2 pointer variables. In the second case and the destination is a memory location indicated through a pointer variable and the source can be: • A 16-bit immediate value • A 16-bit MPL data: MPL register, parameter, variable or user variable Programming Examples © ElectroCraft 2013 340 MPD User Manual 1) Source: 16-bit immediate value, Destination: 16-bit MPL data. The immediate value can be decimal or hexadecimal user_var = 100; // set user variable user_var with value 100 user_var = 0x100; // set user variable user_var with value 0x100 (256) label1: user_var = label; // set user variable user_var with label1 value 2) Source: 16-bit MPL data, Destination: 16-bit MPL data. var_dest = var_source; // copy value of var_source in var_dest var_dest = -var_source; // copy negate value of var_source in var_dest 3) Source: high or low part of a 32-bit MPL data, Destination: 16-bit MPL data. The 32-bit MPL data can be either long or fixed int_var = long_var(L); // copy low part of long_var in int_var int_var = fixed_var(H); // copy high part of fixed_var in int_var 4) Source: a memory location indicated through a pointer variable, Destination: 16-bit MPL data. The memory location can be of 3 types: RAM for data (dm), RAM for MPL programs (pm), EEPROM SPIconnected for MPL programs (spi). If the pointer variable is followed by a + sign, after the assignment, the pointer variable is incremented by 1 p_var = 0x4500; // set 0x4500 in pointer variable p_var var1 = (p_var),spi; // var1 = value of the EEPROM memory location 0x4500 var1 = (p_var+),spi; // var1 = value of the EEPROM memory location 0x4500 // p_var = 0x4501 p_var = 0x8200; // set 0x8200 in pointer variable p_var var1 = (p_var),pm; // var1 = value of the RAM memory location 0x8200 for //MPL programs var1 = (p_var+),pm; // var1 = value of the RAM memory location 0x8200 fior //MPL programs, then set p_var = 0x8201 p_var = 0xA00; // set 0xA00 in pointer variable p_var var1 = (p_var),dm; // var1 = value of the RAM memory location 0xA00 for //MPL data var1 = (p_var+),dm; // var1 = value of the RAM memory location 0xA00 for //MPL data, then set p_var = 0xA01 5) Source: the result of the checksum. Destination: 16-bit MPL data. The checksum is performed with all locations situated between 2 memory addresses. These are specified either as immediate values or via 2 pointer variables. The memory can be of 3 types: RAM for data (dm), RAM for MPL programs (pm), EEPROM SPI-connected for MPL programs (spi). checksum, spi 0x4000, 0x4500, var1; // var1=checksum value computed // between EEPROM memory addresses 0x4000 and 0x4500 © ElectroCraft 2013 341 MPD User Manual start = 0x9000; // set start address = 0x9000 end = 0x9100; // set end address = 0x9100 checksum, pm start, stop, var1; // var1=checksum value computed // between RAM (for MPL programs) addresses 0x9000 and 0x9100 pointed by the MPL // variables start and stop 6) Source: 16-bit immediate value (decimal or hexadecimal) or 16-bit MPL data. Destination: a memory location indicated through a pointer variable. The memory location can be of 3 types: RAM for data (dm), RAM for MPL programs (pm), EEPROM SPI-connected for MPL programs (spi). If the pointer variable is followed by a + sign, after the assignment, the pointer variable is incremented by 1 p_var = 0x4500; // set 0x4500 in pointer variable p_var (p_var),spi = -5; // write value –5 in the EEPROM memory location // 0x4500 (p_var+),spi = var1; // write var1 value in the EEPROM memory location // 0x4500, then set p_var = 0x4501 p_var = 0x8200; (p_var),pm = 0x10; // set 0x8200 in pointer variable p_var // write value 0x10 in RAM memory location 0x8200 for // MPL programs (p_var+),pm = var1; // write var1 value in RAM memory location 0x8200 for // MPL programs, then set p_var = 0x8201 p_var = 0xA00; // set 0xA00 in pointer variable p_var (p_var),dm = 50; // write value 50 in the RAM memory location 0xA00 for // MPL data (p_var+),dm = var1; // write var1 value in the RAM memory location 0xA00 // for MPL data, then set p_var = 0xA01 Remark: The MPL assignment instructions with source an immediate value or a MPL data and destination a MPL data, use a short address format for the destination. The short address format requires a destination address between 0x200 and 0x3FF or between 0x800 and 0x9FF. This restriction is respected now by all the predefined or user-defined MPL data, hence you can use the above assignment instructions without checking the variables addresses. However, considering possible future developments, the MPL also includes assignment instructions using a full address format where the destination address can be any 16-bit value. The following commands support full addressing: int_var,dm = 100; // set int_var = 100 using full addressing int_var,dm = 0x100; // set int_var = 0x100(256) using full addressing var_dest,dm = var_source; // copy value of var_source in var_dest using // full addressing See also: Assignment and Data Transfer. 32-bit data – MPL Programming Details MPL Description © ElectroCraft 2013 342 MPD User Manual 6.2.3.4.2. Setup 32-bit variable The MPL instructions presented in this paragraph show you the options you have to: 1. Assign a value to a 32-bit long or fixed MPL data 2. Assign a value to the high (16MSB) or low (16LSB) part of a 32-bit long or fixed data 3. Transfer in 2 consecutive memory locations, a 32-bit value or the value of a 32-bit long or fixed MPL data In the first case, the destination is a 32-bit MPL data: MPL parameter or user variable and the source can be: • A 32-bit immediate value • A 32-bit MPL data: MPL register, parameter, variable or user variable (direct or negated) • A 16-bit MPL data left shifted by 0 to 16 • 2 consecutive memory locations, indicated through a pointer variable In the second case, the destination is the high or low part of a 32-bit MPL data: MPL parameter or user variable and the source can be: • A 16-bit immediate value • A 16-bit MPL data: MPL register, parameter, variable or user variable In the third case, the destination is 2 consecutive memory locations, indicated through a pointer variable and the source can be: • A 32-bit immediate value • A 32-bit MPL data: MPL parameter, variable or user variable ProgrammingProgrammable Examples 1) Source: 32-bit immediate value, Destination: 32-bit MPL data. The immediate value can be decimal or hexadecimal. The destination can be either a long or a fixed variable long_var = 100000; // set user variable long_var with value 100000 long_var = 0x100000; // set user variable long_var with value 0x100000 fixed_var = 1.5; // set user variable fixed_var with value 1.5 (0x18000) fixed_var = 0x14000; // set user variable fixed_var with value 1.25 (0x14000) 2) Source: 32-bit MPL data, Destination: 32-bit MPL data. var_dest = var_source; // copy value of var_source in var_dest var_dest = -var_source; // copy negate value of var_source in var_dest Remark: source and destination must be of the same type i.e. both long or both fixed 3) Source: 16-bit immediate value (decimal or hexadecimal) or 16-bit MPL data, Destination: high or low part of a 32-bit MPL data. The 32-bit MPL data can be either long or fixed long_var(L) = -1; // write value –1 (0xFFFF) into low part of long_var fixed_var(H) = 0x2000; // write value 0x2000 into high part of fixed_var © ElectroCraft 2013 343 MPD User Manual long_var(L) = int_var; // copy int_var into low part of long_var fixed_var(H) = int_var; // copy int_var into high part of fixed_var 4) Source: 16-bit MPL data left shifted 0 to 16. Destination: 32-bit MPL data. The 32-bit MPL data can be either long or fixed long_var = int_var << 0; // copy int_var left shifted by 0 into long_var fixed_var = int_var << 16; // copy int_var left shifted by 16 fixed_var Remarks: • The left shift operation is done with sign extension. If you intend to copy the value of an integer MPL data into a long MPL data preserving the sign use this operation with left shift 0 • If you intend to copy the value of a 16-bit unsigned data into a 32-bit long variable, assign the 16bit data in low part of the long variable and set the high part with zero. Examples: var = 0xFFFF; // As integer, var = 1, as unsigned integer var = 65535 lvar = var << 0; // lvar = -1 (0xFFFFFFFF), the 16MSB of lvar are all set to 1 the // sign bit of var lvar(L) = var; // lvar(L) = 0xFFFF lvar(H) = 0; // lvar(H) = 0. lvar = 65535 (0x0000FFFF) 5) Source: 2 consecutive memory locations, indicated through a pointer variable, Destination: 32-bit MPL data. The memory locations can be of 3 types: RAM for data (dm), RAM for MPL programs (pm), EEPROM SPI-connected for MPL programs (spi). The pointer variable indicates first of the 2 memory locations. If the pointer variable is followed by a + sign, after the assignment, it is incremented by 2. The destination can be either a long or a fixed MPL data p_var = 0x4500; var1 = (p_var),spi; // set 0x4500 in pointer variable p_var // var1 = value of the EEPROM memory location 0x4500 var1 = (p_var+),spi; // var1 = value of the EEPROM memory location 0x4500, // then set p_var = 0x4502 p_var = 0x8200; var1 = (p_var),pm; // set 0x8200 in pointer variable p_var // var1 = value of the RAM memory location 0x8200 for MPL // programs var1 = (p_var+),pm; // var1 = value of the RAM memory location 0x8200 for MPL // programs, then set p_var = 0x8202 p_var = 0xA00; var1 = (p_var),dm; // set 0xA00 in pointer variable p_var // var1 = value of the RAM memory location 0xA00 for MPL // data var1 = (p_var+),dm; // var1 = value of the RAM memory location 0xA00 for MPL // data, then set p_var = 0xA02 © ElectroCraft 2013 344 MPD User Manual 6) Source: 32-bit immediate value (decimal or hexadecimal) or a 32-bit MPL data. Destination: 2 consecutive memory locations indicated through a pointer variable. The memory locations can be of 3 types: RAM for data (dm), RAM for MPL programs (pm), EEPROM SPI-connected for MPL programs (spi). The pointer variable indicates first of the 2 memory locations. If the pointer variable is followed by a + sign, after the assignment, it is incremented by 2. The source can be either a long or a fixed MPL data. p_var = 0x4500; // set 0x4500 in pointer variable p_var (p_var),spi = 200000; // write 200000 in the EEPROM memory location 0x4500 (p_var+),spi = var1; // write var1 value in the EEPROM memory location // 0x4500, then set p_var = 0x4502 p_var = 0x8200; // set 0x8200 in pointer variable p_var (p_var),pm = 3.5; // write value 3.5 in RAM memory location 0x8200 for // MPL programs (p_var+),pm = var1; // write var1 value in RAM memory location 0x8200 for // MPL programs, then set p_var = 0x8202 p_var = 0xA00; // set 0xA00 in pointer variable p_var (p_var),dm = -1L; // write –1 (0xFFFFFFFF) in the RAM memory location // 0xA00 (p_var+),dm = var1; // write var1 value in the RAM data memory location // 0xA00, then set p_var = 0xA02 When this operation is performed having as source an immediate value, the MPL compiler checks the type and the dimension of the immediate value and based on this generates the binary code for a 16-bit or a 32-bit data transfer. Therefore if the immediate value has a decimal point, it is automatically considered as a fixed value. If the immediate value is outside the 16-bit integer range (-32768 to +32767), it is automatically considered as a long value. However, if the immediate value is inside the integer range, in order to execute a 32-bit data transfer it is necessary to add the suffix L after the value, for example: 200L or –1L. Examples: user_var = 0x29E; // write CPOS address in pointer variable user_var (user_var),dm = 1000000; // write 1000000 (0xF4240) in the CPOS parameter i.e // 0x4240 at address 0x29E and 0xF at address 0x29F (user_var+),dm = -1; // write -1 (0xFFFF) in CPOS(L). CPOS(H) remains // unchanged. CPOS is (0xFFFFF) i.e. 1048575, // and user_var is incremented by 2 user_var = 0x29E; // write CPOS address in pointer variable user_var (user_var+),dm = -1L; // write –1L long value (0xFFFFFFFF) in CPOS i.e. // CPOS(L) = 0xFFFF and CPOS(H) = 0xFFFF, // user_var is incremented by 2 user_var = 0x2A0; // write CSPD address in pointer variable user_var (user_var),dm = 1.5; // write 1.5 (0x18000) in the CSPD parameter i.e © ElectroCraft 2013 345 MPD User Manual // 0x8000 at address 0x2A0 and 0x1 at address 0x2A1 Remark: The MPL assignment instructions with source an immediate value or a MPL data and destination a MPL data, use a short address format for the destination. The short address format requires a destination address between 0x200 and 0x3FF or between 0x800 and 0x9FF. This restriction is respected now by all the predefined or user-defined MPL data, hence you can use the above assignment instructions without checking the variables addresses. However, considering possible future developments, the MPL also includes assignment instructions using a full address format where the destination address can be any 32-bit value. The following commands support full addressing: long_var,dm = 100000; // set long_var = 100000 in using full addressing long_var,dm = 0x100000; // set long_var = 0x100000 using full addressing var_dest,dm = var_source; // copy value of var_source in var_dest using // full addressing See also: Assignment and Data Transfer. 16-bit data – MPL Programming Details MPL Description 6.2.3.5. Arithmetic and logic manipulation The MPL offers the possibility to perform the following operations with the MPL data: • Addition • Subtraction • Multiplication • Division • Left and right shift • logic AND / OR Except the multiplication, the result of these operations is saved in the left operand. For the multiplication, the result is saved in the dedicated product register. The operands are always treated as signed numbers and the right shift is performed with sign-extension. Addition: The right-side operand is added to the left-side operand The left side operand can be: • A 16-bit MPL data: MPL parameter or user variable • A 32-bit MPL data: MPL parameter or user variable The right side operand can be: • A 16-bit immediate value • A 16-bit MPL data: MPL parameter, variable or user variable • A 32-bit immediate value, if the left side operand is a 32-bit MPL data © ElectroCraft 2013 346 MPD User Manual • A 32-bit MPL data: MPL parameter, variable or user variable, if the left side operand is a 32-bit data too Programming Examples int_var += 10; // int_var1 = int_var1 + 10 int_var += int_var2; // int_var = int_var + int_var2 long_var += -100; // long_var = long_var + (-100) = long_var – 100 long_var += long_var2; // long_var = long_var + long_var2 fixed_var += 10.; // fixed_var = fixed_var + 10.0 fixed_var += fixed_var2; // fixed_var = fixed_var + fixed_var2 Subtraction: The right-side operand is subtracted from the left-side operand The left side operand can be: • A 16-bit MPL data: MPL parameter or user variable • A 32-bit MPL data: MPL parameter or user variable The right side operand can be: • A 16-bit immediate value • A 16-bit MPL data: MPL parameter, variable or user variable • A 32-bit immediate value, if the left side operand is a 32-bit MPL data • A 32-bit MPL data: MPL parameter, variable or user variable, if the left side operand is a 32-bit data too Programming Examples int_var -= 10; // int_var1 = int_var1 - 10 int_var -= int_var2; // int_var = int_var - int_var2 long_var -= -100; // long_var = long_var - (-100) = long_var + 100 long_var -= long_var2; // long_var = long_var - long_var2 fixed_var -= 10.; // fixed_var = fixed_var - 10.0 fixed_var -= fixed_var2; // fixed_var = fixed_var - fixed_var2 Remark: At addition and subtraction, when the left operand is a 32-bit long or fixed MPL data and the right operand is a 16-bit integer value, it is treated as follows: • Sign extended to a 32-bit long value, if the left operand is a 32-bit long • Set as the integer part of a fixed value, if the left operand is a 32-bit fixed Multiplication: The 2 operands are multiplied and the result is saved in a dedicated 48-bit product register (PREG). This can be accessed via the MPL variables: PRODH – the 32 most significant bits, and PROD – the 32 least significant bits of the product register. The result of the multiplication can be left or right-shifted with 0 to 15 bits, before being stored in the product register. At right shifts, high order bits are sign-extended and the low order bits are lost. At left shifts, high order bits are lost and the low order bits are zeroed. The result is preserved in the product register until the next multiplication. © ElectroCraft 2013 347 MPD User Manual The first (left) operand can be: • A 16-bit MPL data: MPL parameter, variable or user variable • A 32-bit MPL data: MPL parameter, variable or user variable The second (right) operand can be: • A 16-bit immediate value • A 16-bit MPL data: MPL parameter, variable or user variable Remark: The result is placed in the product register function of the left operand. When shift is 0: • In the 32 least significant bits, when the left operand is a 16-bit integer. The result is a 32-bit long integer • In all the 48 bits, when the left operand is a 32-bit fixed. The result has the integer part in the 32 most significant bits and the fractional part in the 16 least significant bits • In all the 48 bits, when the left operand is a 32-bit long. The result is a 48-bit integer Programming Examples long_var * -200 << 0; // PROD = long_var * (-200) fixed_var * 10 << 5; // PROD = fixed_var * 10 * 25 i.e. fixed_var *320 int_var1 * int_var2 >> 1; // PROD = (int_var1 * int_var2) / 2 long_var * int_var >> 2; // PROD = (long_var * int_var) / 4 long_var = PROD; // save 32LSB of PROD in long_var long_var = PROD(H); // save 32MSB of PROD in long_var i.e. bits 47-15 Division: The left operand – the dividend, is divided by the right operand – the divisor, and the result is saved in the left operand.. The first (left) operand is a 32-bit MPL data: MPL parameter or user variable. The second (right) operand is a 16-bit MPL data: MPL parameter, variable or user variable The result, saved in the first operand is a fixed value with the integer part in the 16 most significant bits and the fractional part in the 16 least significant bits. Programming Examples long_var /= int_var; // long_var = long_var / int_var fixed_var /= int_var; // fixed_var = fixed_var / int_var Left and right shift: The operand is left or right shifted with 0 to 15. The result is saved in the same operand. At right shifts, high order bits are sign-extended and the low order bits are lost. At left shifts, high order bits are lost and the low order bits are zeroed. The operand can be: • A 16-bit MPL data: MPL parameter, variable or user variable • A 32-bit MPL data: MPL parameter, variable or user variable © ElectroCraft 2013 348 MPD User Manual • The 48-bit product register with the result of the last multiplication © ElectroCraft 2013 349 MPD User Manual Programming Examples long_var << 3; // long_var = long_var * 8 int_var = -16; // int_var = -16 (0xFFF0) int_var >> 3; // int_var = int_var / 8 = -2 (0xFFFE) PROD << 1; // PREG = PREG * 2 Remark: The shifts instructions having PROD as operand are performed on all the 48-bits of the product register. Logic AND / OR: A logic AND is performed between the operand and a 16-bit data (the AND mask), followed by a logic OR between the result and another 16-bit data (the OR mask). The operand is a 16-bit MPL data: MPL register, MPL parameter or user variable The AND and OR masks are 16-bit immediate values, decimal or hexadecimal. Programming Examples int_var = 13; // int_var = 13 (0xD) SRB int_var, 0xFFFE, 0x2;// set int_var bit 0 = 0 and bit 1 = 1 // int_var = 12 (0xC) The SRB instruction allows you to set/reset bits in a MPL data in a safe way avoiding the interference with the other concurrent processes wanting to change the same MPL data. This is particularly useful for the MPL registers, which have bits that can be manipulated by both the drive/motor and the user at MPL level. Remark: The SRB instruction, use a short address format for the operand. The short address format requires an operand address between 0x200 and 0x3FF or between 0x800 and 0x9FF. This restriction is respected now by all the predefined or user-defined MPL data, hence you can use the above assignment instructions without checking the variables addresses. However, considering possible future developments, the MPL also includes a similar instruction SRBL using a full address format where the operand address can be any 16-bit value. The SRBL command has the following mnemonic: SRBL MPLvar, 0xFFFE, 0x2; // set bit 0 = 0 and bit 1 = 1 in MPLvar with // using full addressing See also: MPL Description © ElectroCraft 2013 350 MPD User Manual 6.2.3.6. Multi-axis control 6.2.3.6.1. Axis identification In multiple-axis configurations, each axis (drive/motor) needs to be identified through a unique number – the axis ID. This is a value between 1 and 255. If the destination of a message is specified via an axis ID, the message is received only by the axis with the same axis ID. The axis ID is initially set at power on using the following algorithm: a. With the value read from the EEPROM setup table containing all the setup data. b. If the setup table is invalid, with the last axis ID value read from a valid setup table c. If there is no axis ID set by a valid setup table, with the value read from the hardware switches/jumpers for axis ID setting d. If the drive/motor has no hardware switches/jumpers for axis ID setting, with the default axis ID value which is 255. Remark: If the axis ID read from a valid setup table is 0, the axis ID is set with the value read from the hardware switches/jumpers or in their absence according with d) Typically, the axis ID is kept constant during operation at the value established during the setup phase. However, if needed, you can change the axis ID to any of the 255 possible values, using the MPL instruction AXISID, followed by an integer value between 1 and 255. Apart from the axis ID, each drive has also a group ID. The group ID represents a filter for multicast messages. The destination of a multicast message is specified via a group ID. When a multicast message is received, each axis compares the group ID from the message with its own group ID. If the axis group ID has a bit in common with the group ID from the message, the message is accepted. The group ID is an 8-bit integer value. Each bit corresponds to one group: bit 0 – group 1, bit 1 – group 2… bit 7 – group 8. Hence a drive/motor can be programmed to be member of up to 8 groups. When a MPL command is sent to a group, all the axes members of this group will receive the command. For example, if a drive/motor has the group ID = 11 (1011b), it is member of groups 1, 2 and 4 and will receive the messages sent any of these groups. For each drive/motor you can: • Set its group ID using the MPL instruction GROUPID • Add new groups to its group ID using the MPL instruction ADDGRID • Remove groups from its group ID using the MPL instruction REMGRID. Remarks: • You can read at any moment the actual values of the axis ID and group ID of a drive/motor from the Axis Address Register AAR • By default all the drives are set as members of group 1. • A broadcast to all the axes means to send a message with the destination group ID = 0 Variables AAR © ElectroCraft 2013 MPL register (Axis Address Register). Contains the Group ID in the 8MSB and the Axis ID in the 8LSB 351 MPD User Manual Instructions AXISID value Set axis ID = value. Value is an 8-bit integer between 1 and 255 GROUPID (1,3,5,..) Set group ID = value. Value is an 8-bit integer, where: • Bit 0 is set to 1, if (group) 1 occurs in the parenthesis, else it is set to 0 • Bit 1 is set to 1, if (group) 2 occurs in the parenthesis, else it is set to 0 • … • Bit 7 is set to 1, if (group) 8 occurs in the parenthesis, else it is set to 0 ADDGRID (2,4,6…) Add the groups from parenthesis to the Group ID. The corresponding bits from Group ID will be set to 1 REMGRID (2,5…) Remove the groups from parenthesis from the Group ID. The corresponding bits from Group ID will be set to 0 Programming Example AXISID 10; // set axis ID = 10 GROUPID (2,3); // set group ID = 6 (110b) i.e. bits 1, 2 = 1 ADDGRID (4); // add group 4. Group ID = 14 (1110b) i.e. bits 1, 2, 3 = 1 REMGRID (2,4); // remove groups 2 and 4. Group ID = 4 (100b) i.e. bit 2 = 1 // AAR = 40Ah i.e. group ID = 4 and axis ID = 10 (Ah) See also: Communication Protocols – RS232 & RS485 Communication Protocols – CAN MPL Description 6.2.3.6.2. Data transfers between axes There are 2 categories of data transfer operations between axes: 1. Read data from a remote axis. A variable or a memory location from the remote axis is saved into a local variable 2. Write data to a remote axis or group of axes. A variable or a memory location of a remote axis or group of axes is written with the value of a local variable In a read data from a remote axis operation: • The source is placed on a remote axis and can be: A 16-bit MPL data: MPL register, parameter, variable or user variable A memory location indicated through a pointer variable • The destination is placed on the local axis and can be: A 16-bit MPL data: MPL register, parameter or user variable © ElectroCraft 2013 352 MPD User Manual Programming Examples 1) Source: remote 16-bit MPL data, Destination: local 16-bit MPL data. // set local_var with value of remote_var from axis 2 local_var = [2]remote_var; Remark: If remote_var is a user variable, it has to be declared in the local axis too. Moreover, for correct operation, remote_var must have the same address in both axes, which means that it must be declared on each axis on the same position. Typically, when working with data transfers between axes, it is advisable to establish a block of user variables that may be the source, destination or pointer of data transfers, and to declare these data on all the axes as the first user variables. This way you can be sure that these variables have the same address on all the axes. 2) Source: remote memory location pointed by a remote pointer variable, Destination: 16-bit MPL data. The remote memory location can be of 3 types: RAM memory for MPL data (dm), RAM memory for MPL programs (pm), EEPROM SPI-connected memory for MPL programs (spi). If the pointer variable is followed by a + sign, after the assignment, the pointer variable is incremented by 1 if the destination is a 16-bit integer or by 2 if the destination is a 32-bit long or fixed local_var = [2](p_var),spi; // local_var = value of EEPROM program memory // location from axis 2, pointed by p_var from axis 2 long_var = [3](p_var+),dm; // local long_var = value of RAM data memory // locations from axis 3, pointed by p_var from axis 3 // p_var is incremented by 2 int_var = [4](p_var+),pm; // local int_var = value of RAM program memory // location from axis 4, pointed by p_var from axis 4; // p_var is incremented by 1 Remark: The MPL instructions for data transfers between axes use a short address format for the remote source when this is a MPL data. The short address format requires a source address between 0x200 and 0x3FF or between 0x800 and 0x9FF. This restriction is respected now by all the predefined or user-defined MPL data, hence you can use the above assignment instructions without checking the variables addresses. However, considering possible future developments, the MPL also includes data transfers using a full address format where the source address can be any 16-bit value. The following command supports full addressing: local_var = [2]remote_var,dm; // set local_var with value of remote_var // from axis 2 using extended addressing In a write data to a remote axis or group of axes operation: • The source is placed on the local drive and can be: A 16-bit MPL data: MPL register, parameter, variable or user variable • The destination is placed on the remote axis or group of axes and can be: A 16-bit MPL data: MPL register, parameter or user variable A memory location indicated through a pointer variable Programming Examples © ElectroCraft 2013 353 MPD User Manual 1) Source: local 16-bit MPL data, Destination: remote 16-bit MPL data. [2]remote_var = local_var; // set remote_var from axis 2 with local_var value [G2]remote_var = local_var; // set remote_var from group 2 with local_var value [B]remote_var = local_var; // set remote_var from all axes with local_var value // broadcast with group ID = 0 -> got by everyone 2) Source: 16-bit MPL data, Destination: remote memory location pointed by a remote pointer variable. The remote memory location can be of 3 types: RAM memory (dm), RAM memory for MPL programs (pm), EEPROM SPI-connected memory for MPL programs (spi). If the pointer variable is followed by a + sign, after the assignment, the pointer variable is incremented by 1 if the source is a 16-bit integer or by 2 if the source is a 32-bit long or fixed [2](p_var),spi = local_var; // set local_var value in EEPROM program memory // location from axis 2, pointed by p_var from axis 2 [G3](p_var+),dm = long_var; // set local long_var value in RAM data memory // location from group 3 of axes, each location being // pointed its own p_var, which is incremented by 2 [4](p_var+),pm = int_var; // set local int_var value in RAM program memory // location from axis 4, pointed by p_var from axis 4; // p_var is incremented by 1 Remark: The MPL instructions for data transfers between axes use a short address format for the remote destination when this is a MPL data. The short address format requires a destination address between 0x200 and 0x3FF or between 0x800 and 0x9FF. This restriction is respected now by all the predefined or user-defined MPL data, hence you can use the above assignment instructions without checking the variables addresses. However, considering possible future developments, the MPL also includes data transfers using a full address format where the destination address can be any 16-bit value. The following command supports full addressing: [G2]remote_var,dm = local_var; // set remote_var from group 2 with // local_var value, using extended addressing See also: MPL Description © ElectroCraft 2013 354 MPD User Manual 6.2.3.6.3. Remote control The MPL includes powerful instructions through which you can program a drive to issue MPL commands to another drive or group of drives. You can include these instructions in the MPL program of a drive, which can act like a host and can effectively control the operation of the other drives from the network. These MPL instructions are: [axis]{MPL command1; MPL command2;…}; [group]{MPL command1; MPL command2;…}; [broadcast]{MPL command1; MPL command2;…}; where MPL command1, MPL command2, etc. can be any single axis MPL instructions. A single axis MPL instruction is defined as an instruction that does not transfer data or sends MPL commands to other axes. If you include multiple MPL commands separated by semicolon (;), these will be sent one by one in order from left to right i.e. first MPL command1, then MPL command2, etc. Remark: Most of the MPL instructions enter in the category of those that can be sent by a drive/motor to another one using the above MPL commands. Programming Examples [G1]{CPOS=2000;}; // send a new CPOS command to all axes from group 1 [G1]{UPD}; // send an update command to all the axes from group 1 // all axes from group 1 will start to move simultaneously [B]{STOP;}; // broadcast a STOP command to all axes from the network See also: MPL Description © ElectroCraft 2013 355 MPD User Manual 6.2.3.6.4. Axis Synchronization The MPL provides a synchronization procedure between the ElectroCraft drives/motors connected in a CAN network. When the synchronization procedure is active, the execution of the control loops is synchronized within a 10 time interval. Due to this powerful feature, drifts between the drives/motors are eliminated. The synchronization process is performed in two steps. First, the synchronization master sends a synchronization message to all axes, including to itself. When this message is received, all the axes read their own internal time. Next, the master sends its internal time to all the synchronization slaves, which compare it with their own internal time. If there are differences, the slaves correct slightly their sampling periods in order to keep them synchronized with those of the master. A drive/motor becomes the synchronization master when it receives the MPL command SETSYNC value where value represents the time interval in internal units between the synchronization messages sent by the synchronization master. Recommended value is 20ms. 6.2.3.7. Monitoring 6.2.3.7.1. Position Triggers A position trigger is a position value with which the actual position is continuously compared. The compare result is shown in the Status Register High (SRH). If the actual position is below a position trigger, the corresponding bit from SRH is set to 0, else it is set to 1. In total there are 4 position triggers. Their status is shown in SRH bits 4 to 1. The position triggers are set in the following MPL parameters: POSTRIGG1 – for Position Trigger 1 POSTRIGG2 – for Position Trigger 1 POSTRIGG3 – for Position Trigger 1 POSTRIGG4 – for Position Trigger 1 You can change at any moment the value of a position trigger. © ElectroCraft 2013 356 MPD User Manual The actual position that is compared with the position triggers is: • The Load position feedback (MPL variable APOS_LD) for configurations with position sensor • The position reference (MPL variable TPOS – Target position) in the case of steppers controlled in open-loop Remark: The position triggers can be used to monitor the motion progress. If this operation is done from a host, you may program the drive/motor to automatically issue a message towards the host, each time when the status of a position trigger is changed. See also: Position Triggers – Related MPL Instructions and Data MPL Description © ElectroCraft 2013 357 MPD User Manual 6.2.3.7.2. Position Triggers - Related MPL Instructions and Data Parameters POSTRIGG1 Position trigger 1. Measured in position units. POSTRIGG2 Position trigger 2. Measured in position units. POSTRIGG3 Position trigger 3. Measured in position units. POSTRIGG4 Position trigger 4. Measured in position units. Variables APOS_LD Actual load position. Measured in position units. Alternate name: APOS TPOS Target position – position reference computed by the reference generator at each slow loop sampling period. Measured in position units Programming Example // Position feedback: 500 lines incremental // encoder (2000 counts/rev) POSTRIGG1 = 2000;//Set First Position Trigger = 1[rot] See also: Position Triggers – MPL Programming Details MPL Description 6.2.3.7.3. Status Register The drive/motor status condition is described in registers SRH and SRL. See also: Status register low part – SRL Status register high part – SRH MPL Description © ElectroCraft 2013 358 MPD User Manual 6.2.3.7.4. FAULT Status A drive/motor enters in the FAULT status, when an error occurs. In the FAULT status: • The drive/motor is in AXISOFF with the control loops and the power stage deactivated • The MPL program execution is stopped • The error register MER shows the type of errors detected and the status register SRH.15 signals the fault condition • Ready and error outputs (if present) are set to the not ready level, respectively to the error active level. When available, ready green led is turned off and error red led is turned on Remark: The following conditions signaled in MER do not set the drive/motor in fault status: • Drive /motor disabled due to the enable input set on the disable level • Command error • Negative limit switch input on active level • Positive limit switch input on active level • Position wraparound • Serial and CAN bus communication errors You can modify this default behavior by changing the MPL interrupt service routines The drive/motor can be got out from the FAULT status, with the MPL command FAULTR – fault reset. This command clears most of the error bits from MER, sets the ready output (if available) to the ready level, and sets the error output (if available) to the no error level. Remarks: • The FAULTR command does not change the status of MER.15 (enable input on disabled level), MER.7 (negative limit switch input active), MER.6 (positive limit switch input active) and MER.2 (invalid setup table) • The drive/motor will return to FAULT status if there are errors when the FAULTR command is executed See also: MPL Description © ElectroCraft 2013 359 MPD User Manual 6.2.3.7.5. Messages sent to the host You can program a drive/motor to send messages to your host. The messages are all of type “Take Data 2” (see Communication Protocols: RS232 & RS485 or CAN) i.e. return the value of a MPL data, like if the drive/motor would have had received a “Give Me Data 2” request from the host to return that MPL data. The message transmission can be triggered by: • Conditions which change the status registers SRL, SRH or the error register MER • The execution of the MPL command SEND from your MPL program. Through this command you can send to your host the contents of any MPL data In the first case, you can select the registers bits, which will trigger a message when are changed. The selection is done via 3 masks, one for each register, set in MPL parameters: SRL_MASK, SRH_MASK, MER_MASK. A bit set in a mask, enables a message transmission when the same bit from the corresponding register changes. When the transmission is triggered by a bit change in SRH (high part) or SRL (low part), the message sent contains these 2 registers grouped together as a single 32-bit register/data, with SRH on bits 31-16. When the transmission is triggered by a bit change in MER, the message sent contains this register. The host ID is specified via the MPL parameter MASTERID. This contains the host ID (an integer value between 1 and 255), multiplied by 16, plus 1. For example, if the host ID is 1, the value of MASTERID must be 1 *16 + 1 = 17. Remark: By default, at power on, the MASTERID is set for a host ID equal with the drive/motor axis ID. Therefore, the messages will be sent via RS-232 serial communication. If the host ID is set different from the drive/motor axis ID, the messages are sent via the other communication channels: CAN bus, RS485, etc Parameters MASTERID Provides the host ID (address), according with formula: MASTERID = host ID * 16 + 1 SRL_MASK Mask for SRL register. A bit set to 1, enables to send SRH and SRL when the same bit from SRL changes SRH_MASK Mask for SRH register. A bit set to 1, enables to send SRH and SRL when the same bit from SRH changes MER_MASK from MER changes Mask for MER register. A bit set to 1, enables to send MER when the same bit Variables SRL MPL register. Low part of the 32-bit status register grouping key information about the drive/motor status SRH MPL register. High part of the 32-bit status register grouping key information concerning the drive/motor status MER MPL register. Groups all the errors conditions © ElectroCraft 2013 360 MPD User Manual Instructions SEND var Sends a “Take Data 2” message with var contents. Var can be any 16-bit or 32-bit MPL data: register, parameter or variable Programming Examples MASTERID = 33; // Set host ID / address = 2 //Send SRH & SRL if motion complete or pos. trigger 1 bits change SRH_MASK = 0x0002; SRL_MASK = 0x0400; MER_MASK = 0xFFFF; // send MER on any bit change SEND CAPPOS; // Send to host contents of variable CAPPOS See also: Communication Protocols – RS232 & RS485 Communication Protocols – CAN MPL Description © ElectroCraft 2013 361 MPD User Manual 6.2.3.8. Miscellaneous This categ gory includes the following g MPL instructtions: FAULTR Fault reset. Gets out th he drive/moto or from the FAULT status in which it e enters e occurs. After a FAUL LTR comman nd, most of tthe error bitss from when an error MER are cleared (set to o 0), the Rea ady output (if present) is sset to “ready” level, the Error ou utput (if prese ent) is set to ““no error” leve el. Remarks: • AULT reset co ommand doe s not change e the status o of MER.15 (e enable The FA input on o disabled le evel), MER.7 7 (negative lim mit switch inp put active), M MER.6 (positiv ve limit switch h input active) and MER.2 ((invalid setup p table) • The drrive/motor willl return to F FAULT statuss if there are e errors whe en the FAULT TR command is executed SAVE Saves the acttual values of o the MPL parameters ffrom the RA AM memory iinto the EEP PROM memory, m in the setup table e. Through th his command d, you can sa ave all the ssetup modifica ations do one, after the e power on initialization. SCIBR va alue16 he serial comm munication in nterface (SCI)) baud rate. S SCI is used in n data Changes th ex xchanges on RS232 or RS S485 The serial baud b rate is set s at power o on using the fo ollowing algorithm: a. With the value read from the EEP PROM setup ttable b. If the setup s table is s invalid, with h the last bau ud rate read from a valid setup table c. If there is no baud ra ate set by a vvalid setup tab ble, with 9600 0. Remarks: © ElectroC Craft 2013 • Use thiis command when a drive e/motor opera ates in AUTO ORUN (after p power on starrts to executte the MPL program from m the EEPR ROM) and it must commu unicate with a host at a ba aud rate diffe erent from th he default vallue. In this cas se, the MPL program p mustt start with a sserial baud ra ate change. • An alte ernate solution to the abo ove case is to o set via SCIIBR comman nd the desired d baud rate an nd then to sa ave it in the EE EEPROM, with h command S SAVE. After a reset, the drive/motor d sttarts directly with the new w baud rate, if the able was valid d. Once set, tthe new defau ult baud rate is preserved,, even setup ta if the se etup table is later on disab bled, because the default serial baud rrate is stored in i a separate area of the E EEPROM. 36 62 MPD U User Manual CANBR value16 Changes the CAN bus baud rate as follows: The CAN baud rate is set at power on using the following algorithm: d. With the value read from the EEPROM setup table e. If the setup table is invalid, with the last baud rate read from a valid setup table f. If there is no baud rate set by a valid setup table, with 500kb. Remarks: • Use this command when a drive/motor operates in AUTORUN (after power on starts to execute the MPL program from the EEPROM) and it must communicate with a host at a baud rate different from the default value. In this case, the MPL program must start with a CAN baud rate change. • An alternate solution to the above case is to set via CANBR command the desired baud rate and then to save it the EEPROM, with command SAVE. After a reset, the drive/motor starts directly with the new baud rate, if the setup table was valid. Once set, the new default baud rate is preserved, even if the setup table is later on disabled, because the default CAN baud rate is stored in a separate area of the EEPROM LOCKEEPROM value16 Locks or unlocks the EEPROM write protection. When the EEPROM is writeprotected, it is not possible to write data into the EEPROM, with the exception of the MPL command SAVE. This command temporary unlocks the EEPROM, saves the setup data and then locks back the EEPROM. Value16 may have the following values: 0 – Disables EEPROM write protection 1 – Enables write protection for the last quarter of the EEPROM 2 – Enables write protection for the last half of the EEPROM 3 – Enables write protection for the entire EEPROM Example: An EEPROM has 8Kwords. In the MPL program space occupies the address range: 40005FFFh. LOCKEEPROM 1 protects the address range: 5800-5FFFh, LOCKEEPROM 2 protects the address range: 5000-5FFFh and LOCKEEPROM 3 protects the entire address range: 4000-5FFFh. ENEEPROM Enables EEPROM usage after it was disabled by the initialization of feedback devices like SSI or EnDat encoders using the same SPI link as the EEPROM NOP No operation BEGIN First instruction of a MPL program. © ElectroCraft 2013 363 MPD User Manual END Last instruction of the main section of a MPL program. When END instruction is executed, the MPL program execution is stopped. Remark: It is mandatory to end the main section of a MPL program with an END command. All the MPL functions and the MPL interrupt service routines must follow after the END command. ENDINIT END of the INITialization part of the MPL program. This command uses the available setup data to perform key initializations, but does not activate the controllers or the PWM outputs. These are activated with the AXISON command Remarks: • After power on, the ENDINIT command may be executed only once. Subsequent ENDINIT commands are ignored. • The first AXISON command must be executed only after the ENDINIT command • Typically, the ENDINIT command is executed at the beginning of a MPL program and may be followed by the AXISON command even if no motion mode was set. In the absence of any programmed motion, the drive applies zero voltage to the motor. Alternately, after ENDINIT you can set a first motion and then execute AXISON See also: MPL Description © ElectroCraft 2013 364 MPD User Manual 6.2.4. MPL Instruction set 6.2.4.1. MPL Instructions This section describes the complete set of MPL instructions, grouped by functionality. In each group, the instructions are ordered alphabetically. The groups are: • • Motion programming and control, including o Motion configuration o Motor commands Program flow (decision) group o Events o Motion Controller Events o Jumps and function calls o MPL interrupts • I/O handling (firmware FAxx) • I/O handling (firmware FBxx) • Assignment and data transfer • Arithmetic and logic operations • Multi axis control and monitoring • Miscellaneous • On-line commands The presentation also lists the Obsolete instructions together with their equivalents. The description of each MPL instruction includes: • Syntax • Operands • Binary code • Description • Example(s) All the notational conventions used are grouped in the symbols section. © ElectroCraft 2013 365 MPD User Manual 6.2.4.2. Symbols used in instructions descriptions Symbol Description &Label Value of a MPL program label i.e. a MPL program address &V16 Address of a 16-bit integer variable &V32 Address of a 32-bit long or fixed variable (V16) Contents of memory location from address equal with V16 value (fa) Full full addressing. Source/destination operand provided with 16-bit address. Some MPL instructions using 9-bit short addressing are doubled with their long addressing equivalent 9LSB(&V16) The 9 LSB (less significant bits) of the address of a 16-bit integer 9LSB(&V32) The 9 LSB (less significant bits) of the address of a 32-bit long or fixed A Message destination is an axis indicated via its Axis ID A/G Message destination can be an axis indicated via an Axis ID or a group of axes indicated by a Group ID ANDdis 16-bit AND mask. See Table MCRx & AND/OR masks for DISIO#n and Table MCRx & PxDIR addresses ANDen 16-bit AND mask. See Table MCRx & AND/OR masks for ENIO#n and Table MCRx & PxDIR addresses ANDin 16-bit AND mask. See Table AND/OR masks for SETIO#n IN ANDm 16-bit user-defined AND mask ANDout 16-bit AND mask. See Table AND/OR masks for SETIO#n OUT ANDrst 16-bit AND mask. See Table AND/OR masks for ROUT#n ANDset 16-bit AND mask. See Table AND/OR masks for SOUT#n Bit_mask 16-bit AND mask. See Tables PxDIR & Bit_mask for V16=IN#n and table MCRx & PxDIR addresses D_ref 32-bit fixed value D_time 16-bit value Flag Condition Flag for GOTO/CALL LengthMLI Length of a MPL instruction code in words – 1 MCRx See Tables MCRx & AND/OR masks for ENIO#n / DISIO#n and Table MCRx & PxDIR addresses ORdis 16-bit OR mask. See Table MCRx & AND/OR masks for DISIO#n and Table MCRx & PxDIR addresses ORen 16-bit OR mask. See Table MCRx & AND/OR masks for ENIO#n and Table MCRx & PxDIR addresses ORin 16-bit OR mask.. See Table AND/OR masks for SETIO#n IN ORm 16-bit user-defined OR mask ORout 16-bit OR mask. See Table AND/OR masks for SETIO#n OUT ORrst 16-bit OR mask. See Table AND/OR masks for ROUT#n © ElectroCraft 2013 366 MPD User Manual ORset 16-bit OR mask. See Table AND/OR masks for SOUT#n PxDIR See Table PxDIR & Bit_msk for V16=IN#n and Table MCRx & PxDIR addresses DM RAM memory for MPL data PM RAM memory for MPL programs SPI E2ROM memory for MPL programs TM Type of memory. When used in syntax TM should be replaced by DM or PM or SPI. When used in code, see Table TM values. VAR Any 16/32 –bit MPL data i.e.: register, parameter, variable, user-variable VAR16 Any 16-bit integer MPL data VAR16D A 16-bit integer MPL parameter or user-variable, used as destination: VAR16S Any 16-bit integer MPL data used as source VAR32 Any 32-bit long or fixed MPL data i.e.: parameter, variable, user-variable VAR32(L) 16LSB of a 32-bit long or fixed variable (seen as a 16-bit integer) VAR32(H) 16MSB of a 32-bit long or fixed variable (seen as a 16-bit integer) VAR32D A 32-bit long or fixed MPL parameter of user variable, used as destination VAR32S Any 32-bit long or fixed MPL data value16 16-bit integer value value32 32-bit long or fixed value value32(L) 16LSB of a 32-bit long or fixed value value32(H) 16MSB of a 32-bit long or fixed value © ElectroCraft 2013 367 MPD User Manual 6.2.4.3. Instructions Categories 6.2.4.3.1. Motion configuration Syntax Description CIRCLE Define circular segment for vector mode CPA Command Position is Absolute CPR Command Position is Relative EXTREF Set external reference type INITCAM addrS, addrD Copy CAM table from EEPROM (addrS address) to RAM (addrD address) LPLANE Define coordinate system for linear interpolation mode MODE CS Set MODE Cam Slave MODE GS Set MODE Gear Slave MODE LI Set MODE Linear Interpolation MODE PC Set MODE Position Contouring MODE PE Set MODE Position External MODE PP Set MODE Position Profile MODE PSC Set MODE Position S-Curve MODE PT Set MODE PT MODE PVT Set MODE PVT MODE SC Set MODE Speed Contouring MODE SE Set MODE Speed External MODE SP Set MODE Speed Profile MODE TC Set MODE Torque Contouring MODE TEF Set MODE Torque External Fast MODE TES Set MODE Torque External Slow MODE TT Set MODE Torque Test MODE VC Set MODE Voltage Contouring MODE VEF Set MODE Voltage External Fast MODE VES Set MODE Voltage External Slow MODE VM Set MODE Vector Mode MODE VT Set MODE Voltage Test PTP Define a PT point PVTP Define a PVT point © ElectroCraft 2013 368 MPD User Manual REG_OFF Disable superposed mode REG_ON Enable superposed mode RGM Reset electronic gearing/camming master mode SEG Define a contouring segment SETPT Setup PT mode operation SETPVT Setup PVT mod operation SGM Set electronic gearing/camming master mode TUM0 Target update mode 0 TUM1 Target update mode 1 VPLANE Define coordinate system for Vector Mode VSEG Define linear segment for vector mode © ElectroCraft 2013 369 MPD User Manual 6.2.4.3.2. Motor commands Syntax Description AXISOFF AXIS is OFF (deactivate control) AXISON AXIS is ON (activate control) ENDINIT END of Initialization RESET RESET drive / motor SAP Set Actual Position STA Set Target position = Actual position STOP STOP motion STOP! STOP motion when the programmed event occurs UPD Update motion mode and parameters. Start motion UPD! Update motion mode and parameters when the programmed event occurs © ElectroCraft 2013 370 MPD User Manual 6.2.4.3.3. Events Syntax Description !ALPO Set event when absolute load position is over a value !ALPU Set event when absolute load position is under a value !AMPO Set event when absolute motor position over a value !AMPU Set event when absolute motor position under a value !CAP Set event when a capture input goes low or high !IN#n Set event when digital input #n goes low or high !LSN Set event when the negative limit switch (LSN) goes low or high !LSP Set event when positive limit switch (LSP) goes low or high !LSO Set event when load speed is over a value !LSU Set event when load speed is under a value !MC Set event when the actual motion is completed !MSO Set event when motor speed is over a value !MSU Set event when motor speed is under a value !PRO Set event when position reference is over a value !PRU Set event when position reference is under a value !RPO Set event when relative load position is over a value !RPU Set event when relative load position is under a value !RT Set event after a wait time !SRO Set event if speed reference is over a value !SRU Set event if speed reference is under a value !TRO Set event if torque reference is over a value !TRU Set event if torque reference is under a value !VO Set event if a long/fixed variable is over a value !VU Set event if a long/fixed variable is under a value WAIT! Wait until the programmed event occurs © ElectroCraft 2013 371 MPD User Manual 6.2.4.3.4. Jumps and function calls Syntax Description ABORT Abort the execution of a function called with CALLS CALL Call a MPL function CALLS Cancelable CALL of a MPL function GOTO Jump RET Return from a MPL function 6.2.4.3.5. MPL interrupts Syntax Description DINT Disable globally all MPL interrupts EINT Enable globally all MPL interrupts RETI Return from a MPL Interrupt Service Routine © ElectroCraft 2013 372 MPD User Manual 6.2.4.3.6. I/O handling (Firmware FAxx) Syntax Description DISCAPI Disable 1st capture/encoder index input to detect transitions DIS2CAPI Disable 2nd capture/encoder index input to detect transitions DISLSN Disable negative limit switch (LSN) input to detect transitions DISLSP Disable positive limit switch (LSP) input to detect transitions EN2CAPI0 Enable 2nd capture/encoder index input to detect a high to low transition EN2CAPI1 Enable 2nd capture/encoder index input to detect a low to high transition ENCAPI0 Enable 1st capture/encoder index input to detect a high to low transition ENCAPI1 Enable 1st capture/encoder index input to detect a low to high transition ENLSN0 Enable negative limit switch (LSN) input to detect a high to low transition ENLSN1 Enable negative limit switch (LSN) input to detect a low to high transition ENLSP0 Enable positive limit switch (LSP) input to detect a low to high transition ENLSP1 Enable positive limit switch (LSP) input to detect a high to low transition OUTPORT Set Enable, LSP, LSN and general purpose outputs OUT#28-31 ROUT#n Set low the output line #n SETIO#n Set IO line #n as input or as output SOUT#n Set high the output line #n V16D = IN#n Read input #n. V16D = input #n status V16D = INPUT1, ANDm V16D = logical AND between inputs IN#25 to IN#32 status and ANDm mask V16D = INPUT2, ANDm V16D = logical AND between inputs IN#33 to IN#39 status and ANDm mask V16D = INPORT, ANDm V16D = status of inputs Enable, LSP, LSN plus IN#36 to IN#39 © ElectroCraft 2013 373 MPD User Manual 6.2.4.3.7. I/O handling (firmware FBxx) Syntax Description !CAP Set event on capture inputs !LSN Set event on negative limit switch input !LSP Set event on positive limit switch input DISCAPI Disable 1st capture/encoder index input to detect transitions DIS2CAPI Disable 2nd capture/encoder index input to detect transitions DISLSN Disable negative limit switch (LSN) input to detect transitions DISLSP Disable positive limit switch (LSP) input to detect transitions EN2CAPI0 Enable 2nd capture/encoder index input to detect a high to low transition EN2CAPI1 Enable 2nd capture/encoder index input to detect a low to high transition ENCAPI0 Enable 1st capture/encoder index input to detect a high to low transition ENCAPI1 Enable 1st capture/encoder index input to detect a low to high transition ENLSN0 Enable negative limit switch (LSN) input to detect a high to low transition ENLSN1 Enable negative limit switch (LSN) input to detect a low to high transition ENLSP0 Enable positive limit switch (LSP) input to detect a low to high transition ENLSP1 Enable positive limit switch (LSP) input to detect a high to low transition user_var = IN(n) Read input n in the user variable user_var user_var = IN(n1, n2, n3, …) Read inputs n1, n2, n3,… in the user variable user_var OUT(n) =value16 Set the output line as specified by value16 OUT(n1, n2, n3, …) =value16 Set the output lines n1 n2, n3 as specified by value16 SetAsInput(n) Set the I/O line #n as an input SetAsOutput(n) Set the I/O line #n as an output SRB Set/reset bits from a MPL data STOP! Stop motion with the acceleration/deceleration set in CACC, when the programmed event occurs UPD! Update the motion mode and/or the motion parameters when the programmed event occurs WAIT! Wait until the programmed event occurs. If the command is followed by value16, the wait ends after the time interval specified in this 16-bit integer value. Value16 is measured in time units © ElectroCraft 2013 374 MPD User Manual 6.2.4.3.8. Assignment and data transfer Syntax Description V16 = label V16 = &label V16D = V16S V16D = V16S V16 = val16 V16 = val16 V16D = V32S(H) V16D = V32S(H) V16D = V32S(L) V16D = V32S(L) V16D, dm = V16S V16D = V16S (fa) V16D, dm = val16 V16D = val16 (fa) V16D = (V16S), TM V16D = (V16S) from TM memory V16D = (V16S+), TM V16D = (V16S) from TM memory, then V16S += 1 (V16D), TM = V16S (V16D) from TM memory = V16S (V16D), TM = val16 (V16D) from TM memory = val16 (V16D+), TM = V16S (V16D) from TM memory = V16S, then V16D += 1 (V16D+), TM = val16 (V16D) from TM memory = val16, then V16D += 1 V32(H) = val16 V32(H) = val16 V32(L) = val16 V32(H) = val16 V32D(H) = V16S V32D(H) = V16 V32D(L) = V16S V32D(L) = V16 V16D = -V16S V16D = -V16S V32D = V32S V32D = V32S V32 = val32 V32 = val32 V32D =V16S << N V32D = V16S left-shifted by N V32D, dm = V32S V32D from dm = V32S (fa) V32D, dm = val32 V32 from dm = val32 (fa) V32D = (V16S), TM V32D = (V16S) from TM memory V32D = (V16S+), TM V32D = (V16S) from TM memory, then V16S += 2 (V16D), TM = V32S (V16D) from TM memory = V32S (V16D), TM = val32 (V16D) from TM memory = val32 (V16D+), TM = V32S (V16D) from TM memory = V32S, then V16D += 2 (V16D+), TM = val32 (V16D) from TM memory = val32, then V16D += 2 V32D = -V32S V32D = -V32S © ElectroCraft 2013 375 MPD User Manual 6.2.4.3.9. Arithmetic and logic operations Syntax Description V16 += val16 V16 = V16 + val16 V16D += V16S V16D = V16D + V16S V32 += val32 V32 = V32 + val32 V32D += V32S V32D = V32D + V32S V16 -= val16 V16 = V16 - val16 V16D -= V16S V16D = V16D - V16S V32 -= val32 V32 = V32 - val32 V32D -= V32S V32D = V32D - V32S V16 * val16 << N 48-bit product register = (V16 * val16) >> N V16 * val16 >> N 48-bit product register = (V16 * val16) >> N V16A * V16B << N 48-bit product register = (V16A * V16B) << N V16A * V16B >> N 48-bit product register = (V16A * V16B) >> N V32 * V16 << N 48-bit product register = (V32 * V16) << N V32 * V16 >> N 48-bit product register = (V32 * V16) >> N V32 * val16 << N 48-bit product register = (V32 * val16) << N V32 * val16 >> N 48-bit product register = (V32 * val16) >> N V32=/V16 Divide V32 to V16 PROD <<= N Left shift 48-bit product register by N V16 <<= N Left shift V16 by N V32 <<= N Left shift V32 by N PROD >>= N Right shift 48-bit product register by N V16 >>= N Right shift V16 by N V32 >>= N Right shift V32 by N SRB V16, ANDm, ORm Set / Reset Bits from V16 SRBL V16, ANDm, ORm Set / Reset Bits from V16 (fa) 6.2.4.3.10. Multiple axis control and monitoring Syntax Description [A/G] { MPL Instr} Send MPL instruction to [A/G] [A/G] V16D = V16S [A/G] V16D = local V16S © ElectroCraft 2013 376 MPD User Manual [A/G] V16D, dm = V16S [A/G] V16D = local V16S (fa) [A/G] (V16D), TM = V16S [A/G] (V16D), TM = local V16S [A/G] (V16D+), TM = V16S [A/G] (V16D), TM = local V16S, then V16D += 1 [A/G] V32D = V32S [A/G] V32D = local V32S [A/G] V32D, dm = V32S [A/G] V32D = local V32S (fa) [A/G] (V16D), TM = V32S [A/G] (V16D), TM = local V32S [A/G] (V16D+), TM = V32S [A/G] (V16D), TM = local V32S, then V16D += 2 V16D = [A] V16S Local V16D = [A] V16S V16D = [A] V16S, dm Local V16D = [A] V16S, dm (fa) V16D = [A] (V16S), TM Local V16D = [A] (V16S), dm V16D = [A] (V16S+), TM Local V16D = [A] (V16S), dm, then V16S += 1 V32D = [A] V32S Local V32D = [A] V32S V32D = [A] V32S, dm Local V32D = [A] V32S, dm (fa) V32D = [A] (V16S), TM Local V32D = [A] (V16S), TM V32D = [A] (V16S+), TM Local V32D = [A] (V16S), TM, then V16S += 2 ADDGRID (value16_1, value16_2,…) Add groups to the Group ID AXISID Set Axis ID GROUPID (value16_1, value16_2,…) Set GROUP ID SETSYNC Enable/disable synchronization between axes SEND Send to host the contents of a MPL variable REMGRID (value16_1, value16_2,…) Remove groups from the Group ID © ElectroCraft 2013 377 MPD User Manual 6.2.4.3.11. Miscellaneous Syntax Description BEGIN BEGIN of a MPL program CANBR val16 Set CAN bus baud rate CHECKSUM, TM Start, Stop, V16D V16D=Checksum between Start and Stop addresses from TM ENEEPROM Enables EEPROM usage after it was disabled by the initialization of SSI or ENDat encoders END END of a MPL program ENDINIT END of INITialization part of the MPL program FAULTR Reset FAULT status. Return to normal operation LOCKEEPROM Locks or unlocks the EEPROM write protection NOP No Operation SAVE Save setup data in the EEPROM memory SCIBR V16 Set RS-232/Rs485 serial communication interface (SCI) baud rate STARTLOG V16 Start the data acquisition STOPLOG Stop the data acquisition © ElectroCraft 2013 378 MPD User Manual 6.2.4.3.12. On line commands Syntax Description (?)GiveMeData Ask one axis to return a 16/32 bit data from memory TakeData Answer to GiveMeData request (??)GiveMeData2 Ask a group of axes to return each a 16/32 bit data from memory TakeData2 Answer to GiveMeData2 request GetMPLData Ask one axis to return a MPL data TakeData Answer to Get MPL Data request GetVersion Ask one axis the firmware version TakeVersion Answer to Get version request Get checksum Ask one axis to return the checksum between 2 addresses from its MPL memory Take checksum Answer to Get checksum request PING Ask a group of axes to return their axis ID PONG Answer to a PING request GETERROR Get last error reported by slaves SAVEERROR Save slave error in EEPROM Remark: The online instructions are intended only for host/master usage and cannot reside in a MPL program. Therefore their syntax is fictive, its only goal being to identify these commands. In the Binary Code Viewer you can “emulate” a GiveMeData request for a MPL variable using syntax ?name and a GiveMeData2 request using syntax ??name. In both cases, name is the MPL variable name. In the Command interpreter, you can check the value of any MPL data, by sending a GiveMeData request using the syntax ?name, where name is the MPL data name. The value returned with the TakeData answer is displayed. Through the command interpreter you may also send a Get checksum request using the syntax: CHECKSUM Start_address, Stop_address. The value returned with Take checksum is displayed. © ElectroCraft 2013 379 MPD User Manual 6.2.4.3.13. Obsolete Instructions The obsolete instructions listed below have been replaced with or included as functionality in other MPL commands. The obsolete instructions may still be used with their syntax (except the ADDGRID, GROUPID and REMGRID commands), but in this case you can’t benefit from the extended functionalities of their equivalents. Obsolete syntax Replace syntax Remarks ADDGRID value16 ADDGRID (value_1, value_2,…) The binary code is identical; the syntax was changed to allow setting adding more than one group. The old syntax is no more supported DISIO#n – Not required anymore. All the I/O pins are already set ENIO#n – Not required anymore. All the I/O pins are already set GROUPID value16 GROUPID (value_1, value_2,…) The binary code is identical; the syntax was changed to allow setting adding more than one group. The old syntax is no more supported MODE CS0 MODE CS1 MODE CS2 MODE CS MODE CS3 MODE GS0 MODE GS1 MODE GS2 MODE GS MODE GS3 MODE PC0 MODE PC1 MODE PC2 MODE PC MODE PC3 MODE PE0 MODE PE1 MODE PE2 MODE PE MODE PE3 MODE PP0 MODE PP1 MODE PP2 MODE PP MODE PP3 MODE PPD0 – © ElectroCraft 2013 It is seen as a particular case of electronic gearing 380 MPD User Manual MODE PPD1 MODE PPD2 MODE PPD3 MODE SC0 MODE SC1 MODE SE0 MODE SE1 MODE SP0 MODE SP1 MODE SPD0 MODE SPD1 MODE SC – MODE SE – MODE SP – – RAOU – Handled automatically REMGRID value16 REMGRID(value_1, value_2,…) The binary code is identical; the syntax was changed to allow setting adding more than one group. The old syntax is no more supported SAOU – Handled automatically SPIBR V16 – Handled automatically STOP – STOP! – STOP0 STOP1 STOP2 STOP3 STOP1! STOP2! STOP3! STOP3! © ElectroCraft 2013 381 MPD User Manual 6.2.5. Instru uctions desc criptions 6.2 2.5.1.1. en absolute load position > !ALPO Sett event whe Syntax !ALPO va alue32 ! if Ab bsoluteLoadP PositionOver value32 !ALPO VA AR32 ! if Ab bsoluteLoadP PositionOver VAR32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets th he event con ndition when the load abso olute position n is equal or over the spe ecified value or the value of the speciffied variable. After you ha ave programm med an event, you o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the mon nitoring of th he event, w when load a absolute position >= vallue32, respec ctively VAR32 2. This operration erasess a previouss programme ed event tha at has occurred. © ElectroC Craft 2013 38 82 MPD U User Manual Example //Stop motion when load position >= 3 rev //Position feedback: 500 lines encoder (2000 counts/rev) !ALPO 6000; //Set event: when load absolute position is >= 3 rev STOP!;//Stop the motion when the event occurs WAIT!;//Wait until the event occurs © ElectroCraft 2013 383 MPD User Manual 6.2 2.5.1.2. !ALPU Sett event whe en absolute load position < Syntax !ALPU va alue32 ! if Ab bsoluteLoadP PositionUnder value32 !ALPU VA AR32 ! if Ab bsoluteLoadP PositionUnder VAR32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets th he event condition when the t load abso olute position is equal or u under the spe ecified value or the value of the speciffied variable. After you ha ave programm med an event, you o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the mon nitoring of th he event, w when load a absolute position <= vallue32, respec ctively VAR32 2. This operration erasess a previouss programme ed event tha at has occurred. Example // /Change sp peed comman nd when lo oad absolut te positio on is <= 10 0 rev © ElectroC Craft 2013 38 84 MPD U User Manual //Position feedback: 500 lines encoder (2000 counts/rev) !ALPU 20000;//Set event: when load absolute position is <= 10 rev CSPD = 13.3333;//new slew speed command = 500[rpm] UPD!; //execute on event WAIT!;//Wait until the event occurs © ElectroCraft 2013 385 MPD User Manual 6.2 2.5.1.3. !AMPO Se et event whe en absolute e motor pos sition > Syntax !AMPO value32 v ! if Ab bsoluteMotorrPositionOverr value32 !AMPO VAR32 V ! if Ab bsoluteMotorrPositionOverr VAR32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets th he event condition when the t motor abssolute positio on is equal or over the spe ecified value or the value of the speciffied variable. After you ha ave programm med an event, you o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the next instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the mon nitoring of th he event, wh hen motor a absolute possition >= vallue32, respec ctively VAR32 2. This operration erasess a previouss programme ed event tha at has occurred. Example © ElectroC Craft 2013 38 86 MPD U User Manual //Reverse when motor position >= 1rev //Position feedback: 500 lines encoder (2000 counts/rev) CACC = 0.1591; //acceleration rate = 500[rad/s^2] CSPD = 40; //jog speed = 1200[rpm] MODE SP; // set trapezoidal speed profile mode UPD; //execute immediate CSPD = -40; //jog speed = -1200[rpm] !AMPO 2000; // Set event: when motor absolute position >= 1 rot WAIT!; //Wait until the event occurs UPD; //Update. Speed command is reversed Remark: You can activate a new motion on a programmed event in 2 ways: • Set UPD! command then wait the event with WAIT!. This will activate the new motion immediately when the event occurs • Wait the event with WAIT!, then update the motion with UPD. This will activate the new motion with a slight delay compared with the first option © ElectroCraft 2013 387 MPD User Manual 6.2 2.5.1.4. !AMPU Set event whe en absolute e load position <= Syntax !AMPU va alue32 ! if Ab bsoluteMotorrPositionUnde er value32 !AMPU VAR32 V ! if Ab bsoluteMotorrPositionUnde er VAR32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets th he event cond dition when th he motor abs olute position n is equal or u under the spe ecified value or the value of the speciffied variable. After you ha ave programm med an event, you o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the mon nitoring of th he event, wh hen motor a absolute possition <= vallue32, respec ctively VAR32 2. This operration erasess a previouss programme ed event tha at has occurred. Example © ElectroC Craft 2013 38 88 MPD U User Manual //Stop when motor position <= -3 rev //Position feedback: 500 lines encoder (2000 counts/rev) CACC = 0.1591; //acceleration rate = 500[rad/s^2] CSPD =-40; //jog speed = 1200[rpm] MODE SP; UPD; //execute immediate !AMPU -6000;// Set event: when motor position is < -3rev STOP!; //Stop when the event occurs WAIT!; //Wait until the event occurs © ElectroCraft 2013 389 MPD User Manual 6.2 2.5.1.5. !CAP Set event e when n function of capture in nput Syntax !CAP ! if CA APture triggerred Operands s – Binary co ode Description Sets th he event cond dition when th he programm med transition occurs on on ne of the 2 ca apture inputs. Typically, on o the capture e inputs are connected th he 1st and 2nd encoder iindex. med transition n occurs on e either of these e inputs, the ffollowing happ pens: When the programm • otor position APOS_MT A is captured and d memorized d in the MPL vvariable CAP PPOS, Mo exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured instead • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, when lo oad position iss captured in CAPPOS. The se election betwe een master and load posittion is done as follows: loa ad position is ssaved in CAP PPOS2 only for the setup p configuration e different sensors for load and ns which use motor and foresee a transmission ratio between the em. For all the other setup urations, the master positio on is saved in n CAPPOS2 configu After you y have prog grammed an event, e you ca an do the follo owing actions: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monittoring of the event, when n the program mmed transition (low to hiigh or high to o low) occurrs on the sellected capturre input. Thiss operation e erases a pre evious progra ammed event that has occu urred. Example // /Stop moti ion on next t encoder index © ElectroC Craft 2013 39 90 MPD U User Manual ENCAPI1; //Enable 1st capture input for low->high transitions !CAP; // Set event on 1st capture (low->high transition) STOP!;//Stop the motion when event occurs WAIT!;//Wait until the event occurs CPOS = CAPPOS; // new command position = captured position CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; WAIT!; //wait for completion © ElectroCraft 2013 391 MPD User Manual 6.2 2.5.1.6. !IN Set eve ent when fu unction of d digital input Syntax !IN#n 0 ! if Inp put#n is 0 !IN#n 1 ! if Inp put#n is 1 Operands s n: inpu ut line numberr (0<=n<=39)) Binary co ode Description Sets the t event co ondition when n the digital input #n be ecomes 0, re espectively 1. The conditiion of the inp put #n is tes sted at each slow loop sa ampling perio od. After you have progra ammed an eve ent, you can do d the followiing actions: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes monitorin ng of the ev vent when th he digital inp put #n beco omes 0 (!IN# #n 0), respec ctively 1 (!IN# #n 1). This operation erasses a previou us programm med event tha at has occurred. Example // / Start mo otion when digital input i #36 i is high !I IN#36 1; // / set even nt when in nput #36 is s high // /Position profile. Position P feedback: f 5 500-lines encoder © ElectroC Craft 2013 39 92 MPD U User Manual CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD!; //execute on event WAIT!;//Wait until the event occurs © ElectroCraft 2013 393 MPD User Manual 6.2 2.5.1.7. !LSN Set event e when function off LSN inputt Syntax !LSN ! if Lim mitSwitchNeg gative active Operands s – Binary co ode Description Sets the event con ndition when the program mmed transitio on occurs at the negative e limit y have prog grammed an e event, you ca an do the follo owing actionss: switch input. After you • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes monitoring g of the even nt when the p rogrammed ttransition occurs at the neg gative limit sw witch input. Th his operation erases a pre evious program mmed event tthat has occu urred. Example // /Reverse when w negati ive limit switch is reached // /Position feedback: 500 lines s encoder ( (2000 coun nts/rev) CA ACC = 0.06 637; //a acceleratio on rate = 200[rad/s^ ^2] CS SPD = -16. .6667; //j jog speed = -500[rpm m] MO ODE SP; UP PD; //e execute imm mediate EN NLSN1;//En nable negat tive limit t switch fo or low->hi igh transit tions !L LSN; //Se et event on n negative e limit swi itch(low-> >high trans sition) WA AIT!;//Wai it until th he event occurs o !M MC; // li imit switch h is activ ve -> quick k stop mod de active WA AIT!;// wa ait until the t motor stops beca ause only then the n new // mo otion comma ands are accepted a © ElectroC Craft 2013 39 94 MPD U User Manual CSPD = 40; //jog speed = 1200[rpm] MODE SP; //after quick stop set again the motion mode UPD; //execute immediate © ElectroCraft 2013 395 MPD User Manual 6.2 2.5.1.8. !LSP Set event e when function off LSP input Syntax !LSP ! if Lim mitSwitchPossitive active Operands s – Binary co ode Description Sets the event con ndition when the program mmed transitiion occurs at the positive e limit switch input. After you y have prog grammed an e event, you ca an do the follo owing actionss: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes monitoring of the even nt when the p programmed ttransition occcurs at the po ositive limit sw witch input. Th his operation erases a pre evious program mmed event tthat has occu urred. Example // /Reverse when w positi ive limit switch is reached // /Position feedback: 500 lines s encoder ( (2000 coun nts/rev) CA ACC = 0.06 637; //a acceleratio on rate = 200[rad/s^ ^2] CS SPD = 16.6 6667; //j jog speed = 500[rpm] MO ODE SP; UP PD; //e execute imm mediate EN NLSP1;//En nable posit tive limit t switch fo or low->hi igh transit tions !L LSP; //Se et event on n positive e limit swi itch(low-> >high trans sition) WA AIT!;//Wai it until th he event occurs o !M MC; // li imit switch h is activ ve -> quick k stop mod de active WA AIT!;// wa ait until the t motor stops beca ause only then the n new // mo otion comma ands are accepted a © ElectroC Craft 2013 39 96 MPD U User Manual CSPD = -40; //jog speed = -1200[rpm] MODE SP; //after quick stop set again the motion mode UPD; //execute immediate © ElectroCraft 2013 397 MPD User Manual 6.2 2.5.1.9. !MC Set ev vent when m motion com mplete Syntax !MC !(set event) e if Motio onComplete Operands s – Binary co ode Description Sets th he event con ndition when the actual m otion is comp pleted. The m motion compllete is set in the t following conditions: • Du uring position control: If UPGRAD DE.11=1, whe en the positio on reference arrives at the e position to reach (commande ed position) and a the positio on error rema ains inside a ssettle band de efined by POSOK KLIM, for a pre eset stabilize time interval defined by TO ONPOSOK If UPGRAD DE.11=0, whe en the positio on reference arrives at the e position to reach (commande ed position) • Du uring speed control, c when the speed refference arrive es at the com mmanded spee ed The motion m complete condition n is reset wh hen a new m motion is started i.e. whe en the update e command – UPD is exec cuted. Remarrk: In case of o steppers controlled c op pen-loop, the motion comp plete conditio on for positio oning is alway ys set when the position n reference a arrives at the e position to reach indepe endently of the e UPGRADE E.11 status. Execution Activate es monitoring g of the even nt when the actual motion is complete ed. This ope eration erases a previous prrogrammed event e that hass occurred. Example // /Execute successive s position profiles // / Position n feedback: : 500 line es encoder (2000 cou unts/rev) PO OSOKLIM = 10; //Set settle ba and to 0.00 05[rot] TO ONPOSOK = 10; //Set stabilize e time to 0 0.01[s] SR RB UPGRADE E, 0xFFFF, 0x0800; // / motion c complete w with settle e band CA ACC = 0.31 183;//accel leration rate r = 1000 0[rad/s^2] CS SPD = 100; ;//slew spe eed = 3000 0[rpm] CP POS = 2000 00;//positi ion comman nd = 10[rot t] CP PR; //posi ition comma and is rel lative © ElectroC Craft 2013 39 98 MPD U User Manual MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; WAIT!; // set event and wait for motion complete ... // start here next move © ElectroCraft 2013 399 MPD User Manual 6.2 2.5.1.10. !PRO Set event e when n position re eference > Syntax !PRO valu ue32 ! if Po ositionReferen nceOver valu ue32 !PRO VAR32 ! if Po ositionReferen nceOver VAR R32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets th he event cond dition when the position re eference is eq qual or over tthe specified value or the value of the specified varriable. After yyou have prog grammed an event, you can do the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the next instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monittoring of the event, when position refe erence >= vallue32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. Example:: // /Stop moti ion when po osition re eference >= = 3 rev © ElectroC Craft 2013 40 00 MPD U User Manual //Position feedback: 500 lines encoder (2000 counts/rev) !PRO 6000; //Set event: when motor position reference is >= 3 rev STOP!;//Stop the motion when the event occurs WAIT!;//Wait until the event occurs © ElectroCraft 2013 401 MPD User Manual 6.2 2.5.1.11. !PRU Set event e when n position re eference < Syntax !PRU valu ue32 ! if PositionR ReferenceUnd der value32 !PRU VAR R32 der VAR32 ! if PositionR ReferenceUnd Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets th he event cond dition when th he position re ference is eq qual or under the specified value or the value of the specified varriable. After yyou have prog grammed an event, you can do the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the next instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monittoring of the event, when position refe erence <= vallue32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. Example:: // /Stop moti ion when po osition re eference >= = 3 rev © ElectroC Craft 2013 40 02 MPD U User Manual //Position feedback: 500 lines encoder (2000 counts/rev) !PRU 6000; //Set event: when position reference is >= 3 rev STOP!;//Stop the motion when the event occurs WAIT!;//Wait until the event occurs © ElectroCraft 2013 403 MPD User Manual 6.2 2.5.1.12. !SRO Set event e when n speed refe erence > Syntax !SRO valu ue32 ! if Sp peedReferencceOver value32 !SRO VAR32 ! if Sp peedReferencceOver VAR3 32 Operands s VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets th he event cond dition when th he speed refe erence is equal or over the e specified va alue or the value of the spe ecified variab ble. After you have program mmed an eve ent, you can d do the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the next instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monittoring of the event, when n speed referrence >= value32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. Example:: // /Stop moti ion when sp peed refer rence >= 31 15 rpm © ElectroC Craft 2013 40 04 MPD U User Manual //Position feedback: 500 lines encoder (2000 counts/rev) !SRO 10.5; //Set event: when speed reference is >= 315 rpm STOP!;//Stop the motion when the event occurs WAIT!;//Wait until the event occurs © ElectroCraft 2013 405 MPD User Manual 6.2 2.5.1.13. !SRU Set event e when n speed refe erence <= Syntax !SRU valu ue32 ! if Sp peedReferencceUnder valu ue32 !SRU VAR R32 ! if Sp peedReferencceUnder VAR R32 Operands s VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets th he event condition when the speed refe ference is equ ual or under tthe specified value or the value of the specified varriable. After yyou have prog grammed an event, you can do the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the next instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monittoring of the event, when n speed referrence <= value32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. Example:: // /Motor is decelerati ing. Start t a positio on profile e when spee ed © ElectroC Craft 2013 40 06 MPD U User Manual //reference < 600 rpm //Position feedback: 500 lines encoder (2000 counts/rev) !SRU 20; //Set event: when position reference is <= 3 rev // prepare new motion mode CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD!; //execute on event WAIT!;//Wait until the event occurs © ElectroCraft 2013 407 MPD User Manual 6.2 2.5.1.14. !TRO Set event e when n torque refe erence >= Syntax !TRO valu ue32 ! if To orqueReferen nceOver value e32 !TRO VAR R32 32 ! if To orqueReferen nceOver VAR3 Operands s VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets th he event cond dition when th he current/torrque referencce is equal orr over the spe ecified value or the value of the speciffied variable. After you ha ave programm med an event, you o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the mon nitoring of th he event, wh hen current/ttorque refere ence >= vallue32, respec ctively VAR32 2. This operration erasess a previouss programme ed event tha at has occurred. Example:: © ElectroC Craft 2013 40 08 MPD U User Manual // Motor will reach a hard stop. Disable control when torque // reference > 1 A = 1984 internal current units !TRO 1984.0; // set event when torque reference > 1 A WAIT!;//Wait until the event occurs AXISOFF; // disable control © ElectroCraft 2013 409 MPD User Manual 6.2 2.5.1.15. !TRU Set event e when torque refe erence <= Syntax !TRU valu ue32 ! if To orqueReferen nceUnder valu ue32 !TRU VAR R32 ! if To orqueReferen nceUnder VAR R32 Operands s VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets the t event co ondition when the curren nt/torque refe erence is eq qual or unde er the specifiied value or the value of the specified d variable. A After you havve programme ed an event, you can do the following actions: a • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the mon nitoring of th he event, wh hen current/ttorque refere ence <= vallue32, respec ctively VAR32 2. This operration erasess a previouss programme ed event tha at has occurred. Example © ElectroC Craft 2013 410 MPD U User Manual // Disable control when torque reference > 1 A = 1984 IU !TRO 1984.0; // set event when torque reference > 1 A WAIT!;//Wait until the event occurs AXISOFF; // disable control © ElectroCraft 2013 411 MPD User Manual 6.2 2.5.1.16. !RPO Set event e when n relative loa ad/motor po osition > Syntax !RPO valu ue32 ! if Re elativePositio onOver value3 32 !RPO VAR32 ! if Re elativePositio onOver VAR3 32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets the event con ndition when the load rela ative position n is equal or over the spe ecified o the value of o the specifie ed variable. T The relative po ement value or osition is the load displace from th he beginning of the actual movement. Remark: The orig gin for the rellative position n measureme ent (MPL vari riable POS0) is set on of the target update mode. Unde der TUM1, P POS0 = TPO OS. Under T TUM0, functio POS0= =APOS_LD. After you y have prog grammed an event, e you ca an do the follo owing actions: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monito oring of the event, when lo oad relative position >= value32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. © ElectroC Craft 2013 412 MPD U User Manual Example //Stop motion when after moving 3 rev //Position feedback: 500 lines encoder (2000 counts/rev) !RPO 6000; //Set event: when load relative position is >= 3 rev STOP!;//Stop the motion when the event occurs WAIT!;//Wait until the event occurs © ElectroCraft 2013 413 MPD User Manual 6.2 2.5.1.17. !RPU Set event e when n relative loa ad/motor po osition < Syntax !RPU valu ue32 ! if Re elativePosition nUnder value e32 !RPU VAR R32 ! if Re elativePosition nUnder VAR3 32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets th he event con ndition when the t load relattive position is equal or u under the spe ecified value or o the value of o the specifie ed variable. T The relative po osition is the load displace ement from th he beginning of the actual movement. Remark: The orig gin for the rellative position n measureme ent (MPL vari riable POS0) is set on of the target update mode. Unde der TUM1, P POS0 = TPO OS. Under T TUM0, functio POS0= =APOS_LD. After you y have prog grammed an event, e you ca an do the follo owing actions: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monito oring of the event, when lo oad relative position <= value32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. © ElectroC Craft 2013 414 MPD U User Manual Example //Move negative and change speed command after 10 rev //Position feedback: 500 lines encoder (2000 counts/rev) !RPU 20000;//Set event: when load relative position is <= 10 rev CSPD = 13.3333;//new slew speed command = 500[rpm] UPD!; //execute on event WAIT!;//Wait until the event occurs © ElectroCraft 2013 415 MPD User Manual 6.2 2.5.1.18. !RT Set ev vent after a wait time Syntax !RT value e32 ! if Re elativeTime > = value32 !RT VAR3 32 ! if Re elativeTime > = VAR32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets th he event cond dition when th he relative tim me is equal orr greater than the 32-bit va alue or the va alue of the specified s long g variable. T The relative ttime RTIME is computed d with formula: RTIME = ATIME – TIIME0, where ATIME is a 32-bit abso olute time counter, mented by 1 at each slow lo oop sampling g period and increm TIME0 0 is the ATIME value when n the wait eve ent was set. A After power o on, TIME0 is set to 0. RTIME is update ed together wiith ATIME, att each slow lo oop sampling period. a RTIME start s ONLY a after the execcution of the ENDINIT (e end of Remark: ATIME and zation) comm mand. Therefo ore you shoulld not set wa ait events beffore executin ng this initializ comma and After you y have prog grammed an event monito oring you nee ed to wait unttil the program mmed event occurs, o using g the MPL com mmand WAIT T!. Otherwise e, the program m will continue e with the nex xt instructions s that may ov verride the eve ent monitoring. Execution Activattes the monitoring of the event e when s ystem relativve time >= value32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. Example // /Introduce a 100 ms delay © ElectroC Craft 2013 416 MPD U User Manual !RT 100; // set event: After a wait of 100 slow-loop periods // 1 slow-loop period = 1ms WAIT!; © ElectroCraft 2013 // wait the event to occur 417 MPD User Manual 6.2 2.5.1.19. !MSO Set event when n motor spe eed >= Syntax !MSO vallue32 ! if Mo otorSpeedOvver value32 !MSO VA AR32 ! if Mo otorSpeedOvver VAR32 Operands s VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets th he event con ndition when the t motor sp eed is equal or over the 32-bit value o or the value of the specifiied fixed variable. After yo ou have prog grammed an event, you can do the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monito oring of the event e when m motor speed >= value32, re espectively VA AR32. This op peration erases a previous s programmed has occurred.. d event that h Example // /Motor is accelerati ing. Stop motion whe en motor © ElectroC Craft 2013 418 MPD U User Manual //speed > 600 rpm //Position feedback: 500 lines encoder (2000 counts/rev) !MSO 20; //Set event: when motor speed is > 600 rpm STOP!;//Stop the motion when the event occurs WAIT!;//Wait until the event occurs © ElectroCraft 2013 419 MPD User Manual 6.2 2.5.1.20. !MSU Set event e when n motor spe eed <= Syntax !MSU vallue32 ! if Mo otorSpeedUn nder value32 !MSU VAR32 ! if Mo otorSpeedUn nder VAR32 Operands s VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets th he event condition when the t motor spe eed is equal o or under the 32-bit value o or the value of the specifiied fixed variable. After yo ou have prog grammed an event, you can do the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monito oring of the event e when m motor speed <= value32, re espectively VA AR32. This op peration erases a previous s programmed has occurred.. d event that h Example // /Motor is decelerati ing. Start t a positio on profile e when moto or // /speed < 600 6 rpm © ElectroC Craft 2013 42 20 MPD U User Manual //Position feedback: 500 lines encoder (2000 counts/rev) !MSU 20; //Set event: when motor speed is < 600 rpm // prepare new motion mode CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD!; //execute on event WAIT!;//Wait until the event occurs © ElectroCraft 2013 421 MPD User Manual 6.2 2.5.1.21. !LSO Set event e when load speed d> Syntax !LSO valu ue32 ! if Lo oadSpeedOve er value32 !LSO VAR R32 ! if Lo oadSpeedOve er VAR32 Operands s VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets the event con ndition when the load spe eed is equal or over the 3 32-bit value o or the ou have prog grammed an event, you can do value of the specifiied fixed variable. After yo the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monittoring of the event e when lo oad speed >= = value32, re espectively VA AR32. This op peration erases a previous s programmed d event that h has occurred.. Example // /Stop moti ion when lo oad speed > 600 rpm © ElectroC Craft 2013 42 22 MPD U User Manual //Load Position feedback: 500 lines encoder (2000 counts/rev) !LSO 20; //Set event: when load speed is > 600 rpm STOP!;//Stop the motion when the event occurs WAIT!;//Wait until the event occurs © ElectroCraft 2013 423 MPD User Manual 6.2 2.5.1.22. !LSU Set event e when load speed d< Syntax !LSU valu ue32 ! if Lo oadSpeedUnd der value32 !LSU VAR R32 ! if Lo oadSpeedUnd der VAR32 Operands s VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets th he event con ndition when the t load spee ed is equal o or under the 32-bit value o or the value of the specifiied fixed variable. After yo ou have prog grammed an event, you can do the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monittoring of the event e when lo oad speed <= = value32, re espectively VA AR32. This op peration erases a previous s programmed d event that h has occurred.. Example // / Start a position profile p wh hen load sp peed < 600 0 rpm // / Load Pos sition feed dback: 500 0 lines enc coder (200 00 counts/r rev) © ElectroC Craft 2013 42 24 MPD U User Manual !LSU 20; //Set event: when motor speed is < 600 rpm // prepare new motion mode CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD!; //execute on event WAIT!;//Wait until the event occurs © ElectroCraft 2013 425 MPD User Manual 6.2 2.5.1.23. !VO Set ev vent when v variable >= Syntax !VO VAR32A, value32 2 ! if Va ar32AOver va alue32 !VO VAR32A, VAR32B B ! if Va ar32AOver VA AR32B Operands s VAR32 2A: fixed or lo ong variable VAR32 2B: fixed or lo ong variable value3 32: 32-bit fixed d or long imm mediate value Binary co ode Description Sets th he event cond dition when th he selected v ariable (any 3 32-bit fixed orr long MPL da ata) is equal or over the specified s valu ue or the valu ue of anotherr 32-bit variab ble. After you have ammed an eve ent, you can do d the followiing actions: progra • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monito oring of the event e when th he selected va ariable >= value32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. Example © ElectroC Craft 2013 42 26 MPD U User Manual //Wait until master position MREF > 500 counts, then activate //electronic gearing slave mode !VO MREF, 500; //Set event when variable MREF is >= 500 GEAR = 1; // gear ratio GEARMASTER = 1; // Gear ratio denominator GEARSLAVE = 1; // Gear ratio numerator EXTREF 2; // read master from 2nd encoder or pulse & dir MASTERRES = 2000; // master resolution MODE GS; //Set as slave, position mode TUM1; //Set Target Update Mode 1 SRB UPGRADE, 0xFFFF, 0x0004;//UPGRADE.2=1 enables CACC limitation CACC = 0.3183; //Limit maximum acceleration at 1000[rad/s^2] UPD!; //execute on event © ElectroCraft 2013 427 MPD User Manual 6.2 2.5.1.24. !VU Set ev vent when v variable <= Syntax !VU VAR3 32A, value32 2 ! if Va ar32AUnder vvalue32 !VU VAR3 32A, VAR32B B ! if Va ar32AUnder V VAR32B Operands s VAR32 2A: fixed or lo ong variable VAR32 2B: fixed or lo ong variable value3 32: 32-bit fixed d or long imm mediate value Binary co ode Description Sets th he event cond dition when th he selected v ariable (any 3 32-bit fixed orr long MPL da ata) is equal or under the specified value or the valu ue of anotherr 32-bit variab ble. After you u have ammed an eve ent, you can do d the followiing actions: progra • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP! • Wait for the pro ogrammed event to occur, with comman nd WAIT! The prrogrammed event e is autom matically erassed when the e event occurrs or if the tim meout for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the ne ext instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monito oring of the event e when th he selected va ariable <= value32, respecctively VAR32 2. This operattion erases a previous pro grammed eve ent that has o occurred. Example © ElectroC Craft 2013 42 28 MPD U User Manual //Wait until master position MREF < 500 counts, then activate //electronic gearing slave mode !VU MREF, 500; //Set event when variable MREF is <= 500 GEAR = 1; // gear ratio GEARMASTER = 1; // Gear ratio denominator GEARSLAVE = 1; // Gear ratio numerator EXTREF 2; // read master from 2nd encoder or pulse & dir MASTERRES = 2000; // master resolution MODE GS; //Set as slave, position mode TUM1; //Set Target Update Mode 1 SRB UPGRADE, 0xFFFF, 0x0004;//UPGRADE.2=1 enables CACC limitation CACC = 0.3183; //Limit maximum acceleration at 1000[rad/s^2] UPD!; //execute on event © ElectroCraft 2013 429 MPD User Manual 6.2 2.5.1.25. GiveMeDa ata/TakeData a Syntax VAR ?V – Operands s Ask k one axis to return a 16/3 32 bit value fro om memory Ans swer to GiveM MeData reque est VAR: 16/32-bit 1 MPL L data: registe er, parameterr, variable or u user variable Remark: The onlin ne instruction ns are intend ded only for h host/master usage and ccannot ogram. There efore their syn yntax is fictive e, the only go oal being to id dentify reside in a MPL pro these commands. nterpreter, yo ou can checkk the value o of any MPL d data, by send ding a In the Command in MeData reque est with synta ax ?VAR. The e value return ned with the TakeData an nswer, GiveM is disp played. The same s syntax may be used d in the Bina ary Code View wer to “emula ate” a GiveM MeData reque est and a Take eData answe er Binary co ode Description Throug gh GiveMeD Data comma and an exte rnal device can requesst data from m one drive/m motor. The requested data can be: • AM memory ffor data (dm) A MPL datta from the RA • A memory location from m the RAM me emory for MP PL programs ((pm) • A memory location from m the EEPRO M SPI-conne ected memoryy (spi) The dimension of th he requested data is speccified in the biinary code through the VT T bit: 0 – 16-b bit, 1 – 32-bit. The data is id dentified by itts memory ad ddress and typ pe: In the expeditor add dress, bit H – the host bit – must be se et to 1 only if the host send ds the MeData reque est via seria al RS-232 lin nk. For deta ails, see seriial communiccation GiveM protoc col description n. The an nswer to a GiiveMeData command is a TakeData m message inclu uding the exp peditor Axis ID D, the address of the data returned and its value. Remark: The Giv veMeData an nd TakeData a commands must be ussed only forr data nges betwee en 2 devices s. In a multii-axis CAN b bus network, the GiveMe eData exchan command must be sent to a sing gle axis. If thiis command is sent to a g group of drive es, the © ElectroC Craft 2013 43 30 MPD U User Manual TakeData answers from different drives will have all the same identifier and therefore can’t be correctly identified. © ElectroCraft 2013 431 MPD User Manual 6.2 2.5.1.26. GiveMeDa ata2/TakeDa ata2 Syntax ??VAR R An nswer to GiveMeData2 req quest – Operands s As sk a group of axes a to return n each a 16/3 32 bit data from memory VAR: 16/32-bit 1 MPL L data: registe er, parameterr, variable or u user variable Remark: The onlin ne instruction ns are intend ded only for h host/master usage and ccannot ogram. There efore their syn yntax is fictive e, the only go oal being to id dentify reside in a MPL pro these commands. e Binary Cod de Viewer you y can to ““emulate” a GiveMeData a2 request a and a In the TakeD Data2 answerr with syntax ??VAR. ? Binary co ode Description Throug gh GiveMeDa ata2 comman nd an extern al device can n request datta from a gro oup of drives//motors, using g a multicast or broadcast message. Th he requested data can be: • A MPL datta from the RA AM memory ffor data (dm) • A memory location from m the RAM me emory for MP PL programs ((pm) • A memory location from m the EEPRO M SPI-conne ected memoryy (spi) The dimension of th he requested data is speccified in the biinary code through the VT T bit: 0 – 16-b bit, 1 – 32-bit. The data is id dentified by itts memory ad ddress and typ pe: The answer a to a GiveMeData a2 command d is a TakeData2 message including the expeditor Axis ID, th he address off the data retu urned and its value. © ElectroC Craft 2013 43 32 MPD U User Manual Remark: The GiveMeData2 and command can be sent simultaneously to a group of drives/motors from a CAN bus network. Even if all the axes answer in the same time, the host will get the TakeData2 answers one by one, prioritized in the ascending order of the expeditors’ axis ID: axis 1 – highest priority, axis 255 – lowest priority. Hence these commands allow optimizing bus traffic, by sending for the same data, a single request to all the drives involved. © ElectroCraft 2013 433 MPD User Manual 6.2 2.5.1.27. GetMPLDa ata/TakeMP PLData Syntax Operands s – As sk one axis to return a MPL L data – An nswer to GetM MPLData requ uest – Remark: The onlin ne instruction ns are intend ded only for h host/master usage and ccannot reside in a MPL pro ogram. There efore their syn yntax is fictive e, the only go oal being to id dentify these commands. Binary co ode Descrription Thro ough GetMPLData comm mand an external device ccan request a MPL data frrom one drive e/motor. The dimension d of the requeste ed data is spe ecified in the b binary code through t the VT V bit: 0 – 16--bit, 1 – 32-biit. The MPL d data is identiffied by its add dress. GetMP PLData instru uction uses a 9-bit shorrt address fo for the MPL data. Bit va alue X specifiies the addres ss range: In the expeditor add dress, bit H – the host bit – must be se et to 1 only if the host send ds the PLData requ uest via seria al RS-232 lin nk. For deta ails, see serial communiccation GetMP protoc col description n. The answer to a GetMPLData G a command iis a TakeMP PLData messsage includin ng the he address off the MPL datta returned an nd its value. expeditor Axis ID, th a TakeMPL LData comma ands are optimized for req quests of MPL L data The GetMPLData and es). For this ttype of data exchanges, GetMPLData a and (registters, parametters, variable TakeM MPLData pro ovide shorter messages a and occupy lless commun nication band dwidth compa ared with Give eMeData and d TakeData. © ElectroC Craft 2013 43 34 MPD U User Manual Remark: The GetMPLData and TakeMPLData commands must be used only for data exchanges between 2 devices. In a multi-axis CAN bus network, the GetMPLData command must be sent to a single axis. If this command is sent to a group of drives, the TakeMPLData answers from different drives will have all the same identifier and therefore can’t be correctly identified. © ElectroCraft 2013 435 MPD User Manual 6.2 2.5.1.28. GetVersion/TakeVers sion Syntax Operands s – As sk one axis to return the firm mware versio on – An nswer to GetV Version reque est – Remark: The onlin ne instruction ns are intend ded only for h host/master usage and ccannot reside in a MPL pro ogram. There efore their syn yntax is fictive e, the only go oal being to id dentify these commands. Binary co ode Description Throug gh GetVersio on command an external d device can req quest the firm mware version n from one drrive/motor. In the expedito or address, b it H – the host bit – must be set to 1 o only if the ho ost sends the e GetVersion n request via a serial RS-2 232 link. For details, see serial communication protocol descripttion. The firrmware versio on has the fo orm: FxyzA, w where xyz is the firmware e number (3 d digits) and A is the firmwa are revision. The T answer to o a GetVersio on command d is a TakeVe ersion age including the expeditor Axis ID and d the ASCII co ode of 4 charracters: 3 dig gits for messa the firm mware numbe er + 1 letter fo or the firmwarre revision. Remark: The GetV Version and TakeVersion n commandss must be use ed only betw ween 2 es. In a multi-axis CAN bus s network, th e GetMPLDa ata command d must be sen nt to a device single axis. If this command c is sent s to a grou up of drives, tthe TakeVers sion answerss from s identifie er and therefo ore can’t be co orrectly identiified. different drives will have all the same 6.2 2.5.1.29. GetChecks sum/TakeC Checksum Syntax Checksum Start, End Ask one axis to retu urn the checkssum between n Start and Sttop addresses s MPL memorry from its Answerr to GetChec cksum requesst Operands s Start: 16-bit 1 unsigne ed integer value representting the checkksum start address © ElectroC Craft 2013 43 36 MPD U User Manual End: 16-bit unsigne ed integer valu ue representi ng the checkksum end add dress Remark: The onlin ne instruction ns are intend ded only for h host/master usage and ccannot reside in a MPL pro ogram. There efore their syn yntax is fictive e, the only go oal being to id dentify these commands. e Command interpreter, you can ge et a checksu um between 2 MPL pro ogram In the addres sses by sendiing a GetChe ecksum requ uest with the ssyntax: Checksum m Start, End Where e, Start, End d represent th he start and e end addresse es for the che ecksum. The value returne ed with the Ta akeChecksu um answer, is displayed. Description Throug gh GetCheck ksum comma and an extern nal device can n check the in ntegrity of the e data saved in a drive/m motor EEPR ROM or RAM M memory. T The memoryy type is sellected d addresses. automatically function of the starrt and the end dress, bit H – the host bit – must be se et to 1 only if the host send ds the In the expeditor add MeData reque est via seria al RS-232 lin nk. For deta ails, see seriial communiccation GiveM protoc col description n. The answer a to a GetChecksu um command d is a TakeC Checksum, which return ns the expeditor axis ID, and a the check ksum result i..e. the sum m modulo 65536 6 of all the me emory ons between the t start and the t end addre esses. locatio 6.2 2.5.1.30. = Assign a 16-bit va alue to a M MPL variablle or a mem mory locatiion Syntax VAR16D V = lab bel se et VAR16D to value of a lab bel VAR16D V = va alue16 se et VAR16D to value16 VAR16D V = VA AR16S se et VAR16D to VAR16S value VAR16D V = VA AR32S(L) se et VAR16D to VAR32S(L) vvalue VAR16D V = VA AR32S(H) se et VAR16D to VAR32S(H) value VAR16D, V dm = value16 se et VAR16D fro om dm to valu ue16 © ElectroC Craft 2013 43 37 MPD U User Manual VAR16D, V dm = VAR16S se et VAR16D fro om dm to VAR R16S VAR16D V = (V VAR16S), Typ peMem se et VAR16D to &(VAR16S) from TM VAR16D V = (V VAR16S+), Ty ypeMem se et VAR16D to &(VAR16S) from T TM, then VA AR16S += 1 (VAR16D), ( Ty ypeMem = va alue16 se et &( VAR16D D) from TM to value16 (VAR16D), ( Ty ypeMem = VA AR16S se et &( VAR16D D) from TM to VAR16S (VAR16D+), ( TypeMem T = value16 v se et &( VAR1 6D) from T TM to value e16, then VA AR16D += 1 (VAR16D+), ( TypeMem T = VAR16S V se et &( VAR16 6D) from TM to VAR16S, then VA AR16D += 1 VAR32D(L) V = value16 se et VAR32D low w word to vallue16 VAR32D(L) V = VAR16S se et VAR32D (L L) to VAR16 vvalue VAR32D(H) V = value16 se et VAR32D hig gh word to va alue16 VAR32D(H) V = VAR16S se et VAR32D (H H) to VAR16 vvalue Legend d: D (destinattion), S (sourc ce). Operands s label: 16-bit 1 address s of a MPL instruction labe el value1 16: 16-bit integer immediatte value VAR16 6x: integer va ariable VAR16 6x VAR32 2x(L): the low w word of VAR R32x long varriable VAR32 2x(H): the hig gh word of VA AR32x long va ariable Dm: da ata memory operand o TypeM Mem: memory y operand. esenting a 16 (VAR1 16x): contents s of variable VAR16x, V repre 6-bit address of a variable ode Binary co © ElectroC Craft 2013 43 38 MPD U User Manual © ElectroCraft 2013 439 MPD User Manual Description Assigns a 16-bit value to a MPL variable or a memory location. The options are: The destination is 16-bit MPL variable and the source is: a 16-bit immediate value, a label, 16-bit MPL variable, high or low part of a 32-bit MPL variable or the contents of a memory location whose address is indicated by a 16-bit MPL variable (a pointer). The destination is a memory location whose address is indicated by a 16-bit MPL variable (a pointer) and the source is: a 16-bit immediate value or a 16-bit MPL variable. The destination is the high or low part of a 32-bit MPL variable and the source is: a 16-bit immediate value or a 16-bit MPL variable. If the pointer variable is followed by a + sign, after the assignment, it is incremented by 1. The memory location can be of 3 types: RAM for data (dm), RAM for MPL programs (pm), EEPROM SPI-connected for MPL programs (spi). © ElectroCraft 2013 440 MPD User Manual Some instructions use u a 9-bit sh hort address for the destin nation variable. Bit value X specifies th he destination n address rang ge: All pre edefined or user-defined MPL M data are e inside these e address ran nges, hence these instruc ctions can be used withoutt checking the e variables ad ddresses. How wever, consid dering future developmentts, the MPL also includes a assignment in nstructions ussing a full add dress on address can be any 16 6-bit value. In this case desstination varia able is where the destinatio ed by “,dm”. followe Execution s a 16-bit valu ue from the so ource to the d destination Copies Example1 1 ar1; int Va La abel1: 1 = MPL pro ogram addr ress // Label1 ... Var1 = Label1; Before in nstruction After instruction Label1 0x1234 Label1 0x1234 Var1 x Var1 0x1234 Example2 2 ar1; int Va ... Var1 = 26438; Before in nstruction Var1 x © ElectroC Craft 2013 After instruction Var1 44 41 26438 MPD U User Manual Example3 int Var1, Var2; ... Var2 = Var1; Before instruction After instruction Var2 0x56AB Var2 0x56AB Var1 x Var1 0x56AB Example4 int Var1; long Var3; ... Var1 = Var3(L); Before instruction After instruction Var3 0x56ABCD98 Var3 0x56ABCD98 Var1 x Var1 0xCD98 Example5 int Var1; long Var3; .... Var1 = Var3(H); Before instruction After instruction Var3 0x56ABCD98 Var3 0x56ABCD98 Var1 x Var1 0x56AB © ElectroCraft 2013 442 MPD User Manual Example6 int Var1; ... Var1, dm = 3321; Before instruction After instruction Var1 Var1 x 3321 Example7 int Var1, Var2; ... Var1, dm = Var2; Before instruction After instruction Var1 0x0A01 Var1 0x0A01 Var2 x Var2 0x0A01 Example8 int Var1, pVar2; ... Var1 = (pVar2), dm; Before instruction After instruction pVar2 pVar2 0x0A01 Data memory 0x0A01 Data memory 0x0A01 0x1234 0x0A01 0x1234 Var1 x Var1 0x1234 © ElectroCraft 2013 443 MPD User Manual Example9 int Var1, pVar2; ... Var1 = (pVar2+), dm; Before instruction After instruction pVar2 pVar2 0x0A01 Data memory 0x0A02 Data memory 0x0A01 0x1234 0x0A02 0x0014 Var1 x Var1 0x0014 Example10 int pVar1; ... (pVar1), spi = 0x5422; Before instruction pVar1 After instruction 0x5100 SPI data memory 0x1100 pVar1 0x5100 SPI data memory x 0x1100 0x5422 (SPI memory offset is 0x4000, i.e. SPI addr = var.addr – 0x4000) © ElectroCraft 2013 444 MPD User Manual Example11 int pVar1; ... (pVar1+), spi = 0x5422; Before instruction pVar1 After instruction 0x5100 SPI data memory 0x1100 pVar1 0x5101 SPI data memory x 0x1100 0x5422 (SPI memory offset is 0x4000, i.e. SPI addr = var.addr – 0x4000) Example12 int pVar1, Var2; ... (pVar1), pm = Var2; Before instruction After instruction pVar1 0x8200 pVar1 0x8200 Var2 0xA987 Var2 0xA987 pm memory 0x8200 data pm memory x © ElectroCraft 2013 0x8200 445 data 0xA987 MPD User Manual Example13 int pVar1, Var2; ... (pVar1+), pm = Var2; Before instruction After instruction pVar1 0x8200 pVar1 0x8201 Var2 0xA987 Var2 0xA987 pm memory 0x8200 data pm memory x 0x8200 data 0xA987 Example14 long Var5; ... Var5(H) = 0xAA55 ; Before instruction After instruction Var5 Var5 0x12344321 0xAA554321 Example15 long Var5; ... Var5(L) = 0xAA55; Before instruction After instruction Var5 Var5 0x12344321 © ElectroCraft 2013 446 0x1234AA55 MPD User Manual Example16 int Var1; long Var5; ... Var5(H) = Var1; Before instruction After instruction Var1 0x7711 Var1 0x7711 Var5 0x12344321 Var5 0x77114321 Example17 int Var1; long Var5; ... Var5(L) = Var1; Before instruction After instruction Var1 0x7711 Var1 0x7711 Var5 0x12344321 Var5 0x12347711 © ElectroCraft 2013 447 MPD User Manual 6.2 2.5.1.31. = Read diigital input((s) and ass sign a 16-b bit MPL varriable t value (Firmware ( v version FAx xx) with their Syntax VAR16D = IN#n read input #n # into VAR1 6D VAR16D = INPUT1, AN NDm read inputs s IN#25 to IN#32 into V VAR16D with h ANDm VAR16D = INPUT2, AN NDm read input IN#33 to I N#39 into V VAR16D with h ANDm VAR16D = INPORT, ANDm A read Enablle, LSP, LSN N and IN#36 to IN#39 into o VAR16D with w ANDm Operands s Var16D D: integer varriable IN#n : the source is s input n (0= > >N PRO OD = (VAR16**value16) >> N VAR16 * VALUE16 << > >N PRO OD = (VAR16A A*VAR16B) > >> N VAR16A * VAR16B << > >N PRO OD = (VAR32**value16) >> N VAR32 * VALUE16 << > N PRO OD = (VAR32**VAR16) >> N VAR32 * VAR16 << N PRO OD = (VAR32**VAR16) << N Operands s VAR16 6D: destinatio on integer varriable VAR16 6S: source intteger variable e VAR32 2D: destinatio on long/fixed variable v VAR32 2S: source lon ng/fixed varia able value16: 16-bit imm mediate intege er value value3 32: 32-bit imm mediate long value v N: resu ult shift factor © ElectroC Craft 2013 48 86 MPD U User Manual Binary code Description Multiplies 2 operands. The first operand (left one) can be a 16-bit or 32-bit MPL variable. The second operand (right one) can be a 16-bit immediate value or another 16-bit MPL variable. The result is saved in a dedicated 48-bit product register left or right shifted by 0 to 15 bits. The MPL long variables PROD and PRODH show the 32LSB respectively the 32 MSB of the product register. © ElectroCraft 2013 487 MPD User Manual Execution Product register = (first operand * second operand) shifted to left or right with the specified number of bits Example1 int Var1; long var2; ... Var1 * 0x125; Var2 = PROD; Before instruction After instruction Var1 0x1256 Var1 0x1256 Product register x Product register 0x00000014FC6E Var2 x Var2 0x0014FC6E Example2 int Var1; long Var2; ... Var1 * 0x125 << 12; Var2 = PRODH; Before instruction After instruction Var1 0x1256 Var1 0x1256 Product register x Product register 0x00014FC6E000 Var2 X Var2 0x00014FC6 Example3 int Var2, Var3; long Var4; ... Var2 * Var3 >> 4; Var4 = PROD; Before instruction After instruction Var2 Var2 © ElectroCraft 2013 0x1256 0x1256 488 MPD User Manual Var3 0x125 Var3 0x125 Product register x Product register 0x000000014FC6 Var4 x Var4 0x00014FC6 Example4 int Var2, Var3; long Var7; ... Var2 * Var3 << 8; Var7 = PROD(H); Before instruction After instruction Var2 0x1256 Var2 0x1256 Var3 0x125 Var3 0x125 Product register x Product register 0x000014FC6E00 Var7 x Var7 0x000014FC Example5 long Var1, Var2; ... Var1 * 0x125; Var2 = PROD; Before instruction After instruction Var1 0x001256AB Var1 0x1256 Product register x Product register 0x000014FD31B7 Var2 x Var2 0x14FD31B7 Example6 long Var1, Var2; ... © ElectroCraft 2013 489 MPD User Manual Var1 * 0x125 << 12; Var2 = PROD(H); Before instruction After instruction Var1 0x001256AB Var1 0x1256 Product register x Product register 0x014FD31B7000 Var2 x Var2 0x014FD31B © ElectroCraft 2013 490 MPD User Manual Example7 long Var2, Var9; int Var3; ... Var2 * Var3 >> 4; Var9 = PROD(H); Before instruction After instruction Var2 0x001256AB Var2 0x001256AB Var3 0x125 Var3 0x125 Product register x Product register 0x0000014FD31B Var9 x Var9 0x0000014F Example8 long Var2, Var9; int Var3; ... Var2 * Var3 << 8; Var9 = PROD; Before instruction After instruction Var2 0x001256AB Var2 0x001256AB Var3 0x125 Var3 0x125 Product register x Product register 0x0014FD31B700 Var9 X Var9 0xFD31B700 6.2.5.1.43. / Syntax VAR32 /= VAR16 Operands divide VAR32 with VAR16 VAR16: the divisor, integer variable © ElectroCraft 2013 491 MPD User Manual VAR32 2: the dividend d, fixed variab ble Binary co ode Description The le eft operand – the dividend d is divided b by the right o operand – th he divisor, an nd the result is saved in th he left operan nd. The divid dend / quotien nt is a 32-bit fixed variable and visor a 16-bit integer i variab ble. the div Execution Left op perand = left operand o / righ ht operand Example d var1; // Define fi ixed variab ble user_1 1 fixed int var2; v // De efine inte eger variab ble user_2 2 var1 = 11.0; var2 = 3; var1 /= var2; Before in nstruction After in nstruction Var1 11.0 (0x xB0000) Var1 3.6666 (0 0x3AAAA) Var2 3 Var2 3 6.2 2.5.1.44. >> Syntax VAR16 >> >= N shift VAR16 V right b by N VAR32 >> >= N shift VAR32 V right b by N PROD >> >= N shift PROD P (produ uct reg.) right by N Operands s VAR16 6: integer variiable VAR32 2: long or fixed variable PROD: 48-bit produ uct register N: shiftt factor © ElectroC Craft 2013 49 92 MPD U User Manual Binary co ode Description The op perand is righ ht shifted with the specified d number of b bits (N). High o order bits are e signextend ded and the lo ow order bits are lost. If the e operand is PROD, the en ntire 48-bit prroduct registe er is right shiftted. Execution Variab ble = Value of variable shiftted to right wiith N bits Example1 1 int Var1; V ... Var1 >>= 4; nstruction Before in 0x x1256 Var1 Example2 2 Afterr instruction Var1 0x0125 long Var1; ... Var1 >>= 12; nstruction Before in Var1 Example3 3 Afterr instruction 0x x1256ABAB Var1 0x0001256 6A PROD >>= 4; © ElectroC Craft 2013 49 93 MPD U User Manual Before instruction Product register © ElectroCraft 2013 After instruction 0x12560000ABCD Product register 494 0x0012560000ABC MPD User Manual 6.2 2.5.1.45. << Syntax VAR16 << <= N shift VAR16 V left byy N VAR32 << <= N shift VAR32 V left byy N PROD << <= N shift PROD P (produ uct reg.) right by N Operands s VAR16 6: integer variiable VAR32 2: long variable PROD: product regiister N: shiftt factor Binary co ode Description The op perand is left shifted with the specified number of b bits (N). High order bits arre lost and th he low order bits are zero oed. If the o operand is PR ROD, the en ntire 48-bit prroduct registe er is left shifte ed. Execution Variab ble = Value of variable shiftted to left with h N bits Example1 1 ar1; int Va ... < 4; Var1 <<= © ElectroC Craft 2013 49 95 MPD U User Manual Before instruction Var1 After instruction 0x1256 Var1 0x2560 Example2 long Var1; ... Var1 <<= 12; Before instruction Var1 After instruction 0x1256ABAB Var1 0x6AABAB000 Example3 PROD <<= 4; Before instruction PROD © ElectroCraft 2013 After instruction 0x12560000ABCD PROD 496 0x2560000ABCD0 MPD User Manual 6.2 2.5.1.46. ABORT Syntax Abort cance elable MPL fu nction ABORT Operands s – Binary co ode Description ABORT T command cancels the e execution of a MPL function called using CA ALLS instructtion. After the e execution of ABORT, the MPL pro ogram contin nues with the e next instructtion after the cancelable c ca all of the funcction. Example .. ... CA ALLS First_function; ; //Cance elable cal ll of First t_function n ST TOP; //Stop the motio on .. ... EN ND; //End of o MPL pro ogram irst_Function: //def finition of f First_Fu unction Fi .. ... CA ALL Second d_Function; ; //Call function Second_Fun nction MO ODE PP; .... RE ET; //R Return from m First_Fu unction Se econd_Function: //de efinition of o First_F Function .. ... GO OTO user_l label, user r_var,EQ;/ //Branch to o user_lab belif //user r_var ==0 ABORT; ; //Cancel the execut tion of Fi irst_Functi ion ext MPL ins struction executed i is STOP; //Ne user_l label: .... RE ET; © ElectroC Craft 2013 //R Return from m Second_f function 49 97 MPD U User Manual 6.2 2.5.1.47. ADDGRID Syntax ADDGRID D (value_1, value_2,…) v Operands s Add the spe ecified groupss to GROUP IID value_ _1, value_2: specify s a grou up number be tween 1 and 8 Binary co ode Description The co ommand adds s more group ps to the grou up ID. On eacch axis, the group ID repre esents a filterr for a multicast transmiss sion. When a multicast m message is re eceived, each h axis compa ares the mess sage group ID D with its own n group ID. If the two group p IDs have att least one grroup in comm mon, the mes ssage is acce epted. For exxample, if an axis is memb ber of group 1 and group 3, it will receiive all the me essages sent with a group ID including group g ID is an n 8-bit intege er value. Each h bit correspo onds to one g group: 1 or grroup 3. The group bit 0 – group 1, bit 1 – group 2… bit 7 – group p 8. After th he execution of this command, the grou up ID value iss modified as follows: • p) 1 occurs in the parenthe esis Bit 0 is set to 1, if (group • Bit 1 is set to 1, if (group p) 2 occurs in the parenthe esis • … • Bit 7 is set to 1, if (group p) 8 occurs in the parenthe esis. Example // /local axis has grou up ID = 1 -> - belongs s to group 1 AD DDGRID (2, 4); //l local axis belongs a also to gro oups 2 and d 4 //ne ew group ID D = 11 (00 0001011b) .. ... [G G4] {STOP;} //s send stop motion m to all axes f from group p 4 //lo ocal axis will w stop too as mem mber of gr roup 4 © ElectroC Craft 2013 49 98 MPD U User Manual 6.2 2.5.1.48. AXISID Syntax AXISID value16 v Set AXIS ID D address AXISID VAR16 V Set AXIS ID D with value o of VAR16 Operands s value1 16: immediate e value between 1 and 255 5 VAR16 6: integer variiable Binary co ode Description The co ommand chan nges the axis s ID. In multip ple-axis config gurations, eacch axis is iden ntified through a unique number betw ween 1 and 255 – the a axis ID. If the e destination n of a age is an axis ID, the mess sage is receivved only by the axis with th he same axis ID. messa After th he execution of this comm mand, the axiss ID is set with h the immedia ecified ate value spe or the value of the 16-bit 1 variable e. Example AX XISID 10; //f from now on n, the loc cal axis ID D is 10 .. ... [1 10] {AXISID 9;} //c change the ID of axi is 10 to 9 (this //in nstruction is send a and execute ed on //th he actual axis a 10) .. ... [9 9] {CSPD = 30;} //Se end CPOS = 30 to axi is 9 (previ ious axis 10) © ElectroC Craft 2013 49 99 MPD U User Manual 6.2 2.5.1.49. AXISOFF Syntax AXISOFF F Operands s AXIIS is OFF (de eactivate control) – Binary co ode Description The co ommand deac ctivates the drive d control lo oops, the refe erence generrator and the PWM output commands for the pow wer stage (a all the switch hing devicess are off). A All the urements rem main active and therefore th he motor currrents, speed, position as w well as measu the supply voltage continue to be updated a and monitore ed. The AXIS SOFF comma and is atically generated when a protection iis triggered o or when the drive Enable input automa goes frrom status en nabled to status disabled. Example // / Execute repetitive e moves. After A each one, set AXISOFF. // / Motor ma ay move fre eely. Rest tart after 20s. Posi ition // / feedback k: 500 line es increme ental encod der (2000 counts/rev v) CA ACC = 0.3183;//accel leration ra ate = 1000 0[rad/s^2] CS SPD = 33.3333;//slew w speed = 1000[rpm] 1 CP POS = 6000;//positio on command = 3[rot] CP PA; //position comma and is abso olute Loop: MO ODE PP; // / position profile CP POS += 600 00; set new w position n command UP PD; //execute immedi iate AX XISON; //Activat te the cont trol loops s and PWM o outputs !M MC; // set event on motion com mplete WA AIT!;//Wait until th he event oc ccurs i.e. . the motor r stops AXISOFF; A // /Deactivate e the cont trol loops and PWM o outputs !RT 20000; //set a 20s 2 delay (1s ( = 1000 0 slow loop p sampling gs) AIT!; //Wai it until th he event occurs (to pass the 20s) WA GO OTO Loop; © ElectroC Craft 2013 //Restart t the motio on 50 00 MPD U User Manual 6.2 2.5.1.50. AXISON Syntax AXISON Operands s AXIS is ON (activate co ontrol) – Binary co ode Description The co ommand activ vates the driv ve control loo ops, the referrence genera ator and the PWM output commands for f the powe er stage. Th e AXISON ccommand restores the n normal on after an AXISOFF. A It is s typically use ed following a fault reset co ommand FAU ULTR, operatio or afterr the drive/mo otor Enable input goes from m status disab bled to statuss enabled. When AXISON A is set after an AXISOFF A com mmand, the re eference gen nerator resum mes its calculations for last programme ed motion m mode from th he same poiint left beforre the d/motor has moved m during g AXISOFF, itts actual values for positio on and AXISOFF. If the load uite a lot from m the values o of the target p position and speed provided by speed may differ qu erence genera ator. In order update the re eference generator: the refe • Set again the mo otion mode, even e if it rema ains the same e. The motion mode comm mands, omatically se et the target update mod de zero (TUM M0), which u updates the target auto position and spee ed with the ac ctual measure ed values of tthe load posittion and spee ed • Exe ecute update command c UP PD • Exe ecute AXISON N If first AXISON A is iss sued after power on before e setting any motion mode e, the drive applies zero vo oltages to the e motor. Example // / Execute repetitive e moves. After A each one, set AXISOFF. // / Motor ma ay move fre eely. Rest tart after 20s. Posi ition // / feedback k: 500 line es increme ental encod der (2000 counts/rev v) CA ACC = 0.3183;//accel leration ra ate = 1000 0[rad/s^2] CS SPD = 33.3333;//slew w speed = 1000[rpm] 1 CP POS = 6000;//positio on command = 3[rot] CP PA; //position comma and is abso olute Loop: MO ODE PP; // / position profile CP POS += 600 00; set new w position n command UP PD; //execute immedi iate © ElectroC Craft 2013 50 01 MPD U User Manual AXISON; //Activate the control loops and PWM outputs !MC; // set event on motion complete WAIT!;//Wait until the event occurs i.e. the motor stops AXISOFF; //Deactivate the control loops and PWM outputs !RT 20000; //set a 20s delay (1s = 1000 slow loop samplings) WAIT!; //Wait until the event occurs (to pass the 20s) GOTO Loop; © ElectroCraft 2013 //Restart the motion 502 MPD User Manual 6.2 2.5.1.51. BEGIN Syntax BEGIN Beginning g of a MPL pro ogram Operands s – Binary co ode Description This command c mu ust be the first in a MP PL program. In the AUTORUN mode e, the drive/m motor reads the t first EEPR ROM memory ry location at address 0x4 4000 and che ecks if the bin nary code is 0x649C 0 corre esponding to the MPL insttruction BEGIIN. If this con ndition is true, the MPL prrogram from the t EEPROM M memory is executed sta arting with the e next ction after BE EGIN. If the e condition iss false, the d drive/motor e enters in the slave instruc mode and a waits to receive r comm mands from a host via a co ommunication n channel. Example BE EGIN; // Starti ing point of o a MPL p program .. .. EN NDINIT; //E End of init tializatio on ... ND; EN © ElectroC Craft 2013 //e end of main n section of a MPL p program 50 03 MPD U User Manual 6.2 2.5.1.52. CALL Syntax CALL Lab bel Unconditiona U l CALL CALL vallue16 l CALL Unconditiona U CALL VA AR16 l CALL Unconditiona U CALL Lab bel, VAR, Fla ag CALL C if VAR R Flag 0 CALL vallue16, VAR, Flag F CALL C if VAR R Flag 0 CALL VA AR16, VAR, Flag F CALL C if VAR R Flag 0 Operands s Label: a label provid ding the 16-bit value of a M MPL function address Value1 16: immediate e 16-bit of a MPL M function address VAR16 6: integer variiable containing the MPL ffunction addre ess VAR: 16 1 or 32-bit MPL M test varia able compared d with 0 Flag: one o of the con nditions: EQ, NEQ, LT, LE Q, GT, GEQ © ElectroC Craft 2013 50 04 MPD U User Manual Binary code Description Calls a MPL function (subroutine). A MPL function is a set of MPL commands which starts with a label and ends with the RET instruction. The label gives the MPL function address and name. MPL function address may also be specified by an immediate value or by the value of a 16-bit MPL variable. The call can be unconditional or unconditional. In a conditional call, a condition is tested. If the condition is true the MPL function is executed, else the next MPL command is carried out. The condition is specified by a 16-bit or 32-bit test variable (VT=0 for 16-bit variable and VT = 1 for 32-bit variable) and a test condition added after the label with the MPL function address. The test variable is always compared with zero. The possible test conditions are: © ElectroCraft 2013 505 EQ if VAR = 0 NEQ if VAR ≠ 0 LT if VAR < 0 LEQ if VAR ≤ 0 GT if VAR > 0 GEQ if VAR ≥ 0 MPD User Manual Example CALL Function1, var1, GEQ; //call Function1 if i_var1 >= 0 CALL Function1, var1, EQ; //call Function1, if i_var1 = 0 CALL Function1, var1, NEQ; //call Function1, if i_var1 != 0 CALL Function1; //call Function1 unconditionally ... END; // end of MPL program main section Function1: ... RET; © ElectroCraft 2013 506 MPD User Manual 6.2 2.5.1.53. CALLS CALLS Cancelable calll of a MPL function Syntax CALLS Label Cancelable C CALL C of a MP PL function CALLS VAR16 V Cancelable C CALL C with add dress set in V VAR16 Operands s Label: 16-bit progra am memory address VAR16 6: integer variiable Binary co ode Description Calls a MPL functio on (subroutine e) with possib bility to interru upt the functio on execution using ABOR RT command. This is a can ncelable call. A MPL functtion is a set o of MPL comm mands which starts with a label and ends e with the e RET instrucction. The lab bel gives the e MPL on address and a name. MPL M function n address m may also be e specified b by an functio immed diate value or by the value of a 16-bit M PL variable. Only one o function may m be called with a cance elable call at a time. A can ncelable call isssued while another a one is still active e (the called function is iin execution)) is ignored a and a comma and error is set in error register r MER R.14. Also sta atus register low SRL.7 is set. While a cancelable call is active, SRL.8 = 1. Example .. .. CC CALL fct1; ; //c cancelable call of F Function1 ST TOP; .. .. EN ND; Function n1: // Function1 definitio on ... ABORT; © ElectroC Craft 2013 // if this co ommand is encountere ed or 50 07 MPD U User Manual // got via a communication channel ... // next instruction executed is STOP RET; © ElectroCraft 2013 508 MPD User Manual 6.2 2.5.1.54. CANBR Syntax CANBR value16 v Set CA AN-bus Baud Rate to value e16 CANBR VAR16 V Set CA AN-bus Baud Rate to VAR R16 Operands s value1 16: 16-bit unsiigned integer immediate va alue VAR16 6: 16-bit integ ger variable Binary co ode Description Sets the baud rate and a bit sampling timing fo r the CAN-bu us communica ation channel. The aud settings can c be provide ed either as a an immediate e value or by tthe value of a MPL new ba variable e. In both cas ses, the possible values arre: The cu urrent CAN-bus settings are a saved in tthe MPL regiister CBR, an nd may be re ead at any mo oment. The CA AN-bus baud rate is set att power on ussing the follow wing algorithm m: a. With the value read r from the EEPROM se etup table b. If th he setup table e is invalid, with w the last ba aud rate read d from a valid setup table c. If th here is no baud rate set by y a valid setu p table, with 5 500kb Remarrks: • © ElectroC Craft 2013 Us se this comma and when a drive/motor d op perates in AU UTORUN (aftter power on starts to execute e the MPL M program m from the EEP PROM) and iit must communicate with a host at a CAN baud d rate differen nt from the de efault value. In this case, the MPL pro ogram ust start with a CAN baud rate r change. mu 50 09 MPD U User Manual • An alternate solution to the above case is to set via CANBR command the desired baud rate and then to save it in the EEPROM, with the command SAVE. After a reset, the drive/motor starts directly with the new baud rate, if the setup table was valid. Once set, the new default baud rate is preserved, even if the setup table is later on disabled, because the default CAN baud rate is stored in a separate area of the EEPROM. Example CANBR 0x1273; // set CAN-bus for 1Mb © ElectroCraft 2013 510 MPD User Manual 6.2 2.5.1.55. CHECKSU UM Syntax CHECKS SUM, TM Val_ _S, Val_E, VA ARD Checksum betwee en addresses Val_S and V Val_E en addresse es set in varriables CHECKS SUM, TM VAR R_S, VAR_E, VARD Checksum betwee _S and VAR_ _E VAR_ Operands s Val_S: 16-bit unsign ned integer va alue represen nting the checcksum start address Val_E: 16-bit unsigned integer va alue representting the checksum end address VAR_S S: 16-bit variab ble containing g the checksu um start addre ess VAR_E E: 16-bit variab ble containing g the checksu um end addre ess VARD: 16-bit variablle containing the checksum m result TM: Memory type (s see TypeMem m table below w) Binary co ode Description Compu utes the sum module 6553 36 of all the memory loca ations betwee en a start ad ddress and an end address s. The start address a and tthe end addrress may be specified as 16-bit ed immediate e values or via a 2 16-bit MP L variables. T The checksum m result is savved in unsigne a 16-bit destination variable. The e memory loccation can be of 3 types: R RAM for data (dm), or MPL progra ams (pm), EE EPROM SPI-cconnected forr MPL program ms (spi). RAM fo Example // / compute checksum between b EEP PROM addre esses 0x500 00 and 0x5 5007 in nt user_var; .. ... © ElectroC Craft 2013 511 MPD U User Manual CHECKSUM, spi 0x5000, 0x5007, user_var; // user_var = checksum value Before instruction After instruction user_var EEPROM 0x5000 x start address 0xB004 user_var EEPROM 0x5000 0xD467 start address 0xB004 EEPROM address 0x5001 0x0FF1 EEPROM address 0x5001 0x0FF1 EEPROM address 0x5002 0x0366 EEPROM address 0x5002 0x0366 EEPROM address 0x5003 0x0404 EEPROM address 0x5003 0x0404 EEPROM address 0x5004 0x0C09 EEPROM address 0x5004 0x0C09 EEPROM address 0x5005 0x0010 EEPROM address 0x5005 0x0010 EEPROM address 0x5006 0x00E7 EEPROM address 0x5006 0x00E7 EEPROM address 0x5007 0x0008 EEPROM address 0x5007 0x0008 © ElectroCraft 2013 512 MPD User Manual 6.2 2.5.1.56. CIRCLE Only available on multii-axis Motion Controller Syntax CIRCLE1 Radius, The eta_inc CIRCLE2 2 Radius, The eta_start Operands s Vector CIRCLE C segm ment Radius s – circle radius Theta_ _start – start angle a for circu ular segment Theta_inc – angle in ncrement for circular c segm ment Binary co ode Description CIRCLE E1 and CIRC CLE2 define a circular se gment for 2D D trajectory e executed in V Vector Mode. Positive values for Theta_ _inc mean C CW moveme ent while negative values mean ovement. CW mo Based on Radius, Theta_inc and Theta_sstart the MP PL compiler from Motion nPRO s the actual parameters p u sed by the m motion controller to generate the Developer computes oints for slave e axes. PVT po If the po oints are sent from a host then the follo owing relation ns must be ussed to compute the actual parameters p of the circular segment: © ElectroC Craft 2013 513 MPD U User Manual Example // Vector mode – circle with radius 3.14mm. Position feedbacks: 500 // lines incremental encoder SETMODE 0xCF00; //Clear buffer VPLANE (A, B, C); //Define coordinate system and tangent axis RESRATIOX=0u; RESRATIOY=0u; NLINESTAN=2000; MODE VM; // Set Vector Mode // Circular segment of radius 3.14159[mm], with initial angle 0[deg] and angle increment 360[deg]) CIRCLE1 1L, 360.; CIRCLE2 1L, 0.; UPD; //Execute immediate // Insert End Segment VSEG1 0L, 0L; VSEG2 0L, 0L; © ElectroCraft 2013 514 MPD User Manual 6.2 2.5.1.57. CPA Syntax CPA Command C Po osition is Abso olute Operands s – Binary co ode Description After the t executio on of this in nstruction, al l subsequen nt position ccommands w will be considered as abs solute in the following m motion modess: trapezoidal profiles, S--curve profiles s, PVT and PT. P This setting remains un ntil the executtion of a CPR R command. Example // /Position profile // /Position feedback: 500 lines increment tal // / encoder (2000 coun nts/rev) CA ACC = 0.3183;//accel leration ra ate = 1000 0[rad/s^2] CS SPD = 16.6667;//slew w speed = 500[rpm] 5 CP POS = 12000;//positi ion command d = 6[rot] ] CP PA; //position comma and is abso olute MO ODE PP; TU UM1; //set Target Up pdate Mode 1 UP PD; //execute immedi iate © ElectroC Craft 2013 515 MPD U User Manual 6.2 2.5.1.58. CPR Syntax CPR Command C Po osition is Rela ative Operands s – Binary co ode Description After the t executio on of this in nstruction, al l subsequen nt position ccommands w will be considered as rela ative in the following mo otion modes: trapezoidall profiles, S--curve profiles s, PVT and PT. P This settin ng remains un ntil the execu ution of a CPA A command. In the trapezo oidal profile mode, the position to rea ach can be ccomputed in 2 ways: standard (default) or additive e. In standarrd relative m ode, the possition to reacch is compute ed by g the position n increment to t the instan ntaneous possition in the m moment whe en the adding comma and is executted. In the additive relative e mode, the p position to rea ach is computted by adding g the position n increment to t the previo ous position tto reach, ind dependently o of the moment when the command c was s issued. ve mode is activated byy setting ACR R.11 = 1 an nd is automa atically The additive relativ ed after an update comma and UPD, wh hich sets ACR R.11 = 0 resttoring the standard disable relative e mode. Example // /Position profile // /Position feedback: 500 lines increment tal // / encoder (2000 coun nts/rev) CA ACC = 0.3183;//accel leration ra ate = 1000 0[rad/s^2] CS SPD = 16.6667;//slew w speed = 500[rpm] 5 CP POS = 7000;//positio on command = 3.5[rot t] CP PR; //position comma and is rela ative MO ODE PP; TU UM1; //set Target Up pdate Mode 1 UP PD; //execute immedi iate !M MC; WAIT!; //wait fo or completi ion 6.2 2.5.1.59. DINT Syntax © ElectroC Craft 2013 516 MPD U User Manual DINT Disable D MPL INTerrupts s Operands – Binary co ode Description After the t execution n of this ins struction, all the MPL in nterrupts are globally dissabled indepe endently of the eir status in th he interrupt ccontrol registe er ICR. Use th he EINT instru uction to glob bally enable MPL M interrupts s. After power p on, the e MPL interrup pts are globa ally enabled to ogether with the MPL interrupts Int0, Int1, Int2 and d Int3. These e interrupts h handle the d drive/motor prrotections an nd the u a defau ult set of interrrupt service ro outines (ISR)). transitiions on the Enable input, using Remarrk: Some of the t drive/moto or protectionss may not worrk properly if the MPL Interrupts are not handled corrrectly. In orde er to avoid thiis situation ke eep in mind th he following rrules: • The MPL interrup pts must be kept globallyy enabled to allow executtion of the IS SR for e MPL interru upts triggered d by protection g a MPL interrrupt executio on, the those ns. As during MPL L interrupts arre globally diisabled, you should keep p the ISR as short as posssible, witho out waiting loo ops. If this is not possible, you must glo obally enable e the interruptts with EINT T command during d your IS SR execution. • If you modify the interrupt serrvice routines for Int 0 to IInt 4, make ssure that you u keep o MPL commands c fro om the defau ult ISR. Put in other words, you may add d your the original own commands, but these should s not in nterfere with the original MPL comm mands. eover, the orig ginal MPL com mmands musst be present in all the ISR R execution pa aths. More Example DI INT; //globally disa able all MP PL interru upts © ElectroC Craft 2013 517 MPD U User Manual 6.2 2.5.1.60. DIS2CAPI Syntax DIS2CAP PI Operands s DISable D 2nd CAPture C Inde ex – Binary co ode Description After the execution n of this instru uction the 2n nd capture/en ncoder index input capabiility to detect transitions is disabled. he EN2CAPI0 0 or EN2CAP PI1 instructio ons to enable e this input ccapability to d detect Use th high-lo ow or low-high h transitions. Example DI IS2CAPI; //disable 2nd 2 capture e/encoder index inpu ut 6.2 2.5.1.61. DISCAPI Syntax DISCAPI s Operands DISable D CAP Pture Index – Binary co ode Description After the execution n of this instrruction the 1sst capture/en ncoder index input capabiility to detect transitions is disabled. he ENCAPI0 or o ENCAPI1 instructions tto enable thiss input capab bility to detectt highUse th low or low-high tran nsitions. Example DI ISCAPI; //disable 1s st capture/ /encoder i index input t © ElectroC Craft 2013 518 MPD U User Manual 6.2 2.5.1.62. DISLSN Syntax DISLSN Operands s DISable D Limitt Switch Nega ative – Binary co ode Firmware e version FAx xx Firmware e version FBx xx Description After the execution of this instru uction, the ne egative limit sswitch input ccapability to d detect ed. transitiions is disable Use th he ENLSN0 or o ENLSN1 in nstructions to o enable this input capabiility to detect highlow or low-high tran nsitions. puts i.e. to prrotect againstt accidental m moves Remarrk: The main task of the liimit switch inp outside e the working g area is perfo ormed indepe endently of the e fact that the e limit switch iinputs are enabled or not to t detect transitions Example DI ISLSN; //disable LSN N input cap pability t to detect t transition ns © ElectroC Craft 2013 519 MPD U User Manual 6.2 2.5.1.63. DISLSP Syntax DISLSP Operands s DISable D Limitt Switch Posittive – Binary co ode Firmware e version FAx xx Firmware e version FBx xx Description After the execution of this instru uction, the po ositive limit sswitch input ccapability to d detect ed. transitiions is disable Use th he ENLSP0 orr ENLSP1 ins structions to e enable this input capabilityy to detect hig gh-low or low--high transitio ons. Remarrk: The main task of the liimit switch inp puts i.e. to prrotect againstt accidental m moves outside e the working g area is perfo ormed indepe endently of the e fact that the e limit switch iinputs are enabled or not to t detect transitions Execution o detect trans itions Disable positive limit switch input capability to Example DI ISLSN; //disable LSN N input cap pability t to detect t transition ns © ElectroC Craft 2013 52 20 MPD U User Manual 6.2 2.5.1.64. EINT Syntax EINT Enable E MPL INTerrupts I Operands s – Binary co ode Description After the t execution n of this insttruction, the MPL interrup pts are globa ally enabled. If an interrupt flag is set and the interrupt is enab bled in the intterrupt contro ol register ICR R, the nd the associiated interrup pt service rou utine is called d. The interrupt request is accepted an nterrupts can be globally disabled using g the DINT insstruction. MPL in Example EI INT; //globally enab ble all MPL L interrup pts 6.2 2.5.1.65. EN2CAPI0 0 Syntax EN2CAPII0 Operands s Enable E 2ndCA APture Indexx 1->0 – Binary co ode Description Enable es 2nd capturre/encoder in ndex input ca pability to de etect a transition from 1(hig gh) to 0(low). When the firrst transition occurs: o • he input capa ability to dete ect transitionss is disabled d. It must be enabled aga ain to Th de etect another transition t • Mo otor position APOS_MT A is s captured an d memorized d in the MPL vvariable CAP PPOS, exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured insttead • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, l when lo oad position iss captured in CAPPOS. © ElectroC Craft 2013 52 21 MPD U User Manual The se election betwe een master and load posit ion is done as follows: load position is ssaved in CAP PPOS2 only for the setup p configuration ns which use e different sensors for load and motor and foresee a transmission ratio between the em. For all the other setup urations, the master m positio on is saved in n CAPPOS2. configu Example // /Stop moti ion on next t 2nd enco oder index EN N2CAPI0; //Set / event t: When th he 2nd enco oder index x goes high h->low !C CAP; ST TOP!;//Sto op the moti ion when event e occur rs WA AIT!;//Wai it until th he event occurs o CP POS = CAPP POS; // new w command position = captured d position CP PA; //posi ition comma and is abs solute MO ODE PP; TU UM1; //set t Target Up pdate Mode e 1 UP PD; //exec cute immedi iate !M MC; WAIT!; //wait fo or completi ion 6.2 2.5.1.66. EN2CAPI1 Syntax EN2CAPII1 Operands s Enable E 2ndCA APture Indexx 0->1 – ode Binary co Description Enable es 2nd capture/encoder in ndex input ca apability to de etect a transittion from 0(lo ow) to 1(high). When the first transition occurs: • he input capa ability to dete ect transitionss is disabled d. It must be enabled aga ain to Th de etect another transition t • Mo otor position APOS_MT A is s captured an d memorized d in the MPL vvariable CAP PPOS, exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured insttead © ElectroC Craft 2013 52 22 MPD U User Manual • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, l when lo oad position iss captured in CAPPOS. The se election betwe een master and load posit ion is done as follows: load position is ssaved in CAP PPOS2 only for the setup p configuration ns which use e different sensors for load and motor and foresee a transmission ratio between the em. For all the other setup urations, the master m positio on is saved in n CAPPOS2. configu Example // /Stop moti ion on next t 2nd enco oder index EN N2CAPI1; //Set / event t: When th he 2nd enco oder index x goes low->high !C CAP; ST TOP!;//Sto op the moti ion when event e occur rs WA AIT!;//Wai it until th he event occurs o CP POS = CAPP POS; // new w command position = captured d position CP PA; //posi ition comma and is abs solute MO ODE PP; TU UM1; //set t Target Up pdate Mode e 1 UP PD; //exec cute immedi iate !M MC; WAIT!; //wait fo or completi ion 6.2 2.5.1.67. ENCAPI0 Syntax ENCAPI0 0 Operands s Enable E CAPture Index 1-> >0 – ode Binary co Description Enable es 1st capture/encoder ind dex input cap pability to dettect a transitiion from 1(hig gh) to 0(low). When the firrst transition occurs: o • © ElectroC Craft 2013 he input capa ability to dete ect transitionss is disabled d. It must be enabled aga ain to Th de etect another transition t 52 23 MPD U User Manual • Motor position APOS_MT is captured and memorized in the MPL variable CAPPOS, except the case of open-loop systems, where reference position TPOS is captured instead • Master position APOS2 or load position APOS_LD is captured and memorized in the MPL variable CAPPOS2, except the case of steppers controlled open loop with an encoder on the load, when load position is captured in CAPPOS. The selection between master and load position is done as follows: load position is saved in CAPPOS2 only for the setup configurations which use different sensors for load and motor and foresee a transmission ratio between them. For all the other setup configurations, the master position is saved in CAPPOS2. Example //Stop motion on next 1st encoder index ENCAPI0; //Set event: When the 1st encoder index goes high->low !CAP; STOP!;//Stop the motion when event occurs WAIT!;//Wait until the event occurs CPOS = CAPPOS; // new command position = captured position CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; WAIT!; //wait for completion © ElectroCraft 2013 524 MPD User Manual 6.2 2.5.1.68. ENCAPI1 Syntax ENCAPI1 1 Operands s Enable E CAPture Index 0-> >1 – Binary co ode Description Enable es 1st capturre/encoder ind dex input cap pability to de etect a transittion from 0(lo ow) to 1(high). When the first transition occurs: • he input capa ability to dete ect transitionss is disabled d. It must be enabled aga ain to Th de etect another transition t • Mo otor position APOS_MT A is s captured an d memorized d in the MPL vvariable CAP PPOS, exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured insttead • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, l when lo oad position iss captured in CAPPOS. The se election betwe een master and load posit ion is done as follows: load position is ssaved in CAP PPOS2 only for the setup p configuration ns which use e different sensors for load and motor and foresee a transmission ratio between the em. For all the other setup urations, the master m positio on is saved in n CAPPOS2. configu Example // /Stop moti ion on next t 1st enco oder index EN NCAPI1; // /Set event: : When the e 1st encod der index goes low-> >high !C CAP; ST TOP!;//Sto op the moti ion when event e occur rs WA AIT!;//Wai it until th he event occurs o CP POS = CAPP POS; // new w command position = captured d position CP PA; //posi ition comma and is abs solute MO ODE PP; TU UM1; //set t Target Up pdate Mode e 1 UP PD; //exec cute immedi iate !M MC; WAIT!; //wait fo or completi ion © ElectroC Craft 2013 52 25 MPD U User Manual 6.2 2.5.1.69. END Syntax END END E of a MPL program Operands s – Binary co ode Description The END E comman nd indicates the end of a MPL prog gram main ssection. Next MPL instruc ctions (if pres sent) are not executed. Affter this comm mand the MP PL program sshould contain n MPL functio ons and MPL L interrupt se ervice routiness as well as other data likke the cam ta ables. The EN ND command d effectively sstops the exe ecution a MP PL program p putting the driv ve/motor in a wait loop for MPL comma ands received d via a commu unication cha annel. Remarrk: The END instruction does d not mod dify the contrrol loops. Use e MPL comm mands AXISON / AXISOFF F to enable / disable d the co ontrol loops, tthe reference e generator an nd the o PWM outputs. Example // Starti ing point of o a MPL p program BE EGIN; .. .. EN NDINIT; //E End of init tializatio on ... //e end of main n section of a MPL p program ND; EN 6.2 2.5.1.70. ENDINIT Syntax END E of INITia alization ENDINIT s Operands – Binary co ode © ElectroC Craft 2013 52 26 MPD U User Manual Description The ENDINIT instru uction marks the END of the INITializa ation part of the MPL program. ommand use es the availab ble setup data a to perform key initializattions, but doe es not This co activatte the contro ollers or the PWM outpu ts. These arre activated with the AX XISON comma and. After power p on, th he ENDINIT command m may be exe ecuted only once. Subsequent ENDIN NIT commands are ignorred. The first AXISON ccommand mu ust be T command. executted only after the ENDINIT Example BE EGIN; // Starti ing point of o a MPL p program .. .. EN NDINIT; //E End of init tializatio on ... //e end of main n section of a MPL p program ND; EN 6.2 2.5.1.71. ENEEPRO OM Syntax ENEEPROM s Operands ENnable e communicattion with the E EEPROM – Binary co ode Description Enables the SPI-ba ased commu unication with h the drive/m motor EEPRO OM after thiss was eedback deviices like SSI or EnDat encoders, whicch use disabled by the initialization of fe the sam me SPI link as the EEP PROM. This initialization is done during the ENDINIT comma and. The EN NEEPROM co ommand is in ntended for th he hosts workking with ElecctroCraft drive es set in conffigurations with w SSI or EnDat encod ders as possition feedbacck. Following g this comma and, the intern nal SPI-link with w the SSI o or EnDat enccoders is disa abled and the e SPIlink witth the EEPR ROM is enabled. This o offers accesss to the drivve EEPROM after execution of the END DINIT comma and, without rresetting the d drives. EEPROM co ommand musst be execu uted only AF FTER issuing g the Remarrk: The ENE comma ands AXISOF FF and END which w stop the e motor contro ol and MPL p program execution Example NEEPROM; // enable EEPROM E EN © ElectroC Craft 2013 52 27 MPD U User Manual 6.2 2.5.1.72. ENIO 6.2 2.5.1.73. ENLSN0 Syntax ENIO Operands s – Binary co ode Description Example EN NIO; Syntax Enable E Limit Switch Negattive 1->0 ENLSN0 s Operands – Binary co ode Firmware e version FAx xx © ElectroC Craft 2013 52 28 MPD User Manual Firmware version FBxx Description Enables negative limit switch input capability to detect a transition from 1(high) to 0(low). When the first transition occurs: • The input capability to detect transitions is disabled. It must be enabled again to detect another transition • Motor position APOS_MT is captured and memorized in the MPL variable CAPPOS, except the case of open-loop systems, where reference position TPOS is captured instead • Master position APOS2 or load position APOS_LD is captured and memorized in the MPL variable CAPPOS2, except the case of steppers controlled open loop with an encoder on the load, when load position is captured in CAPPOS. The selection between master and load position is done as follows: load position is saved in CAPPOS2 only for the setup configurations which use different sensors for load and motor and foresee a transmission ratio between them. For all the other setup configurations, the master position is saved in CAPPOS2. Example //Reverse when the active low negative limit switch is reached //Position feedback: 500 lines encoder (2000 counts/rev) CACC = 0.0637; //acceleration rate = 200[rad/s^2] CSPD = -16.6667; //jog speed = -500[rpm] MODE SP; UPD; //execute immediate ENLSN0;//Enable negative limit switch for high->low transitions !LSN; //Set event on negative limit switch(high->low transition) WAIT!;//Wait until the event occurs !MC; // limit switch is active -> quick stop mode active WAIT!;// wait until the motor stops because only then the new // motion commands are accepted CSPD = 40; //jog speed = 1200[rpm] MODE SP; //after quick stop set again the motion mode UPD; //execute immediate 6.2.5.1.74. ENLSN1 Syntax ENLSN1 © ElectroCraft 2013 Enable Limit Switch Negative 0->1 529 MPD User Manual Operands s – Binary co ode Firmware e version FAx xx Firmware e version FBx xx Description Enable es negative limit switch inp put capability to detect a transition from m 0(low) to 1((high). When the first trans sition occurs: • he input capa ability to dete ect transitionss is disabled d. It must be enabled aga ain to Th de etect another transition t • Mo otor position APOS_MT A is s captured an d memorized d in the MPL vvariable CAP PPOS, exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured insttead • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, l when lo oad position iss captured in CAPPOS. The se election betwe een master and load posit ion is done as follows: load position is ssaved in CAP PPOS2 only for the setup p configuration ns which use e different sensors for load and motor and foresee a transmission ratio between the em. For all the other setup urations, the master m positio on is saved in n CAPPOS2. configu Example // /Reverse when w the ac ctive high h negative limit swi itch is rea ached // /Position feedback: 500 lines s encoder ( (2000 coun nts/rev) CA ACC = 0.06 637; //a acceleratio on rate = 200[rad/s^ ^2] CS SPD = -16. .6667; //j jog speed = -500[rpm m] MO ODE SP; UP PD; //e execute imm mediate EN NLSN1;//En nable negat tive limit t switch fo or low->hi igh transit tions !L LSN; //Se et event on n negative e limit swi itch(low-> >high trans sition) © ElectroC Craft 2013 53 30 MPD U User Manual WAIT!;//Wait until the event occurs !MC; // limit switch is active -> quick stop mode active WAIT!;// wait until the motor stops because only then the new // motion commands are accepted CSPD = 40; //jog speed = 1200[rpm] MODE SP; //after quick stop set again the motion mode UPD; //execute immediate © ElectroCraft 2013 531 MPD User Manual 6.2 2.5.1.75. ENLSP0 Syntax ENLSP0 Operands s Enable E Limit Switch Positivve 1->0 – Binary co ode Firmware e version FAx xx Firmware e version FBx xx Description Enable es positive lim mit switch inp put capability to detect a trransition from m 1(high) to 0 0(low). When the first trans sition occurs: • he input capa ability to dete ect transitionss is disabled d. It must be enabled aga ain to Th de etect another transition t • Mo otor position APOS_MT A is s captured an d memorized d in the MPL vvariable CAP PPOS, exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured insttead • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, l when lo oad position iss captured in CAPPOS. The se election betwe een master and load posit ion is done as follows: load position is ssaved in CAP PPOS2 only for the setup p configuration ns which use e different sensors for load and motor and foresee a transmission ratio between the em. For all the other setup urations, the master m positio on is saved in n CAPPOS2. configu Example // /Reverse when w the ac ctive low positive l limit swit tch is reac ched // /Position feedback: 500 lines s encoder ( (2000 coun nts/rev) CA ACC = 0.06 637; //a acceleratio on rate = 200[rad/s^ ^2] CS SPD = -16. .6667; //j jog speed = -500[rpm m] © ElectroC Craft 2013 53 32 MPD U User Manual MODE SP; UPD; //execute immediate ENLSP0;//Enable positive limit switch for high->low transitions !LSP; //Set event on positive limit switch(high->low transition) WAIT!;//Wait until the event occurs !MC; // limit switch is active -> quick stop mode active WAIT!;// wait until the motor stops because only then the new // motion commands are accepted CSPD = 40; //jog speed = 1200[rpm] MODE SP; //after quick stop set again the motion mode UPD; //execute immediate © ElectroCraft 2013 533 MPD User Manual 6.2 2.5.1.76. ENLSP1 Syntax ENLSP1 Operands s Enable E Limit Switch Positivve 0->1 – Binary co ode Firmware e version FAx xx Firmware e version FBx xx Description Enable es positive lim mit switch inp put capability to detect a trransition from m 0(low) to 1((high). When the first trans sition occurs: • he input capa ability to dete ect transitionss is disabled d. It must be enabled aga ain to Th de etect another transition t • Mo otor position APOS_MT A is s captured an d memorized d in the MPL vvariable CAP PPOS, exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured insttead • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, l when lo oad position iss captured in CAPPOS. The se election betwe een master and load posit ion is done as follows: load position is ssaved in CAP PPOS2 only for the setup p configuration ns which use e different sensors for load and motor and foresee a transmission ratio between the em. For all the other setup urations, the master m positio on is saved in n CAPPOS2. configu Example // /Reverse when w the ac ctive high h positive limit swi itch is rea ached // /Position feedback: 500 lines s encoder ( (2000 coun nts/rev) CA ACC = 0.06 637; //a acceleratio on rate = 200[rad/s^ ^2] CS SPD = -16. .6667; //j jog speed = -500[rpm m] © ElectroC Craft 2013 53 34 MPD U User Manual MODE SP; UPD; //execute immediate ENLSP1;//Enable positive limit switch for low->high transitions !LSP; //Set event on positive limit switch(low->high transition) WAIT!;//Wait until the event occurs !MC; // limit switch is active -> quick stop mode active WAIT!;// wait until the motor stops because only then the new // motion commands are accepted CSPD = 40; //jog speed = 1200[rpm] MODE SP; //after quick stop set again the motion mode UPD; //execute immediate © ElectroCraft 2013 535 MPD User Manual 6.2 2.5.1.77. EXTREF Syntax EXTREF value Operands s Set S EXTernal REFerence ttype value: type of refere ence 0, 1 or 2 Binary co ode Description Sets th he external re eference type depending o n the parame eter value: • value = 0: online – the referrence is sent via a commu unication cha annel in one of the varriables EREFP P, EREFS, EREFT, EREF FV function off the control m mode • value = 1: analo ogue – the refe erence is rea ad from a dedicated analog gue input • value = 2: digital – the refe erence is pro ovided as pullse & directio on or encode er like signals Example EX XTREF 1; // the ex xternal ref ference is s read from m the anal logue // input dedicated d for this p purpose © ElectroC Craft 2013 53 36 MPD U User Manual 6.2 2.5.1.78. FAULTR Syntax FAULTR FAULT F Reset Operands s – Binary co ode Description Gets ou ut the drive/m motor from the e FAULT sta tus in which it enters whe en an error occcurs. After a FAULTR co ommand, mos st of the erro or bits from M MER are clea ared (set to 0 0), the esent) is set to ready leve el, the Error output (if pre esent) is set to no Ready output (if pre evel. error le Remarrks: • The e FAULT rese et command does not cha ange the statu us of MER.15 5 (enable inp put on disa abled level), MER.7 M (nega ative limit swittch input activve), MER.6 (p positive limit sswitch inpu ut active) and d MER.2 (inva alid setup tablle) • The e drive/motorr will return to t FAULT sta atus if there are errors w when the FAULTR com mmand is exe ecuted Example FA AULTR; // reset fault stat tus 6.2 2.5.1.79. GOTO Syntax GOTO La abel Unconditiona U abel l GOTO to La GOTO Va alue16 Unconditiona U l GOTO to Va alue16 GOTO VA AR16 Unconditiona U l GOTO to ad ddress stored d in VAR16Ad ddr GOTO La abel, VAR, Fla ag GOTO G Label if VAR Flag 0 GOTO Va alue16, VAR, Flag GOTO G Value16 if VAR Fla ag 0 GOTO VA AR16, VAR, Flag F GOTO G address set in Var1 16Addr if VAR R16 Flag 0 Operands s Label: a label provid ding the 16-bit value of a ju ump address Value1 16: immediate e 16-bit jump address VAR16 6: integer variiable containing the jump a address VAR: 16 1 or 32-bit MPL M test varia able compared d with 0 © ElectroC Craft 2013 53 37 MPD U User Manual Flag: one o of the con nditions: EQ, NEQ, LT, LE Q, GT, GEQ Binary co ode Description Execute es a jump to the MPL pro ogram positio on specified vvia the jump a address. The e jump address s is provided d via a label, an immedia ate value or by the value e of a 16-bitt MPL variable e. The jump p can be unconditional o or unconditio onal. In a co onditional jum mp, a conditio on is tested. If the condition is true the jump is executed, e else the next MPL comma and is carried out. The con ndition is speccified by a 16 6-bit or 32-bit test variable and a test condition added d after the la abel with the jump addresss. The test variable is a always e test conditio ons are: comparred with zero.. The possible © ElectroC Craft 2013 53 38 EQ if VAR = 0 NEQ if VAR ≠ 0 LT if VAR < 0 LEQ if VAR ≤ 0 GT if VAR > 0 GEQ if VAR ≥ 0 MPD U User Manual Example GOTO label1, var1, LT; // jump to label1 if var1 < 0 GOTO label2, var1, LEQ; // jump to label2 if var1 <= 0 GOTO label3, var1, GT; // jump to label3 if var1 > 0 GOTO label4; GOTO var_address; // unconditional jump to label4 // unconditional jump to jumps address // provided by var_address value © ElectroCraft 2013 539 MPD User Manual 6.2 2.5.1.80. GROUPID Syntax GROUPID D (value_1, value_2,…) Se et GROUP ID D address Operands s value_ _1, value_2: specify s a grou up number be tween 1 and 8 Binary co ode Description The co ommand sets s the group ID. On each axis, the gro oup ID represents a filterr for a multica ast transmiss sion. When a multicast me essage is recceived, each axis compare es the messa age group ID with its own group g ID. If th he two group p IDs have at least one gro oup in commo on, the mess sage is accep pted. For exa ample, if an a axis is memb ber of group 1 and group 3, it will receive all the messages sent w with a group ID including g group 1 or gro oup 3. v Each b bit correspond ds to one group: bit 0 – gro oup 1, The grroup ID is an 8-bit integer value. bit 1 – group 2… bitt 7 – group 8. After th he execution of this command, the grou up ID value iss set as follow ws: • p) 1 occurs in the parenthe esis, else it is set to 0 Bit 0 is set to 1, if (group • Bit 1 is set to 1, if (group p) 2 occurs in the parenthe esis, else it is set to 0 • … • Bit 7 is set to 1, if (group p) 8 occurs in the parenthe esis, else it is set to 0. Example GR ROUPID (1, 3); //l local axis belongs t to groups 1 and 3 .. .. [G G3] {STOP;} //s send stop command c to o all axes from grou up 3 //the co ommand is executed b by local axis too © ElectroC Craft 2013 54 40 MPD U User Manual 6.2 2.5.1.81. INITCAM Syntax m table from E EEPROM to R RAM INITCAM LoadAddress, RunAddres ss Copy cam Operands s LoadAddress: 16-bit unsigned integer - cam ta able start add dress in the E EEPROM RunAdd dress: 16-bit unsigned u inte eger - cam tab ble start addre ess in the RA AM Binary co ode Description Prepare es a cam tab ble for use. The T cam tab les are first d downloaded into the EEP PROM memory of the driv ve/motor, tog gether with t he rest of th he MPL prog gram. Then using INITCA AM command a cam table is copied from m the EEPRO OM memory in nto the drive//motor RAM memory. m The LoadAddress s is the start a address in the EEPROM m memory where the cam tab ble was down nloaded and the t RunAddre ress is the sta art address in n the RAM me emory where to copy the cam table. After A the exe ecution of thiis command the MPL va ariable TART takes the value of th he RunAddresss CAMST Example IN NITCAM 18864,2560; //Copy CAM table e from EEPR ROM memory y ess 0x49B0) ) to RAM m memory //(addre //(addre ess 0xA00) © ElectroC Craft 2013 54 41 MPD U User Manual 6.2 2.5.1.82. LOCKEEP PROM Syntax LOCKEEPROM value16 LOCK/unlock EEPRO OM Operands s value1 16: integer vallue between 0 and 3 Binary co ode Description Locks or o unlocks the e EEPROM write w protectio on. When the e EEPROM iss write-proteccted, it is not possible p to write data into the EEPROM M, with the e exception of the MPL com mmand SAVE. Value16 may y have the following valuess: 0 – Disables EEPROM wrrite protection n 1 – Enables write protection for the lasst quarter of th he EEPROM 2 – Enables write protection for the lasst half of the E EEPROM 3 – Enables write protection for the enttire EEPROM M Example /An EEPROM M has 8Kwor rds. In the e MPL prog gram space occupies the // // /address range: 4000 0-5FFFh. LO OCKEEPROM 0; // disa able EEPROM M write pr rotection LO OCKEEPROM 1; // prot tect the ad ddress ran nge: 5800-5 5FFFh, LO OCKEEPROM 2; // prot tect the ad ddress ran nge: 5000-5 5FFFh LO OCKEEPROM 3; // prot tect the en ntire addr ress range: : 4000-5FF FFh © ElectroC Craft 2013 54 42 MPD U User Manual 6.2 2.5.1.83. LPLANE Only available on multii-axis Motion Controller Syntax LPLANE (X_axis, Y_a axis, Z_axis) Operands s Linear interpolation P LANE X_axis s, Y_axis, Z_a axis: slave ax xes defining th he coordinate e system Binary co ode Description Sets th he 2D/3D co oordinate sys stem for Lin near Interpola ation Mode using slave axes specifie ed with X_axis s, Y_axis and d Z_axis. Example // 2D linear in nterpolated d profile. Position feedbacks s: 500 line es remental encoder e //incr DE 0xCF00; ; //Clear buffer b SETMOD LPLANE E (A, C); //Slaves A and C de efine the coordinate e system MODE LI; L // Set t Linear In nterpolati ion Mode // Inc crement po osition wit th (X, Y) = (0.5[rot t], 0.05[r rot]) LPOS1 1000L, 10 00L; LPOS2 1000L, 10 00L; / UPD; //Execute immediate // Inc crement po osition wit th (X, Y) = (0.05[ro ot], 0.5[r rot]) LPOS1 100L, 100 00L; LPOS2 100L, 100 00L; crement po osition wit th (X, Y) = (0.5[rot t], 0.1[ro ot]) // Inc LPOS1 1000L, 20 00L; LPOS2 1000L, 20 00L; crement po osition wit th (X, Y) = (0.5[rot t], 0.5[ro ot]) // Inc LPOS1 1000L, 10 000L; LPOS2 2 1000L, 1000L; 1 © ElectroC Craft 2013 54 43 MPD U User Manual 6.2 2.5.1.84. LPOS Only available on multii-axis Motion Controller Syntax LPOS1 Pos_X, P Pos_Y Y, Pos_Z LPOS2 Pos_X, P Pos_Y Y, Pos_Z LPOS1 Pos_X, P Pos_Y Y LPOS2 Pos_X, P Pos_Y Y Operands s 3D Linea ar interpolatio on POS segm ment 2D Linea ar interpolatio on POS segm ment Pos_X X: X axis posittion incremen nt for 2D/3D trrajectory Pos_Y Y: Y axis posittion incremen nt for 2D/3D trrajectory Pos_Z Z : Z axis posittion incremen nt for 3D traje ectory Binary co ode © ElectroC Craft 2013 54 44 MPD U User Manual Description LPOS1 and LPOS2 define a segment for 2D/3D trajectory executed in Linear Interpolation mode. Based on Pos_X, Pos_Y and Pos_Z the MPL compiler from MotionPRO Developer computes the actual parameters used by the motion controller to generate the PVT points for slave axes. If the points are sent from a host then the following relations must be used to compute the actual parameters of the segment: Example // 2D linear interpolated profile. Position feedbacks: 500 lines © ElectroCraft 2013 545 MPD User Manual //incremental encoder SETMODE 0xCF00; //Clear buffer LPLANE (A, C); //Slaves A and C define the coordinate system MODE LI; // Set Linear Interpolation Mode // Increment position with (X, Y) = (0.5[rot], 0.05[rot]) LPOS1 1000L, 100L; LPOS2 1000L, 100L; UPD; //Execute immediate // Increment position with (X, Y) = (0.05[rot], 0.5[rot]) LPOS1 100L, 1000L; LPOS2 100L, 1000L; // Increment position with (X, Y) = (0.5[rot], 0.1[rot]) LPOS1 1000L, 200L; LPOS2 1000L, 200L; // Increment position with (X, Y) = (0.5[rot], 0.5[rot]) LPOS1 1000L, 1000L; LPOS2 1000L, 1000L; © ElectroCraft 2013 546 MPD User Manual 6.2 2.5.1.85. MODE CS Syntax MODE CS S Operands s Set S axis in MO ODE Cammin ng Slave – Binary co ode Description Sets th he drive/moto or to operate in the electro onic camming g slave mode e. In this mode, the drive/m motor perform ms a position control c with rreference set by a cam pro ofile function of the masterr position. The cam profile e is defined byy a cam table e – a set of (X X, Y) points, w where X is cam c table inp put i.e. the master m positio on and Y is the cam tab ble output i.e e. the corresponding slav ve position. Between the e points the drive/motor performs a linear olation. interpo The ne ew motion mo ode becomes effective at th ate command UPD. he next upda Example // / Electron nic camming g slave. Master M posi ition is r read from 2 2nd // / encoder inputs. Ma aster resol lution: 20 000 counts/ /rev CA AMSTART = 0xF000; // /Initialize e CAM tabl le start ad ddress EX XTREF 2; // master position p re ead from P P&D or 2nd encoder CA AMOFF = 200; //Cam offset o from m master CA AMX = 0.5; //Cam inp put correct tion facto or CA AMY = 1.5; //Cam out tput correc ction fact tor MA ASTERRES = 2000; // master res solution MO ODE CS; //Set electr ronic cammi ing slave mode TU UM1; //Set Target Up pdate Mode 1 SR RB ACR, 0xEFFF, 0x00 000; //Camm ming mode: : Relative UP PD; //execute immedi iate © ElectroC Craft 2013 54 47 MPD U User Manual 6.2 2.5.1.86. MODE GS Syntax MODE GS S Operands s Set S axis in MO ODE Gear Sl ave – Binary co ode Description Sets th he drive/moto or to operate in the elect ronic gearing g slave mode e. The drive//motor perform ms a position control and follows the master posittion with a prrogrammable e gear ratio. At A each slow w loop samp pling period, the slave ccomputes the e master po osition increme ent and multiplies it with itts programme ed gear ratio. The result iss the slave po osition reference incrementt, which adde ed to the prevvious slave po osition refere ence gives the e new ence. slave position refere The new w motion mod de becomes effective e at th he next updatte command U UPD. Example // /Electroni ic gearing g. Master position is receiv ved via // /communica ation ch hannel inp puts. Maste er resolut tion: 2000 counts/re ev // / On slave e axis (Axi is ID = 1): GE EAR = 0.3333; // gea ar ratio GE EARMASTER = 3; //gea ar ratio de enominator r GE EARSLAVE = 1; //gear r ratio num merator EX XTREF 0; // master position p go ot via com mmunication n channel MA ASTERRES = 2000; // master res solution RE EG_ON; //Enable supe erposition MO ODE GS; //Set as sla ave, positi ion mode TU UM1; //Set Target Up pdate Mode 1 SR RB UPGRADE, 0xFFFF, 0x0004; // /UPGRADE.2 2 = 1 CA ACC = 0.9549; //Limi it maximum accelerat tion at 300 00[rad/s^2 2] UP PD; //execute immedi iate © ElectroC Craft 2013 54 48 MPD U User Manual 6.2 2.5.1.87. MODE LI Only available on multii-axis Motion Controller Syntax MODE LI Operands s MODE Linear Interpo lation mode – Binary co ode Description Sets the motion con ntroller to operate in linear interpolation mode. In thiss mode the m motion s a 2D/3D tra ajectory base ed on linear ssegments. Th he motion mo ode is controlller generates configu ured with SET TMODE comm mand. The pa ath segments can be store ed in the non n-volatile mem mory of the m motion controller or receive ed via a comm munication cha annel from a host. Each segment s is split s in PVT points and ssent to the sslaves which h, using 3rd order interpolation, rebuild d the trajecto ory. The seg gments seque ence must fiinish with the e end nt. If the sequ uence doesn’’t have an en nd segment th hen the motio on controller e enters segmen in Quickstop mode and a the stops the slaves. Example // 2D linear in nterpolated d profile. Position feedbacks s: 500 line es //incr remental encoder e DE 0xCF00; ; //Clear buffer b SETMOD LPLANE E (A, C); //Slaves A and C de efine the coordinate e system MODE LI; L // Set t Linear In nterpolati ion Mode // Inc crement po osition wit th (X, Y) = (0.5[rot t], 0.05[r rot]) LPOS1 1000L, 10 00L; LPOS2 1000L, 10 00L; / UPD; //Execute immediate // Inc crement po osition wit th (X, Y) = (0.05[ro ot], 0.5[r rot]) LPOS1 100L, 100 00L; LPOS2 100L, 100 00L; © ElectroC Craft 2013 54 49 MPD U User Manual // Increment position with (X, Y) = (0.5[rot], 0.1[rot]) LPOS1 1000L, 200L; LPOS2 1000L, 200L; // Increment position with (X, Y) = (0.5[rot], 0.5[rot]) LPOS1 1000L, 1000L; LPOS2 1000L, 1000L; © ElectroCraft 2013 550 MPD User Manual 6.2 2.5.1.88. MODE PC Syntax MODE PC C s Operands MODE M Positio on Contouring g – Binary co ode Description Sets th he drive/moto or to operate in the position n contouring m mode. In the contouring m modes, an arb bitrary path is described d via a seriies of pointss. Between the points, linear interpo olation is perrformed, lead ding to a co ntour describ bed by a succession of linear segme ents. In the po osition contou uring, the drivve/motor perfforms a positiion control an nd the path re epresents a position p refere ence. The ne ew motion mo ode becomes effective at th he next upda ate command UPD. Example e // / Position contourin ng with pos sition fee edback on m motor: 500 0 lines // / incremen ntal encode er (2000 counts/rev) c ) MO ODE PC;//S Set Positio on Contour ring TU UM1;//Star rt from act tual value e of positi ion refere ence SE EG 100U, 20.00000;// 2 / 1st poin nt UP PD; //Exec cute immedi iate SE EG 100U, 0.00000; 0 // / 2nd poin nt SE EG 0, 0.0; ; //End of contourin ng 6.2 2.5.1.89. MODE PE E Syntax MODE PE E Operands s MODE M Positio on External – © ElectroC Craft 2013 55 51 MPD U User Manual Binary co ode Description Sets th he drive/mottor to operatte in the po osition extern nal mode. In this mode e, the drive/m motor performs a position control with the position reference prrovided by an nother device. There are 2 types of external e referrences (selecctable via the MPL instru uction EF): EXTRE • Ana alogue – read d from a dedic cated analogu ue input (MPL L variable AD D5) • Online – rec ceived online via a comm unication cha annel from a host and savved in the MPL varriable EREFP P an limit the maximum spee ed at sudden changes of tthe position rreference and d thus You ca to reduce the mecha anical shocks s. This feature e is activated d by setting UPGRADE.2=1 and ximum speed d value in CSP PD. the max The new w motion mod de becomes effective e at th he next updatte command U UPD. Example e d position n command from f the a nalogue re eference input //Read EXTREF F 1; MODE PE; P //External posit tion CSPD = 100;// Limit L = 300 00[rpm] SRB UP PGRADE, 0x xFFFF, 0x00 004; //UPG GRADE.2 = 1 UPD; //execute / immediate 6.2 2.5.1.90. MODE PP Syntax MODE PP P Operands s MODE M Positio on Profile – Binary co ode © ElectroC Craft 2013 55 52 MPD U User Manual Description Sets th he drive/moto or to operate in the trapezo oidal position profile mode e. In this mode, the drive/m motor perform ms a position n control. Th he built-in refference gene erator compu utes a positio on profile with h a trapezoida al shape of th he speed, due to a limited d acceleration n. You specify y either a po osition to reac ch in absolutte mode or a position inccrement in re elative mode, plus the slew w (maximum travel) t speed and the acce eleration/dece eleration rate.. The ne ew motion mo ode becomes effective at th he next upda ate command UPD. Example e // / Position n profile. Position feedback: 500 lines s increment tal // / encoder (2000 coun nts/rev) CA ACC = 0.31 183; //a acceleratio on rate = 1000[rad/s s^2] CS SPD = 33.3 3333; //s slew speed = 1000[rp pm] CP POS = 6000 0; //p position co ommand = 3 3[rot] CP PR; //position comm mand is relative SR RB ACR 0xF FFFF, 0x800 0; // and additive MO ODE PP; // / set trape ezoidal po osition pro ofile mode e TU UM1; //set t Target Up pdate Mode 1 UP PD; //exe ecute immed diate !M MC; WAIT!; //wait fo or completi ion 6.2 2.5.1.91. MODE PSC C Syntax MODE PS SC Operands s MODE M Positio on S-curve – Binary co ode Description Sets th he drive/moto or to operate in i the S-curve e profile mode. In this mod de, the drive//motor perform ms a position n control. The e built-in referrence genera ator computess a position p profile with an n S-curve sha ape of the sp peed. This sha ape is due to o the jerk limittation, leading to a trapezo oidal or triang gular profile for f the accele eration and an S-curve pro ofile for the sspeed. You sp pecify either a position to reach r in abso olute mode orr a position increment in re elative mode, plus the sle ew (maximum m travel) spe ed, the maxiimum accele eration/decele eration nd the jerk ratte. The jerk ra ate is set indiirectly via the e jerk time, wh hich represen nts the rate an time ne eeded to reac ch the maximum accelerattion starting frrom zero © ElectroC Craft 2013 55 53 MPD U User Manual The ne ew motion mo ode becomes effective at th he next upda ate command UPD. Example e // / S-curve profile. Position P feedback: f 5 500 lines incrementa al // / encoder (2000 coun nts/rev) TJ JERK = 50; ;//jerk = 2e+004[rad 2 d/s^3] CA ACC = 0.31 183;//accel leration rate r = 1000 0[rad/s^2] CS SPD = 33.3 3333;//slew w speed = 1000[rpm] CP POS = 2000 00;//positi ion comman nd = 10[rot t] CP PR; //posi ition comma and is rel lative MO ODE PSC; // / set S-cu urve profi ile mode SR RB ACR, 0x xFFFE, 0x00 000; //Sto op using an n S-curve profile UP PD; //exec cute immedi iate !M MC; WAIT!; //wait fo or completi ion 6.2 2.5.1.92. MODE PT Syntax T MODE PT Operands s MODE M Positio on Time – Binary co ode Description Sets th he drive/moto or to operate in the PVT m mode. In this m mode, the driive/motor perrforms a posittion control. The T built-in re eference gen nerator computes a positio oning path ussing a series of points. Ea ach point spe ecifies the dessired Position n, and Time, i.e. contains a PT B the PT P points the reference ge enerator perfo orms a linear interpolation. data. Between The ne ew motion mo ode becomes effective at th he next upda ate command UPD. © ElectroC Craft 2013 55 54 MPD U User Manual Example // PT sequence. Position feedback: 500 lines incremental // encoder (2000 counts/rev) SETPVT 0xC000; //Clear PT buffer, disable counter check //Don’t change counter & buffer low condition MODE PT; // Set PT Mode TUM1;//Start from actual value of position reference CPR; PTP 2000L, 100U, 0; //PT(1[rot], 0.1[s]) UPD; //Execute immediate PTP 0L, 100U, 0; //PT(1[rot],0.2[s]) PTP -2000L, 100U, 0; //PT(0[rot],0.3[s]) !MC; WAIT!; //wait for completion © ElectroCraft 2013 555 MPD User Manual 6.2 2.5.1.93. MODE PVT T Syntax MODE PV VT s Operands MODE M Positio on Velocity Tiime – Binary co ode Description Sets th he drive/moto or to operate in the PVT m mode. In this m mode, the driive/motor perrforms a posittion control. The T built-in re eference gen nerator computes a positio oning path ussing a series of points. Each E point specifies s the desired Possition, Velocity and Time e, i.e. ns a PVT da ata. Between the PVT poi nts the refere ence generattor performs a 3rd contain order interpolation. The ne ew motion mo ode becomes effective at th he next upda ate command UPD. Example e // / PVT sequ uence. Posi ition feed dback: 500 lines inc cremental // / encoder (2000 coun nts/rev) MA ASTERID = 4081; // Set S host address a to 255 (255< <<4+1) SE ETPVT 0xC0 000; //C Clear PVT buffer, b di isable coun nter check k //Do on’t change counter & buffer low condit tion MO ODE PVT; // / Set PVT Mode TU UM1;//Star rt from act tual value e of positi ion refere ence CP PR; // Rel lative mode e PV VTP 400L, 60, 10U, 0;//PVT(0. 0 2[rot], 18 800[rpm], 0.01[s]) UP PD; //Exec cute immedi iate PV VTP 400L, 0, 10U, 0; ;//PVT(0.4 4[rot], 0[r rpm], 0.02 2[s]) !M MC; WAIT!; //wait fo or completi ion © ElectroC Craft 2013 55 56 MPD U User Manual 6.2 2.5.1.94. MODE SC Syntax MODE SC C Operands s MODE M Speed d Contouring – Binary co ode Description Sets th he drive/moto or to operate in speed con ntouring mode e. In the conto ouring modess, you can program an arbitrary a path h via a ser ies of pointss. Between the points, linear olation is perrformed, lead ding to a co ntour describ bed by a succession of linear interpo segme ents. In the speed s contou uring, the drivve/motor perfforms a spee ed control an nd the path re epresents a speed reference. The new w motion mod de becomes effective e at th he next updatte command U UPD. Example // / Speed contouring with w positi ion feedba ack on moto or: 500 li ines // / incremen ntal encode er (2000 counts/rev) c ) MO ODE SC;//S Set Speed Contouring C g TU UM1;//Star rt from act tual value e of positi ion refere ence SE EG 100U, 20.00000;// 2 / 1st poin nt UP PD; //Exec cute immedi iate SE EG 100U, 0.00000; 0 // / 2nd poin nt SE EG 0, 0.0; ; //End of contourin ng © ElectroC Craft 2013 55 57 MPD U User Manual 6.2 2.5.1.95. MODE SE Syntax MODE SE E Operands s MODE M Speed d External – Binary co ode Description Sets the drive/motorr to operate in n the speed e external mode. In this mod de, the drive//motor ms a speed co ontrol with the e speed referrence provide ed by anotherr device. Therre are perform 2 types s of external re eferences (se electable via tthe MPL instrruction EXTREF): • Ana alogue – read d from a dedic cated analogu ue input (MPL L variable AD D5) • Online – rec ceived online via a comm unication cha annel from a host and savved in the MPL varriable EREFS S an limit the maximum acce eleration at s udden chang ges of the spe eed reference and You ca thus to reduce the mechanical m sh hocks. This fe eature is activvated by settin ng UPGRADE.2=1 e maximum ac cceleration va alue in CSPD D. and the The new w motion mod de becomes effective e at th he next updatte command U UPD. Example // / External l mode onli ine. Read speed refe erence fro om variable e EREFS // / Position n feedback: : 500 line es incremen ntal // / encoder (2000 coun nts/rev) ER REFS = 33. .3333;// ER REFS initi ial = 1000[ [rpm] EX XTREF 0; MO ODE SE; // /External speed s CA ACC = 0.31 183;// Limi it = 1000[ [rad/s^2] SR RB UPGRADE E, 0xFFFF, 0x0004; //UPGRADE.2 / 2 = 1 UP PD; //execute immedi iate © ElectroC Craft 2013 55 58 MPD U User Manual 6.2 2.5.1.96. MODE SP Syntax MODE SP P Operands s MODE M Speed d Profile – Binary co ode Description Sets the drive/moto or to operate e in trapezoi dal speed profile mode. In this mode e, the motor perform ms a speed co ontrol. The bu uilt-in referencce generator computes a sspeed drive/m profile with a trapez zoidal shape, due to a limitted acceleration The ne ew motion mo ode becomes effective at th ate command UPD. he next upda Example:: // / Position n feedback: : 500 line es incremen ntal // / encoder (2000 coun nts/rev) CACC C = 0.3183; //a acceleratio on rate = 1000[rad/s s^2] CSPD C = 6.6667; //j jog speed = 200[rpm] MODE M SP; // set speed profile m mode UPD; U execute imm mediate //e © ElectroC Craft 2013 55 59 MPD U User Manual 6.2 2.5.1.97. MODE TC Syntax MODE TC C Operands s MODE M Torque Contouring g – Binary co ode Description Sets th he drive/moto or to operate in torque con ntouring mode e. In the contouring modess, you can program an arbitrary a path h via a ser ies of pointss. Between the points, linear olation is perrformed, lead ding to a co ntour describ bed by a succession of linear interpo segme ents. In the to orque contou uring, the drivve/motor perfforms a torqu ue control an nd the path re epresents a current c referen nce. Remarrk: The torqu ue contouring g mode has b been foresee en for testing g during the setup phase The new w motion mod de becomes effective e at th he next updatte command U UPD. Example / current scaling: 1A 1 = 1984 IU I // MO ODE TC; //S Set Torque Contourin ng RE EF0 = 992; //I Initial ref ference se et to 0.5[A A] SE EG 2999U, 0.06601; UP PD; Execute imm mediate //E SE EG 1U, 0.03745; SE EG 1999U, 0.29800; SE EG 1U, 0.28970; SE EG 2999U, -0.26468; SE EG 1U, -0.22781; SE EG 0, 0.0; © ElectroC Craft 2013 End of cont touring //E 56 60 MPD U User Manual 6.2 2.5.1.98. MODE TEF F Syntax MODE TE EF MODE M Torque External Fa ast MODE TE ES MODE M Torque External Sl ow Operands s – Binary co ode Description Sets the drive/motorr to operate in n the torque e external mode. In this mod de, the drive//motor ms a torque control with a current refere ed by anotherr device. Therre are perform ence provide 2 types s of external re eferences (se electable via tthe MPL instrruction EXTREF): • Ana alogue – read d from a dedic cated analogu ue input (MPL L variable AD D5) • Online – rec ceived online via a comm unication cha annel from a host and savved in the MPL varriable EREFT T t current re eference is read from the a analogue inpu ut, the referen nce update ccan be When the done in n 2 ways: • MO ODE TES – att each slow lo oop sampling period • MO ODE TEF – att each fast loo op sampling p period When the t current re eference is re eceived onlin ne via a comm munication ch hannel only o option MODE TES is possible. The new w motion mod de becomes effective e at th he next updatte command U UPD. Example // /Set torque mode wit th referenc ce read fr rom an anal logue inpu ut EX XTREF 1; // external type: t anal logue input t MO ODE TEF; External to orque, upd date in fas st loop //E UP PD; //e execute imm mediate © ElectroC Craft 2013 56 61 MPD U User Manual 6.2 2.5.1.99. MODE TT Syntax T MODE TT Operands s MODE M Torque Test – Binary co ode Description Sets the drive/motorr to operate in n torque test mode. In thiss mode a currrent comman nd can c off a limited ra amp. For AC C motors (likke for be set using a test reference consisting ess motors), the t test mode e offers also the possibilityy to rotate a current examplle the brushle reference vector with h a programm mable speed. As result, the ese motors can be moved d in an w using g the position n sensor. Th he main adva antage of thiss test “open-loop” mode without s the possibility to conductt in a safe wa ay a series of tests, which ccan offer important mode is informa ation about the motor parameters, p ntegrity of th he its drive status and the in connec ctions. Remarrk: The torque e test mode has h been fore eseen to facilittate the testin ng during the setup phase. It is not inten nded for norm mal operation The new w motion mod de becomes effective e at th he next updatte command U UPD. Example // /Torque te est mode, brushless b AC motor. The drive e has // /peak curr rent 16.5A -> 32736 IU (intern nal curren nt units) // /360° electric angle e -> 65536 internal units // / fast loo op sampling g period = 0.1ms. Mo otor has 2 pole pair rs MO ODE TT; // /Torque Tes st Mode RE EFTST_A = 1984;//Ref ference sa aturation = 1[A] RI INCTST_A = 20;//Refe erence inc crement = 1 10[A/s] TH HTST = 0;/ //Electric angle = 0[deg] 0 TI INCTST = 7;//Electri 7 ic angle increment i ~ ~= 2e+002[ [deg/s] UP PD; //update immedia ate © ElectroC Craft 2013 56 62 MPD U User Manual 6.2 2.5.1.100. MODE VC Syntax MODE VC C Operands s MODE M Voltag ge Contouring g – Binary co ode Description Sets th he drive/moto or to operate in voltage con ntouring mode e. In the conttouring modess, you can program an arbitrary a path h via a ser ies of pointss. Between the points, linear olation is perrformed, lead ding to a co ntour describ bed by a succession of linear interpo segme ents. In the vo oltage contou uring, the drivve/motor perfforms a voltage control an nd the path re epresents a voltage v referen nce. Remarrk: The voltag ge contouring g mode has been foresee en for testing g during the setup phase The new w motion mod de becomes effective e at th he next updatte command U UPD. Example MODE VC; //Set / Volt tage Contou uring REF0 = 7744; //Initial / reference set to 3[V] 4 -0.5 51620; SEG 4999U, immediate //Execute / UPD; 1 -0.4920 03; SEG 1U, SEG 1999U, 1 1.93 3600; SEG 1U, 1 1.92673 3; SEG 2000U, 2 0.00 0000; SEG 999U, 9 -9.03 3500; SEG 1U, 1 -9.0313 34; SEG 0, 0 0.0; 6.2 2.5.1.101. //End of o contour ring MODE VES S Syntax ES MODE VE MODE M Voltag ge External S low MODE VE EF MODE M Voltag ge External Fa ast © ElectroC Craft 2013 56 63 MPD U User Manual Operands s – Binary co ode Description Sets the drive/motorr to operate in n the voltage external mod de. In this mod de, the drive//motor ms a voltage control c with a voltage referrence provide ed by anotherr device. There are perform 2 types s of external re eferences (se electable via tthe MPL instrruction EXTREF): • Ana alogue – read d from a dedic cated analogu ue input (MPL L variable AD D5) • Online – rec ceived online via a comm unication cha annel from a host and savved in the MPL varriable EREFT T t voltage re eference is re ead from the a analogue inpu ut, the reference update ccan be When the done in n 2 ways: • MO ODE VES – att each slow lo oop sampling period • MO ODE VEF – att each fast loo op sampling p period When the t voltage re eference is re eceived onlin ne via a comm munication channel only o option MODE TES is possible. ge contouring g mode has been foresee en for testing g during the setup Remarrk: The voltag phase The new w motion mod de becomes effective e at th he next updatte command U UPD. Example // /Read voltage refere ence from variable v E EREFV ER REFV = 30;// EREFV initial i = 30[IU] 3 EX XTREF 0; MO ODE VES; //External voltage UP PD; //execute immedi iate © ElectroC Craft 2013 56 64 MPD U User Manual 6.2 2.5.1.102. MODE VT Syntax MODE VT T Operands s MODE M Voltag ge Test – Binary co ode Description Sets the drive/motorr to operate in n voltage test mode. In thiss mode a volttage comman nd can c off a limited ra amp. For AC C motors (likke for be set using a test reference consisting ess motors), the test mode e offers also th he possibility to rotate a vo oltage examplle the brushle reference vector with h a programm mable speed. As result, the ese motors can be moved d in an w using g the position n sensor. Th he main adva antage of thiss test “open-loop” mode without s the possibility to conductt in a safe wa ay a series of tests, which ccan offer important mode is informa ation about the motor parameters, p ntegrity of th he its drive status and the in connec ctions. Remarrk: The voltag ge test mode e has been fforeseen to ffacilitate the testing durin ng the setup phase. p It is no ot intended forr normal operration The new w motion mod de becomes effective e at th he next updatte command U UPD. Example MO ODE VT; //V Voltage Tes st Mode RE EFTST_V = 5022; //R Reference saturation s n value = 1 1[V] RI INCTST_V = 4; //R Reference increment i value = 1[ [V/s] UP PD; //U Update imme ediate © ElectroC Craft 2013 56 65 MPD U User Manual 6.2 2.5.1.103. MODE VM Only available on multii-axis Motion Controller Syntax MODE VM M Operands s MODE Vector V Mode – Binary co ode Description Sets th he motion con ntroller to ope erate in vecto or mode. In tthis mode the e motion con ntroller generates a 2D tra ajectory usin ng circular an nd linear se egments. The e motion mo ode is ured with SET TMODE comm mand. configu The pa ath segments can be store ed in the non n-volatile mem mory of the m motion controller or receive ed via a comm munication cha annel from a host. Each segment s is split s in PVT points and ssent to the sslaves which h, using 3rd order interpolation, rebuild d the trajecto ory. The seg gments seque ence must fiinish with the e end nt. If the sequ uence doesn’’t have an en nd segment th hen the motio on controller e enters segmen in Quickstop mode and a the stops the slaves. Example // 2D linear in nterpolated d profile. Position feedbacks s: 500 line es remental encoder e //incr DE 0xCF00; ; //Clear buffer b SETMOD VPLANE E (A, B, C); C MODE VM; V // Set t Vector Mo ode // Inc crement po osition wit th (X, Y) = (0.1[rot t], 0.1[ro ot]) VSEG1 200L, 200 0L; VSEG2 200L, 2 200L L; / immediate UPD; //Execute // Cir rcular seg gment of ra adius 3.14 4159[mm], w with initi ial angle 2 20[deg] // and d angle in ncrement 50 0[deg]) CIRCLE E1 1L, 50. .; CIRCLE2 1L, 20.; // Inc crement po osition wit th (X, Y) = (0.5[rot t], 1[rot]) VSEG1 1000L, 20 000L; VSEG2 2 1000L, 2000L; 2 rcular seg gment of ra adius 6.28 8319[mm], w with initi ial angle 1 10[deg] // Cir © ElectroC Craft 2013 56 66 MPD U User Manual // and d angle in ncrement 90 0[deg]) CIRCLE E1 2L, 90. .; CIRCLE2 2L, 10.; // Ins sert End Segment S VSEG1 0L, 0L; VSEG2 V 0L, 0L; 0 A, B, C); // wait fo or motion completion n WMC (A 6.2 2.5.1.104. NOP Syntax No N Operation n NOP s Operands – Binary co ode Description No ope eration is exe ecuted. The MPL M program m will continue e with the ne ext instruction n. The NOP in nstruction ma ay be used to introduce a d delay between n two instructtions. Example Va ar1=100; LOOP: // execute a 100 times s a loop ar1-=1; Va // decrement Var1 by 1 NO OP; ion // no operati GO OTO LOOP, Var1, GEQ; ; // stay in i loop if f Var1 >= 0 © ElectroC Craft 2013 56 67 MPD U User Manual 6.2 2.5.1.105. OUT Syntax OUT(n1, n2, …) = valu ue16 OUTput O value e16 to I/O n1,, n2, … OUT(n1, n2, …) = VAR R16 OUTput O VAR16 value to n 1, n2, … Operands s n1, n2: IO line numb ber value16 6: 16-bit integ ger immediate e value VAR16 6: 16-bit intege er variable Binary co ode Description The ins struction sets one or seve eral output lin es simultaneously with the immediate value or the value v of the sp pecified varia able. Each bit from the the output line has associatted through its number id dentifier assocciated an conttrol bit identified If the abo ove bits from V VAR are set to 1, the corrresponding ou utputs are set high (1), else e the outputs are set low (0 0). L the output lines are numbered from 0 to 15. Each product has a specific nu umber In MPL of outpu uts, therefore e only a part of o the 15 outp put lines is use ed. Warnin ng! Check ca arefully your drive/motor for the availlable outputss. Do not use this comma and if any of th he above outp tputs is not avvailable. You can always sset separatelyy each of the outputs o using the OUT com mmand This instruction use es a 9-bit short address for the desttination variable. Bit 9 va alue X es the destina ation address range: specifie © ElectroC Craft 2013 56 68 MPD U User Manual Example int user_var; user_var = 0x800A;// setup user_var variable OUTPORT user_var;//Send variable address to external output port // The command sets high the outputs: #25/Ready, #31 and #29 // and low the outputs: #12/Error, #30 and #28 © ElectroCraft 2013 569 MPD User Manual 6.2 2.5.1.106. OUTPO ORT Syntax OUTPOR RT VAR16 Operands s OUTput O VAR16 value to IO OPORT VAR16 6: 16-bit integ ger variable Binary co ode Description The ins struction sets simultaneous sly the followi ng drive/moto or output liness: • Rea ady output (#25/READY) – set by bit 15 5 from VAR16 6 • Erro or output (#12 2/ERROR) – set by bit 14 from VAR16 • Gen neral-purpose e outputs: #31, #30, #29, # #28 – set by b bits 3, 2, 1, an nd 0 from VAR16 If the above a bits fro om VAR are set s to 1, the ccorrespondin ng outputs are e set high (1)), else the outtputs are set low (0). In MPL L the I/O line es are numbe ered: #0 to # #39. Each pro oduct has a sspecific numb ber of inputs and outputs, therefore only a part of th he 40 I/O lines is used. The I/O numberring is nce each prod duct has its o own list of ava ailable I/Os. common for all the products; hen ng! Check carefully c yourr drive/motor for the avaiilable outputss. Do not use this Warnin command if any off the above outputs o is no ot available. Y You can alwa ays set sepa arately o the outputs s using the OU UT command d each of This in nstruction use es a 9-bit sh hort address s for the desttination varia able. Bit 9 va alue X specifiies the destination address s range: Example in nt user_var; us ser_var = 0x800A;// setup user r_var vari iable OU UTPORT user_var;//Se end variabl le address s to extern nal output t port // / The comm mand sets high h the ou utputs: #2 25/Ready, # #31 and #2 29 // / and low the output ts: #12/Err ror, #30 a and #28 © ElectroC Craft 2013 57 70 MPD U User Manual 6.2 2.5.1.107. PING/PON NG Syntax G value16 PING – Operands s Re equest the axiis ID and firm mware version n from a group p of axes An nswer to PING G value1 16: 16 bit imm mediate value,, used to com mpute each axxis answer de elay Remark: The onlin ne instruction ns are intende ed only for h host/master communication n and m. Therefore their syntax iis fictive, the only goal be eing to cannot reside in a MPL program fy these comm mands. identify In the Command in nterpreter, yo ou can checkk which drivess/motors are connected in n your g a PING requ uest with synttax PING valu ue16. The PO ONG answerss from networrk by sending all the axes are disp played in the output windo ow. Binary co ode Description By bro oadcasting a PING comm mand, the ho ost/master can find the axis ID of a all the drives//motors prese ent in the nettwork. When tthe PING req quest is sent via an RS-23 32 link the ho ost bit (H) fro om the expeditor addresss must be se et to 1. For details, see serial communication protocol descripttion. The op perand of PIN NG, value16,, represents a time interva al measured in µs. This tiime is multipllied with the axis ID of ea ach axis to p provide a time e delay for ssending the P PONG answe er. For exam mple if value1 16 is 2000 th hen the drive e/motor with axis ID = 10 00 will answe er after a dela ay of 100 x 20 000µs = 0.2s. The time delay is necesssary only if the e host is conn nected via an n RS-232 link with one of th he drives/mottors from a CAN-bus netw work. If the host is directly connected c on n the CAN-buss network, va alue16 can be e 0. NG command d is sent from m the Comma and Interprete er without ope erand, Remark: If the PIN alue16 is set by b default at 2000. This vvalue corresponds to the h highest seriall baud the va rate off 115200. Forr smaller baud d rates the va alue16 must b be increased p proportionallyy. © ElectroC Craft 2013 57 71 MPD U User Manual Each axis will answer to a PING command with a PONG message, which provides the Axis ID and the firmware version of the expeditor. The firmware version has the form: FxyzA, where xyz is the firmware number (3 digits) and A is the firmware revision. The PING message will include the ASCII code of 4 characters: 3 digits for the firmware number + 1 letter for the firmware revision. © ElectroCraft 2013 572 MPD User Manual 6.2 2.5.1.108. PTP Syntax alue, T_value e, C_value PTP P_va Deffine a PT poin nt via immedia ate values PTP P_va ar, T_var, C_value Deffine a PT poin nt via MPL va ariables Operands s P_valu ue – 32-bit lon ng integer imm mediate value e: PT point po osition T_valu ue – 16-bit uns signed intege er immediate vvalue: PT poiint time C_valu ue – 7-bit integer immediatte value, PVT T point integritty counter P_var – long variable, contains th he PT point p position T_var – integer variable, contains s the PVT po oint time Binary co ode Description Defines s a PT point. The PT position and time values may b be provided e either as imme ediate values or via the values of 2 MPL L variables. A PT point p also inc cludes a 7-bitt integrity cou unter. The ho ost must incrrement by on ne the integrity y counter each time when n it sends a new PT poin nt. If the inte egrity counterr error checkin ng is activate ed, every tim me when the e drive/motorr receives a new PT po oint, it comparres its interna ally computed d integrity co ounter value w with the one sent with the e PTP comma and. The PT point p is accep pted only if th he two valuess are equal. IIf the values of the two inte egrity counterrs do not mattch, the integ grity check errror is triggere ed, the drive//motor sends the PVTSTS S to the hos st with PVTS STS.12 =1 a and the PT point receivved is ded. Each time a PT point is accepted, the drive/mo otor automaticcally incremen nts its discard internal integrity cou unter. © ElectroC Craft 2013 57 73 MPD U User Manual Example SETPT 0xCF00; //Clear PT buffer MODE PT; // Set PT Mode TUM1; //Start from actual value of position reference CPR; PTP 2000L, 2000U, 0; //PT(1[rot], 2[s]) UPD; //Execute immediate PTP 6000L, 500U, 0; //PT(4[rot],2.5[s]) PTP -2000L, 500U, 0; //PT(3[rot],3[s]) !MC; WAIT!; //wait for completion © ElectroCraft 2013 574 MPD User Manual 6.2 2.5.1.109. PVTP Syntax Define a PVT po oint via immed diate values ue, T_value, C_value C PVTP P_value, V_valu T_ C_value e PVTP P_var, V_var, T_var, Operands s Define a PVT po oint via MPL vvariables P_valu ue – 24-bit lon ng integer imm mediate value e: PVT point p position V_valu ue – 24-bit fix xed immediatte value (16M MSB integer part and 8LS SB fractional part): PVT po oint velocity T_valu ue – 9-bit integ ger immediate e value: PVT point time C_valu ue – 7-bit integer immediatte value, PVT T point integritty counter P_var – long variable, contains th he PVT point position V_var – fixed variab ble, contains the t PVT pointt velocity T_var – integer variable, contains s the PVT po oint time Binary co ode Description Defines s a PVT point. The PVT position, p veloccity and time values may be provided either as imm mediate values s or via the va alues of 3 MP PL variables. A PVT point also in ncludes a 7-bit integrity co ounter. The h host must incrrement by on ne the y counter eac ch time when n it sends a n new PVT point. If the inte egrity counterr error integrity checkin ng is activate ed, every tim me when the drive/motor receives a new PVT po oint, it comparres it’s interna ally computed d integrity cou with the one ssent with the PVTP unter value w comma and. The PVT T point is acce epted only if tthe two value es are equal. If the values of the two inte egrity counterrs do not mattch, the integ grity check errror is triggere ed, the drive//motor sends the PVTSTS S to the hos st with PVTS STS.12 =1 and the PVT point receivved is ded. Each tim me a PVT point is accepte ed, the drive/m motor automa atically increm ments discard its interrnal integrity counter. c © ElectroC Craft 2013 57 75 MPD U User Manual Example SETPVT 0xCF00; //Clear PVT buffer MODE PVT; // Set PVT Mode TUM1; //Start from actual value of position reference CPR; PVTP 12000L, 0.04, 300U, 0;//PVT(6[rot], 1.199[rpm], 0.3[s]) UPD; //Execute immediate PVTP -8000L, 0, 200U, 0;//PVT(2[rot], 0[rpm], 0.5[s]) !MC; WAIT!; //wait for completion © ElectroCraft 2013 576 MPD User Manual 6.2 2.5.1.110. REG OFF Syntax REG_OFF Operands s REGistration R OFF – Binary co ode Description Disables the superposition of th he electronic gearing mod de with a seccond motion m mode. sed mode, th e electronic g gearing slave e mode is sto opped When you disable the superpos he drive/moto or executes only the oth her motion. If you want to remain in the and th electro onic gearing slave mode,, set first the e electronic gearing slavve move and d then disable e the superpo osed mode. Example RE EG_OFF; //Disable su uperpositio on MO ODE GS; //Set as sla ave, positi ion mode UP PD; //execute immedi iate // / drive/motor remain ns in gear slave mod de without superposi ition © ElectroC Craft 2013 57 77 MPD U User Manual 6.2 2.5.1.111. REG ON Syntax REG_ON Operands s REGistration R ON – Binary co ode Description The instruction ena ables the sup perposition of the electronic gearing mo ode with a se econd n mode. When this supe erposed mod de is activatted, the possition referen nce is motion compu uted as the su um of the position referencces for each o of the 2 superrposed motion ns. You may m enable the superp posed mode at any moment, inde ependently o of the activattion/deactivation of the electronic e ge earing slave.. If the sup perposed mo ode is activatted during an n electronic gearing g motio on, any subse equent motion mode chan nge is treated d as a secon nd move to be b superpose ed over the b basic electronic gearing m move, instead d of replacing g it. If the sup perposed mod de is activate ed during ano other motion m mode, a seco ond electronic c gearing mode will start u using the mo otion parametters previouslly set. This move m is superposed ove er the first o one. After the first move e ends, any other subseq quent motion will be added d to the electrronic gearing.. Example // /Set elec ctronic ge earing sla ave more // /Master re esolution: 2000 coun nts/rev with sup perposed m mode enab bled. EAR = 0.3333; // gea ar ratio GE GE EARMASTER = 3; //gea ar ratio de enominator r GE EARSLAVE = 1; //gear r ratio num merator EX XTREF 0; // master position p go ot via com mmunication n channel MA ASTERRES = 2000; // master res solution RE EG_ON; //Enable supe erposition MO ODE GS; //Set as sla ave, positi ion mode TU UM1; //Set Target Up pdate Mode 1 SR RB UPGRADE, 0xFFFF, 0x0004; // /UPGRADE.2 2 = 1 CA ACC = 0.9549; //Limi it maximum accelerat tion at 300 00[rad/s^2 2] UP PD; //execute immedi iate © ElectroC Craft 2013 57 78 MPD U User Manual 6.2 2.5.1.112. REMGRID Syntax REMGRID D (value_1, value_2, v …) REMove R spec cified groups from GRoup ID Operands s value_ _1, value_2: specify s a grou up number be tween 1 and 8 Binary co ode Description The command c rem moves group ps from the group ID. On each axxis, the grou up ID represents a filter for f a multicas st transmissio on. When a multicast message is rece eived, a compare es the message group ID with its own group ID. If the two grou up IDs each axis have at a least one group g in comm mon, the messsage is acce epted. For exa ample, if an a axis is membe er of group 1 and group 3, it will rece eive all the m messages sen nt with a gro oup ID including group 1 or group 3. The group ID is an 8-bit integ ger value. Ea ach bit corresp ponds … bit 7 – grou up 8. to one group: bit 0 – group 1, bit 1 – group 2… After th he execution of this command, the grou up ID value iss modified as follows: • p) 1 occurs in the parenthe esis Bit 0 is set to 0, if (group • Bit 1 is set to 0, if (group p) 2 occurs in the parenthe esis • … • Bit 7 is set to 0, if (group p) 8 occurs in the parenthe esis. Example GR ROUPID (8);//local axis a belong gs to grou ups 8 AD DDGRID (2, 5);//loca al axis bel longs to g groups 2, 5 and 8 .. .. RE EMGRID (5, 8);//loca al axis bel longs only y to group 2 © ElectroC Craft 2013 57 79 MPD U User Manual 6.2 2.5.1.113. RESET Syntax RESET Operands s Reset R DSP prrocessor – Binary co ode Description Resets the drive/mo otor. The com mmand may b be used by a an external de evice to reinitialize ve/motor afterr downloading g new setup d data. the driv Remarrk: The drive//motor key in nitializations are done at ENDINIT command, usin ng the availab ble setup data a. This proces ss is irreversib ble. If later on n the setup da ata is changed, it is not pos ssible to exec cute again the ENDINIT ccommand. It iis necessary to reset the drive, and the en to execute ENDINIT com mmand © ElectroC Craft 2013 58 80 MPD U User Manual 6.2 2.5.1.114. RET Syntax RET RETurn n from a MPL L function Operands s – Binary co ode Description Ends th he execution of a MPL fun nction and perrforms the retturn to the ne ext MPL instru uction after the function call. Example .. .. CA ALL Function1; // Call Funct tion1 UP PD; mediate is s next inst truction // Update imm e af fter RET // executed .. .. Function n1: .. .. RE ET; © ElectroC Craft 2013 //E Exit from Function1 F 58 81 MPD U User Manual 6.2 2.5.1.115. RETI Syntax RETI RETurn n from a MPL L Interrupt fun nction Operands s – Binary co ode Description Ends th he execution of a MPL ISR R and returns to the MPL ccommand whose execution was postpon ned by the MPL M interruptt. RETI globa ally enables tthe MPL inte errupts which were globally y disabled wh hen the MPL interrupt was accepted and d the ISR wass called. Example In nt5_WrapAround: // / Int5 ISR: : position n wraparoun nd FF; AXISOF RETI; © ElectroC Craft 2013 / return fr rom MPL IS SR // 58 82 MPD U User Manual 6.2 2.5.1.116. RGM Syntax RGM Reset R axis as s Gear/Cam M Master Operands s – Binary co ode Description Resets the drive/mo otor from the electronic e gea aring / cammiing master op peration. Whe en set ster, the drive/motor send ds either the load position n APOS (if O OSR.15 = 0) o or the as mas position n reference TPOS T (if OSR R.15 = 1) to th he axis or the e group of axxes specified in the MPL parameter p SL LAVEID. Folllowing a RG GM command d, the maste er transmissiion is disabled. The instruc ction become es effective att the next upd date command d UPD. Remarrk: Setting / resetting the master operration does n not change th he motion mo ode of the ma aster Example RG GM; // / exit from m master mode; m UP PD; // / update 6.2 2.5.1.117. ROUT Syntax Reset R OUT#n n to low state (0) ROUT#n Operands s n: outp put line numbe er (0<=n<=39 9) ode Binary co © ElectroC Craft 2013 58 83 MPD U User Manual Description ROUT#n instruction sets low (0 logic) the output line number n. In MPL the I/O lines are numbered: #0 to #39. Each product has a specific number of inputs and outputs, therefore only a part of the 40 I/O lines is used. The I/O numbering is common for all the products; hence each product has its own list of available I/Os. Example ROUT#28; © ElectroCraft 2013 //Reset output line #28 to 0 (set low) 584 MPD User Manual 6.2 2.5.1.118. SAP Syntax SAP valu ue32 Set Actual A Position n to value32 SAP VAR R32 Set Actual A Position n to VAR32 Operands s value3 32: 32-bit long g immediate value v VAR32 2: long variab ble Binary co ode Description Sets/ch hanges the re eferential for position mea asurement b by changing ssimultaneously the load po osition APOS and the targe et position TP POS values, w while keeping g the same po osition error POSERR. You u can specify y the new possition either a as an immediate value orr via a 32-bit long variable.. SAP comma and can be e executed at a any moment during motion and e following efffect: has the • If last l motion mode m setting was w done with h TUM1: TP POS = new_v value; AP POS = TPOS – POSERR; • If last l motion mode m setting was w done with hout TUM1, i.e 0: e. with TUM0 AP POS = new_v value; TP POS = APOS + POSERR; Remarrk: In case of steppers controlled o open loop wiith no positio on feedback, SAP comma and sets the new n position value only in TPOS. This in nstruction use es a 9-bit sh hort address s for the desttination varia able. Bit 9 va alue X specifiies the destination address s range: © ElectroC Craft 2013 58 85 MPD U User Manual Example // Position profile. Position feedback: 500 lines incremental // encoder (2000 counts/rev) CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 33.3333;//slew speed = 1000[rpm] CPOS = 6000;//position command = 3[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate !MC; // set event when motion is completed WAIT!;//Wait until the event occurs i.e. the motor stops // At this point TPOS=6000, APOS = 6000-POSERR SAP 2000; // Set actual position 1[rot] // Now, TPOS=2000, APOS=2000-POSERR © ElectroCraft 2013 586 MPD User Manual 6.2 2.5.1.119. SAVE Syntax Sav ve setup data in the EEPRO OM SAVE Operands s – Binary co ode Description Saves the actual va alues of all th he MPL param meters with ssetup data fro om the active e data m into the t EEPROM M memory, in tthe setup tab ble. Through tthis command d, you RAM memory can sa ave all the settup modificatio ons done, aftter the power on initializatio on. Example SA AVE; // Sa ave setup data d in th he EEPROM s setup tabl le © ElectroC Craft 2013 58 87 MPD U User Manual 6.2 2.5.1.120. SCIBR Syntax SCIBR va alue16 Set S Serial Co ommunication Interface Ba aud Rate to va alue16 SCIBR VA AR16 Set S Serial Co ommunication Interface Ba aud Rate to VA VAR16 Operands s value1 16: 16-bit integ ger immediate value betwe een 0 and 4 VAR16 6: integer variiable Binary co ode Description Sets th he baud rate on the RS23 32/RS485 serrial communiccation interface (SCI). The e new baud rate r can be provided eith her as an im mmediate vallue or by the e value of a MPL variablle. In both cas ses, the poss sible values arre: The se erial baud rate e is set at pow wer on using tthe following algorithm: a. With the value read r from the EEPROM se etup table b. If th he setup table e is invalid, with w the last ba aud rate read d from a valid setup table c. If th here is no baud rate set by y a valid setu p table, with 9 9600. Remarrks: • © ElectroC Craft 2013 Us se this comma and when a drive/motor d op perates in AU UTORUN (aftter power on starts to execute e the MPL M program m from the EEP PROM) and iit must communicate with a host at a baud rate different from m the default value. In thiss case, the M MPL program m must art with a seria al baud rate change. c sta 58 88 MPD U User Manual • An alternate solution to the above case is to set via SCIBR command the desired baud rate and then to save it in the EEPROM, with the command SAVE. After a reset, the drive/motor starts directly with the new baud rate, if the setup table was valid. Once set, the new default baud rate is preserved, even if the setup table is later on disabled, because the default serial baud rate is stored in a separate area of the EEPROM. Example SCIBR 4; © ElectroCraft 2013 // sets the SCI baud rate to 115200 baud 589 MPD User Manual 6.2 2.5.1.121. SEG Syntax SEG D_tiime, D_ref Define a contouring segm ment via imm ediate valuess SEG VAR R16, VAR32 Define a contouring segm ment via MPL L variables Operands s D_time e –16-bit unsigned integer value: segme ent time D_ref: 32-bit 3 fixed im mmediate valu ue: segment rreference incrrement per tim me unit VAR16 – 16-bit integ ger variable: segment s time e VAR32 – 32-bit fixed d variable: seg gment referen nce incremen nt per time un nit Binary co ode Description Define es a contourin ng segment. The T time and d the referencce incrementt per time uniit may be pro ovided either as immediate e values or vvia the valuess of 2 MPL variables. The e time represents the seg gment duratio on expressed d in time uniits i.e. in num mber of slow w loop T reference e increment rrepresents the amount of reference varriation sampling periods. The per tim me unit i.e. per slow loop sa ampling perio od. SEG VAR16, V VAR3 32 uses a 9-bit short addrress for the operand. Bit 9, value X, spe ecifies the des stination addrress range: © ElectroC Craft 2013 59 90 MPD U User Manual Example // Position contouring with position feedback on motor: 500 lines // incremental encoder (2000 counts/rev) MODE PC;//Set Position Contouring TUM1;//Start from actual value of position reference SEG 100U, 20.00000; //1st segment. At its end, TPOS increases with // 20*100 = 2000 counts (i.e. 1 rev) UPD; //Execute immediate SEG 100U, 0.00000; // 2nd segment. At its end TPOS remains the same 0, 0.0; //End of contouring © ElectroCraft 2013 591 MPD User Manual SEG 6.2 2.5.1.122. SEND Syntax SEND VA AR16 SEND D the content of VAR16 SEND VA AR32 SEND D the content of VAR32 Operands s VAR16 6: integer variiable VAR32 2: long/fixed variable v Binary co ode Description When the instructio on is encounttered, the co ontent of VAR R16/VAR32 iss sent using “Take 2 message type. t The ins struction usess a 9-bit sho ort address for the destin nation Data 2” variable. Bit value X specifies the e destination address rang ge: Execution alue of VAR16 6/VAR32 is se ent using “Ta ke Data 2” message. The va Example MA ASTERID = 33; // Set t host ID / address = 2 // /Send SRH & SRL if motion m com mplete or p pos. trigg ger 1 bits change SR RH_MASK = 0x0002; SR RL_MASK = 0x0400; ME ER_MASK = 0xFFFF; // / send MER R on any bi it change SE END CAPPOS S; // Send to host contents c of f variable e CAPPOS 6.2 2.5.1.123. SetAsInpu ut Syntax SetAsInp put(n1, n2, n3 3,…) Operands s SetAsInput the I/O lines nu umbers n1, n2 2, n3 n1, n2, n3: IO line number. n It specifies the po osition of the control bit asssociated to th he I/O k. line in the IO_mask © ElectroC Craft 2013 59 92 MPD U User Manual Binary co ode Description Some drives/motors d s include I/O lines that m may be used either as inp puts or as ou utputs. Before using these lines as inpu uts you have e to use the S SetAsInput ccommand witth the e input numbe ers identifies the correspo onding bit from the input numbers as argument. The sk, i.e. input number n 2 has s associated bit 2 in the IO O_mask. In M MPL the inputt lines IO_mas are num mbered from 0 to 15. Remarrks: • Che eck the drive//motor user manual m to find d how are se et, after powe er-on, the I/O O lines thatt may be used d either as inp puts or as outtputs. Each p product has a specific num mber of inpu uts, therefore only a part off the 15 inputt lines is used d. • You u need to set an a I/O line as s input, only o once, after power on Example e Se etAsInput(2,5); //S Set IO line e 2 and 5 as inputs v1 1 = IN(2); //Read I/ /O line 2 data d into variable v v1 6.2 2.5.1.124. SetAsOutp put Syntax SetAsOu utput(n1, n2, n3,…) Operands s SetAsOutput I/O lines num mbered n1, n2 2, n3 n1, n2, n3: IO line number. n It specifies the po osition of the control bit asssociated to th he I/O k. line in the IO_mask Binary co ode © ElectroC Craft 2013 59 93 MPD U User Manual Description Some drives/motors d s include I/O lines that m may be used either as inp puts or as ou utputs. Before using these lines as outp puts you have e to use the S SetAsOutputt command h having ument the outtput lines num mbers. The o output lines nu umbers identtifies the conttrol bit as argu from the IO_mask, i.e. output number 7 has a associated bit 7 in the IO_ _mask, setting g to 1 e IO line will be b used as ou utput. In MPL L the output lin nes are numb bered from 0 tto 15. bit 7 the Remark ks: • Che eck the drive//motor user manual m to find d how are se et, after powe er-on, the I/O O lines thatt may be used d either as inp puts or as outtputs. Each p product has a specific num mber of inpu uts and outpu uts, therefore only a part off the 15 outpu ut lines is used. • You u need to set an a I/O line as s output, only once, after p power on Example e Se erAsOutput(7); //S Set IO line e 7 as out tput Ou ut(4,7)=0x0090; //S Set I/O lin nes 4 and 7 to High. . 6.2 2.5.1.125. SETIO Syntax SETIO#n IN SETIO#n S as Input I port SETIO#n OUT SETIO#n S as OUTput O port Operands s n: I/O number n 0<=n n<=39) Binary co ode © ElectroC Craft 2013 59 94 MPD U User Manual Description Some drives/motors include I/O lines that may be used either as inputs or as outputs. Before using these lines, you need to specify how you want to use them, with the SETIO commands: SETIO#n OUT; //Set the I/O line #n as an input SETIO#n IN; //Set the I/O line #n as an output Remarks: • Check the drive/motor user manual to find how are set, after power-on, the I/O lines that may be used either as inputs or as outputs • You need to set an I/O line as input or output, only once, after power on In MPL the I/O lines are numbered: #0 to #39. Each product has a specific number of inputs and outputs, therefore only a part of the 40 I/O lines is used. The I/O numbering is common for all the products; hence each product has its own list of available I/Os. Example SETIO#12 OUT; //Set IO line 12 as output ROUT#12; //Reset IO line 12 level low (0 logic) SETIO#12 IN; //Set IO line 12 as input v1 = IN#12; //Read I/O line 12 data into variable v1 © ElectroCraft 2013 595 MPD User Manual © ElectroCraft 2013 596 MPD User Manual 6.2 2.5.1.126. SETMODE E Only available on multii-axis Motion Controller Syntax SETMOD DE value16 Operands s SET 2D//3D motion MODE value1 16: 16-bit integ ger immediate value Binary co ode Description Sets th he Vector or Linear Interp polation Mode e as specified d by value16 6. Value16 ha as the followin ng significance: Remarrk: after SET TMODE execu ution, a copyy of value16 6 is saved in the MPL va ariable MACOM MMAND. © ElectroC Craft 2013 59 97 MPD U User Manual Example // 3D linear interpolated profile. Position feedbacks: 500 lines //incremental encoder SETMODE 0xCF00; //Clear buffer LPLANE (A, B, C); MODE LI; // Set Linear Interpolation Mode //Increment position with (X, Y, Z) = (0.5[rot], 0.05[rot], 0.05[rot]) LPOS1 1000L, 100L, 100L; LPOS2 1000L, 100L, 100L; UPD; //Execute immediate //Increment position with (X, Y, Z) = (0.05[rot], 0.5[rot], 0.05[rot]) LPOS1 100L, 1000L, 100L; LPOS2 100L, 1000L, 100L; //Increment position with (X, Y, Z) = (0.5[rot], 0.1[rot], 0.25[rot]) LPOS1 1000L, 200L, 500L; LPOS2 1000L, 200L, 500L; //Increment position with (X, Y, Z) = (0.5[rot], 0.5[rot], 0.5[rot]) LPOS1 1000L, 1000L, 1000L; LPOS2 1000L, 1000L, 1000L; © ElectroCraft 2013 598 MPD User Manual 6.2 2.5.1.127. SETPT Syntax SETPT va alue16 Operands s SETup S PT mo ode operation n value1 16: 16-bit integ ger immediate value Binary co ode Description Sets the PT mode e operation as a specified b by the value e16. Value16 has the follo owing cance: signific Remarrk: after SETPT executio on, a copy of value16 iis saved in the MPL va ariable PVTMODE. © ElectroC Craft 2013 59 99 MPD U User Manual Example SETPT 0xE02F; //Leave PT buffer intact; Change integrity //counter value to 17 MODE PVT; // Set PVT Mode TUM1;//Start from actual value of position reference CPR; PVTP 2000L, 0.0667, 500U, 17;//PVT(1[rot], 1.9[rpm], 0.5[s]) UPD; //Execute immediate PVTP 0L, 0.0667, 500U, 18;//PVT(1[rot], 1.99997[rpm], 1[s]) PVTP 6000L, 0, 500U, 19;//PVT(4[rot], 0[rpm], 1.5[s]) © ElectroCraft 2013 600 MPD User Manual 6.2 2.5.1.128. SETPVT Syntax SETPVT value16 Operands s SETup S PVT mode m operatio on value1 16: 16-bit integ ger immediate value Binary co ode Description Sets th he PVT mod de operation as specified by the value e16. Value16 6 has the follo owing signific cance: Remarrk: after SET TPVT executtion, a copy of value16 is saved in the MPL va ariable PVTMODE. © ElectroC Craft 2013 60 01 MPD U User Manual Example // PVT sequence. Position feedback: 500 lines incremental // encoder (2000 counts/rev) MASTERID = 4081; // Set host address to 255 (255<<4+1) SETPVT 0xC000; //Clear PVT buffer, disable counter check //Don’t change counter & buffer low condition MODE PVT; // Set PVT Mode TUM1;//Start from actual value of position reference CPR; // Relative mode PVTP 400L, 60, 10U, 0;//PVT(0.2[rot], 1800[rpm], 0.01[s]) UPD; //Execute immediate PVTP 400L, 0, 10U, 0;//PVT(0.4[rot], 0[rpm], 0.02[s]) !MC; WAIT!; //wait for completion © ElectroCraft 2013 602 MPD User Manual 6.2 2.5.1.129. SETSYNC Syntax SETSYNC C value16 Operands s SET S SYNChrronization valu ue16 value1 16: 16-bit integ ger immediate value Binary co ode Description Enables/disables the transmissio on of synchro onization messages. The drive/motor, were m are e enabled, is master m for the e synchroniza ation process. This is perfo ormed these messages in two steps. s First, the t master se ends a synch hronization me essage to all axes, including to itself. When W this me essage is rece eived, all the axes read th heir own interrnal time. Nexxt, the master sends its intternal time to o all the slave es, which com mpare it with their own in nternal e slaves corre ect slightly the eir sampling periods in ord der to time. If there are diffferences, the hem synchro onized with those t of the e master. Ass effect, whe en synchronizzation keep th procedure is active, the executio on of the conttrol loops on tthe slaves is synchronized d with those of o the maste er within a 10μs 1 time intterval. Due tto this powe erful feature, drifts betwee en master and slave axes s are elimina ated. The MP PL command SETSYNC value activate es the synchrronization pro ocedure if vallue is differen nt from 0. Va alue represents the time intterval in interrnal units betw ween the syn nchronization messages ssent by the m master. Recommended valu ue is 20ms. Setting value e to 0 stops the master transmissionss and vates the sync chronization procedure. p deactiv Remarrk: The mastter for synch hronization prrocedure can n be any driive/motor from m the network k or a host. The master for this proce ess may or m may not be the same witth the overall motion applic cation masterr (if present). Example SE ETSYNC 20; //Send sy ynchronizat tion messa ages every 20[ms] © ElectroC Craft 2013 60 03 MPD U User Manual 6.2 2.5.1.130. SGM Syntax SGM Set S axis as Gear/Cam G Masster Operands s – Binary co ode Description Sets the drive/motorr in the electrronic gearing g / camming m master opera ation. When sset as masterr, the drive/m motor sends either the lo oad position A APOS (if OS SR.15 = 0) o or the position n reference TPOS T (if OSR R.15 = 1) to th he axis or the e group of axxes specified in the MPL parameter p SL LAVEID. Folllowing a SG GM command d, the maste er transmissiion is enabled d. The instruc ction becomes s effective at the next upda ate command d UPD. Remarrk: Setting / resetting the master operration does n not change th he motion mo ode of the ma aster Example // / On master axis: SL LAVEID = 31; 3 // send to ax xis 31 SG GM; //Enab ble Master in Electr ronic Geari ing mode SR RB OSR, 0x xFFFF, 0x80 000; // OS SR.15=1 -> Send Posi ition Refer rence UP PD; //exec cute immedi iate © ElectroC Craft 2013 60 04 MPD U User Manual 6.2 2.5.1.131. SOUT Syntax SOUT#n Operands s Set S OUT#n to o high state (1 1) n: outp put line numbe er (0<=n<=39 9) Binary co ode Description SOUT# #n instruction sets high (1 logic) the ou utput line num mber n. In MP PL the I/O line es are numbered: #0 to #39 9. Each produ uct has a spe ecific number of inputs and d outputs, therefore p of the 40 0 I/O lines is used. The I/O O numbering is common fo or all the prod ducts; only a part hence each e product has its own list of availablle I/Os. Example OUT#12; SO © ElectroC Craft 2013 Set output line #12 to 1 (set high) //S 60 05 MPD U User Manual 6.2 2.5.1.132. SRB/SRBL L Syntax SRB VAR R16, ANDmas sk, ORmask Set/Re eset Bits of VA AR16 (short a addressing) SRBL VA AR16, ANDma ask, ORmask k Set/Re eset Bits of VA AR16 (full add dressing) Operands s VAR16 6: integer variiable ANDma ask: 16-bit ma ask for AND operation o ORmas sk: 16-bit mas sk for OR ope eration Binary co ode Description Perform ms a logic AND A between n VAR16 and d the AND m mask, followe ed by a logic OR betwee en the result and a the OR mask. The re esult is saved d in VAR16. These instrucctions may be e used to set/reset individu ual bits from a register or a MPL variable without affe ecting the other ones. SRB B performs th hese operatio ons in a safe e way avoidin ng the interfe erence current proce esses wantin g to change e the same M MPL data. T This is with the other conc or the MPL re egisters, which h have bits th hat can be manipulated byy both particullarly useful fo drive/m motor and user at MPL leve el. SRB us ses a 9-bit sh hort address s for the operrand. Bit 9 va alue X speciffies the destin nation address s range: All pre edefined or user-defined u MPL M data arre inside thesse address rranges, hence this instruc ction can be used u without checking the e variables ad ddresses. How wever, consid dering future developmentts, the MPL also includes S SRBL instrucction using a 1 16-bit full add dress for the operand. © ElectroC Craft 2013 60 06 MPD U User Manual Example in nt var1; .. ... SR RB var1, 0xFF0F, 0x0 0003; //Reset / bi ts 4 to 7, , set bits 0 // /and 1 of v var1 6.2 2.5.1.133. STARTLOG Syntax STARTLO OG value Operands s START LOGGER value: integer value e 1 or 2 Binary co ode Description Starts the t acquisitio on of the varia ables selecte ed in the Setu up Logger V Variables diallogue. Value may m have the following values: 1 – acq quire data at each e current loop sampling g or from n to o n current loo op samplings 2 – acq quire data at each position n/speed samp pling loop or ffrom n to n p position/speed d loop samplin ngs Where n is the numb ber of samplin ngs between two consecutive data acquisitions. he data acqu uisition simulta aneously on all the axes for multi-axiss data Remarrk: To start th logging g send a broadcast messag ge with the S TARTLOG co ommand. Example // / In the Setup Logge er Variable es, the nu umber of sa amplings b between // / data acquisitions is set to 1 ST TARTLOG 1; rrent loop sampling // Save data every cur ST TARTLOG 2; sition/spee ed loop sa ampling // Save data every pos [b b]{STARTLOG 1;} // Start S multi i-axis log gging. The data is s saved at // every e curre ent loop s sampling © ElectroC Craft 2013 60 07 MPD U User Manual 6.2 2.5.1.134. STOPLOG G Syntax STOPLOG Operands s STOP LO OGGER – Binary co ode Description Stops the t data acq quisition of th he variables selected in the Setup L Logger Variables dialogu ue. To upload d and plot th he data save ed in the drivve’s acquisitiion buffer usse the Loggerr | Upload Da ata menu com mmand. e axes for mu ulti-axis loggin ng, send a broadcast messsage Remark: To stop the data acquisittion on all the e STOPLOG command. with the Example TOPLOG; ST // Stop the t data ac cquisition n on the cu urrent axi is [b b]{STOPLOG;} © ElectroC Craft 2013 // Stop the data d acqui isition on all the a axes. 60 08 MPD U User Manual 6.2 2.5.1.135. STA Syntax STA Set S Target po osition = Actu al position Operands s – Binary co ode Description Sets th he value of the target posittion (the posittion reference e) to the value e of the actua al load positio on i.e. TPOS = APOS_LD D. The comm mand may be e used in clo osed loop sysstems when the t load/moto or is still follo owing a hard stop, to repo osition the tarrget position to the actual load position. next motion m mode is set w without Remarrk: The STA command is automaticallyy done if the n TUM1 (i.e. using th he default targ get update m mode TUM0). In this case the target po osition peed are both h updated witth the actual values of the e load positio on and respecctively and sp load sp peed: TPOS = APOS_LD and TSPD = ASPD_LD. Example MO ODE PC; //S Set Positio on Contour ring Mode 2 TU UM1; //Set target t upd date mode 1 SE EG 100U, 5.00000; //Set 1st 1 motion n segment. Increment t //positi ion refere nce with 5 counts for //the ne ext 100 sa mpling per riods UP PD; //Updat te immedia ate SE EG 100U, 5.00000; //Set 2st 2 motion n segment. SE EG 100U, -20.00000; //Set 3st 3 motion n segment. SE EG 100U, 10.00000; //Set 4st 4 motion n segment. SE EG 0, 0.; //End of o contour ring mode ST TA; © ElectroC Craft 2013 rget posit tion value e (TPOS) equal to //the ac ctual //Set tar posi ition value e (APOS_LD D) 60 09 MPD U User Manual 6.2 2.5.1.136. STOP Syntax STOP! STOP S motion n on event Operands s – Binary co ode Description Executtes a STOP command c whe en a program mmed event occurs. Example:: // / Move at constant speed s and stop when input 36 goes low. // / Position n feedback: : 500 line es encoder (2000 cou unts/rev) CA ACC = 0.3183; //acce eleration rate r = 100 00[rad/s^2] ] CS SPD = 33.3333;//jog speed = 10 000[rpm] MO ODE SP; TU UM1; //set Target Up pdate Mode 1 UP PD; //exe ecute immed diate !I IN#36 0; // Set even nt: when in nput #36 g goes low ST TOP!; //Stop the mot tion when event e occu urs WA AIT!; //Wait until the t event occurs o © ElectroC Craft 2013 610 MPD U User Manual 6.2 2.5.1.137. TUM Syntax TUM0 Set S Target Up pdate Mode 0 TUM1 Set S Target Up pdate Mode 1 Operands s – Binary co ode Description Sets th he target update mode 0 or o 1. The TUM M0 and TUM1 1 instructions offer 2 choicces for starting a new motio on mode. After a TUM1 com mmand, the reference ge enerator com mputes the n new motion mode trajectory starting frrom the actua al values of po osition and sp peed referencce. After a TUM0 com mmand, the re eference gen nerator first updates the p position and sspeed referen nces with the e actual value es of the load d position and d speed (TPO OS=APOS_LD D and TSPD= =ASPD_LD) and then starrts to compute e the new mo otion mode tra ajectory. der to By deffault, each co ommand setting a motion mode activattes the TUM0 0 mode. In ord activatte the TUM1 mode, exec cute the MP PL instruction TUM1 AFT TER the com mmand setting g the motion mode m and BEFORE the UP PD command d. As a general g rule, TUM1 T mode is recommen nded for norm mal operation. Use TUM0 in the following situations: • FF command d, where sign nificant differe ences Recovery from an error settting AXISOF ay occur betw ween the las st target possition and sp peed values computed b by the ma refe erence generator before the AXISOF F and the a actual values of the load//motor pos sition and spe eed • Pre ecise relative positioning frrom the pointt where the lo oad/motor has hit a marke er – to elim minate the following error • Wh hen you start / stop your motor m using on nly AXISON / AXISOFF commands • If you y switch fro om a torque control mode e (where targ get position a and speed arre not com mputed by the e reference generator) g to a motion mod de performing g position or sspeed con ntrol © ElectroC Craft 2013 611 MPD U User Manual Remark: In open loop control of steppers, TUM0 is ignored as there is no position and/or speed feedback The instructions become effective at the next update command UPD. Example1: // Start a position profile with TUM1. Position feedback: // 500 lines incremental encoder (2000 counts/rev) CACC = 0.3183; //acceleration rate = 1000[rad/s^2] CSPD = 33.3333; //slew speed = 1000[rpm] CPOS = 6000; //position command = 3[rot] CPR; //position command is relative SRB ACR 0xFFFF, 0x800; // and additive MODE PP; // set trapezoidal position profile mode TUM1; //set Target Update Mode 1 UPD; //execute immediate Example2: // Start a position profile with TUM0. Position feedback: // 500 lines incremental encoder (2000 counts/rev) CACC = 0.3183; //acceleration rate = 1000[rad/s^2] CSPD = 33.3333; //slew speed = 1000[rpm] CPOS = 6000; //position command = 3[rot] CPR; //position command is relative SRB ACR 0xFFFF, 0x800; // and additive MODE PP; // set trapezoidal position profile mode // No need to set TUM0 before UPD as MODE PP does it automatically UPD; //execute immediate © ElectroCraft 2013 612 MPD User Manual 6.2 2.5.1.138. UPD Syntax UPD! UPDate U motio on on event ! Operands s – Binary co ode Description Executtes an UPD command c whe en a program mmed event occcurs. Example // / Start a speed prof file and ch hange spee ed after 3 seconds. // / Position feedback: : 500 lines s encoder (2000 coun nts/rev) CA ACC = 0.1591;//accel leration ra ate = 500[ [rad/s^2] CS SPD = 40;//jog speed d = 1200[rp pm] MO ODE SP; TU UM1;//set Target Upd date Mode 1 UP PD;//execute immedia ate !R RT 3000; // set even nt after a wait time e of 3s CS SPD = 20;//jog speed d = 600[rpm m] UP PD!;//Update on even nt WA AIT!; //Wait until the t event occurs o © ElectroC Craft 2013 613 MPD U User Manual 6.2 2.5.1.139. VPLANE Only available on multii-axis Motion Controller Syntax VPLANE (X_axis, Y_a axis, Tangent_ _axis) Vecto or PLANE Operands s X_axis s, Y_axis, Tan ngent_axis: sllave axes deffining the coo ordinate syste em Binary co ode Description Sets th he 2D coordiinate system m for Vector Mode using the slave axxes specified d with X_axis,, Y_axis. and d Tangent_ax xis. Example // 2D linear in nterpolated d profile. Position feedbacks s: 500 line es remental encoder e //incr DE 0xCF00; ; //Clear buffer b SETMOD VPLANE E (A, B, C);// C X_axi is = A, Y_ _axis = B a and Tangen nt_axis = C RESRAT TIOX=0u; RESRAT TIOY=0u; NLINES STAN=2000; ; MODE VM; V // Set t Vector Mo ode // Ci ircular se egment of radius 3.14159[mm], , with in nitial angle 0[deg] and angle in ncrement 360[deg]) 3 CIRCLE E1 1L, 360 0.; CIRCLE2 2 1L, 0.; UPD; //Execute / immediate // Ins sert End Segment S VSEG1 0L, 0L; VSEG2 V 0L, 0L; 0 A, B, C); // wait fo or motion completion n WMC (A © ElectroC Craft 2013 614 MPD U User Manual 6.2 2.5.1.140. VSEG Only available on multii-axis Motion Controller Syntax VSEG1 Pos_X, P Pos_Y Y VSEG2 Pos_X, P Pos_Y Y Operands s Vector linear SEGme ent Pos_X X: X axis posittion incremen nt for 2D trajecctory Pos_Y Y: Y axis posittion incremen nt for 2D trajecctory ode Binary co Description VSEG1 1 and VSEG2 define a linear segment fo or 2D trajecto ory executed in Vector Mod de. Based on Radius, Theta_inc and a Theta_sttart the MPL L compiler ffrom the a actual eters used by the motion controller to ge enerate the P PVT points forr slave axes. parame If the po oints are sent from a host then the follo owing relation ns must be ussed to compute the actual parameters p of a path segm ment: © ElectroC Craft 2013 615 MPD U User Manual Example // 2D linear interpolated profile. Position feedbacks: 500 lines //incremental encoder SETMODE 0xCF00; //Clear buffer LPLANE (A, C); //Slaves A and C define the coordinate system MODE LI; // Set Linear Interpolation Mode // Increment position with (X, Y) = (0.5[rot], 0.05[rot]) LPOS1 1000L, 100L; LPOS2 1000L, 100L; UPD; //Execute immediate // Increment position with (X, Y) = (0.05[rot], 0.5[rot]) LPOS1 100L, 1000L; LPOS2 100L, 1000L; // Increment position with (X, Y) = (0.5[rot], 0.1[rot]) LPOS1 1000L, 200L; LPOS2 1000L, 200L; // Increment position with (X, Y) = (0.5[rot], 0.5[rot]) LPOS1 1000L, 1000L; LPOS2 1000L, 1000L; © ElectroCraft 2013 616 MPD User Manual 6.2 2.5.1.141. WAIT! Syntax WAIT! WAIT motion event ! WAIT! va alue32 WAIT motion event ! but exit if time e > value32 Operands s value3 32: 32-bit long g immediate value v – wait lo oop timeout limit Binary co ode Description Stops the MPL program executio on, until the prrogrammed e event occurs. During this p period, only the e MPL comm mands receive ed via a comm munication ch hannel are pro ocessed. You u may also sp pecify the tim meout limit for f the wait, by adding a time value e after the W WAIT! comma and: value32. If the monito ored event do oesn’t occur in n the time limit set, the waiit loop is interrrupted; the ev vent checking g is reset and d the MPL prrogram passe es to the nextt MPL instructtion. The time eout is measu ured in interna al time units i..e. slow loop sampling perriods. Example1 1 // / Unconditional wait t for a mot tion compl lete event // / Position profile. Position feedback: f tal 500 lines increment // / encoder (2000 coun nts/rev) CS SPD = 10;//slew spee ed = 300[rp pm] CP POS = 4000;//positio on command = 2[rot] CP PR;//position comman nd is relat tive MO ODE PP; UP PD;//execute immedia ate !M MC; // set motion co omplete eve ent WA AIT!; //wait for the e programme ed event t to occur // / if the final posit tion is not t reached or the mot tion compl lete is // / not set because th he settle band b and t time condit tions are not met // / the MPL program wi ill remain at this p point © ElectroC Craft 2013 617 MPD U User Manual Example2 //Conditional wait for a limit switch event // Speed profile. Position feedback: 500 lines incremental // encoder (2000 counts/rev) CACC = 0.1591;//acceleration rate = 500[rad/s^2] CSPD = 40; //jog speed = 1200[rpm] MODE SP; TUM1; //set Target Update Mode 1 UPD;//execute immediate ENLSP1; // activate LSP input to detect low->high transitions !LSP; // set event of LSP transition WAIT! 5000; //Wait until the event occurs but no more than 5[s] STOP; // stop motion © ElectroCraft 2013 618 MPD User Manual 6.2 2.5.1.142. WAMPU Syntax WAMPU (Slave), value e32 Wait for slave’s Ab bsolute Motorr Position Und der value32 WAMPU (Slave), VAR R32 der VAR32 Wait for slave’s Ab bsolute Motorr Position Und Operands s Slave: slave axis monitored for event e occurre nce VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the slave’s s motorr absolute po sition becomes equal or u under the spe ecified ave programm med an event, you value or the value of the speciffied variable. After you ha o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n of slave axe es when the e event occurs, with comman nd STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for waiit expires. Execution on <= Activattes the monitoring of the event e on the sslave axis, w when motor ab bsolute positio value3 32, respective ely VAR32. Th he motion con ntroller appliccation remainss in a loop un ntil the event on the slav ve axis occu urs or it tim meouts. This operation e erases a pre evious ammed event that has occu urred. progra © ElectroC Craft 2013 619 MPD U User Manual Example //Stop slave B and C when the motor position <= -3 rev on slave A //Position feedback: 500 lines encoder (2000 counts/rev) // Wait for event : When axis A motor absolute position is // equal or under value -3 rot WAMPU (A), -6000L; (B,C) { STOP; // Stop motion with acceleration / deceleration set } © ElectroCraft 2013 620 MPD User Manual 6.2 2.5.1.143. WAMPO Syntax WAMPO (Slave) value e32 Wait for slave’s Absolute Motor Po osition Over vvalue32 WAMPO (Slave) VAR3 32 Operands s Wait for slave’s Absolute Motor Po osition Over V VAR32 Slave: slave axis monitored for event e occurre nce VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the slave’s motor absolute po osition becom mes equal or over the spe ecified ave programm med an event, you value or the value of the speciffied variable. After you ha o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n of slave axe es when the e event occurs, with comman nd STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the wait expires.. Execution Activattes the monitoring of the event on >= e on the sslave axis, w when motor ab bsolute positio value3 32, respective ely VAR32. Th he motion con ntroller appliccation remainss in a loop un ntil the event on the slav ve axis occu urs or it tim meouts. This operation e erases a pre evious ammed event that has occu urred. progra © ElectroC Craft 2013 62 21 MPD U User Manual Example //Reverse motion on B slave when motor position >= 1rev on C slave //Position feedback: 500 lines encoder (2000 counts/rev) (B) { //Speed profile on B slave CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 3.3333;//jog speed = 100[rpm] MODE SP; TUM1; //set Target Update Mode 1 UPD; // execute immediate } CSPD = -40; //jog speed = -1200[rpm] (B)CSPD = CSPD; //Send the local variable CSPD to variable CSPD of // slaves (B) // Wait for event : When axis C motor absolute position is equal // or over value 1 rot WAMPO (C), 2000L; (B) { UPD; // Update immediate. Speed command is reversed } Remark: You can activate a new motion on a programmed event in 2 ways: • Set UPD! command then wait for event occurrence. This will activate the new motion immediately when the event occurs • Wait the event then update the motion with UPD. This will activate the new motion with a slight delay compared with the first option © ElectroCraft 2013 622 MPD User Manual 6.2 2.5.1.144. WALPU Syntax WALPU (Slave) ( value3 32 Wait for slave’s s Absolute Load Possition Under vvalue32 WALPU (Slave) ( VAR3 32 Operands s Wait for slave’s s Absolute Load Possition Under V VAR32 Slave: slave axis monitored for event e occurre nce VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the slave’s load absolute possition become es equal or u under the spe ecified ave programm med an event, you value or the value of the speciffied variable. After you ha o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n of slave axe es when the e event occurs, with comman nd STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the e wait expires. Execution Activattes the monittoring of the event on the slave axis, w when load ab bsolute positio on <= value3 32, respective ely VAR32. Th he motion con ntroller appliccation remainss in a loop un ntil the event on the slav ve axis occu urs or it tim meouts. This operation e erases a pre evious ammed event that has occu urred. progra © ElectroC Craft 2013 62 23 MPD U User Manual Example //Set the speed command when load absolute position is <= 10 rev //Position feedback: 500 lines encoder (2000 counts/rev) // Wait for event : When axis B load absolute position is equal // or under value 10 rot CSPD = 13.3333;//new slew speed command = 500[rpm] WALPU (B), 20000L; (C)CSPD = CSPD; //Send the local variable CSPD to variable CSPD // of slaves (C) © ElectroCraft 2013 624 MPD User Manual 6.2 2.5.1.145. WALPO Syntax WALPO (Slave), ( value e32 Wait slav ve’s Absolute e Load Positio on Over value e32 WALPO (Slave), ( VAR3 32 Operands s Wait slav ve’s Absolute e Load Positio on Over VAR R32 Slave: slave axis monitored for event e occurre nce VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the slave’s load absolute possition becom mes equal or over the spe ecified ave programm med an event, you value or the value of the speciffied variable. After you ha o the following g actions: can do • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n of slave axe es when the e event occurs, with comman nd STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the wait expires.. Execution Activattes the monittoring of the event on the slave axis, w when load ab bsolute positio on >= value3 32, respective ely VAR32. Th he motion con ntroller appliccation remainss in a loop un ntil the event on the slav ve axis occu urs or it tim meouts. This operation e erases a pre evious ammed event that has occu urred. progra © ElectroC Craft 2013 62 25 MPD U User Manual Example //Stop all slaves when load position on slave B >= 3 rev //Position feedback: 500 lines encoder (2000 counts/rev) TIMEOUT 1000L; // Set wait timeout to 1[s] // Wait for event : When axis B motor absolute position is equal // or over value 1 rot WAMPO (B), 6000L; STOP; // Stop the motion © ElectroCraft 2013 626 MPD User Manual 6.2 2.5.1.146. SAVEERR ROR Syntax SAVEERROR VAR32 Operands s GET oldest ERROR ffrom RAM VAR32 2: 32-bit long variable conttaining the sla ave error ode Binary co Description Saves the t slave erro or from VAR3 32 in a circula ar buffer locatted in EEPRO OM. The buffe er can hold up p to 8 error co odes. If the bu uffer is full an nd a new erro or is saved then the oldestt error is overw written. The content of VA AR32 must b be initialized using the GE ETERROR V VAR32 comma and. Example trieve old dest 3 erro ors and sa ave them in n the EEPR ROM // Ret LONG error_code e e; //define e variable e error_cod de GETERR ROR error_ _code; //Re ead oldest t error fro om motion controller r RAM SAVEER RROR error r_code; // Save the error in t the motion n controlle er EEPROM GETERR ROR error_ _code; //Re ead second d error fro om motion controller r RAM SAVEER RROR error r_code; // Save the error in t the motion n controlle er EEPROM GETERR ROR error_ _code; //Re ead third error from m motion c controller RAM SAVEER RROR error r_code; // Save the error in t the EEPROM M SEND error_code e e; // Send third err ror code to o the host t © ElectroC Craft 2013 62 27 MPD U User Manual 6.2 2.5.1.147. GETERRO OR Syntax GETERR ROR VAR32 GET oldest ERROR ffrom RAM GETERR ROR n,VAR32 2 GET n-th h ERROR fro om EEPROM Operands s VAR32 2: 32-bit long variable to sttore the error n : erro or position in the circular buffer ode Binary co Description The mo otion controlle er uses a circ cular buffer in n RAM to storre the slaves’’ errors. The buffer can holld up to 8 erro or codes. If an n error is rece eived and the e buffer is full then the new w error will ove erwrite the old dest one. The e buffer is rea ad with GETERROR VAR3 32 command which retrieve es the oldestt error from the t motion ccontroller RAM M. The errorr code is savved in VAR32. Once it was s read the bu uffer entry is released. GE ETERROR VA AR32 returnss zero he buffer is em mpty. when th The GE ETERROR n,, VAR32 retriieves n-th errror stored in the non-volatile memory of the drive. The T errors arre stored in a circular bufffer that can h hold up to 8 error codes, n = 0 oldest entry e and n = 7 newest entry. e The errrors can be ssaved in the EEPROM witth the comma and SAVEERR ROR command. Example trieve old dest 3 erro ors and sa ave them in n the EEPR ROM // Ret LONG error_code e e; //define e variable e error_cod de GETERR ROR error_ _code; //Re ead oldest t error fro om motion controller r RAM SAVEER RROR error r_code; // Save the error in t the motion n controlle er EEPROM GETERR ROR error_ _code; //Re ead second d error fro om motion controller r RAM SAVEER RROR error r_code; // Save the error in t the motion n controlle er EEPROM GETERR ROR error_ _code; //Re ead third error from m motion c controller RAM SAVEER RROR error r_code; // Save the error in t the EEPROM M GETERR ROR 1, err ror_code; // / Retriev ve second e error from m the EEPRO OM SEND error_code e e; // Send third err ror code to o the host t © ElectroC Craft 2013 62 28 MPD U User Manual 6.2 2.5.1.148. WVDU Syntax WVDU va alue32 Wait Vecto or Distance Under U value32 2 WVDU VA AR32 Wait Vecto or Distance Under U VAR32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the vector v distanc ce is equal or under the sp pecified value or the value of 32ou have progrrammed an e event, you can n do the follow wing actions: bit variable. After yo • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for waiit expires. Execution Activattes the moniitoring of the e event when n vector disttance <= value32, respecctively VAR32 2. The motion n controller application a re emains in a lo oop until the event occurss or it timeou uts. This operation erases a previous prrogrammed event that has occurred. © ElectroC Craft 2013 62 29 MPD U User Manual 6.2 2.5.1.149. WCAP Syntax WCAP1 (Slave) ( Wait W for slave’s s 1st CAPture e input transittion 0 to 1 WCAP0 (Slave) ( Wait W for slave’s s 1st CAPture e input transittion 1 to 0 Operands s Slave: slave axis monitored for event e occurre nce Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the transition t occ curs on the 1sst capture/enccoder index inputs on the slave W the prog grammed tran nsition occurss the following g happens on n the slave axxis: axis. When • The e input capa ability to dete ect transitionss is disabled. It must be enabled aga ain to dettect another transition • Mo otor position APOS_MT A is captured and d memorized d in the MPL vvariable CAP PPOS, exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured instead • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, when lo oad position iss captured in CAPPOS. The se election betwe een master and load posittion is done as follows: loa ad position is ssaved in CAP PPOS2 only for f setup conffigurations wh hich use diffe erent sensors for load and motor and foresee a trans smission ratio o between the em. For all the e other setup configuration ns, the s in CAPPOS2 master position is saved After you y have prog grammed an event, e you ca an do the follo owing actions: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the wait expires.. © ElectroC Craft 2013 63 30 MPD U User Manual Execution Activates the monitoring of the event, when the programmed transition (low to high or high to low) occurs on the 1st capture/encoder index input. The motion controller application remains in a loop until the event on the slave axis occurs or it timeouts. This operation erases a previous programmed event that has occurred. Example //Stop motion on all slaves on next encoder index // Wait for event : When axis A encoder index goes low->high WCAP1 (A); STOP; //Stop the motion (A) { // Command slave A to move on captured position CPOS = CAPPOS; // new command position = captured position CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate } WMC (A); //wait for completion © ElectroCraft 2013 631 MPD User Manual 6.2 2.5.1.150. WVDO Syntax WVDO va alue32 Wait Vecto or Distance Under U value32 2 WVDO VA AR32 Wait Vecto or Distance Under U VAR32 Operands s VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the vector v distanc ce is equal orr over the spe ecified value or the value of 32ou have progrrammed an e event, you can n do the follow wing actions: bit variable. After yo • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for waiit expires. Execution Activattes the moniitoring of the e event when n vector disttance >= value32, respecctively VAR32 2. The motion n controller application a re emains in a lo oop until the event occurss or it timeou uts. This operation erases a previous prrogrammed event that has occurred. © ElectroC Craft 2013 63 32 MPD U User Manual 6.2 2.5.1.151. WTR Syntax WTR (Sla ave) Operands s Wait Targe et Reached Slave: slave axis monitored for event e occurre nce Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the slave s axis rea aches the targ get position. After you havve programmed an a event, you can do the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for waiit expires. Execution Activattes the mon nitoring of th he event wh en target re eached. The motion con ntroller applica ation remains s in a loop unttil the event o occurs or it tim meouts. This o operation era ases a previou us programm med event thatt has occurred d. © ElectroC Craft 2013 63 33 MPD U User Manual 6.2 2.5.1.152. WPRU Syntax WPRU (S Slave), value3 32 Wait fo or slave’s Position P Re ference Und der value32 WPRU (S Slave), VAR32 2 Wait for slave’s Posittion Referencce Under VAR R32 Operands s Slave: slave axis monitored for event e occurre nce VAR32 2: long variab ble value3 32: 32-bit long g immediate value v ode Binary co Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the when the position referen nce is equal o or under the specified value or ecified variab ble. After you have program mmed an eve ent, you can d do the the value of the spe following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the WAIT! comm mand expires. u need to wa ait until the p programmed event Remarrk: After settting UPD! orr STOP! you occurs s using WAIT T!, otherwise, the program m will continue e with the next instruction ns that may ov verride the ev vent monitorin ng. Execution Activattes the monittoring of the event, when position refe erence <= vallue32, respecctively VAR32 2. The motion n controller application a rem mains in a lo oop until the e event on the slave axis oc ccurs or it tim meouts. This operation o era ases a previo ous programm med event tha at has occurred. © ElectroC Craft 2013 63 34 MPD U User Manual Example: //Stop motion when position reference >= 3 rev //Position feedback: 500 lines encoder (2000 counts/rev) WPRU 6000; //Set event: when position reference is >= 3 rev STOP;//Stop the motion when the event occurs © ElectroCraft 2013 635 MPD User Manual 6.2 2.5.1.153. WPRO Syntax WPRO (S Slave), value3 32 Wait for slave’s Position P Referrence Over va alue32 WPRO (S Slave), VAR32 2 Wait for slave’s Po osition Refere ence Over VA AR32 Operands s Slave: slave axis monitored for event e occurre nce VAR32 2: long variab ble value3 32: 32-bit long g immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the slave’s positiion reference e is equal or over the spe ecified value o or the ave programm med an even nt, you can d do the value of the speciffied variable. After you ha following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for waiit expires. Execution Activattes the monittoring of the event, when position refe erence >= vallue32, respecctively VAR32 2. The motion n controller application a rem mains in a lo oop until the e event on the slave axis oc ccurs or it tim meouts. This operation o era ases a previo ous programm med event tha at has occurred. © ElectroC Craft 2013 63 36 MPD U User Manual Example: //Stop motion on all slaves when position reference on slave C >= // 3 rev. Position feedback: 500 lines encoder (2000 counts/rev) // Wait for event : When position reference on axis C is equal or // over value 3rot WPRO (C), 6000L; STOP; //Stop the motion © ElectroCraft 2013 637 MPD User Manual 6.2 2.5.1.154. WMSU Syntax WMSU (S Slave), value3 32 Wait for slave’s M Motor Speed d Under value32 WMSU (S Slave), VAR32 2 Motor Speed d Wait for slave’s M Under VAR32 Operands s Slave: slave axis monitored for event e occurre nce VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets th he event con ndition halts th he execution of the MPL program from m motion con ntroller until th he motor spee ed is equal orr under the 32 d fixed 2-bit value orr the value of the specified variable. After you have h program mmed an even nt, you can do o the following actions: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for waiit expires. Execution Activattes the monito oring of the event e when m motor speed <= value32, re espectively VA AR32. The motion m controller applicatio on remains in e axis n a loop unttil the event on the slave occurs s or it timeou uts. This ope eration erase es a previouss programme ed event tha at has occurred. © ElectroC Craft 2013 63 38 MPD U User Manual Example //Motor on slave A is decelerating. Start a new position profile // on slave A when motor speed < 600 rpm //Position feedback: 500 lines encoder (2000 counts/rev) WMSU (A) 20; //Set event: when motor speed is < 600 rpm // prepare new motion mode (A) { CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD }; © ElectroCraft 2013 639 MPD User Manual 6.2 2.5.1.155. WMSO Syntax WMSO (S Slave), value3 32 Wait fo or slave’s Motor Speed Ove er value32 WMSO (S Slave), VAR32 Wait fo or slave’s Motor Speed Ove er VAR32 Operands s Slave: slave axis monitored for event e occurre nce VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until when the motor speed s is equa al or over the 32-bit value or the value of the able. After yo ou have prog rammed an e event, you ca an do the follo owing specifiied fixed varia actions s: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the wait expires.. Execution Activattes the monittoring of the event on the slave axis, w when motor sspeed >= vallue32, respec ctively VAR32 2. The motion controller ap pplication rem mains in a loop p until the eve ent on the sla ave axis occurs or it timeouts. This ope eration erasess a previous p programmed event that ha as occurred. © ElectroC Craft 2013 64 40 MPD U User Manual Example //Motor is accelerating. Stop motion on all axes when motor //speed > 600 rpm //Position feedback: 500 lines encoder (2000 counts/rev) WMSO (D) 20; //Set event: when motor speed is > 600 rpm STOP;//Stop the motion when the event occurs © ElectroCraft 2013 641 MPD User Manual 6.2 2.5.1.156. WLSP Syntax WLSP1 Wait for slav ve’s Limit Sw witch Positive g goes from 0 tto 1 WLSP0 Wait for slav ve’s Limit Sw witch Positive g goes from 1 tto 0 Operands s – Binary co ode Description Sets the event con ndition when the program mmed transitiion occurs at the positive e limit switch input. After you y have prog grammed an e event, you ca an do the follo owing actionss: • hange the motion m mode and/or the parameters when the e event occurs,, with Ch co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the wait expires.. Execution Activattes monitoring of the even nt when the p programmed ttransition occcurs at the po ositive limit sw witch input. Th his operation erases a pre evious program mmed event tthat has occu urred. © ElectroC Craft 2013 64 42 MPD U User Manual Example //Reverse slave C when positive limit switch is reached //Position feedback: 500 lines encoder (2000 counts/rev) (C) { CACC = 0.0637; //acceleration rate = 200[rad/s^2] CSPD = 16.6667; //jog speed = 500[rpm] MODE SP; UPD; //execute immediate } // Wait for event : When axis C positive limit switch goes low->high WLSP1 (C); // Wait for event : When motion is completed on axis (C) WMC (C); //limit switch is active -> quick stop mode active // wait until the motor stops because only then the // new motion commands are accepted (C) { CSPD = -40; //jog speed = -1200[rpm] MODE SP; //after quick stop set again the motion mode UPD; //execute immediate } © ElectroCraft 2013 643 MPD User Manual 6.2 2.5.1.157. WLSO Syntax WLSO (S Slave), value3 32 Wait fo or slave’s Loa ad Speed Ove er value32 WLSO (S Slave,) VAR32 2 Wait fo or slave’s Loa ad Speed Ove er VAR32 Operands s Slave: slave axis monitored for event e occurre nce VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the load speed is equal or over the 32 2-bit value orr the value o of the able. After yo ou have prog rammed an e event, you ca an do the follo owing specifiied fixed varia actions s: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for waiit expires. Execution Activattes the monittoring of the event e when lo oad speed >= = value32, re espectively VA AR32. The motion m controller applicatio on remains in n a loop unttil the event on the slave e axis occurs s or it timeou uts. This ope eration erase es a previouss programme ed event tha at has occurred. © ElectroC Craft 2013 64 44 MPD U User Manual Example //Stop motion when load speed > 600 rpm //Load Position feedback: 500 lines encoder (2000 counts/rev) WLSO (A) 20; //Set event: when load speed is > 600 rpm STOP;//Stop motion on all axes © ElectroCraft 2013 645 MPD User Manual 6.2 2.5.1.158. WLSN Syntax WLSN1 Wait W for slave’s s Limit Switch h Negative go oes from 0 to 1 WLSN0 Wait W for slave’s s Limit Switch h Negative go oes from 1 to 0 Operands s – Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the programmed transition occcurs at the n negative limit switch input.. After ave programm med an event, you can do tthe following actions: you ha • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the wait expires.. Execution Activattes monitorin ng of the eve ent on the sllave axis, wh hen the prog grammed tran nsition occurs s at the nega ative limit swittch input. The e motion con ntroller appliccation remainss in a loop until u the even nt on the sla ave axis occu urs or it time eouts. This o operation erasses a previou us programm med event thatt has occurred d. © ElectroC Craft 2013 64 46 MPD U User Manual Example //Reverse slave C when negative limit switch is reached //Position feedback: 500 lines encoder (2000 counts/rev) (C) { CACC = 0.0637; //acceleration rate = 200[rad/s^2] CSPD = -16.6667; //jog speed = -500[rpm] MODE SP; UPD; //execute immediate } // Wait for event : When axis C negative limit switch goes low->high WLSN1 (C); CSPD = 40; //jog speed = 1200[rpm] MODE SP; //after quick stop set again the motion mode UPD; //execute immediate © ElectroCraft 2013 647 MPD User Manual 6.2 2.5.1.159. WLSU Syntax WLSU (S Slave), value3 32 Wait for slave’s Load Speed Unde er value32 WLSU (S Slave), VAR32 2 Wait for slave’s Load Speed Unde er VAR32 Operands s Slave: slave axis monitored for event e occurre nce VAR32 2: fixed variab ble value3 32: 32-bit fixed d immediate value v Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the slave’s s load speed is equa al or under the e 32-bit value or the value of the able. After yo ou have prog rammed an e event, you ca an do the follo owing specifiied fixed varia actions s: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for waiit expires. Execution Activattes the monittoring of the event e when lo oad speed <= = value32, re espectively VA AR32. The motion m controller applicatio on remains in n a loop unttil the event on the slave e axis occurs s or it timeou uts. This ope eration erase es a previouss programme ed event tha at has occurred. © ElectroC Craft 2013 64 48 MPD U User Manual Example // Start a position profile when load speed < 600 rpm // Load Position feedback: 500 lines encoder (2000 counts/rev) WLSU (A) 20; //Set event: when motor speed is < 600 rpm // prepare new motion mode (A) { CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 100;//slew speed = 3000[rpm] CPOS = 20000;//position command = 10[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD; } © ElectroCraft 2013 649 MPD User Manual 6.2 2.5.1.160. WIN Syntax WIN#n (S Slave), 0 Wait for f slave’s Inp put#n is 0 WIN#n (S Slave), 1 Wait for f slave’s Inp put#n is 1 Operands s Slave: slave axis monitored for event e occurre nce n: inpu ut line numberr (0<=n<=39)) Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the slave’s digita al input #n be ecomes 0, respectively 1. The slave checks e input #n is tested t at each u have the condition of the h slow loop ssampling period. After you ammed an eve ent, you can do d the followiing actions: progra • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the wait expires.. Execution Activattes monitoring g of the even nt on the slavve axis, when n the digital in nput #n becom mes 0 (!IN#n 0), respectiv vely 1 (!IN#n 1). The mottion controllerr application remains in a loop he event on the slave axis s occurs or it timeouts. Th his operation erases a pre evious until th progra ammed event that has occu urred. © ElectroC Craft 2013 65 50 MPD U User Manual Example // Start motion on slave A when digital input #36 from slave C is high // Wait for event: When axis C digital input 36/IN36 is high WIN#36 (C), 1; (A) { //Position profile CACC = 0.3183;//acceleration rate = 1000[rad/s^2] CSPD = 40.;//slew speed = 1200[rpm] CPOS = 12000L;//position command = 6[rot] CPR; //position command is relative MODE PP; TUM1; //set Target Update Mode 1 UPD; // execute immediate } WMC (A); // wait for motion completion © ElectroCraft 2013 651 MPD User Manual 6.2 2.5.1.161. W2CAP Syntax W2CAP1 (Slave) Wait for slave’s 2nd CA APture input ttransition 0 to o1 W2CAP0 (Slave) Wait for slave’s 2nd CA APture input ttransition 1 to o0 Operands s Slave: slave axis monitored for event e occurre nce Binary co ode Description Sets the t event co ondition and halts the exxecution of th he MPL prog gram from m motion controller until the transition t occurs on the 2n nd capture/en ncoder index iinputs on the slave W the prog grammed tran nsition occurss the following g happens on n the slave axxis: axis. When • The e input capa ability to dete ect transitionss is disabled. It must be enabled aga ain to dettect another transition • Mo otor position APOS_MT A is captured and d memorized d in the MPL vvariable CAP PPOS, exc cept the case e of open-loo op systems, w where referen nce position TPOS is cap ptured instead • Ma aster position APOS2 or lo oad position A APOS_LD is captured and d memorized in the MP PL variable CAPPOS2, C ex xcept the casse of stepperrs controlled open loop with an enc coder on the load, when lo oad position iss captured in CAPPOS. The se election betwe een master and load posittion is done as follows: loa ad position is ssaved in CAP PPOS2 only for f setup conffigurations wh hich use diffe erent sensors for load and motor and foresee a trans smission ratio o between the em. For all the e other setup configuration ns, the s in CAPPOS2 master position is saved After you y have prog grammed an event, e you ca an do the follo owing actions: • Ch hange the motion m mode and/or the parameters when the e event occurs,, with co ommand UPD D! • Stop the motion n when the ev vent occurs, w with command d STOP. e is autom matically erassed when the e event occurrs or if the tim meout The prrogrammed event for the wait expires.. © ElectroC Craft 2013 65 52 MPD U User Manual Execution Activates the monitoring of the event, when the programmed transition (low to high or high to low) occurs on the selected capture input. This operation erases a previous programmed event that has occurred. Example //Stop motion on all slaves on next 2nd encoder index // Wait for event : When axis A 2nd encoder index / home input //goes low->high W2CAP1 (A); STOP; // Stop the motion (A) { // Command slave A to move on captured position CPOS = CAPPOS; // new command position = captured position CPA; //position command is absolute MODE PP; TUM1; //set Target Update Mode 1 UPD; //execute immediate } WMC (A); //wait for completion © ElectroCraft 2013 653 MPD User Manual 6.2.6. MPL Registers 6.2.6.1. AAR - Axis Addresses Register (status, RO) Purpose: AAR is a 16-bit status register, containing information that defines the individual and group addresses of the motion axis. MPL Address: 0x030C Contents. AAR information is structured as follows: Bits 15-8 GRn. Group n selection 0= The motion axis does not belong to group n 1= The motion axis belongs to group n Bits 7-0 AXISID. Axis address value = Individual identification address for the motion axis Remark: The AxisID is initially set at power on using the following algorithm: 1 With the value read from the EEPROM setup table containing all the setup data. 2 If the setup table is invalid, with the last axis ID value read from a valid setup table 3 If there is no axis ID set by a valid setup table, with the value read from the hardware switches/jumpers for axis ID setting 4 If the drive/motor has no hardware switches/jumpers for axis ID setting, with the default axis ID value which is 255. © ElectroCraft 2013 654 MPD User Manual 6.2.6.2. ACR - Auxiliary Command Register (status, R/W) Purpose: ACR is a 16-bit status register. It defines extra settings like: the configuration for automatic start and the external reference, operation options for the S-curve and the electronic camming modes. MPL Address: 0x0912 Contents. ACR information is structured as follows: Bits 15-14 Reserved Bit 13 SOLCTR. Control type for stepper open loop 0= Position control with automatic external reference analogue 1= Speed control with automatic external reference analogue Bit 12 CAMTYPE. Electronic camming type 0= Relative 1= Absolute Bit 11 RPOSTYPE. Relative positioning type 0= Standard 1= Additive Bit 10 POSCTR. Position control 0= Disable 1= Enable Bit 9 SPDCTR. Speed control 0= Disable 1= Enable Bit 8 TCTR. Torque control 0= Disable 1= Enable Bit 7 DIGREF. Digital external reference 0= Disable © ElectroCraft 2013 655 MPD User Manual 1= Enable Bit 6 AREF. Analogue external reference 0= Disable 1= Enable Bits 5 RDAREF. Read analogue external reference for torque mode when “Automatically activated after Power On” is enabled 0= In slow loop 1= In fast loop Bit 4 Reserved Bit 3 AXISEN. Behavior at ENABLE input transitions from low to high 0= Don’t execute AXISON 1= Execute AXISON Bit 2 DIGTYPE. Digital external reference type 0= 2nd encoder 1= Pulse & Direction Bit 1 ASTART. Start automatically after power on 0= Disable 1= Enable Bit 0 STPSC. Stop profile for S-curve motion mode 0= An S-curve profile 1= A trapezoidal profile © ElectroCraft 2013 656 MPD User Manual 6.2.6.3. CBR - CAN baud rate Register (status, R/W) CBR is a 16-bit status register, containing information to setup the communication baud rate parameters for CAN controller. MPL Address: 0x030D Contents. CBR information is structured as follows: Bit 15-8 CANBTR1. CAN bus Timing Register 1 (BTR1) xx = CAN controller bus timing register 1 Bit 7-0 CANBTR0. CAN bus Timing Register 0 (BTR0) xx = CAN controller bus timing register 0 6.2.6.4. CCR - Communication Control Register (command, R/W) CCR is a 16-bit status register, containing settings for the SPI link with the EEPROM memory. MPL Address: 0x030A Contents. CCR information is structured as follows: Bit 15-2 Reserved Bit 1 Reserved Bit 0 SPIMEM. EEPROM memory 0= Not installed 1= Installed © ElectroCraft 2013 657 MPD User Manual 6.2.6.5. CER - Communication Error Register (status, RO) CER is a 16-bit status register, containing status information about communication errors on CAN, SPI and SCI communication channels. MPL Address: 0x0301 Contents. CER information is structured as follows: Bit 15-12 Reserved Bit 11 OFWRER.EnDat encoder offset write error 0= No SPI timeout 1= SPI timeout Bit 10 OFRDER. EnDat encoder offset read error 0= No SPI timeout 1= SPI timeout Bit 9 ALRSER. EnDat encoder alarm reset error 0= No SPI timeout 1= SPI timeout Bit 8 ALRDER. EnDat encoder alarm read error 0= No SPI timeout 1= SPI timeout Bit 7 SPITTO. SPI timeout on write operation 0= No SPI timeout 1= SPI timeout Bit 6 CANBER. CAN bus off error 0= No CAN bus off error 1= Error Bit 5 CANTER. CAN Tx overrun error 0= No CAN transmission overrun error © ElectroCraft 2013 658 MPD User Manual 1= CAN transmission overrun error Bit 4 CANRER. CAN Rx overrun error 0= No CAN reception overrun error 1= CAN reception overrun error Bit 3 Reserved Bit 2 SCIRTO. SCI Rx timeout error 0= No SCI reception timeout error 1= SCI reception timeout error Bit 1 SCITTO. SCI Tx timeout error 0= No SCI transmission timeout error 1= SCI transmission timeout error Bit 0 SCIRER. SCI Rx error 0= No SCI reception error 1= SCI reception error © ElectroCraft 2013 659 MPD User Manual 6.2.6.6. CSR - Communication Status Register (status, RO) CSR is a 16-bit status register, containing status information about the communication channels of the system. MPL Address: 0x030B Contents. CSR information is structured as follows: Bit 15 ELGEAR. Electronic gearing/camming master flag 0= No data to send 1= Data to send Bit 14 AXISDSTP. Axis ID setup flag 0= Initial Axis ID set by software 1= Initial Axis ID set by hardware Bit 13-11 SCIBD. SCI baud rate 000 = 9600 001 = 19200 010 = 38400 011 = 56600 100 = 115200 101 = Reserved 110 = Reserved 111 = Reserved Bit 10 Reserved © ElectroCraft 2013 660 MPD User Manual Bit 9-8 SPIBD. SPI baud rate 00 = 1 MHz 01 = 2 MHz 10 = 5 MHz 11 = Reserved Bit 7-1 Reserved Bit 0 SCITYPE. Serial communication driver type 0= RS-232 1= RS485 © ElectroCraft 2013 661 MPD User Manual 6.2.6.7. ICR - Interrupts Control Register (command, R/W) ICR is a 16-bit command register, enabling/disabling the MPL interrupts. All the unmasked bits of this register will allow the generation of a MPL interrupt at the occurrence of the associated specific situation. MPL Address: 0x0304 Contents. ICR information is structured as follows: Bit 15 GIM. Globally enable/disable MPL interrupts 0= Disable 1= Enable Bit 14-12 Reserved Bit 11 EVNIM. Enable/disable interrupt 11 – “Event set has occurred” 0= Disable 1= Enable Bit 10 TPIM. Enable/disable interrupt 10 – “Time period has elapsed” 0= Disable 1= Enable Bit 9 MOTIM. Enable/disable interrupt 9 – “Motion is complete” 0= Disable 1= Enable © ElectroCraft 2013 662 MPD User Manual Bit 8 PCAPIM. Enable/disable interrupt 8 – “Capture input transition detected” 0= Disable 1= Enable Bit 7 LSWNIM. Enable/disable interrupt 7 – “LSN programmed transition detected” 0= Disable 1= Enable Bit 6 LSWPIM. Enable/disable interrupt 6 – “LSP programmed transition detected” 0= Disable 1= Enable Bit 5 WRPIM. Enable/disable interrupt 5 – “Position wrap around” 0= Disable 1= Enable Bit 4 CMERIM. Enable/disable interrupt 4 – “Communication error” 0= Disable 1= Enable Bit 3 CTRERIM. Enable/disable interrupt 3 – “Control error” 0= Disable 1= Enable Bit 2 SWPRIM. Enable/disable interrupt 2 – “Software protection” 0= Disable 1= Enable Bit 1 PDPIM. Enable/disable interrupt 1 –“Short-circuit” 0= Disable 1= Enable Bit 0 DLSBIM. Enable/disable interrupt 0 – “Enable input has changed” 0= Disable 1= Enable © ElectroCraft 2013 663 MPD User Manual 6.2.6.8. ISR - Interrupts Status Register (status, RO) ISR is a 16-bit status register, containing the interrupt flags for MPL interrupts. Only unmasked MPL interrupts (see Interrupt Control Register - ICR) will generate a MPL interrupt request. MPL Address: 0x0306 Contents. ISR information is structured as follows: Bit 15-12 Reserved Bit 11 EVNIF. Flag for interrupt 11 – “Event set has occurred” 0= Not triggered 1= Triggered Bit 10 TPIF. Flag for interrupt 10 – “Time period has elapsed” 0= Not triggered 1= Triggered Bit 9 MOTIF. Flag for interrupt 9 – “Motion is complete” 0= Not triggered 1= Triggered Bit 8 PCAPIF. Flag for interrupt 8 – “Capture input transition detected” 0= Not triggered 1= Triggered Bit 7 LSWNIF. Flag for interrupt 7 – “LSN programmed transition detected” 0= Not triggered 1= Triggered Bit 6 LSWPIF. Flag for interrupt 6 – “LSP programmed transition detected” 0= Not triggered 1= Triggered Bit 5 WRPIF. Flag for interrupt 5 – “Position wraparound” 0= Not triggered © ElectroCraft 2013 664 MPD User Manual 1= Triggered Bit 4 CMERIF. Flag for interrupt 4 – “Communication error” 0= Not triggered 1= Triggered Bit 3 CTRERIF. Flag for interrupt 3 – “Control error” 0= Not triggered 1= Triggered Bit 2 SWPRIF. Flag for interrupt 2 – “Software protections” 0= Not triggered 1= Triggered Bit 1 PDPIF. Flag for interrupt 1 – “Short-circuit” 0= Not triggered 1= Triggered Bit 0 DSLBIF. Flag for interrupt 0 – “Enable input has changed” 0= Not triggered 1= Triggered © ElectroCraft 2013 665 MPD User Manual 6.2.6.9. MCR - Motion Command Register (status, RO) MCR is a 16-bit status register containing information about the motion modes, reference mode, active control loops, positioning type - absolute or relative, etc. MPL Address: 0x0309 Contents. MCR information is structured as follows: Bit 15 MMODE. Motion mode 0= Same motion mode 1= New motion mode Bit 14 MODECHG. When motion mode is changed 0= Update the reference 1= Keep the reference Bit 13 POSTYPE. Positioning type 0= Relative 1= Absolute Bit 12 REGMODE. Motion superposition 0= Disable the superposition of the electronic gearing mode with a second motion mode 1= Enable the superposition of the electronic gearing mode with a second motion mode Bit 11 ELGEAR. Electronic gearing master 0= Disable the axis as master 1= Enable the axis as master Bit 10 POSLP. Position loop status 0= Disabled 1= Enabled © ElectroCraft 2013 666 MPD User Manual 6.2.7. Bit 9 SPDLP. Speed loop status 0= Disabled 1= Enabled Bit 8 CRTLP. Current loop status 0= Disabled 1= Enabled Bit 7-6 EXTREF. External reference type 00 = On-line reference 01 = Analogue reference 10 = Digital reference 11 = Reserved Bit 5 REFLOC. Analogue external reference for torque/voltage mode update 0= Update in slow control loop 1= Update in fast control loop Bit 4-0 REFTYPE. Reference type 00000 = External reference 00001 = Trapezoidal reference 00010 = Contouring position/speed 00011 = Contouring torque/voltage 00100 = Pulse & direction 00101 = Electronic gearing slave 00110 = Electronic camming slave 00111 = S-curve reference 01000 = Test mode 01001 = PVT 01010 = PT 10000 = Stop 0/1/2 10001 = Stop using trapezoidal profile 10100 = Stop using S-curve profile 10101 = Quickstop © ElectroCraft 2013 667 MPD User Manual 6.2.7.1. MER - Motion Error Register (status, RO) Purpose: MER is a 16-bit status register. It groups together all the errors conditions. Most of the error conditions trigger the FAULT status. MPL Address: 0x08FC Contents. MER information is structured as follows: Bit 15 ENST. Enable status of drive/motor 0= Enabled 1= Disabled Bit 14 CMDER. Command error 0= No command error 1= Command error. The bit is set in 2 cases: Bit 13 UVER. Under voltage error 0= No under voltage error 1= Under voltage error Bit 12 OVER. Over voltage error 0= No over voltage error 1= Over voltage error Bit 11 OTERD. Drive over temperature error 0= No drive over temperature error 1= Drive over temperature error Bit 10 OTERM. Motor over temperature error 0= No motor over temperature error 1= Motor temperature error © ElectroCraft 2013 668 MPD User Manual Bit 9 I2TER. I2T protection error 0= No drive or motor I2T error 1= Drive or motor I2T error Bit 8 OCER. Over-current error 0= No over-current error 1= Over-current error Bit 7 LSNST. Negative limit switch status 0= LSN in not active 1= LSN is active Bit 6 LSPST. Positive limit switch status 0= LSP is not active 1= LSP is active Bit 5 WRPSER. Hall sensor missing /Resolver error /BiSS error /Position wrap around error 0= No error 1= Error Bit 4 SCIER. Communication error 0= No serial or internal communication error 1= Serial or internal communication error Bit 3 CTRER. Control error 0= No control error 1= Control error Bit 2 STPTBL. Setup table status 0= The drive/motor has a valid setup table 1= The drive/motor has an invalid setup table Bit 1 SCER. Short-circuit protection status 0= No short-circuit error 1= Short-circuit error Bit 0 CANBER. CAN bus status 0= No CAN bus error 1= CAN bus error © ElectroCraft 2013 669 MPD User Manual 6.2.7.2. MSR - Motion Status Register (status, RO) MSR is a 16-bit status register, containing information about motion system status and some specific events like: control error condition, position wrap-around, limit switches and captures triggered by programmed transitions, etc. MPL Address: 0x0308 Contents. MSR information is structured as follows: Bit 15 UPDATE. Update the motion mode 0= No update 1= Update Bit 14 EVNRS. Event status 0= Reset after update 1= Set of update Bit 13 AXISST. Axis status 0= Axis Off 1= Axis On Bit 12 Reserved Bit 11 EVNS. Events 0= No event set, or programmed event not occurred yet 1= Last event reached Bit 10 CNTSGS. Contour segment 0= Don’t update 1= Update © ElectroCraft 2013 670 MPD User Manual Bit 9 MOTS. Motion status 0= In motion 1= Motion complete Bit 8 PCAPS. Position capture 0= Not triggered 1= Triggered Bit 7 LSWNS. Negative limit switch 0= Not triggered 1= Triggered Bit 6 LSWPS. Positive limit switch 0= Not triggered 1= Triggered Bit 5 WRPS. Position wrap around 0= Not triggered 1= Triggered Bit 4 Reserved Bit 3 CTRERS. Control error status 0= Not triggered 1= Triggered Bit 2 SWPRS. Software protections status 0= Not triggered 1= Triggered Bit 1 SCUPD. S-Curve update status 0= S-curve updated successfully 1= S-curve update denied (UPD instruction received when motion was not complete) Bit 0 ENDINIT. Drive/motor initialization status 0= Not performed 1= Performed © ElectroCraft 2013 671 MPD User Manual 6.2.7.3. OSR - Operating Settings Register (configuration, R/W) OSR is a 16-bit configuration register, defines some specific operating settings regarding motor control and data acquisition MPL Address: 0x0302 Contents. OSR information is structured as follows: Bit 15 ELGMD. Electronic gearing master mode 0= Send actual position to slave axes 1= Send target position to slave axes Bit 14-13 Reserved Bit 12 PSPLC. Position sensor mounting place 0= Position sensor on motor 1= Position sensor on load Bit 11 LOGGER. PMSM start logging 0= No data logging during PMSM motor start 1= Data logging during PMSM motor start Bit 10 STEPCTRL. Stepper motor control type 0= Open loop 1= Closed loop Bit 9 BKCMD. Brake command 0= Disabled 1= Enabled Bit 8 UDQSAT. Ud,q command saturation method 0= Use independently saturated commands on d and q axes 1= Compute Uq from Ud. Uq = f(Ud) © ElectroCraft 2013 672 MPD User Manual Bit 7-6 PWM. PWM command method 00 = Standard symmetric PWM 01 = Dead-time and Vdc compensation 10 = Dead-time, Vdc compensation and third harmonic injection 11 = Reserved Bit 5 Reserved Bit 4-2 PMSMST. PMSM motor start method 000 = Reserved 001 = a/b, voltage mode, incremental encoder 010 = Start using digital Hall sensors 011 = Reserved 100 = Reserved 101 = Motionless start (encoder only) * 110 = Reserved 111 = Direct start using absolute encoder Bit 1-0 CRTOFF. Current offset detection 00 = No current offset detection 01 = Detection without PWM activated 10 = Detection with PWM activated 11 = Reserved *On select firmware versions only © ElectroCraft 2013 673 MPD User Manual 6.2.7.4. PCR - Motion Status Register (command/status, R/W) PCR is a 16-bit command and status register, containing both masks and status information for MPL protections. MPL Address: 0x0303 Contents. PCR information is structured as follows: Bit 15 I2TDPRS. Status of drive i2t protection 0= Not triggered 1= Triggered Bit 14 Reserved Bit 13 UVPRS. Status of under voltage protection 0= Not triggered 1= Triggered Bit 12 OVPRS. Status of over voltage protection 0= Not triggered 1= Triggered Bit 11 OT2PRS. Status of drive over temperature protection 0= Not triggered 1= Triggered Bit 10 OT1PRS. Status of motor over temperature protection 0= Not triggered 1= Triggered Bit 9 I2TMPRS. Status of motor i2t protection 0= Not triggered 1= Triggered Bit 8 IMAXP. Status of over current protection 0= Not triggered © ElectroCraft 2013 674 MPD User Manual 1= Triggered Bit 7 I2TDPRM. Mask for drive I2t protection 0= Disable 1= Enable Bit 6 Reserved Bit 5 UVPRM. Mask for under voltage protection 0= Disable 1= Enable Bit 4 OVPRM. Mask for over voltage protection 0= Disable 1= Enable Bit 3 OT2PRM. Mask for drive over temperature protection 0= Disable 1= Enable Bit 2 OT1PRM. Mask for motor over temperature protection 0= Disable 1= Enable Bit 1 I2TPRM. Mask for motor I2t protection 0= Disable 1= Enable Bit 0 IMXPRM. Mask for maximum current protection 0= Disable 1= Enable © ElectroCraft 2013 675 MPD User Manual 6.2.7.5. SCR - System Configuration Register (configuration, R/W) SCR is a 16-bit configuration register, defines the basic application configuration regarding the motor type and the feedback sensors used MPL Address: 0x0300 Contents. SCR information is structured as follows: Bit 15 Reserved Bit 14-12 MOTOR. Motor type 000 = Brushless DC 001 = Brushed DC 010 = Brushless AC 011 = Reserved 100 = Stepper 101 = Tri-phases stepper 110 = Reserved 111 = Reserved Bit 11-9 Reserved Bit 8 TSNS2. Drive temperature sensor 0= Disabled 1= Enabled Bit 7 TSNS1. Motor temperature sensor 0= Disabled 1= Enabled Bit 6 Reserved © ElectroCraft 2013 676 MPD User Manual Bit 5-3 SSNS. Speed sensor 000 = Position difference 001 = Tachogenerator 010 = Pulse length from Hall sensor 011 = Reserved 100 = Reserved 101 = Reserved 110 = Reserved 111 = None Bit 2-0 PSNS. Position sensor 000 = Quadrature encoder 001 = Resolver 010 = Sin-cos with/without EnDat 011 = SSI 100 = Linear Hall 101 = BiSS encoder 110 = Reserved 111 = None © ElectroCraft 2013 677 MPD User Manual 6.2.7.6. SRH - Status Register High part (status, RO) Purpose: SRH is the high part of a the status register grouping together all the key status information concerning the drive/motor MPL Address: 0x090F Contents. SRH information is structured as follows: Bit 15 FAULT. Fault status 0= No fault 1= Drive/motor in fault status Bit 14 INCAM. Reference position in absolute electronic camming mode 0= Not reached 1= Reached Bit 13 Reserved Bit 12 INGEAR Gear ratio in electronic gearing mode 0= Not reached 1= Reached Bit 11 I2TWRGD. Drive I2T protection warning 0= Drive I2T warning limit not reached 1= Drive I2T warning limit reached Bit 10 I2TWRGM. Motor I2T protection warning 0= Motor I2T warning limit not reached 1= Motor I2T warning limit reached Bit 9 TRGR. Target command 0= Not reached 1= Reached Bit 8 PCAPS. Capture event/interrupt 0= Not triggered 1= Triggered © ElectroCraft 2013 678 MPD User Manual Bit 7 LSWNS. Limit switch negative event/interrupt 0= Not triggered 1= Triggered Bit 6 LSWPS. Limit switch positive event/interrupt 0= Not triggered 1= Triggered Bit 5 AUTORUN. AUTORUN mode status 0= Disabled 1= Enabled Bit 4 PTRG4. Position trigger 4 0= Not reached 1= Reached Bit 3 PTRG3. Position trigger 3 0= Not reached 1= Reached Bit 2 PTRG2. Position Trigger 2 0= Not reached 1= Reached Bit 1 PTRG1. Position Trigger 1 0= Not triggered 1= Triggered Bit 0 ENDINIT. Drive/motor initialization status 0= Not performed 1= Performed See also: Status register low part – SRL © ElectroCraft 2013 679 MPD User Manual 6.2.7.7. SRL - Status Register Low part (status, RO) Purpose: SRL is the low part of a status register grouping together all the key status information concerning the drive/motor MPL Address: 0x090E Contents. SRL information is structured as follows: Bit 15 AXISST. Axis status 0= Axis Off 1= Axis On Bit 14 EVNS. Events 0= No event set, or programmed event not occurred yet 1= Last programmed event reached Bits 13-11 Reserved. Bit 10 MOTS. Motion status 0= In motion 1= Motion complete Bit 9 Reserved. Bit 8 CALLSST. Cancelable call status 0= No function in execution following a cancelable call 1= A function in execution following a cancelable call Bit 7 CALLWRG. Cancelable call warning 0= No warning 1= Warning – a cancelable call is issued while another cancelable function is in execution Bits 6-0 Reserved See also: Status register high part – SRH © ElectroCraft 2013 680 MPD User Manual 6.2.7.8. SSR - Slave Status Register (status, RO) SSR is a 32-bit status register containing information about slave axes initialization status, setup table status, firmware compatibility and slave presence in the CAN network. MPL Address: 0x07F2 Contents. SSR information is structured as follows: Bit 31 HIERR. H slave initialization status 0= Initialization successful 1= Initialization error Bit 30 HIFW. H slave firmware compatibility with motion controller 0= Firmware compatible 1= Firmware incompatible Bit 29 HISTP. H slave invalid setup table 0= Setup table valid 1= Invalid setup table Bit 28 HDET. H slave detection 0= Detected successfully 1= Not detected Bit 27 GIERR. G slave initialization status 0= Initialization successful 1= Initialization error Bit 26 GIFW. G slave firmware compatibility with motion controller 0= Firmware compatible 1= Firmware incompatible © ElectroCraft 2013 681 MPD User Manual Bit 25 GISTP. G slave invalid setup table 0= Setup table valid 1= Invalid setup table Bit 24 GDET. G slave detection 0= Detected successfully 1= Not detected Bit 23 FIERR. F slave initialization status 0= Initialization successful 1= Initialization error Bit 22 FIFW. F slave firmware compatibility with motion controller 0= Firmware compatible 1= Firmware incompatible Bit 21 FISTP. F slave invalid setup table 0= Setup table valid 1= Invalid setup table Bit 20 FDET. F slave detection 0= Detected successfully 1= Not detected Bit 19 EIERR. E slave initialization status 0= Initialization successful 1= Initialization error Bit 18 EIFW. E slave firmware compatibility with motion controller 0= Firmware compatible 1= Firmware incompatible Bit 17 EISTP. E slave invalid setup table 0= Setup table valid 1= Invalid setup table Bit 16 EDET. E slave detection 0= Detected successfully 1= Not detected Bit 15 DIERR. D slave initialization status 0= Initialization successful 1= Initialization error © ElectroCraft 2013 682 MPD User Manual Bit 14 DIFW. D slave firmware compatibility with motion controller 0= Firmware compatible 1= Firmware incompatible Bit 13 DISTP. D slave invalid setup table 0= Setup table valid 1= Invalid setup table Bit 12 DDET. D slave detection 0= Detected successfully 1= Not detected Bit 11 CIERR. C slave initialization status 0= Initialization successful 1= Initialization error Bit 10 CIFW. C slave firmware compatibility with motion controller 0= Firmware compatible 1= Firmware incompatible Bit 9 CISTP. C slave invalid setup table 0= Setup table valid 1= Invalid setup table Bit 8 CDET. C slave detection 0= Detected successfully 1= Not detected Bit 7 BIERR. B slave initialization status 0= Initialization successful 1= Initialization error Bit 6 BIFW. B slave firmware compatibility with motion controller 0= Firmware compatible 1= Firmware incompatible Bit 5 BISTP. B slave invalid setup table 0= Setup table valid 1= Invalid setup table Bit 4 BDET. B slave detection 0= Detected successfully 1= Not detected © ElectroCraft 2013 683 MPD User Manual Bit 3 AIERR. A slave initialization status 0= Initialization successful 1= Initialization error Bit 2 AIFW. A slave firmware compatibility with motion controller 0= Firmware compatible 1= Firmware incompatible Bit 1 AISTP. A slave invalid setup table 0= Setup table valid 1= Invalid setup table Bit 0 ADET. A slave detection 0= Detected successfully 1= Not detected © ElectroCraft 2013 684 MPD User Manual 6.2.7.9. UPGRADE - Upgrade Register (configuration, R/W) UPGRADE is a 16-bit status register, defining new options and extended features that are activated when their corresponding bits are set. MPL Address: 0x0857 Contents. UPGRADE information is structured as follows: Bit 15 STPTBL. Setup table 0= Valid setup table is not required 1= Valid setup table is required Bit 14 Reserved Bit 13 TXBUFF. CAN-bus transmit buffer length 0= The length of CAN-bus transmit buffer is 1 messages 1= The length of CAN-bus transmit buffer is 5 messages Bit 12 TINTQSTP. MPL time interrupt/quickstop 0= Disable 1= Enable MPL time interrupt and quickstop mode when a limit switch is reached Bit 11 MCM. Motion complete mode 0= Motion complete set when the position reference arrives at the commanded position 1= Motion complete set when the position feedback arrives at the commanded position and remains in a settle band for a preset stabilize time interval Bit 10 I2TPRT. I2T protection 0= One I2T protection common for drive and motor 1= Two I2T protections, one for drive and the other for the motor Bit 9 IPOS. Initial positioning mode 0= Standard – wait time per phase up to 1s 1= Extended – wait time per phase up to 635s © ElectroCraft 2013 685 MPD User Manual Bit 8 IORW. I/O lines read/write 0= Simultaneous read /write of 4 general purpose inputs/outputs 1= Simultaneous read 4 general-purpose inputs and 3 dedicated inputs: Enable, LSP and LSN. Simultaneous set 4 general-purpose outputs and 2 dedicated outputs: Ready and Error. Bit 7 ATIME. Absolute time start 0= After instruction ENDINIT 1= After power on Bit 6 FSTSLW. Position/speed control mode 0= Position/speed control in slow loop 1= Position/speed control in fast loop Bit 5 STBCRT. Standby current for step motors 0= Disable 1= Enable Bit 4 SPDCTR. Speed control error protection 0= Common with position control error protection 1= Separate control error protection for position and speed Bit 3 REG. Registration mode 0= Disabled 1= Enabled Bit 2 LMTSPDACC. Maximal speed/acceleration in motion modes: external, electronic gearing and electronic camming 0= Unlimited 1= Limited Bit 1 STPMD. Stop mode for steppers 0= Disabled 1= Enabled Bit 0 AREFLMT. Analogue reference 0= Symmetrical, only positive or only negative 1= Separately programmable upper and lower limits © ElectroCraft 2013 686 MPD User Manual 6.3. Internal Units and Scaling Factors ElectroCraft drives/motors work with parameters and variables represented in internal units (IU). The parameters and variables may represent various signals: position, speed, current, voltage, etc. Each type of signal has its own internal representation in IU and a specific scaling factor. In order to easily identify each type of IU, these have been named after the associated signals. For example the position units are the internal units for position, the speed units are the internal units for speed, etc. The scaling factor of each internal unit shows the correspondence with the international standard units (SI). The scaling factors are dependent on the product, motor and sensor type. Put in other words, the scaling factors depend on the setup configuration. In order to find the internal units and the scaling factors for a specific case, select the application in the project window and then execute menu command Help | Application Programming | Internal Units and Scaling Factors. Important: The Help | Application Programming | Internal Units and Scaling Factors command provides customized information function of the application setup. If you change the drive, the motor technology or the feedback device, check again the scaling factors with this command. It may show you other relations! 6.4. PRO EEPROM Programmer 6.4.1. PRO EEPROM Programmer All ElectroCraft drives/motors include a non-volatile EEPROM memory. Its role is to: • Keep the setup data in a dedicated area named setup table together with a user programmable application ID, which helps you quickly identify the setup data uploaded from a drive/motor. • Store the MPL motion programs and their associated data like the cam tables needed for electronic camming applications. • Keep the product ID of each drive/motor and the required firmware ID for the programmed application. Remark: The required firmware ID indicates that the actual drive/motor firmware ID must have the same number and a revision letter equal or higher. For example if the required firmware ID is: F000H, the actual drive/motor firmware ID must be F000H or F000I, or F000J, etc. The Drive/Motor PRO EEPROM Programmer is a tool specifically designed for production, through which you can: • Program fast and easy the EEPROM memory of any ElectroCraft drive/motor with all the data needed to run a specific application. These data are grouped into a unique file named software file (with extension .sw) • Check EEPROM data integrity by comparing the information read from the drive/motor memory with that read from a .sw software file • Write protect a part or the entire EEPROM memory. • Get information about the drive/motor configuration ID including the product ID, the firmware ID and the application ID © ElectroCraft 2013 687 MPD User Manual The Drive/Motor PRO EEPROM Programmer is included in both the PROconfig and MotionPRO Developer installation packages and is automatically installed with them. However, it may also be installed separately. To launch the Drive/Motor EEPROM from Windows Start menu execute: “Start | Programs | PROconfig | Drive/Motor PRO EEPROM Programmer” or “Start | Programs | MotionPRO Developer| Drive/Motor PRO EEPROM Programmer” depending on which installation package you have used. You can also start the Drive/Motor PRO EEPROM Programmer from the main folder of the PROconfig / MotionPRO Developer by executing “PRO EEPROMprog.exe”. The Drive/Motor PRO EEPROM Programmer has 3 tabs: Application, Configuration ID and Communication Settings In the Application tab you select a .sw software file. Use the Download button to program it into the drive/motor EEPROM memory. Use the Verify button to check if the information stored in the drive/motor EEPROM is identical with that from the selected .sw file. Press the Checksum button to compute the sum modulo 65536 of all the data from a .sw file. The checksum result may be used by a master during the application initialization to validate that data from a drive/motor EEPROM memory is correct and complete. For example, the host can ask a drive/motor to return the checksum for each block of continuous data from the EEPROM, according with the .sw file. By adding the results returned by the drive/motor, the host obtains a global checksum which must match with the value got when the Checksum button is pressed. Use the Read… button to save the contents of the whole EEPROM memory in a .sw file. The Drive/Motor PRO EEPROM Programmer signals with an OK inside a green disk that the: • Download operation is correctly executed • Verify operation, gives a match between the .sw file and the drive/motor EEPROM contents • Read operation is successfully ended and the .sw file is created Otherwise, an ERROR inside a red disk is displayed together with a message explaining the error type. © ElectroCraft 2013 688 MPD User Manual In the Configuration ID tab, by pressing the Get Info button, you get the drive/motor configuration ID including the product ID, the firmware ID, the EEPROM size and the application ID. The product ID uniquely identifies the drive/motor execution. This information is written by ElectroCraft in the last EEPROM memory locations in especially reserved locations. In these locations ElectroCraft also puts the product EEPROM size in 16-bit Kwords and the required firmware ID. The main goal of this information is to protect against accidental wrong programming of the EEPROM memory or in the case of very big MPL programs against bypassing the EEPROM capacity. Both PROconfig and MotionPRO Developer perform the following verifications every time a setup data or a motion application has to be downloaded. 1) The product ID of the application/setup data to download matches with the product ID stored in the drive/motor EEPROM, or is set as being compatible 2) The required firmware of the application/setup data to download has the same number as the drive/motor actual firmware and either the same or a lower revision The download is performed only if both conditions are true. The application ID is a space reserved for a text of up to 40 characters which you can program. Its main goal is to help you quickly identify the setup data uploaded from a drive/motor. In order to program an application ID, edit your text in the Application ID field and press the Download button. The configuration ID tab may also be used to reprogram the product ID, the required firmware ID and the EEPROM size, if by mistake, the area reserved for this information in the EEPROM memory is erased. In this case, select the product name from the list, add your application ID (if it is the case) and press the Download button. In the Communication Settings tab, you can set the communication type and parameters as well as the EEPROM write protection degree. When you launch the PRO EEPROM Programmer, it tries to communicate with your drive/motor using your last communication settings. If the communication attempt fails, the PRO EEPROM Programmer opens automatically the Communication Settings tab, where you can setup the communication parameters(HELP_COMMUNICATION_SETUP@PROconfig.hlp). Each time when you’ll try to switch to the other tabs, the communication is checked and the other tabs are opened ONLY if the communication is established. © ElectroCraft 2013 689 MPD User Manual If your application does not require storing data in the drive/motor EEPROM at runtime and you don’t intend to change the setup parameters from your host and then to save the changes in the drive/motor EEPROM, you can write protect the entire EEPROM after you download the .sw file. This is an extra protection against accidental wrong commands that may modify EEPROM locations. If your application requires to store data at runtime but you don’t and you don’t intend to change the setup parameters and maybe cam tables (if present) you can write protect only the last quarter or last half of the EEPROM and allow the write operation for the rest. See also: Software Files Creation and Format Communication Setup © ElectroCraft 2013 690 MPD User Manual 6.4.2. PRO EEPROM Programmer File Format The .sw software files can be generated either from PROconfig or from MotionPRO Developer. In PROconfig you create a .sw file with the command Setup | PRO EEPROM Programmer File… The software file generated, includes the setup data and the drive/motor configuration ID with the user programmable application ID. Typically, this type of .sw file is used in applications where the motion programming is done from the host using for example one of the MPL_LIB motion libraries offered by ElectroCraft for: PC applications (written in C/C++, Visual Basic, Delphi Pascal, Labview) or for PLCs according with the PLCOpen standard. © ElectroCraft 2013 691 MPD User Manual In MotionPRO Develop per you creatte a .sw file with w one of th he commandss: Application n | PRO EEP PROM mer File | Mo otion and Se etup or Setup p Only. The o option Motio on and Setup p creates a .s sw file Programm with com mplete information including setup da ata, MPL pro ograms, cam m tables (if present) and the drive/moto or configuration ID. The option o Setup Only produce es a .sw file identical with h that producced by PROconfig i.e. having only the setup data and the configuratio on ID. Software File Format A software file (with ex xtension .sw) is a text file that t can be re ead with any text editor. It contains bloccks of arated by an empty e row. Each E block of data starts w with the block start addresss, followed byy data data sepa values to place in asce ending order at a consecutiv ve addresses:: first data – tto write at start address, se econd o write at sta art address + 1, etc. All the data are e hexadecimal 16- bit va alues (maxim mum 4 data – to hexadecim mal digits). Each E raw con ntains a single data value e. When less then 4 hexa adecimal digitts are shown, the value must be right justiffied. For exam mple 92 repre esent 0x0092 2. See also: Drive/Mottor PRO EEPROM Program mmer © ElectroC Craft 2013 69 92 MPD U User Manual Appendix A : MPL Instructions List [A/G] { MPL Instr} Send MPL instruction to [A/G] [A/G] V16D = V16S [A/G] V16D = local V16S [A/G] V16D, dm = V16S [A/G] V16D = local V16S (fa) [A/G] (V16D), TM = V16S [A/G] (V16D), TM = local V16S [A/G] (V16D+), TM = V16S [A/G] (V16D), TM = local V16S, then V16D += 1 [A/G] V32D = V32S [A/G] V32D = local V32S [A/G] V32D, dm = V32S [A/G] V32D = local V32S (fa) [A/G] (V16D), TM = V32S [A/G] (V16D), TM = local V32S [A/G] (V16D+), TM = V32S [A/G] (V16D), TM = local V32S, then V16D += 2 (?)GiveMeData Ask one axis to return a 16/32 bit data from memory (??)GiveMeData2 Ask a group of axes to return each a 16/32 bit data from memory !ALPO Set event when absolute load position is over a value !ALPU Set event when absolute load position is under a value !AMPO Set event when absolute motor position over a value !AMPU Set event when absolute motor position under a value !CAP Set event when a capture input goes low or high !IN#n Set event when digital input #n goes low or high !LSN Set event when the negative limit switch (LSN) goes low or high !LSP Set event when positive limit switch (LSP) goes low or high !LSO Set event when load speed is over a value !LSU Set event when load speed is under a value !MC Set event when the actual motion is completed !MSO Set event when motor speed is over a value !MSU Set event when motor speed is under a value !PRO Set event when position reference is over a value !PRU Set event when position reference is under a value !RPO Set event when relative load position is over a value © ElectroCraft 2013 693 MPD User Manual !RPU Set event when relative load position is under a value !RT Set event after a wait time !SRO Set event if speed reference is over a value !SRU Set event if speed reference is under a value !TRO Set event if torque reference is over a value !TRU Set event if torque reference is under a value !VO Set event if a long/fixed variable is over a value !VU Set event if a long/fixed variable is under a value ABORT Abort the execution of a function called with CALLS ADDGRID (value16_1, value16_2,…) Add groups to the Group ID AXISID Set Axis ID AXISOFF AXIS is OFF (deactivate control) AXISON AXIS is ON (activate control) BEGIN BEGIN of a MPL program CALL Call a MPL function CALLS Cancelable CALL of a MPL function CANBR val16 Set CAN bus baud rate CHECKSUM, TM Start, Stop, V16D V16D=Checksum between Start and Stop addresses from TM CIRCLE Define circular segment for vector mode CPA Command Position is Absolute CPR Command Position is Relative DINT Disable globally all MPL interrupts DISCAPI Disable 1st capture/encoder index input to detect transitions DIS2CAPI Disable 2nd capture/encoder index input to detect transitions DISLSN Disable negative limit switch (LSN) input to detect transitions DISLSP Disable positive limit switch (LSP) input to detect transitions EINT Enable globally all MPL interrupts EN2CAPI0 Enable 2nd capture/encoder index input to detect a high to low transition EN2CAPI1 Enable 2nd capture/encoder index input to detect a low to high transition ENCAPI0 Enable 1st capture/encoder index input to detect a high to low transition ENCAPI1 Enable 1st capture/encoder index input to detect a low to high transition © ElectroCraft 2013 694 MPD User Manual END END of a MPL program ENDINIT END of Initialization ENEEPROM Enables EEPROM usage after it was disabled by the initialization of SSI or ENDat encoders ENLSN0 Enable negative limit switch (LSN) input to detect a high to low transition ENLSN1 Enable negative limit switch (LSN) input to detect a low to high transition ENLSP0 Enable positive limit switch (LSP) input to detect a low to high transition ENLSP1 Enable positive limit switch (LSP) input to detect a high to low transition EXTREF Set external reference type FAULTR Reset FAULT status. Return to normal operation Get checksum Ask one axis to return the checksum between 2 addresses from its MPL memory GETERROR Get last error reported by slaves GetMPLData Ask one axis to return a MPL data GetVersion Ask one axis the firmware version GOTO Jump GROUPID (value16_1, value16_2,…) Set GROUP ID V16D = IN#n Read input #n. V16D = input #n status INITCAM addrS, addrD Copy CAM table from EEPROM (addrS address) to RAM (addrD address) V16D = INPUT1, ANDm V16D = logical AND between inputs IN#25 to IN#32 status and ANDm mask V16D = INPUT2, ANDm V16D = logical AND between inputs IN#33 to IN#39 status and ANDm mask V16D = INPORT, ANDm V16D = status of inputs Enable, LSP, LSN plus IN#36 to IN#39 LOCKEEPROM Locks or unlocks the EEPROM write protection LPLANE Define coordinate system for linear interpolation mode MODE CS Set MODE Cam Slave MODE GS Set MODE Gear Slave MODE LI Set MODE Linear Interpolation MODE PC Set MODE Position Contouring MODE PE Set MODE Position External MODE PP Set MODE Position Profile MODE PSC Set MODE Position S-Curve MODE PT Set MODE PT MODE PVT Set MODE PVT MODE SC Set MODE Speed Contouring © ElectroCraft 2013 695 MPD User Manual MODE SE Set MODE Speed External MODE SP Set MODE Speed Profile MODE TC Set MODE Torque Contouring MODE TEF Set MODE Torque External Fast MODE TES Set MODE Torque External Slow MODE TT Set MODE Torque Test MODE VC Set MODE Voltage Contouring MODE VEF Set MODE Voltage External Fast MODE VES Set MODE Voltage External Slow MODE VM Set MODE Vector Mode MODE VT Set MODE Voltage Test NOP No Operation OUT(n) =value16 Set the output line as specified by value16 OUT(n1, n2, n3, …) =value16 Set the output lines n1 n2, n3 as specified by value16 OUTPORT Set Enable, LSP, LSN and general purpose outputs OUT#28-31 PING Ask a group of axes to return their axis ID PONG Answer to a PING request PROD <<= N Left shift 48-bit product register by N PROD >>= N Right shift 48-bit product register by N PTP Define a PT point PVTP Define a PVT point REG_OFF Disable superposed mode REG_ON Enable superposed mode REMGRID (value16_1, value16_2,…) Remove groups from the Group ID RESET RESET drive / motor RET Return from a MPL function RETI Return from a MPL Interrupt Service Routine RGM Reset electronic gearing/camming master mode ROUT#n Set low the output line #n SAP Set Actual Position SAVE Save setup data in the EEPROM memory SAVEERROR Save slave error in EEPROM SCIBR V16 Set RS-232/Rs485 serial communication interface (SCI) baud rate © ElectroCraft 2013 696 MPD User Manual SEG Define a contouring segment SEND Send to host the contents of a MPL variable SetAsInput(n) Set the I/O line #n as an input SetAsOutput(n) Set the I/O line #n as an output SETIO#n Set IO line #n as input or as output SETPT Setup PT mode operation SETPVT Setup PVT mod operation SETSYNC Enable/disable synchronization between axes SGM Set electronic gearing/camming master mode SOUT#n Set high the output line #n SRB V16, ANDm, ORm Set / Reset Bits from V16 SRBL V16, ANDm, ORm Set / Reset Bits from V16 (fa) STA Set Target position = Actual position STARTLOG V16 Start the data acquisition STOP STOP motion STOP! STOP motion when the programmed event occurs STOPLOG Stop the data acquisition Take checksum Answer to Get checksum request TakeData Answer to GiveMeData request TakeData Answer to Get MPL Data request TakeData2 Answer to GiveMeData2 request TakeVersion Answer to Get version request TUM0 Target update mode 0 TUM1 Target update mode 1 UPD Update motion mode and parameters. Start motion UPD! Update motion mode and parameters when the programmed event occurs VPLANE Define coordinate system for Vector Mode V16D = [A] V16S Local V16D = [A] V16S V16D = [A] V16S, dm Local V16D = [A] V16S, dm (fa) V16D = [A] (V16S), TM Local V16D = [A] (V16S), dm V16D = [A] (V16S+), TM Local V16D = [A] (V16S), dm, then V16S += 1 V32D = [A] V32S Local V32D = [A] V32S V32D = [A] V32S, dm Local V32D = [A] V32S, dm (fa) © ElectroCraft 2013 697 MPD User Manual V32D = [A] (V16S), TM Local V32D = [A] (V16S), TM V32D = [A] (V16S+), TM Local V32D = [A] (V16S), TM, then V16S += 2 V16 = label V16 = &label V16D = V16S V16D = V16S V16 = val16 V16 = val16 V16D = V32S(H) V16D = V32S(H) V16D = V32S(L) V16D = V32S(L) V16D, dm = V16S V16D = V16S (fa) V16D, dm = val16 V16D = val16 (fa) V16D = (V16S), TM V16D = (V16S) from TM memory V16D = (V16S+), TM V16D = (V16S) from TM memory, then V16S += 1 (V16D), TM = V16S (V16D) from TM memory = V16S (V16D), TM = val16 (V16D) from TM memory = val16 (V16D+), TM = V16S (V16D) from TM memory = V16S, then V16D += 1 (V16D+), TM = val16 (V16D) from TM memory = val16, then V16D += 1 V32(H) = val16 V32(H) = val16 V32(L) = val16 V32(H) = val16 V32D(H) = V16S V32D(H) = V16 V32D(L) = V16S V32D(L) = V16 V16D = -V16S V16D = -V16S V32D = V32S V32D = V32S V32 = val32 V32 = val32 V32D =V16S << N V32D = V16S left-shifted by N V32D, dm = V32S V32D from dm = V32S (fa) V32D, dm = val32 V32 from dm = val32 (fa) V32D = (V16S), TM V32D = (V16S) from TM memory V32D = (V16S+), TM V32D = (V16S) from TM memory, then V16S += 2 (V16D), TM = V32S (V16D) from TM memory = V32S (V16D), TM = val32 (V16D) from TM memory = val32 (V16D+), TM = V32S (V16D) from TM memory = V32S, then V16D += 2 (V16D+), TM = val32 (V16D) from TM memory = val32, then V16D += 2 V32D = -V32S V32D = -V32S V16 += val16 V16 = V16 + val16 © ElectroCraft 2013 698 MPD User Manual V16D += V16S V16D = V16D + V16S V32 += val32 V32 = V32 + val32 V32D += V32S V32D = V32D + V32S V16 -= val16 V16 = V16 - val16 V16D -= V16S V16D = V16D - V16S V32 -= val32 V32 = V32 - val32 V32D -= V32S V32D = V32D - V32S V16 * val16 << N 48-bit product register = (V16 * val16) >> N V16 * val16 >> N 48-bit product register = (V16 * val16) >> N V16A * V16B << N 48-bit product register = (V16A * V16B) << N V16A * V16B >> N 48-bit product register = (V16A * V16B) >> N V32 * V16 << N 48-bit product register = (V32 * V16) << N V32 * V16 >> N 48-bit product register = (V32 * V16) >> N V32 * val16 << N 48-bit product register = (V32 * val16) << N V32 * val16 >> N 48-bit product register = (V32 * val16) >> N V32=/V16 Divide V32 to V16 V16 <<= N Left shift V16 by N V32 <<= N Left shift V32 by N V16 >>= N Right shift V16 by N V32 >>= N Right shift V32 by N VSEG Define linear segment for vector mode WAIT! Wait until the programmed event occurs WALPO Set and wait event when slave’s absolute load position is over a value WALPU Set and wait event when slave’s absolute load position is under a value WAMPO Set and wait event when slave’s absolute motor position over a value WAMPU Set and wait event when absolute motor position under a value WCAP Set and wait event when slave’s 1st capture/encoder index input goes low or high W2CAP Set and wait event when slave’s 2nd capture/encoder index input goes low or high WIN#n Set and wait event when slave’s digital input #n goes low or high WLSN Set event when slave’s negative limit switch (LSN) goes low or high WLSP Set event when slave’s positive limit switch (LSP) goes low or high WLSO Set event when slave’s load speed is over a value © ElectroCraft 2013 699 MPD User Manual WLSU Set event when slave’s load speed is under a value WMC Set and wait event when the actual motion is completed on one or more slave axes WMSO Set and wait event when slave’s motor speed is over a value WMSU Set and wait event when slave’s motor speed is under a value WPRO Set and wait event when slave’s position reference is over a value WPRU Set and wait event when slave’s position reference is under a value WRPO Set and wait event when slave’s relative load position is over a value WRPU Set and wait event when slave’s relative load position is under a value WRT Set event after a wait time WVDU Set and wait event when the vector distance is under a value WVDO Set and wait event when the vector distance is over a value WTR Set and wait event when the slave’s target is reached © ElectroCraft 2013 700 MPD User Manual 7. Appendix B : MPL Data List AAR ACR AD5 AD5 OFF APOS APOS_MT APOS2 ASPD ASPD_LD ASPD_MT ATIME BRAKELIM CACC CADIN CAMINPUT CAMOFF © ElectroCraft 2013 Type: UINT Address: 0x030C Type: UINT Address: 0x0912 Type: UINT Address 0x0241 Type: INT Address: 0x0249 Type: LONG Address: 0x0228 Type: LONG Address: 0x0988 Type: LONG Address: 0x081C Type: FIXED Address: 0x022C Type: FIXED Address: 0x098A Type: FIXED Address: 0x098A Type: LONG Address: 0x02C0 Type: UINT Address: 0x028A Type: FIXED Address: 0x02A2 Type: INT Address 0x025C Type: LONG Address: 0x0901 Type: LONG Address: 0x03AD 701 MPD User Manual CAMSTART CAMX CAMY CAPPOS CAPPOS2 CDEC CLPER CPOS CSPD DBT DIGIN_ACTIVE_LEVEL DIGIN_INVERSION_MASK DIGOUT_INVERSION_MASK E_LEVEL_AD5 ELRESL ENC2THL EREFP EREFS © ElectroCraft 2013 Type: INT Address: 0x03AC Type: FIXED Address: 0x0903 Type: FIXED Address: 0x0905 Type: LONG Address: 0x02BC Type: LONG Address: 0x081E Type: FIXED Address: 0x0859 Type: INT Address: 0x0250 Type: LONG Address: 0x029E Type: FIXED Address: 0x02A0 Type: UINT Address: 0x0253 Type: UINT Address: 0x090C Type: UINT Address: 0x090A Type: UINT Address: 0x090B Type: INT Address: 0x0870 Type: LONG Address: 0x0875 Type: LONG Address: 0x024C Type: LONG Address: 0x02A8 Type: FIXED Address: 0x02A8 702 MPD User Manual EREFT EREFV ERRMAX FILTER1 FILTERQ GEAR GEARMASTER GEARSLAVE HALL30 HALLCASE HOMEPOS HOMESPD I2TINTLIM_D I2TINTLIM_M I2TWARLIM_M ICR INSTATUS INTTABLE © ElectroCraft 2013 Type: INT Address: 0x02A9 Type: INT Address: 0x02A9 Type: INT Address: 0x02C5 Type: INT Address: 0x029D Type: INT Address: 0x0982 Type: FIXED Address: 0x02AC Type: INT Address: 0x0255 Type: INT Address: 0x0256 Type: INT Address: 0x0877 Type: INT Address: 0x0259 Type: LONG Address: 0x0992 Type: FIXED Address: 0x0994 Type: ULONG Address: 0x0980 Type: ULONG Address: 0x0815 Type: ULONG Address: x097E Type: UINT Address: 0x0304 Type: UINT Address: 0x0908 Type: INT Address: 0x0307 703 MPD User Manual IQ IQREF KFFA KII KISPDEST KPI KPSPDEST LEVEL_AD5 LS_ACTIVE MACOMMAND MASTERID MASTERRES MECRESL MER MER_MASK MPOS0 MREF MSPD © ElectroCraft 2013 Type: INT Address: 0x0230 Type: INT Address: 0x022F Type: INT Address: 0x026E Type: INT Address: 0x0273 Type: INT Address: 0x095B Type: INT Address: 0x0271 Type: INT Address: 0x095C Type: INT Address: 0x086F Type: INT Address: 0x0832 Type: ULONG Address: 0x02F2 Type: INT Address: 0x0927 Type: LONG Address: 0x081A Type: LONG Address: 0x024E Type: UINT Address: 0x08FC Type: UINT Address: 0x0965 Type: LONG Address: 0x025E Type: LONG Address: 0x02AA Type: INT Address: 0x0820 704 MPD User Manual MTSTYPE NLINES NLINESTAN OSR PCR PHASEADV POS0 POSERR POSINIT POSOKLIM POSTRIGG1 POSTRIGG2 POSTRIGG3 POSTRIGG4 PVTBUFBEGIN PVTBUFLEN PVTMODE PVTPOS0 © ElectroCraft 2013 Type: INT Address: 0x028C Type: ULONG Address: 0x0984 Type: ULONG Address: 0x0984 Type: UINT Address: 0x0302 Type: UINT Address: 0x0303 Type: INT Address: 0x0257 Type: LONG Address: 0x02B8 Type: INT Address: 0x022A Type: ULONG Address: 0x02F2 Type: UINT Address: 0x036A Type: LONG Address: 0x091A Type: LONG Address: 0x091C Type: LONG Address: 0x091E Type: LONG Address: 0x0920 Type: INT Address: 0x0864 Type: INT Address: 0x0865 Type: UINT Address: 0x086B Type: LONG Address: 0x0869 705 MPD User Manual PVTSENDOFF PVTSTS PWMPER REFTST REFTST_A REFTST_V RESRATIOX RESRATIOY RESRATIOZ RINCTST RINCTST_A RINSTST_V RPOS RTIME SATPWM SCR SEGBUFBEGIN SEGBUFLEN © ElectroCraft 2013 Type: INT Address: 0x092B Type: INT Address: 0x0863 Type: UINT Address: 0x0252 Type: INT Address: 0x0281 Type: INT Address: 0x0281 Type: INT Address: 0x0281 Type: ULONG Address: 0x0880 Type: ULONG Address: 0x0882 Type: ULONG Address: 0x0884 Type: INT Address: 0x0280 Type: INT Address: 0x0280 Type: INT Address: 0x0280 Type: FIXED Address: 0x02BA Type: LONG Address: 0x02C2 Type: INT Address: 0x0254 Type: UINT Address: 0x0300 Type: ULONG Address: 0x0864 Type: ULONG Address: 0x0865 706 MPD User Manual SEGBUFSTS SERRMAX SFI2T_D SFI2T_M SFTADIN SFTKII SFTKPI SLAVEID SLPER SRH SRHMASK SRL SRL_MASK T1MAXPROT T1ONA T1ONB T2MAXPROT TACC © ElectroCraft 2013 Type: ULONG Address: 0x0711 Type: INT Address: 0x0879 Type: INT Address: 0x098C Type: INT Address: 0x0819 Type: INT Address: 0x025D Type: INT Address: 0x0274 Type: INT Address: 0x0272 Type: INT Address: 0x0311 Type: INT Address: 0x0251 Type: UINT Address: 0x090F Type: UINT Address: 0x0963 Type: UINT Address: 0x090E Type: UINT Address: 0x0962 Type: UINT Address: 0x0298 Type: UINT Address: 0x0284 Type: UINT Address: 0x0285 Type: UINT Address: 0x0299 Type: FIXED Address: 0x02B6 707 MPD User Manual TERRMAX THTST TIMAXPROT TIME0 TINCTST TJERK TMLINPER TONPOSOK TPOS TREF TSERRMAX TSPD UMSXPORT IMINPROT UPGRADE UQREF © ElectroCraft 2013 Type: UINT Address 0x02C6 Type: INT Address: 0x0282 Type: UINT Address: 0x02C4 Type: LONG Address: 0x02BE Type: INT Address: 0x0283 Type: LONG Address: 0x08D1 Type: UINT Address: 0x0983 Type: UINT Address: 0x036B Type: LONG Address: 0x02B2 Type: LONG Address: 0x02AE Type: UINT Address: 0x087A Type: FIXED Address: 0x02B4 Type: UINT Address: 0x029A Type: UINT Address: 0x029B Type: UINT Address: 0x0857 Type: INT Address: 0x0232 708 MPD User Manual
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.7 Linearized : Yes Author : Electrocraft Create Date : 2014:06:25 11:46:50+01:00 Modify Date : 2014:09:26 15:53:26-04:00 XMP Toolkit : Adobe XMP Core 5.2-c001 63.139439, 2010/09/27-13:37:26 Metadata Date : 2014:09:26 15:53:26-04:00 Format : application/pdf Title : Motion Programming using MotionPRO Developer - User Manual Creator : Electrocraft Document ID : uuid:61052652-06e8-6542-b561-3bafd703905f Instance ID : uuid:96336036-6fbb-4d48-bb21-4bd6d507c954 Page Count : 720EXIF Metadata provided by EXIF.tools