


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A sample program for executing a trapezoidal motion profile on CNC machines using the Motion Planner software. It includes instructions on setting up commands, using variable and data substitutions, and defining programs and compiled profiles. The example program sets acceleration, velocity, and distance for axes 1 and 2, and executes the motion.
What you will learn
Typology: Lecture notes
1 / 34
This page cannot be seen from the preview
Don't miss anything!
Programming
Fundamentals
Motion Planner Programming Environment
Every 6K Series controller is shipped with Motion Planner, a Windows-based programming tool designed to simplify your programming efforts. The Motion Planner interface allows you to:
PROGRAMMING SUPPORT. To help you program with speed and efficiency, Motion Planner provides these “performance support” features:
Contents of the online help system.
This is an example of a user program. Note that the user program window has it own offering of wizards and file control buttons.
Double-click the icon to view the program in a separate window.
Main Program Editor Window: These are program icons placed by the “Standard Application” program structure wizard. The 1 st^ time you open an icon (double-click), you will be guided through the respective wizard. The next time you open the icon, you can edit the code generated from the wizard.
Click this tab to view the terminal window
Spaces and tabs within a command are processed as neutral characters. Comments can be specified with the semicolon (;) character — all characters following the semicolon and before the command delimiter are considered program comments.
Some commands contain one or more data fields in which you enter numeric or binary values or text:
2 and 10 units/sec
2 , respectively.
The command descriptions provided within the 6K Series Command Reference use alphabetic letters and ASCII symbols
within the S y n t a x description to represent different parameter requirements (see INEN example below).
Type Inputs; Program Debug Tools Syntax <!>INEN
Product Rev 6K 5.
Letter/Symbol Description
a .......... Represents an axis specifier, numeric value from 1 to 8.
B .......... Represents the number of the product's I/O brick. External I/O bricks are represented by numbers 1 through n (to connect external I/O bricks, see your product's Installation Guide ). On-board I/O are address at brick location zero (Ø). If the brick identifier is omitted from the command, the controller assumes the command is supposed to affect the onboard I/O.
b *......... Represents the values 1 , 0 , X or x; does not require field separator between values.
c .......... Represents a character (A to Z, or a to z)
d .......... Represents the values 1 , 0 , X or x, E or e ; does not require field separator between values. E or e enables a specific command field. X or x leaves the specific command field unchanged or ignored. In the ANIEN command, the “d” symbol can also represent a real numeric value.
i .......... Represents a numeric value that cannot contain a decimal point (integer values only). The numeric range varies by command. Field separator required.
r .......... Represents a numeric value that can contain a decimal point, but is not required to have a decimal point. The numeric range varies by command. Field separator required.
t .......... Represents a string of alpha numeric characters from 1 to 6 characters in length. The string must start with a alpha character.
! .......... Represents an immediate command. Changes a buffered command to an immediate command. Immediate commands are processed immediately, even before previously entered buffered commands.
% .......... (Multitasking Only) Represents a task identifier. To address the command to a specific task, prefix the command with “i%”, where “i” is the task number. For example, the 4%CUT command uses task 4 to execute the program called “CUT”.
, .......... (comma) Represents a field separator. Commands with the symbol r or i in their Syntax description require field separators. Commands with the symbol b or d in their Syntax description do not require field separators (but they can be included). See General Guidelines table below.
@ .......... Represents a global specifier, where only one field need be entered. Applicable to all commands with multiple command
< > ...... Indicates that the item contained within the < > is optional, not required by that command. NOTE : Do not confuse with
[ ] ...... Indicates that the command between the [ ] must be used in conjunction with another command, and cannot be used by itself.
Order of Precedence for Command Prefix Characters (from left to right):
1 st: Immediate 2 nd: Task number 3
rd : Apply to all axes or I/O bricks 3 rd^ : Axis number
3 rd^ : I/O brick number
<%><@>Many commands can substitute one or more of its command field values with one of these substitution items (demonstrated in the programming example below):
Programming Example : ( NOTE : The substitution item must be enclosed in parentheses.)
VAR1=15 ; Set variable 1 to 15 A5,(VAR1),4,4 ; Set acceleration to 5,15,4,4 for axes 1-4, respectively VARB1=b1101XX1 ; Set binary variable 1 to 1101XX1 (bits 5 & 6 not affected) GO(VARB1) ; Initiate motion on axes 1, 2 & 4 (value of binary ; variable 1 makes it equivalent to the GO1101 command) OUT(VARB1) ; Turn on outputs 1, 2, 4, and 7 VARS1="Enter Velocity" ; Set string variable 1 to the message "Enter Velocity" V2,(READ1) ; Set the velocity to 2 on axis 1. Read in the velocity for ; axis 2, output variable string 1 as the prompting message ; 1. Operator sees "ENTER VELOCITY" displayed on the screen. ; 2. Operator enters velocity prefixed by !' (e.g., !'20). HOMV2,1,(TW1) ; Set homing velocity to 2 and 1 on axes 1 and 2, respectively. ; Read in the home velocity for axis 3 from thumbwheel set 1 HOMV2,1,(DAT1) ; Set homing velocity to 2 and 1 on axes 1 and 2, respectively. ; Read home velocity for axis 3 from data program 1. VARI1=2*3 ; Set integer variable 1 to 6 (2 multiplied by 3) D(VARI2),,(VARI3) ; Set the distance of axis 1 equal to the value of ; integer variable 2, and the distance of axis 3 equal to ; the value of integer variable 3.
RULE OF THUMB
Comparison and assignment operators are used in command arguments for various functions such as variable assignments, conditional branches, wait statements, conditional GOs, etc. Some examples are listed below:
(e.g., To see a full-text description of each axis status bit accessed with the AS operator, send the TASF command to the 6K controller.)
See page 226.
A ................... Acceleration AD................. Deceleration ANI .............. Voltage at the analog inputs on an expansion I/O brick (see page 76 for bit patterns) * ANO .............. Voltage at the analog outputs on an expansion I/O brick (see page 76 for bit patterns) * AS................. Axis status * ASX .............. Extended axis status (additional axis status items) * D ................... Distance DAC .............. Digital-to-analog converter (output voltage) value * DAT .............. Data program number DKEY............ Value of RP240 Key DPTR............ Data pointer location * DREAD ......... Data from the numeric keypad on the RP DREADF ....... Data from the function keypad on the RP ER................. Error status * FB................. Position of current selected feedback sources * FS................. Following status * IN................. Input status (input bit patterns, see page 76) * INO .............. “Other” input status (ENABLE input reported with bit 6) * LIM .............. Limit status (end-of-travel limits and home limits) * MOV .............. Axis moving status NMCY............ Current master cycle number * OUT .............. Output status (output bit patterns, see page 76) * PANI............ Position of analog input, at 205 counts/volts unless otherwise scaled (servo axes) * PC................. Commanded position * PCC .............. Captured commanded position * PCE .............. Captured encoder position * PCME............ Captured master encoder position * PCMS............ Captured master cycle position * PER .............. Position error (servo axes only) * PME .............. Current master encoder position * PMAS............ Current master cycle position * PE................. Position of master encoder * PSHF............ Net position shift since constant Following ratio * PSLV............ Current commanded position of the slave axis * READ............ Read a numeric value to a numeric variable (VAR) SC................. Controller status * SCAN............ Runtime of the last scanned PLC program * SEG .............. Number of segments available in Compiled Profile memory * SS................. System status * SWAP............ Current active status of tasks * TASK............ Number of the controlling task * TIM .............. Timer value * TRIG............ Trigger interrupt status * TW................. Thumbwheel data read US................. User status * V ................... Velocity (programmed) VAR .............. Numeric variable substitution VARI............ Integer variable substitution VARB............ Binary variable substitution VEL .............. Velocity (commanded by the controller) * VELA............ Velocity (actual, as measured by a position feedback device) * VMAS............ Current velocity of the master axis *
Bit Select Operator The bit select operator (.) makes it easier to base a command argument on the condition of one specific status bit. For example, if you wish to base an IF statement on the condition that a user fault input is activated (error status bit 7 is a binary status bit that is “ 1 ” if a user fault occurred and “Ø” if it has not occurred), you could use this command: IF(ER=bxxxxxx1). Using a bit select operator, you could instead use this command: IF(ER.7=b1).
NOTE : You can use a bit select operator to set a particular status bit (e.g., to turn on onboard programmable output 5, you would type the OUT.5-1 command; to enable error-checking bit 4 to check for drive faults, you would type the ERROR.4-1 command). You can also check specific status bits (e.g., to check axis 2’s axis status bit 25 to see if a target zone timeout
The illustration below identifies the elements that comprise the general structure of a program.
; This is a program that executes a trapezoidal motion ; profile on axes 1 and 2 ; ********************************************************* DEL motion ; (a precaution) Delete program called "motion"
DEF motion ; Begin definition of program called "motion" DRIVE11 ; Enable drives on axes 1 and 2 MC00 ; Set position mode to preset on both axes A20,10 ; Set accel on axis 1 to 20 units/sec/sec, and ; Set accel on axis 2 to 10 units/sec/sec V8,5 ; Set velocity on axis 1 to 8 units/sec, and ; Set velocity on axis 2 to 5 units/sec D100000,75000 ; Set distance to 100,000 counts on axis 1, and ; Set distance to 75,000 counts on axis 2 GO11 ; Execute motion on axes 1 and 2 END ; End definition of program called "motion"
Motion Planner provides wizards that make it easy to create your program. Below is a partial list of the wizards available.
These are command line comments, comprising a semi-colon and text. The comments are separated from the command by a tab. A carriage return is placed at the end of each command line.
Use DEF to begin defining the program.
Contents of the program.
Use DEL to delete the program (a precaution).
Use END to finish defining the program.
Storing Programs
After a program or compiled program/profile is defined (DEF) or downloaded to the 6K controller, it is automatically stored in non-volatile memory (battery-backed RAM). Information on controlling memory allocation is provided below (Memory Allocation, see page 11).
Your controller's memory has two partitions: one for storing programs and one for storing compiled profiles & PLC programs. The allocation of memory to these two areas is controlled with the MEMORY command.
(^)
Executing Programs (options)
Following is a list of the primary options for executing programs stored in your controller:
Method Description See Also
Execute from a terminal emulator
Type in the name of the program and press enter; or write a program to prompt the operator to select a program from the terminal.
Execute as a subroutine from a “main” program
Use a branch (GOTO, GOSUB, or JUMP) from the main program to execute another stored program.
Page 23
Execute automatically when the controller is powered up
Assign a specific program as a startup program with the STARTP command. When you RESET or cycle power to the controller, the startup program is automatically executed.
Page 13
Execute from a PLC program
Write a PLC program that executes a program (using EXE or PEXE) based on a specific condition (e.g., input state). Use the SCANP command to launch the PLC program in the PLC Scan Mode.
Page 104
Execute a specific program with BCD weighted inputs
Define programmable inputs to function as BCD select inputs, each with a BCD weight. A specific program (identified by its number) is executed based on the combination of active BCD inputs. Related commands: INSELP and INFNCi-B or LIMFNCi-B.
Page 82
Execute a specific program with a dedicated input
Define a programmable input to execute a specific program (by number). Related commands: INSELP and INFNCi-iP or LIMFNCi-P.
Page 88
“Call” from a high-level program
Using a programming language such as BASIC or C, write a program that enables the computer to monitor processes and orchestrate motion and I/O by executing stored programs (or individual commands) in the controller.
Page 118
Execute from an RP (remote operator interface)
Execute a stored program from the RUN menu in the RP240’s standard menu system.
Page 111
Execute from your own custom Windows program
Use a programming language (e.g., Visual Basic, Visual C++, etc.) and the 6K Communications Server (provided on the Motion Planner CD) to create your own windows application to control the 6K product.
Creating and Executing a Setup Program
The intent of the Setup program is to place the 6K controller in a ready state for subsequent motion control. The setup program must be called from the “main” program for your application; or you can designate (with STARTP) the setup program as the program to be is automatically executed when the 6K product is powered up or when the RESET command is executed. The setup program typically contains elements such as feedback device configuration, tuning gain selections, programmable I/O definitions, scaling, homing configuration, variable initialization, etc. (more detail on these “basic” features is provided in Chapter 3, Basic Operation Setup ).
The basic process of creating a setup program is:
Or call the setup program from the main program for your application.
Use Motion Planner’s Setup wizard to help you create the basic configuration program. By simply responding to a series of dialog boxes, a program is created with a specific name (as if you created it in the usual process with the DEF and END commands). You can further edit this program in Motion Planner's Editor if you wish. Use the following procedure:
Program Security
Issuing the INFNCi-Q or LIMFNCi-Q command enables the Program Security feature and assigns the Program Access function to the specified programmable input. The “i” represents the number of the programmable input to which you wish to assign the function (see page 76 programmable input bit patterns for your product).
The program security feature denies you access to the DEF, DEL, ERASE, MEMORY, INFNC, and LIMFNC commands until you activate the program access input. Being denied access to these commands effectively restricts altering the user memory allocation. If you try to use these commands when program security is active (program access input is not activated), you will receive the error message *ACCESS DENIED.
For example, once you issue the INFNC5-Q command, onboard input 5 is assigned the program access function and access to the DEF, DEL, ERASE, MEMORY, INFNC, and LIMFNC commands will be denied until you activate onboard input 5.
NOTE : To regain access to these commands without the use of the program access input, you must issue the INEN command to disable the program security input, make the required user memory changes, and then issue the INEN command to re-enable the input. For example, if input 3 on I/O brick 2 is assigned as the Program Security input, use 2INEN.3=1 to disable the input and leave it activated, make the necessary user memory changes, and then use 2INEN.3=E to re-enable the input.
The COMEXR command affects whether a “Pause” input (i.e., an input configured as a pause/continue input with the INFNCi-E command or the LIMFNCi-E command) will pause only program execution or both program execution and motion.
COMEXRØ: (This is the default setting.) Upon receiving a pause input, only program execution will be paused; any motion in progress will continue to its predetermined destination. Releasing the pause input or issuing a !C command will resume program execution.
COMEXR1: Upon receiving a pause input, both motion and program execution will be paused; the motion stop function is used to halt motion. After motion has come to a stop (not during deceleration) , you can release the pause input or issue a !C command to resume motion and program execution.
The COMEXS command determines the impact on motion, program execution, and the command buffer when the 6K receives a Stop command (S, !S, S1, or !S1) or an external Stop input (an input assigned a stop function with INFNCi-D or LIMFNCi-D).
COMEXS0: Under factory default conditions (COMEXS0), when the 6K receives a stop command (S, !S, S1, or !S1) or a stop input (INFNCi-D or LIMFNCi-D), the following will happen:
COMEXS1: Using the COMEXS1 mode, the 6K allows more flexibility in responding to stop conditions, depending on the stop method (see table below).
Stop Method
What Stops? Motion Program
Resume Motion Profile. (Allow resume with a !C command or a resume input * )
Resume Program. (Allow resume with a !C command or a resume input * )
Save Command Buffer. (Save the commands that were in the command buffer when the stop was commanded) !S or S Yes Yes Yes Yes Yes !S1 or S1 Yes No No No Yes Stop input Yes Yes No Yes Yes Pause input * (if COMEXR1)
Yes Yes Yes Yes Yes
Pause input * (if COMEXR0)
No Yes No Yes Yes
COMEXS2: Using the COMEXS2 mode, the 6K responds as it does in the COMEXS0 mode, with the exception that you can still use the program-select inputs to select programs (INSELP value is retained). The program-select input functions are: BCD select (INFNCi-B or LIMFNCi-B), and one-to-one select (INFNCi-P or LIMFNCi-P).
Restricted Commands During Motion
When motion is in progress on a given axis (or task), some commands cannot have their parameters changed until motion is complete (see table below).
For the commands identified in the table, if the continuous command execution mode is enabled (COMEXC1) and you try to enter new command parameters, you will receive the error response MOTION IN PROGRESS. If the continuous command execution mode in disabled (COMEXCØ), which is the default setting, you will receive the response MOTION IN PROGRESS only if you precede the command with the immediate (!) modifier (e.g., !V2Ø); if you enter a command without the immediate modifier (e.g., V2Ø), you will not receive an error response and the new parameter will be ignored and the old parameter will remain in effect.
Multi-Tasking
All of the commands in the table below, except for SCALE, are axis-dependent. That is, if one axis is moving you can change the parameters on the other axes, provided they are not in motion.
Command Description Command Description CMDDIR.........Commanded Direction Polarity JOY............... Joystick Mode Enable DRES .............Drive Resolution JOYA............. Joystick Acceleration DRIVE...........Drive Shutdown JOYAA .......... Average Joystick Acceleration ENCPOL.........Encoder Polarity JOYAD .......... Joystick Deceleration ERES .............Encoder Resolution JOYADA ........ Average Joystick Deceleration FOLEN...........Following Mode Enable JOYVH^ .......... Joystick Velocity High GOL ...............Initiate Linear Interpolated Motion JOYVL .......... Joystick Velocity Low HOM ...............Go Home LHAD............. Hard Limit Deceleration HOMA .............Home Acceleration LHADA .......... Average Hard Limit Deceleration HOMAA...........Average Home Acceleration LSAD............. Soft Limit Deceleration HOMAD...........Home Deceleration LSADA .......... Average Soft Limit Deceleration HOMADA.........Average Home Deceleration PSET............. Establish Absolute Position HOMV .............Home Velocity SCALE .......... Enable/Disable Scale Factors * HOMVF...........Home Final Velocity SCLA............. Acceleration Scale Factor JOG ...............Jog Mode Enable SCLD............. Distance Scale Factor JOGA .............Jog Acceleration SCLV............. Velocity Scale Factor JOGAA...........Average Jog Acceleration JOGAD...........Jog Deceleration JOGADA.........Average Jog Deceleration JOGVH...........Jog Velocity High JOGVL...........Jog Velocity Low
NOTES
Mathematical Operations
The following examples demonstrate how to perform math operations with numeric variables. Operator precedence occurs from left to right (e.g., VAR1=1+1+1∗ 3 sets VAR1 to 9, not 5).
Trigonometric Operations
The examples below demonstrate how to perform trigonometric operations with numeric variables.
Sine E x a m p l e^ R e s p o n s e RADIAN VAR1=SIN(0) VAR1 *VAR1=+0. VAR1=SIN(30) VAR1 *VAR1=+0. VAR1=SIN(45) VAR1 *VAR1=+0. VAR1=SIN(60) VAR1 *VAR1=+0. VAR1=SIN(90) VAR1 *VAR1=+1. RADIAN VAR1=SIN(0) VAR1 *VAR1=+0. VAR1=SIN(PI/6) VAR1 *VAR1=+0. VAR1=SIN(PI/4) VAR1 *VAR1=+0. VAR1=SIN(PI/3) VAR1 *VAR1=+0. VAR1=SIN(PI/2) VAR1 *VAR1=+1.