Lenze PM94P01C User Manual

***************************** HEADER *************************************** ;Title: Pick and Place example program ;Author: Lenze - AC Technology ;Description: This is a sample program showing a simple sequence that ; picks up a part, moves to a set position and drops the part
;**************************** I/O List ************************************ ; Input A1 - not used ; Input A2 - not used ; Input A3 - Enable Input ; Input A4 - not used ; Input B1 - not used ; Input B2 - not used ; Input B3 - not used ; Input B4 - not used ; Input C1 - not used ; Input C2 - not used ; Input C3 - not used ; Input C4 - not used ; Output 1 - Pick Arm ; Output 2 - Gripper ; Output 3 - not used ; Output 4 - not used
;********************** Events ******************* ;Set Events handling here
;********************** Main Program ************
RESET_DRIVE: ;Place holder fo WAIT UNTIL IN_A3: ;Make sure tha continuing ENABLE PROGRAM_START: MOVEP 0 ;Move to Pick po OUT1 = 1 ;Turn on output WAIT TIME 1000 ;Delay 1 sec to OUT2 = 1 ;Turn on output WAIT TIME 1000 ;Delay 1 sec to OUT1 = 0 ;Turn off output MOVED -10 ;Move 10 REVs to OUT1 = 1 ;Turn on output WAIT TIME 1000 ;Delay 1 sec to OUT2 = 0 ;Turn off output WAIT TIME 1000 ;Delay 1 sec to OUT1 = 0 ;Retract Pick ar GOTO PROGRAM_START END
;********************** Sub-Routines ***************
Enter Sub-Routine code here
;********************** Fault Handler Routine ***************
; Enter Fault Handler code here ON FAULT ENDFAULT
PositionServo
Programming Manual for PC-based MotionView
Copyright ©2005 by AC Technology Corporation.
All rights reserved. No part of this manual may be reproduced or transmitted in any form without written permission from AC Technology Corporation. The information and technical data in this manual are subject to change without notice. AC Technology makes no warranty of any kind with respect to this material, including, but not limited to, the implied warranties of its merchantability and fitness for a given purpose. AC Technology assumes no responsibility for any errors that may appear in this manual and makes no commitment to update or to keep current the information in this manual.
MotionView®, PositionServo®, and all related indicia are either registered trademarks or trademarks of Lenze AG in the United States and other countries.
Contents
1. Introduction ............................................................................................................................. 4
1.1 Definitions ..................................................................................................................................................4
1.2 Programming Flowchart .............................................................................................................................5
1.3 MotionView / MotionView Studio ...............................................................................................................6
1.3.1 Main Toolbar ............................................................................................................................6
1.3.2 Program Toolbar ......................................................................................................................8
1.3.3 MotionView Studio - Indexer Program .....................................................................................9
1.4 Programming Basics ................................................................................................................................10
1.5 Using Advanced Debugging Features .....................................................................................................17
1.6 Inputs and Outputs ..................................................................................................................................17
1.7 Events ...................................................................................................................................................... 22
1.8 Variables and Define Statement ..............................................................................................................23
1.9 IF/ELSE Statements ................................................................................................................................24
1.10 Motion ......................................................................................................................................................25
1.10.1 Drive Operating Modes ..........................................................................................................26
1.10.2 Point To Point Moves .............................................................................................................26
1.10.3 Segment Moves .....................................................................................................................27
1.10.4 Registration ............................................................................................................................28
1.10.5 S-Curve Acceleration ............................................................................................................. 29
1.10.6 Motion Queue ........................................................................................................................29
1.11 Subroutines and Loops ............................................................................................................................30
1.11.1 Subroutines ............................................................................................................................30
1.11.2 Loops .....................................................................................................................................31
2. Programming ........................................................................................................................ 32
2.1 Program Structure ...................................................................................................................................32
2.2 Variables .................................................................................................................................................. 34
2.3 Arithmetic Expressions ............................................................................................................................36
2.4 Logical Expressions and Operators ......................................................................................................... 36
2.4.1 Bitwise Operators ..................................................................................................................36
2.4.2 Boolean Operators ................................................................................................................. 37
2.5 Comparison Operators ............................................................................................................................37
2.6 System Variables and Flags ....................................................................................................................38
2.7 System Variables Storage Organization ..................................................................................................38
2.7.1 RAM File for User’s Data Storage .........................................................................................38
2.7.2 Memory Access Through Special System Variables .............................................................39
2.7.3 Memory Access Through MEMSET, MEMGET Statements .................................................40
2.8 System Variables and Flags Summary ....................................................................................................41
2.8.1 System Variables ...................................................................................................................41
2.8.2 System Flags .........................................................................................................................42
2.9 Control Structures .................................................................................................................................... 43
2.9.1 DO/UNTIL Structure ..............................................................................................................43
2.9.2 WHILE Structure ....................................................................................................................43
2.9.3 Subroutines ............................................................................................................................44
2.9.4 IF Structure ............................................................................................................................45
2.9.5 IF/ELSE Structure ..................................................................................................................45
2.9.6 WAIT Statement ....................................................................................................................46
2.9.7 GOTO Statement & Labels ....................................................................................................46
2.10 Scanned Event Statements ..................................................................................................................... 46
PM94P01C 1
Contents
2.11 Motion ......................................................................................................................................................48
2.11.1 How Moves Work ...................................................................................................................48
2.11.2 Incremental (MOVED) and Absolute (MOVEP) Motion .........................................................48
2.11.3 Incremental (MOVED) Motion ................................................................................................49
2.11.4 Absolute (MOVEP) Move .......................................................................................................49
2.11.5 Registration (MOVEDR MOVEPR) Moves ............................................................................50
2.11.6 Segment Moves .....................................................................................................................50
2.11.7 MDV Segments ......................................................................................................................50
2.11.8 S-curve Acceleration ..............................................................................................................52
2.11.9 Motion SUSPEND/RESUME .................................................................................................52
2.11.10 Conditional Moves (MOVE WHILE/UNTIL) ...........................................................................52
2.11.11 Motion Queue and Statement Execution while in Motion ...................................................... 53
2.12 System Status Register (DSTATUS register) ..........................................................................................55
2.13 Fault Codes (DFAULTS register) ............................................................................................................. 56
2.14 Limitations and Restrictions .....................................................................................................................57
2.15 Homing ....................................................................................................................................................58
2.15.1 What is Homing? ................................................................................................................... 58
2.15.2 The Homing Function ............................................................................................................ 58
2.15.3 Home Offset ...........................................................................................................................59
2.15.4 Homing Velocity .....................................................................................................................59
2.15.5 Homing Acceleration ..............................................................................................................59
2.15.6 Homing Switch .......................................................................................................................59
2.15.7 Homing Start ..........................................................................................................................59
2.15.8 Homing Method ..................................................................................................................... 60
2.15.9 Homing Methods ....................................................................................................................61
2.15.9.1 Homing Method 1: Homing on the Negative Limit Switch ......................................................62
2.15.9.2 Homing Method 2: Homing on the Positive Limit Switch .......................................................62
2.15.9.3 Homing Method 3: Homing on the Positive Home Switch & Index Pulse ..............................63
2.15.9.4 Homing Method 4: Homing on the Positive Home Switch & Index Pulse ..............................63
2.15.9.5 Homing Method 5: Homing on the Negative Home Switch & Index Pulse ............................64
2.15.9.6 Homing Method 6: Homing on the Negative Home Switch & Index Pulse ............................64
2.15.9.7 Homing Method 7: Homing on the Home Switch & Index Pulse ............................................65
2.15.9.8 Homing Method 8: Homing on the Home Switch & Index Pulse ............................................66
2.15.9.9 Homing Method 9: Homing on the Home Switch & Index Pulse ............................................67
2.15.9.10 Homing Method 10: Homing on the Home Switch & Index Pulse .......................................... 68
2.15.9.11 Homing Method 11: Homing on the Home Switch & Index Pulse .......................................... 69
2.15.9.12 Homing Method 12: Homing on the Home Switch & Index Pulse .......................................... 70
2.15.9.13 Homing Method 13: Homing on the Home Switch & Index Pulse .......................................... 71
2.15.9.14 Homing Method 14: Homing on the Home Switch & Index Pulse .......................................... 72
2.15.9.15 Homing Method 17: Homing without an Index Pulse .............................................................73
2.15.9.16 Homing Method 18: Homing without an Index Pulse .............................................................74
2.15.9.17 Homing Method 19: Homing without an Index Pulse .............................................................75
2.15.9.18 Homing Method 21: Homing without an Index Pulse .............................................................76
2.15.9.19 Homing Method 23: Homing without an Index Pulse .............................................................77
2.15.9.20 Homing Method 25: Homing without an Index Pulse .............................................................78
2.15.9.21 Homing Method 27: Homing without an Index Pulse .............................................................79
2.15.9.22 Homing Method 29: Homing without an Index Pulse .............................................................80
2.15.9.23 Homing Method 33: Homing to an Index Pulse ..................................................................... 81
2.15.9.24 Homing Method 34: Homing to an Index Pulse ..................................................................... 81
2.15.9.25 Homing Method 35: Using Current Position as Home ...........................................................81
2.15.10 Homing Mode Operation example .........................................................................................82
3. Reference ............................................................................................................................. 83
3.1 Program Statement Glossary ..................................................................................................................83
3.2 Variable List ...........................................................................................................................................103
3.3 Quick Start Examples ............................................................................................................................117
3.3.1 Quick Start - External Torque/Velocity ................................................................................. 117
3.3.2 Quick Start - External Positioning ........................................................................................119
3.3.3 Quick Start - Internal Torque/Velocity ..................................................................................121
3.3.4 Quick Start - Internal Positioning ......................................................................................... 123
3.4 PositionServo Reference Diagrams .......................................................................................................124
PM94P01C2
About These Instructions
This documentation applies to the programming of the PositionServo drive with model numbers ending in “EX” and “RX”. This documentation should be used in conjunction with the PositionServo User Manual (Document S94P01) that shipped with the drive. These documents should be read in their entirety as they contain important technical data and describe the installation and operation of the drive.
Safety Warnings
Take note of these safety warnings and those in the PositionServo User Manual and related documentation.
WARNING! Hazard of unexpected motor starting!
When using MotionView, or otherwise remotely operating the PositionServo drive, the motor may start unexpectedly, which may result in damage to equipment and/or injury to personnel. Make sure the equipment is free to operate and that all guards and covers are in place to protect personnel.
All safety information contained in these Programming Instructions is formatted with this layout including an icon, signal word and description:
Signal Word! (Characterizes the severity of the danger)
Safety Information (describes the danger and informs on how to proceed)
Table 1: Pictographs used in these Instructions
Icon
Warning of hazardous electrical voltage
Warning of a general danger
Warning of damage to equipment
Signal Words
DANGER!
WARNING!
STOP!
Warns of impending danger.
Consequences if disregarded: Death or severe injuries. Warns of potential, very hazardous situations.
Consequences if disregarded: Death or severe injuries. Warns of potential damage to material and equipment.
Consequences if disregarded: Damage to the controller/ drive or its environment.
Information
NOTE
Designates a general, useful note.
If the note is observed then handling the controller/drive system is made easier.
Related Documents
The documentation listed herein contains information relevant to the operation and programming of the Position Servo drive with model numbers ending in “EX” and “RX”. To obtain the latest documentation, visit the Technical Library at http://www.lenze-actech.com.
Table 2: Reference Documentation
Document # Description
S94P01 PositionServo User Manual
PM94P01 PositionServo Programming Manual
P94MOD01 Position Servo ModBus RTU over RS485, ModBus TCP/IP
P94CAN01 PositionServo CANopen Communications Reference Guide
PM94P01C 3
Introduction

1. Introduction

1.1 Definitions
Included herein are definitions of several terms used throughout this programming manual and the PositionServo user manual.
PositionServo: The PositionServo is a programmable digital drive/motion controller, that can be configured as a stand alone programmable motion controller, or as a high performance torque and velocity drive for centralized control systems. The PositionServo family of drives includes the 940 Encoder-based drive and the 941 Resolver-based drive.
MotionView: MotionView is a universal communication and configuration software that is utilized by the PositionServo drive family. MotionView has an automatic self-configuration mechanism that recognizes what drive it is connected to and configures the tool set accordingly. The MotionView platform is divided up into three sections or windows, the “Parameter Tree Window”, the “Parameter View Window” and the “Message Window”. Refer to Section 1.3 for more detail.
SimpleMotion Language (SML): SML is the programming language utilized by MotionView. The SML software provides a very flexible development environment for creating solutions to motion applications. The software allows you to create complex and intelligent motion moves, process I/O, perform complex logic decision making, do program branching, utilize timed event processes, as well as a number of other functions found in PLC’s and high end motion controllers.
User Program (or Indexer Program): This is the SML program, developed by the user to describe the programmatic behavior of the PositionServo drive. The User Program can be stored in a text file on your PC or in the PositionServo’s EPM memory. The User Program needs to be compiled (translated) into binary form with the aid of the MotionView Studio tools before the PositionServo can execute it.
MotionView Studio: MotionView Studio is the front end interface of the MotionView platform. It is a tool suite containing all the software tools needed to program and debug a PositionServo. These tools include a full-screen text editor, a program compiler, status and monitor utilities, an online oscilloscope and a debugger function that allows the user to step through the program during program development.
WARNING!
• Hazard of unexpected motor starting! When using the MotionView software, or otherwise
remotely operating the PositionServo drive, the motor may start unexpectedly, which may result in damage to equipment and/or injury to personnel. Make sure the equipment is free to operate in this manner, and that all guards and covers are in place to protect personnel.
• Hazard of electrical shock! Circuit potentials are up to 480 VAC above earth ground. Avoid direct
contact with the printed circuit board or with circuit elements to prevent the risk of serious injury or fatality. Disconnect incoming power and wait 60 seconds before servicing drive. Capacitors retain charge after power is removed.
PM94P01C4
Introduction

1.2 Programming Flowchart

MotionView utilizes a BASIC-like programming structure referred to as SimpleMotion Programming Language (SML). SML is a quick and easy way to create powerful motion applications.
With SML the programmer describes his system’s logistics, motion, I/O processing and user interaction using the SML structured code. The program structure includes a full set of arithmetic and logical operator programming statements, that allow the user to command motion, process I/O and control program flow.
Before the PositionServo drive can execute the user’s program, the program must first be compiled (translated) into binary machine code, and downloaded to the drive. Compiling the program is done by selecting the [Compile] button from the toolbar. The user can also compile and download the program at the same time by selecting the [Compile and Load] button from the toolbar. Once downloaded, the compiled program is stored in both the PositionServo’s EPM memory and the internal flash memory. Figure 1 illustrates the flow of the program preparation process.
Prepare User Program
COMPILER
Any Error?
NO
Load compiled program
to PositionServo drive
Start Execution in
debugger environment
or at next power up
Fix program errors
YES
Figure 1: Program Preparation
PM94P01C 5
Introduction

1.3 MotionView / MotionView Studio

There are two versions of MotionView Software: one which resides inside the drive’s memory, referred to as “MotionView on Board” (MVOB); and one supplied as a PC-installed software package, referred to simply as MotionView. This manual describes the PC-installed MotionView software for PositionServo drives with P/N ending in EX or RX. The MotionView display is illustrated in Figure 2.
NOTE
For MotionView OnBoard (MVOB), refer to “PositionServo with MVOB Programming Manual” document number PM94M01
Parameter Tree Window
Message Window
Figure 2: MotionView Parameters Display
MotionView is the universal programming software used to communicate with and configure the PositionServo drive. The MotionView platform is segmented into three windows. The first window is the “Parameter Tree Window”. This window is used much like Windows Explorer. The various parameter groups for the drive are represented here as folders or files. Once the desired parameter group file is selected, all of the corresponding parameters within that parameter group will appear in the second window, the “Parameter View Window”. The user can then enable, disable or edit drive features or parameters in the Parameter View window. The third window is the “Message Window”. This window is located at the bottom of the screen and will display communication status and errors.
Parameter View
Window

1.3.1 Main Toolbar

The functions of MotionView are accessible via the Main Toolbar as illustrated in Figure 3. If a function in a pull-down menu or an icon is greyed out that denotes the function is unavailable. A function may be unavailable because a drive is not physically connected to the network or the present set-up and operation of the drive prohibits access to that function.
Figure 3: Main Menu and Toolbar
PM94P01C6
Introduction
Table 3a: Main Menu Text Pull-Down Folders
Main Menu
Node Project Tools View Help
New configuration file New project Browse motor database Toolbar MotionView help
Open configuration file Open project Clear output window Status Bar Product manuals
Save configuration file Close project About MotionView
Load configuration file Save project Time stamp
Set all parameters to default Save all configuration files
Connect drive Options
Disconnect all coneected drives Connection setup
Remove node from project Recent file
Table 3b: Main Menu Icon Functions
Icon Function Description
Connect Build a connection list of the drive(s) to communicate with on the network. Build the
connection list by using any one of these three methods:
Discover [Discover] button discovers all drives on the network that are available for connectivity. Once
Connect If the IP address on the drive is known, enter it in the IP address dialog box and then select
Find by name If a drive has been assigned a specified “Drive Name”, enter this name in the Name dialog box
Connected Drive is connected as a node on the network.
Disconnect Terminate connection to the drive selected (backlit) in the Node Tree.
Add File Import a configuration file to the drive
Open File Recall & open any previously saved configuration files and connection parameters.
Save Save the configuration file and the connection parameters of the drive selected in Node Tree.
Save As Save the configuration file and the connection parameters of the drive selected in Node Tree.
Remove Node Remove a node from the network
drives have been discovered they are listed in the ‘Connect to drive’ list box. To connect one or a number of drives highlight their IP address in this window and press the [Connect] button. The ‘Ctrl’ key on your keyboard can be used to select multiple drives for connection.
[Connect] to access the drive.
and then select [Find by name]. The IP address should then appear in the “Connect To Drive” list. The drive can now be connected by highlighting and pressing the [Connect] button.
Print Print a report for the currently selected drive, containing all parameter set-up and
Help Open MotionView Help folder (from original installation CD)
programming information.
PM94P01C 7
Introduction

1.3.2 Program Toolbar

To view the Program Toolbar, click on the [Indexer Program] folder in the Node Tree. Click anywhere inside the gray Indexer program in the right-hand parameter window to bring up the program toolbar. This paragraph contains a brief description of the programming tools: Compile, Load with Source, Run, Reset, Stop, Step Over, Step Into, Set Breakpoint and Remove Breakpoint. For detailed descriptions of the program toolbar functions refer to paragraphs 1.3.3 and 1.4.
Figure 4: Program Toolbar
Icon Function Description
Compile Check compilation of the indexer program currently in the List View window.
Compile & Load w/ Source Load program including source code to the PositionServo drive listed in Node Tree.
Run Start / Continue program execution.
Main Toolbar
Reset
Stop
Step Over Execute each line of code in the program sequentially on each press on the [Step Over] button excluding subroutines.
Step Into Execute each line of code in the program sequentially on each press on the [Step Into] button, including subroutines.
Set Breakpoint Set breakpoint at current location of cursor in Indexer program.
Remove Breakpoint Remove breakpoint from current location of cursor in Indexer program.
Watch Window Display Parameter I/O window
Reset Drive. Disable drive, stop program execution, and return program processing to the beginning. Program will not restart program execution automatically.
Stop program execution on completion of the current statement being executed. WARNING: Stop button does not place the drive in a disable state or prevent execution of motion commands waiting on the motion stack.
Program
Toolbar
Program
User
Area
Figure 5: MotionView - Indexer Program Display
PM94P01C8
Introduction

1.3.3 MotionView Studio - Indexer Program

The MotionView Studio provides a tool suite used by MotionView to enter, compile, load and debug the user program. To view and develop the user program, select the [Indexer Program] folder in the Parameter (Node) Tree window. Once selected the program toolbar is displayed. The program displayed in the View window is uploaded from the drive when the connection is made between MotionView and the drive. This upload is always performed regardless of program running state. Click anywhere in the Parameter View Window to edit the Indexer program.
Common Programming Actions
Load User program from the PC to MotionView
- Select [Indexer Program] in the Node Tree.
- Select [Import] on the program toolbar. Select the program to import from the PC folder where it is located. This procedure loads the program from the file to the editor window. It doesn’t load the program to the drive’s memory.
Compile program and Load to the drive
- Select [Indexer Program] in the Node Tree.
- Select [Compile & Load W Source] on the program toolbar to to compile the program and load the source code and the compiled binary file to the PositionServo drive. The original source code contained in the drive can be viewed whenever the drive is accessed through MotionView and the Indexer Program folder is opened.
- Select [Compile] to check syntax errors without loading the program to drive. If the compiler finds any syntax error, compilation stops. Errors are reported in bottom portion of the screen in Message window.
Save User program from MotionView to PC.
- Select [Indexer Program] in the Node Tree.
- Select [Export] ] on the program toolbar. The program will be saved to the Windows “My Documents” folder by default.
Run User program in drive.
- Select [Indexer Program] in the Node Tree.
- Select [Run] on the program toolbar. If the program is already running, then first select [Reset] or [Stop] to stop the program.
Step Through the User program.
- Select [Indexer Program] in the Node Tree.
- Select [Step] or [Step over] on the program toolbar. If [Step] is selected, the drive will execute the program one step at a time including subroutines. If [Step Over] is selected, the drive will execute the program one step at a time excluding subroutines. The program statement under execution will be highlighted. If the program is running, it will have to be either stopped or reset.
Set Breakpoint(s) in the program
- Select [Indexer Program] in the Node Tree.
- Place the cursor at the point in the program where the program will stop.
- Select [Set Breakpoint] or [Remove Breakpoint] on the program toolbar. A convenient way to debug a user program is to insert breakpoints at critical junctions throughout the program. These breakpoints stop the drive from executing the program, but do not disable the drive and the position variables. Once the program has stopped, the user can continue to run the program, step through the program or reset the program.
PM94P01C 9
Introduction
Stop program execution
- Select [Indexer Program] in the Node Tree.
- Select [Stop] on the program toolbar. The program will stop after completing the current statement. Select [Run] to resume the program from the same point.
IMPORTANT!
The [Stop] button only stops the execution of the program code. It does not stop motion or disable the drive.
Restart Program execution
- Select [Indexer Program] in the Node Tree.
- Select [Reset] on the program toolbar. The program will be reset and the drive will be disabled. Variables within the drive are not cleared (reset) when program execution is reset. It is important that any variables used by the programmer are set to safe values at the start of the user program.

1.4 Programming Basics

The user program consists of statements which when executed will not only initiate motion moves but also process the drives I/O and make decisions based on drive parameters. Before motion can be initiated, certain drive and I/O parameters must be configured. To configure these parameters perform the following procedure.
Parameter setup
Select [Parameter] folder in the Node Tree window and set the following parameters.
Set the “Drive” to “Position”:
- Select [Drive mode] from the Parameter View Window.
- Select [Position], [Velocity], or [Torque] from the drop down menu depending on the mode the drive is to be operated in. In order to execute the examples contained in this section of the manual the drive will need to be in [Position] mode.
Set the [Reference] to [Internal]:
- Select [Reference] from the Parameter View Window.
- Select [Internal] from the pull down menu to select the user program as the source of the Torque, Velocity, or Position Reference.
Set the [Enable switch function] to [Inhibit]:
- Select [Enable switch function] from the Parameter View Window.
- Select [Inhibit] from the menu to allow the user program control of the enable / disable status of the drive. Input A3 will now act as a hardware inhibit.
I/O Configuration
Input A3 is the Inhibit/Enable special purpose input. Refer to the PS User Manual (S94P01) for more information. Before executing any motion related statements, the drive must be enabled by executing “ENABLE” statement. “ENABLE” statement can only be accepted if input A3 is made. If at any time while drive is enabled A3 deactivates then the fault “F36” (“Drive Disabled”) will result. This is a hardware safety feature.
PM94P01C10
Introduction
Basic Motion Program
Select [Indexer program] from the Node Tree. The Parameter View window will display the current User Program stored in the drive. Note that if there is no valid program in the drive’s memory the program area will be empty.
WARNING!
This program will cause motion. The motor should be disconnected from the application (free to rotate) or if a motor is connected, the shaft must be free to spin 10 revs forward and reverse from the location of the shaft at power up. Also, the machine must be capable of 10 RPS and an accel / decel of 5 RPSS.
In the program area, clear any existing program and replace it with the following program:
UNITS=1 ACCEL = 5 DECEL = 5 MAXV = 10 ENABLE MOVED 10 MOVEDISTANCE -10 END
After the text has been entered into the program area, select the [Compile] icon from the toolbar. After compilation is done, a “Compilation Error” message should appear:
Click [OK] to dismiss the “Compliation error” dialog box. The cause of the compilation error will be displayed in the Message window, located at the bottom of the MotionView OnBoard window. MotionView will also highlight the program line where the error occurred.
UNITS=1 ACCEL = 5 DECEL = 5 MAXV = 10 ; ENABLE MOVED 10 ; MOVEDISTANCE -10 END
The problem in this example is that “MOVEDISTANCE” is not a valid command. Change the text “MOVEDISTANCE” to “MOVED”.
UNITS=1 ACCEL = 5 DECEL = 5 ENABLE MOVED 10 MOVED -10 END
After editing the program, select the [Compile] icon from the program toolbar. After compilation is done, the “Compilation Complete” message box should appear.
PM94P01C 11
Introduction
The program has now been compiled without errors. Select [Compile & Load W Source] to load the program to the drive’s memory. Click [OK] to dismiss the dialog box.
To Run the program, input A3 must be active to remove the hardware inhibit. Select the [Run] icon on the program toolbar. The drive will start to execute the User Program. The motor will spin 10 revolutions in the CCW direction and then 10 revolutions in the CW direction. After all the code has been executed, the program will stop and the drive will stay enabled.
To Restart the program, select the [Reset] icon on the program toolbar. This will disable the drive and reset the program to execute from the start. The program does not run itself automatically. To run the program again, select the [Run] icon on the toolbar.
Program Layout
When developing a program, structure is very important. It is recommended that the program be divided up into the following 7 segments:
Header: The header defines the title of the program, who wrote the program and description of what
the program does. It may also include a date and revision number.
I/O List: The I/O list describes what the inputs and outputs of the drive are used for. For example input A1
might be used as a Start Switch.
Init & Set Var: Initialize and Set Variables defines the drives settings and system variables. For example
here is where acceleration, deceleration and max speed might be set.
Events: An Event is a small program that runs independently of the main program. This section is
used to define the Events.
Main Program: The Main Program is the area where the process of the drive is defined. Sub-Routines: This is the area where any and all sub-routines should reside. These routines will be called
out from the Main Program with a GOSUB command.
Fault Handler: This is the area where the Fault Handler code resides. If the Fault handler is utilized this code
will be executed when the drive generates a fault.
The following is an example of a Pick and Place program divided up into the above segments.
***************************** HEADER ************************************** ;Title: Pick and Place example program ;Author: Lenze - AC Technology ;Description: This is a sample program showing a simple sequence that ; picks up a part, moves to a set position and places the part
;**************************** I/O List ************************************ ; Input A1 - not used ; Input A2 - not used ; Input A3 - Enable Input ; Input A4 - not used ; Input B1 - not used ; Input B2 - not used ; Input B3 - not used ; Input B4 - not used ; Input C1 - not used ; Input C2 - not used ; Input C3 - not used ; Input C4 - not used ; Output 1 - Pick Arm ; Output 2 - Gripper ; Output 3 - not used ; Output 4 - not used
PM94P01C12
Introduction
;********************** Initialize and Set Variables *********************** UNITS = 1 ACCEL = 75 DECEL =75 MAXV = 10 ;V1 = ;V2 =
;********************** Events ********************************************* ;Set Events handling here ;No events are currently defined in this program
;********************** Main Program **************************************
RESET_DRIVE: ;Place holder for Fault Handler Routine WAIT UNTIL IN_A3: ;Make sure that the Enable input is made before continuing ENABLE ;Enable output from drive to motor PROGRAM_START: ;Place holder for main program loop MOVEP 0 ;Move to Pick position OUT1 = 1 ;Turn on output 1 to extend Pick arm WAIT TIME 1000 ;Delay 1 sec to extend arm OUT2 = 1 ;Turn on output 2 to Engage gripper WAIT TIME 1000 ;Delay 1 sec to Pick part OUT1 = 0 ;Turn off output 1 to Retract Pick arm MOVED -10 ;Move 10 REVs to Place position OUT1 = 1 ;Turn on output 1 to extend Pick arm WAIT TIME 1000 ;Delay 1 sec to extend arm OUT2 = 0 ;Turn off output 2 to Disengage gripper WAIT TIME 1000 ;Delay 1 sec to Place part OUT1 = 0 ;Retract Pick arm GOTO PROGRAM_START ;Loop back and continuous execute main program loop END
;********************** Sub-Routines ***************************************
;Enter Sub-Routine code here
;********************** Fault Handler Routine ********************
;Enter Fault Handler code here ON FAULT ;No Fault Handler is currently defined in this program ENDFAULT
Saving Configuration File to PC
The “Configuration File” consists of all the parameter settings for the drive, as well as the User Program. Once you are done setting up the drive’s parameters and have written your User Program, you can save these setting to your computer. To save the settings, select [Save All] from the Main toolbar. Then simply assign your program a name, (e.g. Basic Motion), and click [Save] in the dialog box. The configuration file has a “.dcf” extension and by default will be saved to the “My Documents” folder.
Loading Configuration File to the Drive
There are times when it is desired to import (or export) the program to another drive. Other times the program was prepared off-line. In both scenarios, the program or configuration file needs to be loaded from the PC to the drive. To load the configuration file to the drive, select [Load Configuration] from the Main toolbar. Then simply select the program you want to load and click [Open] in the dialog box. MotionView will first compile the selected program. Once compiled, the [Compilation Complete] dialog box should appear. Click [OK] to dismiss this dialog box. MotionView will then load the selected file to the drive. When done, a “Parameters Successfully Loaded” or similar message will be displayed in the Message Window.
PM94P01C 13
Introduction
Motion source (Reference)
The PositionServo can be set up to operate in one of three modes: Torque, Velocity, or Position. The drive must be given a command before it can initiate any motion. The source for commanding this motion is referred to as the “Reference”. With the PositionServo you have two ways of commanding motion, or two types of References. When the drive’s command signal is from an external source, for example a PLC or Motion Controller, it is referred to as an External Reference. When the drive is being given its command from the User program or through one of the system variables it is referred to as an Internal Reference.
Table 4: Setting the Reference
“Reference” Parameter Setting
Mode External Internal
Torque
Velocity
Position
User Program (Trajectory generator output)
Units
All motion statements in the drive work with User units. The statement on the first line of the test program, UNITS=1, sets the relationship between User units and motor revolutions. For example, if UNITS=0.5 the motor will turn 1/2 of a revolution when commanded to move 1 Unit. When the UNITS variable is set to zero, the motor will operate with encoder counts as User units.
Analog input AIN1 System variable “IREF”
Analog input AIN1 System variable “IREF”
Step/Direction Inputs
Master Encoder Pulse Train Inputs
User Program/Interface
(Trajectory generator)
Time base
Time base is always in seconds i.e. all time-related values are set in USER UNITS/SEC.
Enable/Disable/Inhibit drive
Set “Enable switch function” to “Run”.
When the “Enable switch function” parameter is set to Run, and the Input A3 is made, the drive will be enabled. Likewise, toggling input A3 to the off state will disable the drive.
- Select “Parameter” from the Parameter Tree Window.
- Select “Enable switch function” from the Parameter View Window.
- Select “Run” from the popup menu. This setting is primarily used when operating without any user’s program in torque or velocity mode or as position follower with Step&Direction/Master Encoder reference.
Set “Enable switch function” to “Inhibit”.
In the example of the Enable switch function being set to Run the decision on when to enable and disable the drive is determined by an external device, PLC or motion controller. The PositionServo’s User Program allows the programmer to take that decision and incorporate it into the drive’s program. The drive will execute the User Program whether the drive is enabled or disabled, however if a motion statement is executed while the drive is disabled, the F36 fault will occur. When the “Enable switch function” parameter is set to Inhibit, and Input A3 is on, the drive will be disabled and remain disabled until the ENABLE statement is executed by the User Program.
- Select “Parameter” from the Parameter Tree Window.
- Select “Enable switch function” from the Parameter View Window.
- Select “Inhibit” from the popup menu.
PM94P01C14
Introduction
Faults
When a fault condition has been detected by the drive, the following actions will occur:
- Drive will Immediately be placed in a Disabled Condition.
- Motion Stack will be flushed of any Motion Commands
- Execution of the user program will be terminated and program control will be handed over to the Fault Handler section. If no Fault handler is described then program execution will terminate. See fault handler section.
- A fault code defining the nature of the drive trip will be written to the DFAULTS system variable and can be accessed by the fault handler. Refer to section 2.13 for a list of fault codes.
- The fault code will will be displayed on the drive display.
- Dedicated “Ready” output will turn off.
- Any Output with assigned special function “Fault” will turn on.
- Any Output with assigned special function “ready/enabled” will turn off.
- The “enable” status indicator on the drive display will turn off indicating drive in disabled state.
Clearing a fault condition can be done in one of the following ways:
- Select the [Reset] button from the toolbar.
- Execute the RESUME statement at the end of the Fault Handler routine (see Fault Handler example).
- Send “Reset” command over the Host Interface.
- Cycle power (hard reset).
Fault Handler
The Fault Handler is a code segment that will be executed when the drive is experiencing a fault. The fault handler allows the programmer to analyze the type of fault and define a recovery process for the drive and permits the continuation of program execution. While the drive is executing the Fault Handler Routine the drive is disabled and therefore will not be able to detect any additional faults that might occur. Fault handler code should be treated as the drive’s first reaction on fault. While it executes, the drive will not respond to any I/O, interface commands etc. Therefore the user should use the fault handler to manipulate time critical and safety related I/O and variables and then exit the Fault Handler Routine by executing a “RESUME” statement for a full stop after statement. The Resume statement permits program execution to leave the fault handler and resume back in the main program section of the user code. Use the Resume statement to jump back to a section of the main program that designates the recovery process for the fault. Waiting in Fault handler for I/O state change or for interface command is not allowed. Do that in the code where you point the “RESUME” statement.
Without Fault Handler
To simulate a fault, restart the Pick and Place example program. While the program is running, switch the ENABLE input IN_A3 to the off state. This will cause the drive to generate an F_36 fault (Drive Disabled) and put the drive into Fault Mode. While the drive is in Fault Mode, any digital output currently active will remain active and any output deactivated will remain deactivated, excluding the dedicated ready output and any output that has been assigned special functionality. The program execution will stop and any motion moves will be terminated. In this example the Pick and Place arm may not be in a desired location when the program goes into the fault mode.
PM94P01C 15
Introduction
With Fault Handler
Add the following code to the end of your sample program. While the program is running, switch the ENABLE input IN_A3, to the off state. This will cause the drive to generate an F_36 fault (Drive Disabled) and put the drive into a Fault Mode. From this point the Fault Handler Routine will take over.
F_PROCESS: WAIT UNTIL IN_A4==1 ;Wait until reset switch is made WAIT UNTIL IN_A4==0 ;and then released before GOTO RESET_DRIVE ;returning to the beginning of the program END ;*********************** Sub-Routines ************************************** Enter Sub-Routines here; ;*********************** Fault Handler Routine ***************************** ON FAULT ;Statement starts fault handler routine ;Motion stopped, drive disabled, and events no longer ;scanned while executing the fault handler routine. OUT2 = 0 ;Output 1 off to Disengage gripper. ;This will drop the part in the gripper OUT1 = 0 ;Retract Pick arm to make sure it is up and out of the way RESUME F_PROCESS ;program restarts from label F_PROCESS ENDFAULT ;fault handler MUST end with this statement
NOTE
The following statements can not be used inside the Fault Handler Routine:
- ENABLE
- WAIT
- MOVE
- MOVED
- MOVEP
- MOVEDR
- MOVEPR
- MDV
- MOTION SUSPEND
- MOTION RESUME
- GOTO, GOSUB
- JUMP
- ENABLE
- VELOCITY ON/OFF
Refer to section 2.1 for additional details and the Language Reference section for the statement “ON FAULT/ENDFAULT”.
PM94P01C16
Introduction

1.5 Using Advanced Debugging Features

To debug a program or view the I/O, open the Diagnostic window by clicking on the [Tools] in the Parmeter (Node) Tree list then click on the [Parameter & I/O View] button. The Diagnostic window will open. This window allows the programmer to monitor and set variables, and to view status of drive digital inputs and outputs.
Click on a variable in the variable list on the right-hand side to select that parameter
< -
- >
= >
R
Use the left arrow button to add variables after selecting a variable.
Use the right arrow button to remove variables after selecting a variable.
Use the double right arrow button to remove all variables in left-hand Diagnostic window.
Use the [R] (Refresh) button to refresh variable values.
Figure 6: Variable Diagnostic Display
NOTE
Write-only variables cannot be read. Attempts to either display a write-only variable in the diagnostic window or to read a write-only variable via network communications can show erroneous data.

1.6 Inputs and Outputs

Analog Input and Output
- The PositionServo has two analog inputs. These analog inputs are utilized by the drive as System Variables and are labeled “AIN1” and “AIN2”. Their values can be directly read by the User Program or via a Host Interface. Their value can range from -10 to +10 and correlates to ±10 volts analog input.
- The PositionServo has one analog output. This analog output is utilized by the drive as a System Variable and is labeled “AOUT”. It can be directly written by the User Program or via a Host Interface. Its value can range from -10 to +10 which correlates to ± 10 volts analog input.
NOTE
If an analog output is assigned to any special function from MotionView, writing to AOUT from the User Program will not change its value. If an analog output is set to “Not assigned” then it can be controlled by writing to the AOUT variable.
PM94P01C 17
Introduction
Digital Inputs
- The PositionServo has twelve digital inputs that are utilized by the drive for decision making in the User Program. Example uses: travel limit switches, proximity sensors, push buttons and hand shaking with other devices.
- Each input can be assigned an individual debounce time via MotionView. From the Parameter Tree, select [IO]. Then select the [Digital Input] folder. The debounce times will be displayed in the Parameter View Window. Debounce times can be set between 0 and 1000 ms (1ms = 0.001 sec). Debounce times can also be set via variables in the user program.
- The twelve inputs are separated into three groups: A, B and C. Each group has four inputs and share one common: Acom, Bcom and Ccom respectfully. The inputs are labeled individually as IN_A1 - IN_A4, IN_B1
- IN_B4 and IN_C1 - IN_C4.
- In addition to monitoring each input individually, the status of all twelve inputs can be represented as one binary number. Each input corresponds to 1 bit in the INPUTS system variable. Use the following format:
System Variable INPUTS
Bit # 11 10 9 8 7 6 5 4 3 2 1 0
Input
Name
C4 C3 C2 C1 B4 B3 B2 B1 A4 A3 A2 A1
- Some inputs can have additional special functionality such as Travel Limit switch, Enable input, and Registration input. Configuration of these inputs is done from MotionView or through variables in the user program. Input special functionality is summarized in the table below and in the following sections. The current status of the drive’s inputs is available to the programmer through dedicated System Flags or as bits of the System Variable INPUTS. Table 5 summarizes the special functions for the inputs.
Table 5: Input Functions
Input Special Function
Input A1 negative limit switch
Input A2 positive limit switch
Input A3 Inhibit/Enable input
Input A4 N/A
Input B1 N/A
Input B2 N/A
Input B3 N/A
Input B4 N/A
Input C1 N/A
Input C2 N/A
Input C3 Registration sensor input
Input C4 N/A
PM94P01C18
Introduction
Read Digital Inputs
The Pick and Place example program has been modified below to utilize the “WAIT UNTIL” inputs statements in place of the “WAIT TIME” statements. IN_A1 and IN_A4 will be used as proximity sensors to detect when the pick and place arm is extended and when it is retracted. When the arm is extended, IN_A1 will be in an ON state and will equal “1”. When the arm is retracted, IN_A4 will be in an ON state and will equal “1”.
;********************* Main Program **************************************** RESET_DRIVE: ;Place holder for Fault Handler Routine WAIT UNTIL IN_A3 ;Make sure that the Enable input is made before continuing ENABLE PROGRAM_START: WAIT UNTIL IN_A4==1 ;Make sure Arm is retracted MOVEP 0 ;Move to Pick position OUT1 = 1 ;Turn on output 1 to extend Pick arm WAIT UNTIL IN_A1==1 ; Arm extend OUT2 = 1 ;Turn on output 2 to Engage gripper WAIT TIME 1000 ;Delay 1 sec to Pick part OUT1 = 0 ;Turn off output 1 to Retract Pick arm WAIT UNTIL IN_A4==1 ;Make sure Arm is retracted MOVED -10 ;Move 10 REVs to Place position OUT1 = 1 ;Turn on output 1 on to extend Pick arm WAIT UNTIL IN_A1==1 ; Arm is extended OUT2 = 0 ;Turn off output 2 to Disengage gripper WAIT TIME 1000 ;Delay 1 sec to Place part OUT1 = 0 ;Retract Pick arm WAIT UNTIL IN_A4==1 ;Arm is retracted GOTO PROGRAM_START END
Once the above modifications have been made, export the program to file and save it as “Pick and Place with I/O”, then compile, download and test the program.
ASSIGN & INDEX - Using inputs to generate predefined indexes
“INDEX” is a variable on the drive that can be configured to represent a certain group of inputs as a binary number. “ASSIGN” is the command that designates which inputs are utilized and how they are configured.
Below the Pick and Place program has been modified to utilize this “INDEX” function. The previous example program simply picked up a part and moved it to a place location. For demonstration purposes we will add seven different place locations. These locations will be referred to as Bins. What Bin the part is placed in will be determined by the state of three inputs, B1, B2 and B3.
Bin 1 - Input B1 is made Bin 2 - Input B2 is made Bin 3 - Inputs B1 and B2 are made Bin 4 - Input B3 is made Bin 5 - Inputs B1 and B3 are made Bin 6 - Inputs B2 and B3 are made Bin 7 - Inputs B1, B2 and B3 are made
The “ASSIGN” command is used to assign the individual input to a bit in the “INDEX” variable. ASSIGN INPUT <input name> AS BIT <bit #>
;*********************** Initialize and Set Variables ******************* ASSIGN INPUT IN_B1 AS BIT 0 ;Assign the Variable INDEX to equal 1 when IN_B1 is made ASSIGN INPUT IN_B2 AS BIT 1 ;Assign the Variable INDEX to equal 2 when IN_B2 is made ASSIGN INPUT IN_B3 AS BIT 2 ;Assign the Variable INDEX to equal 4 when IN_B4 is made
PM94P01C 19
Introduction
Table 6: Bin Location, Inputs & Index Values
Bin Location Input State INDEX Value
Bin 1 Input B1 is made 1 Bin 2 Input B2 is made 2 Bin 3 Inputs B1 and B2 are made 3 Bin 4 Input B3 is made 4 Bin 5 Inputs B1 and B3 are made 5 Bin 6 Inputs B2 and B3 are made 6 Bin 7 Inputs B1, B2 and B3 are made 7
The Main program has been modified to change the end place position based on the value of the “INDEX” variable.
;************************** Main Program ********************************** ENABLE PROGRAM_START: WAIT UNTIL IN_A4==1 ;Make sure Arm is retracted MOVEP 0 ;Move to (ABS) to Pick position OUT1 = 1 ;Turn on output 1 to extend Pick arm WAIT UNTIL IN_A1==1 ;Arm extends OUT2 = 1 ;Turn on output 2 to Engage gripper WAIT TIME 1000 ;Delay 1 sec to Pick part OUT1 = 0 ;Turn off output 1 to Retract Pick arm WAIT UNTIL IN_A4==0 ;Make sure Arm is retracted
IF INDEX==1 ;In this area we use the If statement to GOTO BIN_1 ;check and see what state inputs B1, B2 & B3 ENDIF ;are in. IF INDEX==2 ; INDEX = 1 when input B1 is made GOTO BIN_2 ; INDEX = 2 when input B2 is made ENDIF ; INDEX = 3 when input B1 & B2 are made. . ; INDEX = 4 when input B3 is made . ; INDEX = 5 when input B1 & B3 are made. . ; INDEX = 6 when input B2 & B3 are made. IF INDEX==7 ; INDEX = 7 when input B1, B2 & B3 are made GOTO BIN_7 ;We can now direct the program to one of seven ENDIF ;locations based on three inputs.
BIN_1: ;Set up for Bin 1 MOVEP 10 ;Move to Bin 1 location GOTO PLACE_PART ;Jump to place part routine BIN_2: ;Set up for Bin 2 MOVEP 20 ;Move to Bin 2 location GOTO PLACE_PART ;Jump to place part routine BIN_7: ;Set up for Bin 7 MOVEP 70 ;Move to Bin 7 location GOTO PLACE_PART ;Jump to place part routine PLACE_PART: OUT1 = 1 ;Turn on output 1 to extend Pick arm WAIT UNTIL IN_A4 == 1 ;Arm extends OUT2 = 0 ;Turn off output 2 to Disengage gripper WAIT TIME 1000 ;Delay 1 sec to Place part OUT1 = 0 ;Retract Pick arm WAIT UNTIL IN_A4 == 0 ;Arm is retracted GOTO PROGRAM_START END
PM94P01C20
Introduction
NOTE
Any one of the 12 inputs can be assigned as a bit position within the INDEX variable. Only bits 0 through 7 can be used with the INDEX variable. Bits 8-31 are not used and are always set to 0. Unassigned bits in the INDEX variable are set to 0.
BITS 8-31 (not used) A1 0 A2 A4 0 0 0 0
Limit Switch Input Functions
Inputs A1 and A2 can be configured as special purpose inputs from the [Digital IO] folder in MotionView. They can be set to one of three settings:
- The “Not assigned” setting designates the inputs as general purpose inputs which can be utilized by the User Program.
- The “Fault” setting will configure A1 and A2 as Hard Limit Switches. When either input is made the drive will be disabled, the motor will come to an uncontrolled stop, and the drive will generate a fault. If the negative limit switch is activated, the drive will display an F-33 fault. If the positive limit switch is activated the drive will display an F32 fault.
- The “Stop and fault” setting will configure A1 and A2 as End of Travel limit switches. When either input is made the drive will initiate a rapid stop before disabling the drive and generating an F34 or F35 fault (refer to section 2.15 for details). The speed of the deceleration will be set by the value stored in the “QDECEL” System Variable.
NOTE
The “Stop and Fault” function is available in position mode only, (“Drive mode” is set to “Position”). In all other cases, the Stop and Fault function will act the same as the Fault function.
To set this parameter, select the [IO] folder from the Parameter Tree. Then select the [Digital IO] folder. From the Parameter View Window, use the pull-down menu next to [Hard Limit Switches Action] to select the status: Not Assigned, Fault or Stop and Fault.
Digital Outputs Control
- The PositionServo has 5 digital outputs. The “RDY” or READY output is dedicated and will only come on when the drive is enabled, i.e. in RUN mode. The other outputs are labeled OUT1 - OUT4.
- Outputs can be configured as Special Purpose Outputs. If an output is configured as a Special Purpose Output it will activate when the state assigned to it becomes true. For example, if an output is assigned the function “Zero speed”, the assigned output will come on when the motor is not in motion. To configure an output as a Special Purpose Output, select the [IO] folder from the Parameter Tree. Then select the [Digital IO] folder. From the Parameter View Window, select the “Output function” parameter you wish to set (1, 2, 3 or 4).
- Outputs that are configured as “Not assigned” can be activated either via the User Program or from a host interface. If an output is assigned as a Special Purpose Output, neither the user program nor the host interface can overwrite its status.
- The Systems Variable “OUTPUTS” is a read/write variable that allows the User Program, or host interface, to monitor and set the status of all four outputs. Each output allocates 1 bit in the OUTPUTS variable. For example, if you set this variable equal to 15 in the User Program,i.e. 1111 in binary format, then all 4 outputs will be turned on.
- The example below summarizes the output functions and corresponding System Flags. To set the output, write any non-0 value (TRUE) to its flag. To clear the output, write a 0 value (FALSE) to its flag. You can also use flags in an expression. If an expression is evaluated as TRUE then the output will be turned ON. Otherwise, it will be turned OFF.
OUT1 = 1 ;turn OUT1 ON OUT2 = 10 ;any value but 0 turns output ON OUT3 = 0 ;turn OUT3 OFF OUT2 = APOS>3 && APOS<10 ;ON when position within window, otherwise OFF
PM94P01C 21
Introduction
Figure 7: Digital IO Folder

1.7 Events

A Scanned Event is a small program that runs independently of the main program. An event statement establishes a condition that is scanned on a regular basis. Once established, the scanned event can be enabled and disabled in the main program. If condition becomes true and EVENT is enabled, the code placed between EVENT and ENDEVENT executes. Scanned events are used to trigger the actions independently of the main program.
In the following example the Event “SPRAY_GUNS_ON” will be setup to turn Output 3 on when the drive’s position becomes greater than 25. Note: the event will be triggered only at the instant when the drive position becomes greater than 25. It will not continue to execute while the position is greater than 25. (i.e. the event is triggered by the transition in logic from false to true). Note also that main program doesn’t need to be interrupted to perform this action.
;*********************** EVENT SETUP *************************************** EVENT SPRAY_GUNS_ON APOS>25 ;Event will trigger as position passes 25 in pos dir. OUT3=1 ;Turn on the spray guns (out 3 on) ENDEVENT ;End event ;***************************************************************************
Enter the Event code in the EVENT SETUP section of the program. To Setup an Event, the “EVENT” command must be entered. This is followed by the Event Name “SPRAY_GUNS_ON” and the triggering mechanism, “APOS>25”. After that a sequence of programming statements can be entered once the event is triggered. In our case, we will turn on output 3. To end the Event, the “ENDEVENT” command must be used. Events can be activated (turned on) and deactivated (turned off) throughout the program. To turn on an Event, the “EVENT” command is entered, followed by the Event Name “SPRAY_GUNS_ON”. This is completed by the desired state of the Event, “ON” or “OFF”. Refer to Section
2.10 for more on Scanned Events.
;*************************************************************************** EVENT SPRAY_GUNS_ON ON ;Enable ‘spray guns on’ event ;***************************************************************************
Two Scanned Events have been added to the Pick and Place program below to trigger a spray gun on and off. The Event will be triggered after the part has been picked up and is passing in front of the spray guns (position greater than
25). Once the part is in position, output 3 is turned on to activate the spray guns. When the part has passed by the spray guns, (position greater than 75), output 3 is turned off, deactivating the spray guns.
PM94P01C22
Introduction
;*********************** Events ******************************************** EVENT SPRAY_GUNS_ON APOS>25 ;Event will trigger as position passes 25 in pos dir. OUT3=1 ;Turn on the spray guns (out 3 on) ENDEVENT ;End event EVENT SPRAY_GUNS_OFF APOS>75 ;Event will trigger as position passes 75 in pos dir. OUT3=0 ;Turn off the spray guns (out 3 off) ENDEVENT ;End event ;*********************** Main Program ************************************** PROGRAM_START: ;Place holder for main program loop ENABLE ;Enable output from drive to motor EVENT SPRAY_GUNS_ON ON ;Enable ‘spray guns on’ event EVENT SPRAY_GUNS_OFF ON ;Enable ‘spray guns off’ event WAIT UNTIL IN_A4==1 ;Make sure Arm is retracted MOVEP 0 ;Move to Pick position OUT1 = 1 ;Turn on output 1 to extend Pick arm WAIT UNTIL IN_A1==1 ;Arm extends OUT2 = 1 ;Turn on output 2 to Engage gripper WAIT TIME 1000 ;Delay 1 sec to Pick part OUT1 = 0 ;Turn off output 1 to Retract Pick arm WAIT UNTIL IN_A4==1 ;Make sure Arm is retracted MOVEP 100 ;Move to Place position OUT1 = 1 ;Turn on output 1 to extend Pick arm WAIT UNTIL IN_A1==1 ;Arm extends OUT2 = 0 ;Turn off output 2 to Disengage gripper WAIT TIME 1000 ;Delay 1 sec to Place part OUT1 = 0 ;Retract Pick arm WAIT UNTIL IN_A4==1 ;Arm is retracted GOTO PROGRAM_START ;Loop back and continuously execute main program loop END
1.8 Variables and Define Statement
In the previous program for the pick and place machine constants were used for position limits to trigger the event and turn the spray gun ON and OFF. If limits must be calculated based on some parameters unknown before the program runs (like home origin, material width, etc.), then use the User Variables. The PositionServo provides 32 User Variables V0-V31 and 32 User Network Variables NV0-NV31. In the program below, the limit APOS (actual position) is compared to V1 for an ON event and V2 for an OFF event. The necessary limit values could be calculated earlier in the program or supplied by an HMI or host PC.
The DEFINE statement can be used to assign a name to a constant, variable or drive Input/Output. In the program below, constants 1 and 0 are defined as Output_On and Output_Off. DEFINE is a pseudo statement, i.e it is not executed by the program interpreter, but rather substitutes expressions in the subsequent program at the time of compilation.
DEFINE Value2 2
DEFINE Value10 10
V1 = Value2+Value10 ; result is 12
V1 = 2+10 ; does exactly same as above, the result is 12
PM94P01C 23
Introduction
;*********************** Initialize and Set Variables ********************** UNITS = 1 ;Define units for program, 1=revolution of motor shaft ACCEL = 5 ;Set acceleration rate for motion command DECEL = 5 ;Set deceleration rate for motion command MAXV = 10 ;Maximum velocity for motion commands V1 = 25 ;Set Variable V1 equal to 25 V2 = 75 ;Set Variable V2 equal to 75 DEFINE Output_On 1 ;Define Name for output On DEFINE Output_Off 0 ;Define Name for output Off ;*********************** EVENTS ******************************************* EVENT SPRAY_GUNS_ON APOS > V1 ;Event will trigger as position passes 25 in pos dir. OUT3= Output_On ;Turn on the spray guns (out 3 on) ENDEVENT ;End event
EVENT SPRAY_GUNS_OFF APOS > V2 ;Event will trigger as position passes 75 in pos dir. OUT3= Output_Off ;Turn off the spray guns (out 3 off) ENDEVENT ;End even ;*********************** Main Program ************************************* PROGRAM_START: ;Place holder for main program loop ENABLE ;Enable output from drive to motor EVENT SPRAY_GUNS_ON ON ;Enable the ‘spray guns on’ event EVENT SPRAY_GUNS_OFF ON ;Enable the ‘spray guns off’ event WAIT UNTIL IN_A4==1 ;Ensure Arm is retracted before running the program MOVEP 0 ;Move to position 0 to pick part OUT1 = Output_On ;Turn on output 1 to extend Pick arm WAIT UNTIL IN_A1==1 ;Check input to make sure Arm is extended OUT2 = Output_On ;Turn on output 2 to Engage gripper WAIT TIME 1000 ;Delay 1 sec to Pick part OUT1 = Output_Off ;Turn off output 1 to Retract Pick arm WAIT UNTIL IN_A4==1 ;Check input to make sure Arm is retracted MOVED 100 ;Move to Place position OUT1 = Output_On ;Turn on output 1 to extend Pick arm WAIT UNTIL IN_A1==1 ;Check input to make sure Arm is extended OUT2 = Output_Off ;Turn off output 2 to Disengage gripper WAIT TIME 1000 ;Delay 1 sec to Place part OUT1 = Output_Off ;Retract Pick arm WAIT UNTIL IN_A4==1 ;Check input to make sure Arm is retracted GOTO PROGRAM_START ;Loop back and continuously execute main program loop END

1.9 IF/ELSE Statements

An IF/ELSE statement allows the user to execute one or more statements conditionally. The programmer can use an IF or IF/ELSE construct:
Single IF example:
This example increments a counter, Variable “V1”, until the Variable, “V1”, is greater than 10.
Again: V1=V1+1 IF V1>10 V1=0 ENDIF GOTO Again END
PM94P01C24
Introduction
Position Feedback
IF/ELSE example:
This example checks the value of Variable V1. If V1 is greater than 3, then V2 is set to 1. If V1 is not greater than 3, then V2 is set to 0.
IF V1>3 V2=1 ELSE V2=0 ENDIF
Whether you are using an IF or IF/ELSE statement the construct must end with ENDIF keyword.

1.10 Motion

Figure 8 illustrates the Position and Velocity regulator of the PositionServo drive.
Kff is automatically calculated
Kff term
I term
+
+
I term Limit and unti wind-up
+
+
+
Biquad Convergence Filter
Position Command
+
+
-
-
P term
D term
=0
=1
#41 Second Encoder
To Torque Amplifier Current Command
Secondary
Encoder
Primary Encoder
Velocity Command
+
-
Velocity Window
P term
D term
Mechanical Velocity Feedback
I term Limit and unti wind-up
+
+
Current Limiter
Biquad Convergence Filter
Velocity Estimator
Figure 8: PositionServo Position and Velocity Regulator’s Diagram
The “Position Command”, as shown in the regulator’s diagram (Figure 9), is produced by a Trajectory Generator. The Trajectory Generator processes the motion commands produced by the User’s program to calculate the position increment or decrement, also referred to as the “index” value, for every servo loop. This calculated target (or theoretical) position is then supplied to the Regulator input.
The main purpose of the Regulator is to set the motors position to match the target position created by the Trajectory Generator. This is done by comparing the input from the Trajectory Generator with the position feedback from the encoder or resolver, to control the torque and velocity of the motor. Of course there will always be some error in the position following. Such error is referred to as “Position Error” and is expressed as follows:
Position Error = Target Position - Actual Position
When the actual Position Error exceeds a certain threshold value a “Position Error limit”, fault (F_PE) will be generated. The Position Error limit and Position Error time can be set under the Node Tree “Limits”/ “Position Limits” in MotionView. The Position Error time specifies how long the actual position error can exceed the Position Error limit before the fault is generated.
PM94P01C 25
Introduction
T

1.10.1 Drive Operating Modes

There are three modes of operation for the PositionServo: Torque, Velocity and Position. Torque and Velocity modes are generally used when the command reference is from an external device, (Ain). Position mode is used when the command comes from the drives User Program, or from an external device, encoder or a step and direction pulse. Setting the drive’s mode is done from the [Parameter] folder in MotionView. To command motion from the user program the drive must be configured to internal reference mode. When the drive is in position mode, it can be placed into a velocity mode without the need to change operating mode to ‘Velocity’. Velocity profiling from Positioning mode can be turned on and off from the User Program. Executing the VELOCITY ON statement is used to activate this mode while VELOCITY OFF will deactivate this mode. This mode is used for special case indexing moves. Velocity mode is the mode when the target position is constantly advanced with a rate set in the VEL system variable. The Reference arrangements for the different modes of operation are illustrated in Figure 9.
#37, Reference
IREF
"INTERNAL"
+
+
+
"INTERNAL"
"INTERNAL"
#214,#189 TPOS
REGULATOR
POSITION
1
2
3
0 Torque
1 Velocity
2 Position
#34, DRIVEMODE
VELOCITY
REGULATOR
1
2
3
CURRENT
REGULATOR
TO MODULA
MA/MB inputs
User's program
Analog input #1
#79,#80
Master to System
ratio
#35,VELOCITY
#89
Dead Band
#90, Offset
#36,CURRENT SCALE
Gearing
Trajectory Generator
SCALE
Phase Correction
Figure 9: Reference Arrangement Diagram

1.10.2 Point To Point Moves

The PositionServo supports two types of moves: absolute and incremental. The statement MOVEP (Move to Position) is used to make an absolute move. When executing an absolute move, the motor is instructed to move to a known position. The move to this known position is always referenced from the motor’s “home” or “zero” location. For example, the statement (MOVEP 0) will cause the motor to move to its zero or home position, regardless of where the motor is located at the beginning of the move. The statement MOVED (Move Distance) makes incremental, (or relative), moves from its current position. For example, MOVED 10, will cause the motor to move forward 10 user units from it current location.
MOVEP and MOVED statements generate what is called a trapezoidal point to point motion profile. A trapezoidal move is when the motor accelerates, using the current acceleration setting, (ACCEL), to a default top speed, (MAXV), it then maintains that speed for a period of time before decelerating to the end position using the deceleration setting, (DECEL). If the distance to be moved is fairly small, a triangular move profile will be used. A triangular move is a move that starts to accelerate toward the Max Velocity setting but has to decelerate before ever achieving the max velocity in order to reach the desired end point.
PM94P01C26
Introduction
Trapezoidal Move Profile
Velocity (RPS)
Current accel value
Velocity
Top Velocity
Triangular Move Profile
Time
Figure 10: Trapezoidal Move

1.10.3 Segment Moves

MOVED and MOVEP commands facilitate simple motion to be commanded, but if the required move profile is more complex than a simple trapezoidal move, then the segment move MDV can be used.
The profile shown in Figure 11 is divided into 8 segments or 8 MDV moves. An MDV move (Move Distance Velocity) has two arguments. The first argument is the distance moved in that segment. This distance is referenced from the motor’s current position in User Units. The second argument is the desired target velocity for the end of the segment move. That is the velocity at which the motor will run at the moment when the specified distance in this segment is completed.
70
60
Segment Number
50
40
30
20
10
Segment
1
Segment
2
Segment
3
5
Segment
5
Segment
4
10 15
Segment
6
Segment
Segment
7
20 25
8
Distance (User Units)
Figure 11: Segment Move
Table 7: Segment Move
Distance moved
during segment
1 3 56
2 3 12
3 4 16
4 2 57
5 2.5 57
6 3 11
7 5 20
8 5 0
- - -
Velocity at the end of
segment
30
PM94P01C 27
Introduction
Registration Move
Here is the user program for the segment move example. The last segment move must have a “0” for the end velocity, (MDV 5 , 0). Otherwise, fault F_24 (Motion Queue Underflow), will occur.
;Segment moves LOOP: WAIT UNTIL IN_A4==0 ;Wait until input A4 is off before starting the move MDV 3 , 56 ;Move 3 units accelerating to 56 User Units per sec MDV 3 , 12 ;Move 3 units decelerating to 12 User Units per sec MDV 4 , 16 ;Move 4 units accelerating to 16 User Units per sec MDV 2 , 57 ;Move 2 units accelerating to 57 User Units per sec MDV 2.5 , 57 ;Move 2.5 units maintaining 57 User Units per sec MDV 3 , 11 ;Move 3 units decelerating to 11 User Units per sec MDV 5 , 20 ;Move 5 units accelerating to 20 User Units per sec MDV 5 , 0 ;Move 5 units decelerating to 0 User Units per sec WAIT UNTIL IN_A4==1 ;Wait until input A4 is on before looping GOTO LOOP END
NOTE
When an MDV move is executed, the segment moves are stored to a Motion Queue. If the program loops on itself, then the queue will become full and an F_23 Fault Motion Queue Overflow will occur.
Since the MDV moves utilize a Motion Queue, the [Step] or [Step Over] debugging features can not be used.

1.10.4 Registration

Both absolute and incremental moves can be used for registration moves. The statements associated with these moves are MOVEPR and MOVEDR. These statements have two arguments. The first argument specifies the commanded move distance or position. The second argument specifies the move made after the registration input is seen. If the registration move is an absolute move, for MovePR, the first argument is absolute (referenced to the 0 position), the second argument is relative to the registration position. For MoveDR, both arguments are relative. The first is relative to the shaft position when motion is started and the second is relative to the registration position.
Position Registration
Input is made
Commanded
Move
Figure 12: Registration Move
Registration
Move
PM94P01C28
Loading...
+ 104 hidden pages