0% found this document useful (0 votes)
418 views472 pages

Turbo PMAC Training

The document provides an overview of a training session on Turbo PMAC motion control systems held by Delta Tau Data Systems. It introduces Delta Tau and their history and facilities. It also outlines the different sections and topics to be covered each day of the multi-day training, including PMAC introduction, servo tuning, motion programming, machine I/O, and various advanced topics. Product information and support resources are also mentioned.

Uploaded by

Owais Jafri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
418 views472 pages

Turbo PMAC Training

The document provides an overview of a training session on Turbo PMAC motion control systems held by Delta Tau Data Systems. It introduces Delta Tau and their history and facilities. It also outlines the different sections and topics to be covered each day of the multi-day training, including PMAC introduction, servo tuning, motion programming, machine I/O, and various advanced topics. Product information and support resources are also mentioned.

Uploaded by

Owais Jafri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 472

DELTA TAU

DATA SYSTEMS, INC.


welcomes you to
TURBO PMAC TRAINING

Turbo Clipper

MACRO Fiber Optic Ring

Adv900 CNC Console

Turbo PMAC PCI


Brick Controller Geo Brick Drive Geo Brick LV

Turbo Clipper Drive

PeWin32Pro2
Turbo PMAC VME UMAC

Please make yourself comfortable (grab some coffee and a donut).


The instructor will be with you shortly.
About Delta Tau

2
¾ History:
General ‘76-’81
General + Motion Control ‘81-’85
Motion Control Only ‘85 Onward
Motion Control Systems, N.C. ‘95
¾ Yearly Turnover:
Approx. $50 million total

¾ Financing:
Self Financed – Independently Owned

¾ Number of Employees:
Over 200 Worldwide

¾ Facilities:
120,000 sq. ft (approx. 12,000 sq. m.) since ‘99
Excellent Production and R&D Facility
¾ Operation:
ISO-9001-2008 Certified (Dec. ‘06)
Automated Inventory Control (Bar coding)
SMT Assembly Line (Lead-free, RoHS)
Automated Visual and X-Ray Inspection
Automatic In-Circuit Testing
Semi-Automated Functional Testing
Test Results and Date Code Traceability

3
Turbo PMAC Training About Delta Tau
Delta Tau is home of the PMAC

¾ HQ:
Chatsworth, California USA

¾ International Offices:
Switzerland, UK, Korea, Japan, China
¾ Regional Offices:
Multitude of field engineers, distributors
and integrators across the US and the world
Delta Tau Website: www.deltatau.com

Product Information
Distributors and Integrators Contacts
Latest Manuals
Application Notes
White Papers
Software Downloads
Technical Support Contacts
Technical Support Forum

4
Turbo PMAC Training About Delta Tau
Overview of Training Sections

Day 1: Day 3:
PMAC Introduction Machine I/O
PeWin32Pro2 PLC Programs
Manuals and PMAC Variables In-program data gathering
Clocks and Multitasking Final Motion Program and PLC Exercises
DC Brush Motor Setup
Day 4:
DC Brushless Motor Setup
Servo Loop Tuning Advanced: Memory and I/O Map
Advanced: Kinematics
Day 2: Advanced: Position Compare
Servo Loop Algorithm Advanced: Evolution of the Amplifier
Jog Commands Advanced: Commutation
Triggered Jog Moves (Homing)
Day 5:
Coordinate Systems
Quick Data Gathering Advanced: Position Following
Motion Programs Advanced: C.S. Transformation
Linear/Circular Move Modes Advanced: Timebase Control
Rapid, Spline, and PVT Move Modes Advanced: Lookahead
Advanced: Subprograms
Advanced: Compensation Tables

5
Turbo PMAC Training About Delta Tau
Introduction To PMAC

6
PMAC stands for Programmable Multi-Axis Controller
PMAC is one of the world’s most flexible and powerful motion controllers (& PLCs), it is used in a
wide variety of applications ranging from the simplest to those requiring extremely high performance.
Requirements such as accuracy, precision, speed, and power, whether combined or independently.

¾ SemiConductor: ¾ Material Handling/Packaging:


Wafer Handling, Slicing, Wire Bonding Mixing, Cutting, Packaging, Conveyor Belt
Pick & Place, Robotics, Process Production
¾ Aerospace:
Flight Simulations, Manufacturing, Inspection ¾ Entertainment/Special Applications:
Cirque Du Soleil KÀ, Disney, F1 Simulator,
¾ Machine Tool: WindMill, LCD Manufacturing and
Mills, Lathes, Grinders, EDM, Water Jet Inspection,Vehicle Control (autonomous)
Turning Center, Laser Cutting, Bending Punching,
Micro/Nano machining ¾ Military:
Top Secret
¾ Manufaturing:
Optical Grinding, Sewing, Turbine Blades
¾ Positioning:
Telescope, Sub-Micron positioning, DNA sampling
¾ Medical:
M.R.I Machines, Laser Eye Surgery, Optical
Surface Grinding, Stint inspection

7
Turbo PMAC Training Introduction To PMAC
Machine Control Solutions
By Form Factor:

ISA/PCI VME
Controllers
Control Systems
Intelligent Amplifiers
Turbo PMAC PCI

Amplifiers
Turbo PMAC VME

MACRO Control Systems


CNC Systems
Software PMAC PC/104 Turbo PMAC PC/104

Standalone: USB/Ethernet

Brick Controller Turbo Ethernet Ultralite Turbo Clipper

8
Turbo PMAC Training Introduction To PMAC
UMAC Universal Motion and Automation Controller®
Open Architecture. Modular and Expandable Design
Custom configuration with simplified integration
Controllers Latest R/D development.
Custom accessories
Control Systems
Turbo UMAC - Turbo PMAC2 CPU and all accessories
Intelligent Amplifiers
MACRO UMAC - UMAC MACRO Station
Amplifiers Compact UMAC CPCI - Custom Backplane and Breakout

MACRO Control Systems


CNC Systems
Software

!Certified!

9
Turbo PMAC Training Introduction To PMAC
Controller/Amplifier Combinations
UL
ved
Appro
Geo Brick Drive
Controllers 240 VAC Single or 3-Phase Operation
4, 6, or 8-axis @ 5A/10A or 8A/16A
Control Systems (Axes 5&6 @ 15A/30A)
Compact & Very Cost Effective !Certified!

Intelligent Amplifiers Motors: Brush, Brushless, Induction

Amplifiers Geo Brick LV


DC Bus Input: 12-60 VDC
MACRO Control Systems 4, or 8-axis @ 5A continuous 15A peak (1 sec)
Powered by mosfets. NO PWM Noise.
CNC Systems Motors: Brush, Brushless, Stepper
Software
Turbo Clipper Drive
DC Bus Input: 12-60 VDC
4-axis @ 5A continuous 15A peak (1 sec)
Breakout for easy integration
Motors: Brush, Brushless, Stepper

Geo PMAC Drive


240VAC & 480VAC Single or 3-Phase Operation
1, or 2-axis @ 1.5A/4.5A up to 30A/60A
Non-Turbo PMAC2 Controller
Motors: Brush, Brushless

10
Turbo PMAC Training Introduction To PMAC
Panel Mount Amplifiers

Controllers
Control Systems
Intelligent Amplifiers Geo PWM Drive Geo MACRO Drive Geo PMAC Drive

Amplifiers
MACRO Control Systems
3U Amplifiers (Rack Mounted)
CNC Systems Analog (+/-10V) OR Direct PWM interface

Software

Amp-2 3U042 3U201


+/-10V 2/4A Direct PWM Direct PWM
4/8A 20/40A

11
Turbo PMAC Training Introduction To PMAC
MACRO Controllers

Controllers
VME Ultralite

Control Systems UMAC MACRO


Master/Slave
Ethernet Ultralite
Intelligent Amplifiers
PCI Ultralite
Amplifiers MACRO Peripherals
MACRO Control Systems
CNC Systems
Software MACRO Peripherals allow
Distributed Digital and Analog I/Os

MACRO Amplifiers

Geo MACRO Drive

12
Turbo PMAC Training Introduction To PMAC
Advantage 900
Controllers Built-in PC Motherboard Pentium
4, 1 to 3 Ghz, 128 / 512M RAM,
USB2 and Ethernet
Control Systems
Intelligent Amplifiers
Amplifiers
MACRO Control Systems
CNC Systems
PMAC NC Pro2 Software
Software

13
Turbo PMAC Training Introduction To PMAC
Development & Interface

Controllers
Control Systems
Intelligent Amplifiers
Amplifiers
MACRO Control Systems PMAC Executive Pro2 PMAC HMI Pro2

CNC Systems
Software

PMAC NC Pro2 Servo Analyzer

14
Turbo PMAC Training Introduction To PMAC
Application Videos

http://www.deltatau.com/dtmc/index.html

15
Theory Of Operation

16
Turbo PMAC Training
Turbo PMAC Is A Computer
Turbo PMAC handles all of the tasks required for machine control, constantly switching back
and forth between the different tasks thousands of times per second.
¾ Turbo PMAC consists of:
A Digital Signal Processor (Motorola’s DSP56300 family)
Machine interface ICs, ASIC (i.e. Servo, MACRO)
Memory (SRAM & Flash)
Digital electronic circuitry
Power electronic circuitry (i.e. amplifier products)

¾ Turbo PMAC executes (in an elaborately prioritized fashion):


PLC Programs
Motion Programs (independently of PLCs)
Motor Servo Update
Motor Commutation
Housekeeping (safety checks)
Host Communication

¾ Turbo PMAC handles (in a synchronized fashion):


32 motors/axes
16 coordinate systems
Forward and Inverse kinematic algorithms
Multi-block Lookahead algorithms
32,768 user variables
Simultaneous multiple host communication
17
Turbo PMAC Training Theory Of Operation
Typical Machine Setup

Feedback:
A quad B, Sinusoidal, Serial,
Resolver, Incremental, Absolute

Command Motor
Communication:
Output: Types:
USB
±10V Brush
Ethernet
PWM Brushless
Serial
PFM Induction
PCI
Sinusoidal Stepper
VME
Fieldbus

Motor/Encoder
PC/HMI
User Interface PMAC Amplifier

Local General Purpose I/Os / Built-in


Machine I/O:
Analog / digital / Fieldbus

Machine
Inputs/Outputs

18
Turbo PMAC Training Theory Of Operation
Feedback:
A quad B, Sinusoidal, Serial,
Resolver, Incremental, Absolute

Command Motor
Communication:
Output: Types:
USB
±10V Brush
Ethernet
PWM Brushless
Serial
PFM Induction
PCI
Sinusoidal Stepper
VME
Fieldbus

Motor/Encoder
PC/HMI
User Interface PMAC Amplifier

Local General Purpose I/Os / Built-in


Machine I/O:
Analog / digital / Fieldbus

Machine
Inputs/Outputs

19
Turbo PMAC Training Theory Of Operation
Feedback:
A quad B, Sinusoidal, Serial,
Resolver, Incremental, Absolute

Communication: Motor
Types:
USB
Brush
Ethernet
Brushless
Serial
Induction
PCI
Stepper
VME

Motor/Encoder
PC/HMI
User Interface

Local General Purpose I/Os / Built-in


Machine I/O:
Analog / digital / Fieldbus

Machine
Inputs/Outputs

20
Turbo PMAC Training Theory Of Operation
Feedback:
A quad B, Sinusoidal, Serial,
Resolver, Incremental, Absolute

Communication: Motor
Types:
USB Intelligent Amplifier: Brush
Ethernet
Geo Brick Drive Brushless
Serial
Geo Brick LV Induction
PCI
Turbo Clipper Drive Stepper
VME
Geo PMAC

Motor/Encoder
PC/HMI
User Interface

Local General Purpose I/Os / Built-in


Machine I/O:
Analog / digital / Fieldbus Advantages:
Compact
Cost Effective
Less Complicity
Less Wiring
Less Components
Easier Maintenance
Smoother Integration
Machine
Inputs/Outputs

21
Turbo PMAC Training Theory Of Operation
Feedback:
A quad B, Sinusoidal, Serial,
Resolver, Incremental, Absolute

Communication: Motor
Types:
USB
Brush
Ethernet
Brushless
Serial
Induction
PCI
Stepper
VME

Motor/Encoder
PC/HMI
User Interface

Local General Purpose I/Os / Built-in


Machine I/O:
Analog / digital / Fieldbus

Machine
Inputs/Outputs

22
Turbo PMAC Training Theory Of Operation
Feedback:
A quad B, Sinusoidal, Serial,
Turbo PMAC Ultralite Resolver, Incremental, Absolute
Or equivalent

Fiber (glass) Optic


Communication RJ45 Twisted pair
USB, Ethernet, Serial,
PCI, VME Motor
Types:
MACRO System: Brush
Geo MACRO Drive Brushless
UMAC MACRO16 Station Induction
Third Party MACRO Drives Stepper
MACRO Peripherals

Motor/Encoder

PC/HMI
User Interface
Local General Purpose I/Os / Built-in
Machine I/O:
Analog / digital / Fieldbus Advantages:
Distributed Control
Noise immunity
One Ring, Multiple Masters / Stations
Hundreds of motors
Large Machines (~ 4 miles)
Flexible Structures

Machine
Inputs/Outputs

23
Turbo PMAC Training Theory Of Operation
UMAC Training Rack
The UMAC training rack is a mockup of a complete machine setup.
¾ The UMAC training rack consists of:
Turbo PMAC2 CPU
Axis Expansion/Interface Card(s)
Inputs and Outputs I/O Card(s)
Logic And Bus Power Supply
Amplifiers
Motors with encoders
Flag and Limit switches

Analog ±10V Drive


General Purpose I/O switches

Digital PWM Drive


Digital I/O Card

Power Supply
Axis Interface

Motors
CPU

24
Turbo PMAC Training Theory Of Operation
Encoder Input

Digital Inputs

Digital Outputs
±10V PWM
Amplifier Output
Motor Flags

25
Turbo PMAC Training Theory Of Operation
Getting Started
¾ Logic power requirements
Board level, Turbo Clipper: +5 VDC, ±12 VDC
Brick series, Amplifiers: +24 VDC
UMAC rack: From built-in power supply (110 VAC)

¾ Bus power requirements


Low Voltage Drives: Up to 60 VDC
High Voltage Drives: Up to 480 VAC
Single or three phase operation

¾ Power Supply
DC output +5V, ±15V ●

¾ CPU
Let’s power up the UMAC training racks Power PWR good ●
and check the status LEDs! Watchdog WD ●
¾ Axis Card
Power PWR good ●
Encoder power ●

26
Turbo PMAC Training Theory Of Operation
Software Interface

27
Turbo PMAC Training
¾ Development Software (PMAC Executive Pro2 Suite for Windows)
Motor setup, PLC/Motion programs, troubleshooting and
diagnostic, online commands:
PeWin32Pro2
Tuning
Plotting
Automatic setup utilities

¾ Communication Library
For custom front-end interface written in high level
Language, .NET, C++, C#, Visual Studio:
PcommServer

¾ Human Machine Interface


Configurable preprogrammed HMI for CNC, and
general automation:
PMAC NC Pro2
HMI

28
Turbo PMAC Training Software Interface
Establishing Communication
USB / PCI / ISA Ethernet

Serial (RS232)

29
Turbo PMAC Training Software Interface
One-Time Setup

30
Turbo PMAC Training Software Interface
¾ Terminal Window
Online commands Online commands are sent directly to PMAC. Issuing bad/wrong
commands can lead to dangerous conditions.
Querying and writing to variables Caution
Direct read/write of memory registers
Run Motion Program, Enable, Disable PLC

31
Turbo PMAC Training Software Interface
¾ Watch Window
The watch window reads from and writes to the PMAC constantly.
Continual monitoring of variables Inserting bad/wrong commands or variables can lead to dangerous
Direct read of memory registers Caution
conditions.

32
Turbo PMAC Training Software Interface
¾ Position Window
Motor Position, Velocity, Following Error
Unit Conversion Capability

33
Turbo PMAC Training Software Interface
¾ Motor Status Window ¾ Global Status Window
Monitoring motor status dynamically Monitoring PMAC status dynamically
Troubleshooting exercises Troubleshooting exercises
In position, and status bits Global errors

34
Turbo PMAC Training Software Interface
¾ Editor
Compose/edit Motion and PLC programs Downloading bad/wrong commands or variables can lead to
dangerous conditions.
Download code to PMAC Caution
Debugging
Upload data from PMAC

35
Turbo PMAC Training Software Interface
Manuals and PMAC Variables
Essential Reference Manuals

¾ Turbo PMAC User Manual


Special application notes
Overall system configuration
Motor setup, motion and PLC programs

¾ Turbo PMAC Software Reference manual (Turbo SRM)


Global, Motor, Gate array, & Coordinate System parameters
Online & Program Commands
Suggested M-Variables and Memory map

¾ Hardware Reference Manual (HRM)


Specific to controllers and accessories
Hardware specifications and jumper configuration
Pinout descriptions

37 Manuals and PMAC Variables


Turbo PMAC Training
Manuals Access

¾ Delta Tau main page, Support>Documentation>Manuals

¾ Delta Tau Manuals website www.deltatau.com/manuals


Categorized based on different product form factors and families
User manuals, SRM, and HRM

¾ Delta Tau Forums


forums.deltatau.com
FAQ and Q&A
Application notes

38 Manuals and PMAC Variables


Turbo PMAC Training
PMAC Variables

¾ I-Variables
Initialization and setup variables
Have predefined meanings

¾ P-Variables
General purpose user variables w/ 48-bit floating point format
Global access (regardless of coordinate system)

¾ Q-Variables
General purpose user variables w/ 48-bit floating point format
Specific to a coordinate system

¾ M-Variables
Provide user access to memory and I/O
Users define address, offset, and bit width

Up to 213 = 8192 user variables (P, Q, and M-Variables)

39 Manuals and PMAC Variables


Turbo PMAC Training
Hexadecimal Review
¾ To write a Hexadecimal value to PMAC, start with “$”
M1001 = $F0 ; 240 in decimal
I125 = $078200 ; Turbo PMAC address
Decimal Hexadecimal Binary

¾ I9 controls Hex/Dec display selection 0 0 0000

1 1 0001
¾ Example:
2 2 0010

Nibble 2nd 1st 3 3 0011

4 4 0100
Bit 7 6 5 4 3 2 1 0
5 5 0101
Binary 0 1 0 1 1 1 0 0
6 6 0110

Hexadecimal 5 C 7 7 0111

8 8 1000

9 9 1001

10 A 1010

11 B 1011

12 C 1100

13 D 1101

14 E 1110

15 F 1111

40 Manuals and PMAC Variables


Turbo PMAC Training
I-Variables

¾ Categories of I-Variables

Group Range Note

General Global Setup I0 – I99


xx = 1–32, Motor
Motor Setup Ixx00 – Ixx99
Index
Motor Supplemental Iyy00/50 – Iyy49/99 yy = 33–48
System Configuration Reporting I4900 – I4999
Data Gathering & ADC Demux
I5000 – I5099
Control
sx = 51–66,
Coordinate System (C.S.) Isx00 – Isx99
C.S.#+50
MACRO I6800 – I6999
Servo IC Clock Setup I7m00 – I7m09 m = Servo IC #
Servo IC Channel Setup I7mn0 – I7mn9 n = Channel #
Encoder Conversion Table Setup I8000 – I8192

41 Manuals and PMAC Variables


Turbo PMAC Training
P and Q-Variables

¾ General Purpose Variables


Use for general programming purposes
Calculations
P100=P101*(Sin(45))
Q20=Q50*(Cos(30))
Software triggers
IF(Q101=1 AND P10=0)
// Tasks
ENDIF

¾ P-Variables are Global Access Variables

¾ Q-Variables are Coordinate specific


Multiple coordinate systems can use the same Q-Variables without memory location
conflicts.

42 Manuals and PMAC Variables


Turbo PMAC Training
Q-Variables Map

Access Location 1 2 4 8 16
$8000
$81FF C.S.1
C.S.1
$8200 Q0~Q1023
$83FF C.S.9
C.S.1
$8400 Q0~Q2047
$85FF C.S.5
C.S.5
$8600 Q0~Q1023
$87FF C.S.13
C.S.1
$8800 Q0~Q4095
$89FF C.S.3
C.S.3
$8A00 Q0~Q1023
$8BFF C.S.11
C.S.3
$8C00 Q0~Q2047
$8DFF C.S.7
C.S.7
$8E00 Q0~Q1023
$8FFF C.S.14
C.S.1
$9000 Q0~Q8191
$91FF C.S.2
C.S.2
$9200 Q0~Q1023
$93FF C.S.10
C.S.2
$9400 Q0~Q2047
$95FF C.S.6
C.S.6
$9600 Q0~Q1023
$97FF C.S.15
C.S.2
$9800 Q0~Q4095
$99FF C.S.4
C.S.4
$9A00 Q0~Q1023
$9BFF C.S.12
C.S.4
$9C00 Q0~Q2047
$9DFF C.S.8
C.S.8
$9E00 Q0~Q1023
$9FFF C.S.16

43 Manuals and PMAC Variables


Turbo PMAC Training
Q-Variable Memory Mapping

¾ Q0 through Q8191 can all be used in Coordinate System 1 (&1) if there is only one
coordinate system.

¾ For 2 coordinate systems, each of them can have Q0 through Q4095


Q0 variables in C.S.1 and C.S.2 occupy different registers, meaning no memory conflict.
Q4096 in C.S 1 occupies the same register as:
Q0 in Coordinate System 2
Q2048 in Coordinate System 3

¾ If 16 coordinate systems are used, every coordinate system can have Q0 through
Q511 without register conflict.

44 Manuals and PMAC Variables


Turbo PMAC Training
M-Variables

¾ An M-Variable has a prefix as a definition type

M9->Y:$10F0,8,8
Prefix
M-Variable
¾ Definition Types
X: 1 to 24 bits fixed-point in X-memory
Y: 1 to 24 bits fixed-point in Y-memory
D: 48 bits fixed-point across both X and Y-memory
L: 48 bits floating-point across both X and Y-memory
DP: 32 bits fixed-point (low 16 bits of X and Y)
F: 32 bits floating-point (low 16 bits of X and Y)

45 Manuals and PMAC Variables


Turbo PMAC Training
M-Variable Example

M9->Y:$10F0,8,8,U
Format: U for unsigned and S for signed
Width: Default width is 1
Offset: Starting bit number
Address

Y:$10F0 (open memory) bit-by-bit:


Starting at bit 8

23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Width 8 bits

46 Manuals and PMAC Variables


Turbo PMAC Training
Suggested M-Variables

Description Address/Definition
¾ In PEWIN32PRO2, “Configure” menu,
“M-Variables”

¾ Download Suggested M-Variables


Suggested M-Variables can be found in
the Turbo SRM
These predefined pointers are convenient
for users.

¾ Issue SAVE command after download

47 Manuals and PMAC Variables


Turbo PMAC Training
Multi-Tasking and Clock Settings
Multi-Tasking
¾ PMAC is a multi-tasking, real-time computer

¾ Different tasks have different execution priorities

¾ Prioritization scheme ensures vital tasks get accomplished when needed

¾ Programs
Motion Program
One move at a time, all calculations done up to that move
PLC Program
Programmable Logic Controller, continuously being scanned

¾ Multi-Tasking Scheme is realized by:


Task Prioritization
A lower priority task will be interrupted by a higher priority task
Clock Distribution
A higher priority task has a faster update frequency

49 Multi-Tasking and Clock Settings


Turbo PMAC Training
PMAC Task Priority

Priority
High ¾ Single Character I/O
Bringing in or sending out a single character, from or to the host port

¾ Phase cycle
Commutation update for commutated (brushless) motors

¾ Servo cycle
Commanded and actual position difference calculation
Output type conversion for different amplifiers

¾ Real-Time Interrupt (R.T.I.)


Execute Enabled PLC0 / PLCC0 and Motion Program

¾ Background Tasks
Execute Enabled PLCs / PLCCs
Communication response, safety check, housekeeping
Limits, Amplifier faults, and watchdog check

Low
50 Multi-Tasking and Clock Settings
Turbo PMAC Training
Clock Setting

¾I-Variables related to clock setting in PMAC


I7m00 ; Servo IC m MaxPhase/PWM Frequency Control
I7m01 ; Servo IC m Phase Clock Frequency Control
I7m02 ; Servo IC m Servo Clock Frequency Control
I8 ; Real-Time Interrupt Period
m is Servo IC number

¾What is a Servo IC (Gate Array)?


Custom made chip interfacing with motor signals
Encoder feedback
ADC/DAC
Flags and limits
Each chip provides 4 hardware channels for 4 motors
Phase and Servo clock settings are for Servo IC (motor-related task)

51 Multi-Tasking and Clock Settings


Turbo PMAC Training
Clock Generation

¾Clock source
A crystal vibrating with frequency 117,964.8 kHz in Servo IC
Dividing source frequency with numbers generates other frequencies (clocks)

Count MaxPhase Cycle Counts = 2*I7m00+3


I7m00+1

-I7m00-2

PWM Cycle Counts = 4*I7m00+6

52 Multi-Tasking and Clock Settings


Turbo PMAC Training
117,964.8
MaxPhase Frequency = kHz
(2*I7m00+3)
MaxPhase Freq.
PWM Frequency = kHz
2

MaxPhase Freq.
Phase Clock Frequency = kHz
(I7m01+1)
Phase Clock Freq.
Servo Clock Frequency = kHz
(I7m02+1)
Servo Clock Freq.
Real Time Interrupt Freq. = kHz
(I8+1)

¾ I7m01,I7m02,I8 are Frequency Dividers

53 Multi-Tasking and Clock Settings


Turbo PMAC Training
54
SERVO

PLC1

PLC1
PLCC1~31
H.K.
PLCC1~31
H.K.

PLC2 . . .
PLC2
SERVO

. . .PLC2 PLCC1~31
H.K.

PLCC1~31
H.K. PLC3
PLC3. . .

SERVO
PLCC1~31
MOTION H.K.

PLC0,PLCC0

Turbo PMAC Training


PLC4
. . .PLC3

PLCC1~31
PLCC1~31
H.K.
SERVO
R.T.I interrupt

H.K.
Servo interrupt

Phase interrupt

PLC5

PLC4
Multi-Tasking Example

PLCC1~31
H.K.

SERVO
MOTION
Task

R.T.I.
I7m01

I8+1=2
Background

I7m02+1=2
Servo Cycle
Phase Cycle

Multi-Tasking and Clock Settings


*
CT #1 #2 #3 #4 #5 PLC 0 PLC 1…
Servo RTI Background

CT #1 #2 #3 #4 #5 PLC 1 (cont.) HK PLC 2…


Servo Background

CT #1 #2 #3 #4 #5 PLC 2 (cont.) HK Comm. PLC 3…


Servo Background
*
CT #1 #2 #3 #4 #5 PLC 0 Move Planning
Servo RTI

CT #1 #2 #3 #4 #5 Move Planning (cont.) PLC 3 (cont.)…


Servo RTI Background

CT #1 #2 #3 #4 #5 PLC 3 (cont.) HK PLC 1…


Servo Background
*
CT #1 #2 #3 #4 #5 PLC 0 PLC 1 (cont.)…
Servo RTI Background
CT - Conversion Table - Servo Interrupt
# n – Motor n Servo Update
RTI – Real Time Interrupt Task
HK – Housekeeping
* - Start of RTI
Comm. - Communications Line Processing
- Process Flow Direction
55 Multi-Tasking and Clock Settings
Turbo PMAC Training
Frequency Calculators

¾ PMAC Resources menu


PMAC2 Frequency Calculators
Useful tool for Frequency calculation
I10: Servo Interrupt Time
unit: 1 / 8,388,608 msec
Time-Sense of PMAC

Calculator does NOT apply any change in


clock setting

56 Multi-Tasking and Clock Settings


Turbo PMAC Training
Observing CPU Load

¾ PMAC Resources menu


View CPU Resources
Illustrate work load for all tasks
Monitoring available resource for motion
program or PLC
If Background (BG) Tasks got no
resources, PMAC will go watchdog

57 Multi-Tasking and Clock Settings


Turbo PMAC Training
Motor Setup
Setting Up a Motor

¾ Encoder / Motor Wiring

¾ Resetting PMAC to factory default settings (optional) $$$***, Save,


$$$

¾ Dominant Clock Settings, ADC Strobe Word

¾ Encoder Software Setup.


Rotate Motor Shaft By Hand to Verify Feedback

¾ Motor Setup (by type for each channel)

59 Motor Setup
Turbo PMAC Training
Motor Types

¾ Brush

¾ Brushless (servo)
Rotary/Linear

¾ Induction (Advanced)

60 Motor Setup
Turbo PMAC Training
Dominant Clock Settings

I7200=6527 ; Servo IC 2 Max Phase/PWM Frequency Control


I7201=0 ; Servo IC 2 Phase Clock Frequency Control
I7202=3 ; Servo IC 2 Servo Clock Frequency Control
I10=3713991 ; Servo Interrupt Time
Turbo PMAC Script

61 Motor Setup
Turbo PMAC Training
DC Brush Motor Setup
Step 1: Motor Activation (Ixx00)
Step 2: Encoder Conversion Table (I8000s). Type Of Encoder Device.
Step 3: Position/Velocity Feedback (Ixx03, Ixx04)
Step 4: Output Mode: DAC (I7mn6)
Step 5: I2T Protection, Maximum Command Output (Ixx57, Ixx59, Ixx69)
Step 6: Flags, Overtravel Limits (Ixx25, Ixx24)
Step 7: DAC Calibration (Ixx29)
Step 8: Open Loop Test (I7mn0)
Step 9: PID/Position Loop Tuning (Ixx30-Ixx39, Ixx68)
Step 10: Homing and Jogging Settings
Step 11: Simple Jog Moves

Steps 1 through 3 (feedback) are the same for the same type of
encoder regardless of the type of the motor.
Note

62 Motor Setup
Turbo PMAC Training
Step 1: Motor Activation (Ixx00)

Ixx00: Motor xx Activation Control


=0 deactivated (default except for Motor #1)
=1 activated

// Ixx00 Motor xx Activation Control


I100,2,100=1 ; Activate Motors #1 through #2
Turbo PMAC Script

If the motor is deactivated, there will be no encoder feedback.

Note

63 Motor Setup
Turbo PMAC Training
Step 2: Encoder Conversion
Table (I8000s)

¾ Encoder Feedback Devices (Incremental/Absolute)


Digital quadrature (A quad B)
Sinusoidal
Resolver
Serial (EnDat, SSI, BiSS, Yaskawa, Tamagawa etc.)
HiperFace
Analog
Laser Interferometer
MLDT
Mitsubishi
Parallel Binary

64 Motor Setup
Turbo PMAC Training
Encoder Conversion Table
The Encoder Conversion Table (ECT) allows the processing of virtually any kind of feedback
device (raw data). It produces encoder/motor counts used for the servo algorithm, user display
(position window), and for general programming purposes.

65 Motor Setup
Turbo PMAC Training
Encoder Conversion Table

Equivalent Turbo PMAC code to set up the Encoder Conversion Table for Motors 1 and 2
I8000=$78200 ; Encoder Conversion Table Entry 1
I8001=$78208 ; Encoder Conversion Table Entry 2
Turbo PMAC Script

66 Motor Setup
Turbo PMAC Training
Step 3: Position/Velocity Feedback
(Ixx03, Ixx04)
After setting up the ECT, PMAC needs to know where to obtain the ECT results. Set Ixx03
and Ixx04 to the ECT result addresses to close the Position and Velocity Feedback Loops:

// Ixx03 Motor xx Position Loop Feedback Address


I103=$003501 ; Conversion Table Line 0
I203=$003502 ; Conversion Table Line 1

// Ixx04 Motor xx Velocity Loop Feedback Address


I104=$003501 ; Conversion Table Line 0
I204=$003502 ; Conversion Table Line 1
Turbo PMAC Script

Now rotate the unloaded motor shafts by hand. Do you see these motors’ position values
changing in the position window? If so, proceed. If not, double-check wiring and settings up to
this point and then retry.

67 Motor Setup
Turbo PMAC Training
Step 4: Output Mode, DAC (I7mn6)
I7mn6 controls which output formats are used on the command output signal lines for
machine interface channel n of a PMAC2-style Servo IC m.

For a Brush Motor, DAC output is used.


// I7mn6 Servo IC m Channel n Output Mode Select
I7216,2,10=1 ; Use Motors 1 and 2 phases A and B for DAC, C for PWM

Turbo PMAC Script

68 Motor Setup
Turbo PMAC Training
Step 5: I2T Protection
(Ixx57, Ixx58, Ixx69)
¾ Ixx57 sets the magnitude of the maximum continuous current limit for Turbo PMAC’s
integrated current limiting function.

Ixx57 = Int ⎨
( )
⎧ 32768 ⋅ ic ⎫ ic : Continuous
⎬ current rating
⎩ imv ⎭ [amps]
The current value [amps] at which the amplifier produces a 10 V output

¾ Ixx58 sets the maximum integrated current limit for Turbo PMAC’s I2T or |I|T integrated
current limiting function.
Time
(Ixx69) 2 − (Ixx57) 2 permitted at
Ixx58 = 2
⋅ f s ⋅ t p peak current
32768 limit [sec]
Servo Freq. [Hz]
¾ Ixx69 defines the magnitude of the largest output that can be sent from Turbo PMAC’s
PID position/velocity servo loop.

⎧ 32768 ⋅ (i p )⎫
ip : Peak current
Ixx69 = Int ⎨ ⎬
rating [amps]
⎩ imv ⎭
The current value [amps] at which the amplifier produces a 10 V output

69 Motor Setup
Turbo PMAC Training
Need to know amplifier gain (amps/volt), to calculate Max. Amp. Output Current.
Max. DAC output voltage is 10V.

For Our Amplifier (3U AMP-2):


Max Amplifier Output Current = Amplifier Gain * 10V = 0.5 * 10 = 5 Amps

I157=INT(32767*2/5) ; Amplifier continuous current rating 2 Amp


I169=INT(32767*4/5) ; Amplifier peak current rating 4 Amp
I257=I157 ; Assume Motor 2 is the same as Motor 1
I269=I169 ; Assume Motor 2 is the same as Motor 1

Turbo PMAC Script

For default clock settings with AMP-2 analog amplifier:


Default Servo Rate = 2.259 KHz
Permitted Time = 2 seconds

I158=INT((I169*I169 - I157*I157)*2.259*1000*2/(32767*32767))
I258=I158 ; Assumes Motor 2 is the same as Motor 1

Turbo PMAC Script

Always take the smallest permitted continuous and peak current


ratings from the motors and drives. For example, if the drive is rated
at 4 amps Continuous and 8 amps Peak, but the motor only at 2 amps
Continuous and 4 amps Peak, use ic = 2 A and ip = 4 A.
Note

70 Motor Setup
Turbo PMAC Training
I = Measured Current

I2

Ixx692
E1 – E2 + E3 ≥ Emax
Emax This triggers I2T fault

Ixx572 Time
Emax is defined by Ixx58
Maximum Time E1 and E3: Integrator Charge-Up
allowed under Max Current
E2 and E4: Integrator Discharge
I2
Saturation I2T Fault
Ixx692

E1
E3
Ixx572 Time
E2
E4

71 Motor Setup
Turbo PMAC Training
Step 6: Overtravel Limits, Flags
(Ixx24, Ixx25)

Ixx24: Motor xx Flag Mode Control


Hex ($) 0 2 0 0 0 1

Binary 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

Bit 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

=0 PMAC1 style Servo IC


=1 PMAC2 style Servo IC
=0 Use amplifier enable function
=1 Do not use amplifier enable function
=0 Enable hardware position limits
=1 Disable hardware position limits
=0 Enable amplifier fault input
=1 Disable amplifier fault input
= 00 Kill all PMAC motors on fault or F.E.
= 11 Kill all C.S. motors on fault or F.E.
= 1x Kill this motor only on fault or F.E.
=0 Low true fault input
=1 High true fault input

72 Motor Setup
Turbo PMAC Training
// Ixx24 Motor xx Flag Mode Control
I124,2,100=$1 ; Set Motor 1 and 2 flag mode control for PMAC2-Style Servo IC

// Ixx25 Motor xx Flag Address (from Turbo SRM)


I125=$078200 ; First Acc-24E2x (IC 2) Flag Set 1
I225=$078208 ; First Acc-24E2x (IC 2) Flag Set 2

Turbo PMAC Script

¾ Ixx24 specifies how the flag information in the registers specified by Ixx25, Ixx42,
and Ixx43 is used.

¾ Ixx25 tells Turbo PMAC which registers to access for its position-capture flags,
and possibly its overtravel limit input flags and amplifier enable/fault flags, for
Motor xx.

Be sure to download all of the previous settings and issue a save and
$$$ command before continuing to the next section of motor setup.
Note

73 Motor Setup
Turbo PMAC Training
Step 7: DAC Calibration (Ixx29)
DAC offset can be compensated for with Ixx29 in units of 16-bit DAC bits. To manually
calibrate the DAC:

1. Issue a #no0 command, for motor n, and then immediately #nk to kill the motor. If the
motor does not move, the offset is fine.
2. If the motor moves in the positive direction, decrease Ixx29 appropriately until #no0
produces no motion
3. If the motor moves in the negative direction, increase Ixx29 appropriately until #no0
produces no motion

74 Motor Setup
Turbo PMAC Training
Step 8: Open Loop Test

The Open Loop Test makes sure that when outputting positive
command, the encoder position count also goes up.

¾ I7mn0 - Servo IC m Channel n Encoder/Timer Decode Control


Controls how the input signal for Encoder n on a PMAC2-style Servo IC m is decoded
into counts
= 3: x4 quadrature decode CW
= 7: x4 quadrature decode CCW

Open Loop Test Tool

75 Motor Setup
Turbo PMAC Training
¾ Select a beginning open loop magnitude
of 5%, click “Open Loop Test”, and
increment the magnitude up if needed
until satisfactory results are obtained

This test moves the motor noticeably. Make sure all loads are
disconnected from the motor before executing the open loop test!
WARNING

76 Motor Setup
Turbo PMAC Training
Correct Response

With positive command output, encoder


counts increase.

Incorrect Responses

Encoder decode direction (I7mn0) is Output magnitude too small,


reversed duration too long, improper wiring,
or other problem

77 Motor Setup
Turbo PMAC Training
Open Loop Test Troubleshooting

¾ If the response shows encoder decode direction is reversed:


If originally I7mn0 = 3, change it to 7
If originally I7mn0 = 7, change it to 3

¾ If the shape of the result does not conform to the shape shown in the picture on
the right in the previous slide, try increasing the output magnitude (do not
exceed 10%) or decrease the output duration

78 Motor Setup
Turbo PMAC Training
Step 9: PID / Position Loop Tuning

¾Auto Tuning
Under PEWIN32PRO2, Tools menu, PMAC Tuning Pro2
Auto-tuning routine provides an easy way to tune and analyze motor-driver systems

¾Interactive Tuning
Detailed discussion in later section

Auto Tuning Interactive Tuning


for Position for Position

This is only for preliminary tuning with no load attached. Be sure to


disconnect all loads before initially tuning the motors, as this test will
move the motors noticeably!
WARNING

79 Motor Setup
Turbo PMAC Training
PMAC Auto-Tuning: Stage 1

¾ Select motor number using the Gear Icon

¾ Click on the Position Auto Tuning Icon

¾ In the Auto Tuning Window, Select:


Current Loop Mode
Auto-Select Bandwidth
Damping Ratio 0.707 to 1
Velocity Feed Forward
Acceleration Feed Forward
Uncheck
Auto-Select Sample Period
Include Low Pass Filter
None for Integral Action

¾ Click Auto Tune for


tuning action

80 Motor Setup
Turbo PMAC Training
PMAC Auto-Tuning: Stage 2

¾ In Stage 1
Conservative Bandwidth, Proportional and
Derivative gain will be selected
Multiply conservative bandwidth by 2 or 3 as
the new bandwidth

¾ Uncheck
Auto Select Bandwidth

¾ Set Damping ratio 0.707~1

¾ Click on
Re-calculate the gains
Followed by Auto Tune to reevaluate the
gains

81 Motor Setup
Turbo PMAC Training
PMAC Auto-Tuning Stage 3
¾ Uncheck
None in Integral Action, and select soft or hard level of integral with sliding bar

¾ Bandwidth
Increase bandwidth until motor buzzes, and then decrease the bandwidth slightly until it just
stops buzzing

¾ Recalculate the gains

¾ If satisfied, implement the gains, finalizing the Auto Tuning

82 Motor Setup
Turbo PMAC Training
Servo Loop Tuning

Set bandwidth as high Select “Current Loop”


as possible without
causing the motor to
buzz

After
Set between 0.707 everything
and 1.000 is set, click
“AutoTune”

Select feed
forward gains

Select integral action level (system-dependent); ½ way up will usually work to start jogging the
UMAC demo motors

83 Motor Setup
Turbo PMAC Training
Servo Loop Tuning
The resulting screen shows the computed gains from auto-tuning.

If satisfied, click
“Implement”
and then “OK”

If the motor starts to buzz after clicking “Implement,” go back to the


previous screen and AutoTune again with a lower bandwidth entry.

Note

84 Motor Setup
Turbo PMAC Training
Servo Loop Tuning
Click to select Interactive Tuning, which allows the user to manually tune the motors finely to get
the desired following error tolerance

Select Position Step


for Tuning Kp, Kd,
and Ki, or Parabolic
Velocity for Tuning
Kvff, Kaff, and Ixx68

Fine tuning principles will be explained in a later section of the


training called “PMAC Servo Loop Tuning - Interactive Tuning”; for
now, just get the motor to jog.
Note

85 Motor Setup
Turbo PMAC Training
Well-Tuned Step Response Example

Commanded Position

Zero Overshoot Actual Position

Zero Steady-State Error

If your response does not look exactly like this, do not fret. You will
learn how to finely tune motors later in the training
Note

86 Motor Setup
Turbo PMAC Training
Well-Tuned Parabolic Move Example
Commanded Velocity
Actual Velocity
Following Error

Following error negligible


(< 2 cts) for entire trajectory
and centered about zero

If your response does not look exactly like this, do not fret. You will
learn how to finely tune motors later in the training
Note
87 Motor Setup
Turbo PMAC Training
Step 10: Homing and Jogging
Settings

// I7mn2 Servo IC m Channel n Capture Control


I7212,2,10 = 1 ; Motors 1 and 2 Capture on Index (CHCn) high

// Ixx20 Motor xx Jog/Home Acceleration Time


I120,2,100 = 0 ; Force Ixx21 to control jog accel. time

// Ixx21 Motor xx Jog/Home S-Curve Time


I121,2,100 = 25 ; msec

// Ixx22 Motor xx Jog Speed


I122,2,100 = 64 ; cts/msec

// Ixx23 Motor xx Home Speed and Direction


I123,2,100 = 64 ; cts/msec, sign is direction

Turbo PMAC Script


¾ I7mn2 determines which input signal or combination of signals for Channel n of a
PMAC2-style Servo IC m, and which polarity, triggers a hardware position capture of
the counter for Encoder n.
¾ Ixx20 through Ixx23 are self-explanatory.

88 Motor Setup
Turbo PMAC Training
Step 11: Simple Jog Moves

In terminal window, try the following jog commands


¾ Jog Command
#nJ+ ; Jog Positive
#nJ- ; Jog Negative
#nJ/ ; Jog Stop

#1J+
Positive Direction
Jog Move Mode
Motor Number
Addressing Motor

89 Motor Setup
Turbo PMAC Training
Additional Steps
At this point in the motor setup, one should in this order:
1. Connect the load

2. Ensure that the hardware position limit switches are working properly

3. Perform advanced servo loop tuning

90 Motor Setup
Turbo PMAC Training
Brushless Motor Setup
Step 1: Activate motor (Ixx00 = 1), enable commutation (Ixx01 = 1).
Step 2: Encoder Conversion Table (I8000s). Type of Encoder Device.
Step 3: Position/Velocity Feedback (Ixx03, Ixx04)
Step 4: PWM Scale Factor and Output Mode (Ixx66, I7mn6)
Step 5: I2T Protection (Ixx57, Ixx58, Ixx69)
Step 6: Configure amplifier faults and position limits (Ixx24, Ixx25).
Step 7: Current Feedback Address, Commutation Position Address (Ixx82, Ixx83)
Step 8: Commutation Cycle Size (Ixx70, Ixx71)
Step 9: Current Mask and ADC Strobe Word (Ixx84, I7m06)
Step 10: Commutation Angle (Ixx72)
Step 11: ADC Settings (Ixx29, Ixx79, I7m06)
Step 12: Current-Loop Tuning (Ixx61, Ixx62, Ixx76)
Step 13: Motor Phasing (Ixx73, Ixx74, Ixx80)
Step 14: Open-Loop Test, Encoder Decode (I7mn0)
Step 15: Servo Loop Tuning (Ixx30…Ixx39)
Step 16: Configure Homing Flag and Speed, then Home Motor (I7mn2, Ixx23)
Step 17: Simple Jog Moves

91
Turbo PMAC Training
Step 1: Motor Activation (Ixx00)
Ixx00: Motor xx Activation Control
=0 deactivated (default except for Motor #1)
=1 activated

// Ixx00 Motor xx Activation Control


I300,2,100=1 ; Activate Motors #3 through #4
Turbo PMAC Script

Ixx01: Motor xx Commutation Enable


=0 deactivated
=1 activated

// Ixx01 Motor xx Commutation Enable


I301,2,100=1 ; Activate Commutation for Motors #3 through #4

Turbo PMAC Script

If the motor is deactivated, there will be no encoder feedback.

Note

92 Motor Setup
Turbo PMAC Training
Step 2: Encoder Conversion
Table (I8000s)

¾ Encoder Feedback Devices (Incremental/Absolute)


Digital quadrature (A quad B)
Sinusoidal
Resolver
Serial (EnDat, SSI, BiSS, Yaskawa, Tamagawa etc.)
HiperFace
Analog
Laser Interferometer
MLDT
Mitsubishi
Parallel Binary

93 Motor Setup
Turbo PMAC Training
Encoder Conversion Table
The Encoder Conversion Table (ECT) allows the processing of virtually any kind of feedback
device (raw data). It produces encoder/motor counts used for the servo algorithm, user display
(position window), and for general programming purposes.

94 Motor Setup
Turbo PMAC Training
Encoder Conversion Table

Equivalent Turbo PMAC code to set up the Encoder Conversion Table for Motors 3 and 4

I8002=$78210 ; Encoder Conversion Table Entry 3


I8003=$78218 ; Encoder Conversion Table Entry 4
Turbo PMAC Script

95 Motor Setup
Turbo PMAC Training
Step 3: Position/Velocity Feedback
(Ixx03, Ixx04)
After setting up the ECT, PMAC needs to know where to obtain the ECT results. Set Ixx03
and Ixx04 to the ECT result addresses to close the Position and Velocity Feedback Loops:

// Ixx03 Motor xx Position Loop Feedback Address


I303=$003503 ; Conversion Table Line 2
I403=$003504 ; Conversion Table Line 3

// Ixx04 Motor xx Velocity Loop Feedback Address


I304=$003503 ; Conversion Table Line 2
I404=$003504 ; Conversion Table Line 3
Turbo PMAC Script

Now rotate the unloaded motor shafts by hand. Do you see these motors’ position values
changing in the position window? If so, proceed. If not, double-check wiring and settings up to
this point and then retry.

96 Motor Setup
Turbo PMAC Training
Step 4a: PWM Scale Factor (Ixx66)
If the drive’s bus voltage > motor rated voltage:
Motor Rated Voltage [Volts]

Ixx66 =
(1.10 )(I7m00)(Vmotor )
Vbus
DC Bus Voltage of Amplifier [Volts]

Since the Shinano Kenshi Brushless DC motors in our demo racks are rated at 24 VDC and the
drive’s bus is wired at 48 VDC, we use this formula today.
Example (use this today for our training boxes):
#define PWM_DCBusInput 48 ; DC Bus Voltage [VDC] for 3U042 –User Input
#define Mtr3Voltage 24 ; Motor 3 Rated Voltage [VDC] -User Input
#define Mtr4Voltage 24 ; Motor 4 Rated Voltage [VDC] -User Input

I366=1.10*I7200*Mtr3Voltage/PWM_DCBusInput ; Motor 3 PWM Scale Factor


I466=1.10*I7200*Mtr4Voltage/PWM_DCBusInput ; Motor 4 PWM Scale Factor

Turbo PMAC Script


Ixx66 multiplies the output of the digital current loops for Motor xx (which are values
between -1.0 and 1.0) before they are written to the PWM output registers. As such, it
determines the maximum value that can be written to the PWM output register. When
using I7m02, make sure m corresponds to the Servo I.C. that is used for this motor.
97 Motor Setup
Turbo PMAC Training
Step 4a: PWM Scale Factor (Ixx66)
If the drive’s bus voltage < motor rated voltage:

Ixx66 = (1.10 )(I7m00)

Example (do not use this today for our training boxes):
I366=1.10*I7200 ; Motor 3 PWM Scale Factor
I466=1.10*I7200 ; Motor 4 PWM Scale Factor

Turbo PMAC Script

Ixx66 multiplies the output of the digital current loops for Motor x (which are values
between -1.0 and 1.0) before they are written to the PWM output registers. As such, it
determines the maximum value that can be written to the PWM output register.

When using I7m00, make sure m corresponds to the Servo I.C. that is used for this
motor.

98 Motor Setup
Turbo PMAC Training
Step 4b: Output Mode (I7mn6)

I7mn6 controls which output formats are used on the command output signal
lines for machine interface channel n of a PMAC2-style Servo IC m.

I7mn6 = 0: Outputs A and B are PWM; Output C is PWM


I7mn6 = 1: Outputs A and B are DAC; Output C is PWM
I7mn6 = 2: Outputs A and B are PWM; Output C is PFM
I7mn6 = 3: Outputs A and B are DAC; Output C is PFM

// I7mn6 Servo IC m Channel n Output Mode Select


I7236,2,10 = 0 ; Use Motors 3 and 4 phases A, B, and C for PWM

Turbo PMAC Script

One can use I4900 to determine which I.C. chips are present in the system, and I4901 to
determine which kinds of I.C. chips they are. See the Turbo SRM entries for I4900 and
I4901 for more details.

99 Motor Setup
Turbo PMAC Training
Step 5: I2T Protection
(Ixx57, Ixx58, Ixx69)
¾ Ixx57 sets the magnitude of the maximum continuous current limit for Turbo PMAC’s
integrated current limiting function.

Ixx57 = Int ⎨
( )
⎧ 32768 ⋅ (ic ) 2 ⎫
⎬ ⋅ cos 30 ( )
o
ic : Continuous
current rating
⎩ imv ⎭ [amps]
The current value [amps] at which the amplifier produces a 10 V output
¾ Ixx58 sets the maximum integrated current limit for Turbo PMAC’s I2T or |I|T integrated
current limiting function.
Time
(Ixx69) 2 − (Ixx57) 2 permitted at
Ixx58 = 2
⋅ f s ⋅ t p peak current
32768 limit [sec]
Servo Freq. [Hz]
¾ Ixx69 defines the magnitude of the largest output that can be sent from Turbo PMAC’s
PID position/velocity servo loop.

Ixx69 = Int ⎨
( )
⎧⎪ 32768 ⋅ (i p ) 2 ⎫⎪
( )
ip : Peak current
⎬ ⋅ cos 30
o rating [amps]
⎪⎩ imv ⎪⎭
The current value [amps] at which the amplifier produces a 10 V output

100 Motor Setup


Turbo PMAC Training
Step 5: I2T Protection (Ixx57,
Ixx58, Ixx69)
I15=0 ; Trig Operations in Degrees
#define ServoClk P7203 ; Servo Clock [KHz]—computed in Dominant Clock
; Settings Section
#define PWM_ContCurrent 4 ; Continuous Current Limit [Amps] -User Input
#define PWM_PeakCurrent 8 ; Instantaneous Current Limit [Amps] -User Input
#define PWM_MaxADC 13.01 ; = 13.01 A for 3U042 Drive -User Input from
; electrical specs of drive
#define PWM_I2TOnTime 2 ; Time allowed at peak Current [sec] -User Input
ServoClk = 2.259 ; kHz
I357=INT(32767*(PWM_ContCurrent*1.414/PWM_MaxADC)*cos(30))
I369=INT(32767*(PWM_PeakCurrent*1.414/PWM_MaxADC)*cos(30))
I358=INT((I369*I369 - I357*I357)*ServoClk*1000*PWM_I2TOnTime/(32767*32767))
I457=I357 ; Assumes Motor 4 is the same as Motor 3
I458=I358 ; Assumes Motor 4 is the same as Motor 3
I469=I369 ; Assumes Motor 4 is the same as Motor 3
Turbo PMAC Script

Always take the smallest permitted continuous and peak current


ratings from the motors and drives. For example, if the drive is rated
at 4 amps Continuous and 8 amps Peak, but the motor only at 2 amps
Continuous and 4 amps Peak, use ic = 2 A and ip = 4 A.
Note

101 Motor Setup


Turbo PMAC Training
I2

Ixx692
E1 – E2 + E3 ≥ Emax
Emax This triggers I2T fault

Ixx572 Time
Emax is defined by Ixx58
Maximum Time E1 and E3: Integrator Charge-Up
allowed under Max Current
E2 and E4: Integrator Discharge
I2
Saturation I2T Fault
Ixx692

E1
E3
Ixx572 Time
E2
E4

102 Motor Setup


Turbo PMAC Training
Step 6: Overtravel Limits, Flags
(Ixx24, Ixx25)
// Ixx24 Motor xx Flag Mode Control
I324,2,100 = $1 ; Set Motor 3 and 4 flag mode control for PMAC2-Style Servo IC

// Ixx25 Motor xx Flag Address (from Turbo SRM)


I325 = $078210 ; First Acc-24E2x (IC 2) Flag Set 3
I425 = $078218 ; First Acc-24E2x (IC 2) Flag Set 4

Turbo PMAC Script

¾ Ixx24 specifies how the flag information in the registers specified by Ixx25,
Ixx42, and Ixx43 is used.

¾ Ixx25 tells Turbo PMAC which registers to access for its position-capture
flags, and possibly its overtravel limit input flags and amplifier enable/fault
flags, for Motor xx.

Be sure to download all of the previous settings and issue a save and
$$$ command before continuing to the next section of motor setup.
Note

103 Motor Setup


Turbo PMAC Training
Step 7: Current Feedback Address
(Ixx82), Commutation Position
Address (Ixx83)
Obtain these addresses from the Turbo Software Reference Manual:

// Ixx82 Motor xx Current-Loop Feedback Address


I382 = $078216 ; Motor 3, First Acc-24E2 ADC3B
I482 = $07821E ; Motor 4, First Acc-24E2 ADC4B

// Ixx83 Motor xx Commutation Position Address


I383 = $078211 ; First Acc-24E2 Encoder 3
I483 = $078219 ; First Acc-24E2 Encoder 4
Turbo PMAC Script

Ixx82 tells Turbo PMAC which addresses to read to get its current feedback values
for Motor xx if Turbo PMAC is closing the current loop for this motor.

For a motor commutated by Turbo PMAC (Ixx01 = 1 or 3), Ixx83 tells Turbo PMAC
where to read its commutation (phasing) position information for Motor xx every
commutation cycle.

104 Motor Setup


Turbo PMAC Training
Step 8: Commutation Cycle Size
(Ixx70, Ixx71)
¾ Set Ixx70 equal to the number of pole pairs of the motor

¾ Set Ixx71 equal to the number of counts per mechanical revolution

¾ For these motors (from the Shinano Kenshi datasheet for the motors in our demo
racks):

I370,2,100 = 2 ; Motors 3 and 4 each have 2 pole pairs


I371,2,100 = 2000 ; Motors 3 and 4 each have 2000 cts per mechanical revolution

Turbo PMAC Script

105 Motor Setup


Turbo PMAC Training
Step 9: Current Mask (Ixx84), ADC
Strobe Word (I7m06)
I384,2,100=$FFF000 ; Motors 3-4 Current-Loop Feedback Mask Word (drive specific)

I7206=$3FFFFF ; Servo IC 2 ADC Strobe Word (set to $3FFFFF for Geo drives)
I7106=$3FFFFF ; Servo IC 1 ADC Strobe Word (set to $3FFFFF for Geo drives)
I7006=$3FFFFF ; Servo IC 0 ADC Strobe Word (set to $3FFFFF for Geo drives)

Turbo PMAC Script

Ixx84 tells Turbo PMAC which bits of the 24-bit current feedback words to use for the
current value in the current loop equations.

I7m06 controls the ADC strobe signal for machine interface channels on Servo IC m.
Look in the manual for your drive to determine the value to which to set this variable.

106 Motor Setup


Turbo PMAC Training
Step 10: Commutation Angle (Ixx72)
Download the Suggested M-Variables (ConfigureÆM-
VariablesÆDownload Suggested M-Variables) and then put the following variables into a
watch window:

M302, Motor 3 Phase A Output Command Æ


M304, Motor 3 Phase B Output Command Æ
M305, Motor 3 Phase A ADC Reading Æ
M306, Motor 3 Phase B ADC Reading Æ
M402, Motor 4 Phase A Output Command Æ
M404, Motor 4 Phase B Output Command Æ
M405, Motor 4 Phase A ADC Reading Æ
M406, Motor 4 Phase B ADC Reading Æ

107 Motor Setup


Turbo PMAC Training
¾ Type the following commands in a blank Editor window, pressing “Enter” between each
line, and then download:

I300 = 0 I301 = 0 ; Disable motors 3 and commutation


M314 = 1 ; Activate amplifier channels for motor 3
M302 = I7200/20 M304 = -I7200/20 M307 = 0 ; Command current to phases
; A and B of motor 3

Turbo PMAC Script


¾ Now monitor M305, M306 in the watch window. If M305 > 0 and M306 < 0, download this in
a new Editor window:

I300 = 1 I301 = 1
M314 = 0 M302 = 0 M304 = 0 M307 = 0
I372 = 1365
Turbo PMAC Script

¾ Else, if M305 < 0 and M306 > 0, download this in a new Editor window :
I300 = 1 I301 = 1
M314 = 0 M302 = 0 M304 = 0 M307 = 0
I372 = 683
Turbo PMAC Script

¾ If M305 and M306 have the same sign, then choose a larger value for M302 and M304, like
M302=I7200/10, M304=-I7200/10, for example.

108 Motor Setup


Turbo PMAC Training
¾ Type the following commands in a blank Editor window, pressing “Enter” between each
line, and then download:
I400 = 0 I401 = 0 ; Disable motors 4 and commutation
M414 = 1 ; Activate amplifier channels for motor 4
M402 = I7200/20 M404 = -I7200/20 M407 = 0 ; Command current to
; phases A and B of motor 4

Turbo PMAC Script


¾ Now monitor M405, M406 in the watch window. If M405 > 0 and M406 < 0, download this in
a new Editor window:

I400 = 1 I401 = 1
M414 = 0 M402 = 0 M404 = 0 M407 = 0
I472 = 1365
Turbo PMAC Script

¾ Else, if M405 < 0 and M406 > 0, download this in a new Editor window :
I400 = 1 I401 = 1
M414 = 0 M402 = 0 M404 = 0 M407 = 0
I472 = 683
Turbo PMAC Script

¾ If M405 and M406 have the same sign, then choose a larger value for M402 and M404, like
M402=I7200/10, M404=-I7200/10, for example.

109 Motor Setup


Turbo PMAC Training
Step 11: ADC Settings (Ixx29, Ixx79,
I7m06)
¾ The ADC offsets’ importance may vary from one system to another, depending on the
motor(s) type and application requirements.

¾ They can be initially left at default of zero if a motor setup is to be reproduced on


multiple machines by copying the configuration file of the first time integration.

¾ However, they should ultimately be set to minimize measurement offsets from the A
and B-phase current feedback circuits, respectively (read in Suggested M-variables
Mxx05, Mxx06).

¾ One can write a PLC to automatically determine Ixx29 and Ixx79 by sampling their
values over time while commanding zero current to phases A, B, and C. This topic
can be covered by request on the Advanced Training days (Thursday and Friday).

110 Motor Setup


Turbo PMAC Training
Step 12: Current Loop Tuning
¾ Configures current loop tuning parameters Kp1 (Ixx76), Kp2 (Ixx62), and Ki (Ixx61)

¾ Start tuning the current loop using the tool in PMAC Tuning Pro2 by selecting Current
LoopÆ Auto Tuning:

Automatically
select a safe
Then begin
bandwidth and
current loop
current loop
automatic
gains
tuning by
clicking here

If PeWin32Pro2 gives you an error message stating that some of the


gains may be dangerous to implement, do not implement them.
Rather, return to this screen and increase the Excitation Magnitude
to 7500 bits, and then try the automatic tuning again.
Note

111 Motor Setup


Turbo PMAC Training
Click “Implement New Gains and Check Response.” PMAC will then measure and display the
current loop step response.

112 Motor Setup


Turbo PMAC Training
After using automatic tuning to get started, one should manually adjust the loop gains using
the Current Loop Interactive Tune program and click “Step Response” until the response is
like that shown in the next slide.

Click here to
start interactive
tuning

Click here to test


the step response

113 Motor Setup


Turbo PMAC Training
Tuning to a natural frequency of 300-500 Hz is sufficient for most
applications and is sufficient for this training class.
Note
114 Motor Setup
Turbo PMAC Training
Step 13: Motor Phasing
¾ There are five phasing methods available in PMAC:
2-Guess Phasing Method
Stepper Method
Manual Method
Hall Effect Phasing
Absolute Power-On Phasing

2-Guess Phasing Method


The 2-guess is a rough phasing method for motors with relatively small loads or quick setups for
testing. It can be used with any type of feedback. Use this method for today.
Typical (example) values:

I373,2,100=1200 ; Phase Finding Output Value (Adjustable). Units of 16-bit DAC


I374,2,100=8 ; Units of Servo Cycles
I380,2,100=4 ; 2-guess method, no absolute position read, no power-on phasing

Turbo PMAC Script

After downloading these settings, issue #3$ #4$ to phase motors 3 and 4.

115 Motor Setup


Turbo PMAC Training
Step 14: Open Loop Test
¾ In PeWin32Pro2, go to Tools → PMAC Tuning Pro 2
¾ Select the motor you want to tune using the “Motor Select” button on the top
toolbar
¾ Then click Position LoopÆOpen Loop Test

116 Motor Setup


Turbo PMAC Training
¾ Select a beginning open loop magnitude
of 5%, click “Open Loop Test”, and
increment the magnitude up if needed
until satisfactory results are obtained

This test moves the motor noticeably. Make sure all loads are
disconnected from the motor before executing the open loop test!
WARNING

117 Motor Setup


Turbo PMAC Training
Correct Response

With positive command output, encoder


counts increase.

Incorrect Response

Encoder decode direction (I7mn0) is Output magnitude too small,


reversed duration too long, improper wiring,
or other problem

118 Motor Setup


Turbo PMAC Training
Open Loop Test Troubleshooting

¾ For the picture on the left in the previous slide, where the commanded positive output
voltage produces a decrease in motor speed, and vice versa, the encoder decode
variable (I7mn0) has not yet been correctly set. Thus:
If I7mn0 = 3, set I7mn0 = 7

// I7mn0 Servo IC m Channel n Encoder/Timer


// Decode Control
I7230,2,10 = 7 ; Motors 3 and 4 x4 quadrature decode CW
Turbo PMAC Script

If I7mn0 = 7, set I7mn0 = 3

// I7mn0 Servo IC m Channel n Encoder/Timer


// Decode Control
I7230,2,10 = 3 ; Motors 3 and 4 x4 quadrature decode CW

Turbo PMAC Script


¾ If the shape of the result does not conform to the shape shown in the picture on the
right in the previous slide, try increasing the output magnitude (do not exceed 10%) or
decrease the output duration

¾ Try phasing the motor again if that was not done properly

119 Motor Setup


Turbo PMAC Training
Step 15: Servo Loop Tuning (Ixx30
through Ixx39
Can tune motors automatically initially to get them jogging by using PMAC
Tuning Pro2’s Autotune Program (click Position Loop → Regular PID → Auto
Tuning):

Select “AUTO”
Select Motor
Number Here

This is only for preliminary tuning with no load attached. Be sure to


disconnect all loads before initially tuning the motors, as this test will
move the motors noticeably!
WARNING

120 Motor Setup


Turbo PMAC Training
Set bandwidth as high Select “Current Loop”
as possible without
causing the motor to
buzz

After
everything is
Set between 0.707 set, click
and 1.000 “AutoTune”

Select feed
forward gains

Select integral action level (system-dependent); ½ way up will usually work to start

121 Motor Setup


Turbo PMAC Training
The resulting screen shows the computed gains from auto-tuning.

If satisfied, click
“Implement”
and then “OK”

If the motor starts to buzz after clicking “Implement,” go back to the


previous screen and AutoTune again with a lower bandwidth entry.

Note

122 Motor Setup


Turbo PMAC Training
Step 15: Homing and
Jogging Settings

// I7mn2 Servo IC m Channel n Capture Control


I7232,2,10 = 1 ; Motors 1 and 2 Capture on Index (CHCn) high

// Ixx20 Motor xx Jog/Home Acceleration Time


I320,2,100 = 0 ; Force Ixx21 to control jog accel. time

// Ixx21 Motor xx Jog/Home S-Curve Time


I321,2,100 = 25 ; msec

// Ixx22 Motor xx Jog Speed


I322,2,100 = 64 ; cts/msec

// Ixx23 Motor xx Home Speed and Direction


I323,2,100 = 64 ; cts/msec, sign is direction

Turbo PMAC Script


¾ I7mn2 determines which input signal or combination of signals for Channel n of a
PMAC2-style Servo IC m, and which polarity, triggers a hardware position capture of
the counter for Encoder n.

¾ Ixx20 through Ixx23 are self-explanatory.

123 Motor Setup


Turbo PMAC Training
Step 16: Servo Loop Tuning
Click to select Interactive Tuning, which allows the user to manually tune the motors finely to get
the desired following error tolerance

Select Position Step


for Tuning Kp, Kd,
and Ki, or Parabolic
Velocity for Tuning
Kvff, Kaff, and Ixx68

Fine tuning principles will be explained in a later section of the


training called “PMAC Servo Loop Tuning - Interactive Tuning”; for
now, just get the motor to jog.
Note

124 Motor Setup


Turbo PMAC Training
Example of Well-Tuned Step Response

Commanded Position

Zero Overshoot Actual Position

Zero Steady-State Error

If your response does not look exactly like this, do not fret. You will
learn how to finely tune motors later in the training
Note

125 Motor Setup


Turbo PMAC Training
Example of Well-Tuned Parabolic Move

Commanded Velocity
Actual Velocity
Following Error

Following error negligible


(< 2 cts) for entire trajectory
and centered about zero

If your response does not look exactly like this, do not fret. You will
learn how to finely tune motors later in the training
Note
126 Motor Setup
Turbo PMAC Training
Step 17: Simple Jog Moves

In terminal window, try the following jog commands


¾ Jog Command:
#nJ+ ; Jog Positive
#nJ- ; Jog Negative
#nJ/ ; Jog Stop

#3J+
Positive Direction
Jog Move Mode
Motor Number
Addressing Motor

127 Motor Setup


Turbo PMAC Training
Additional Steps
At this point in the motor setup, one should in this order:
1. Connect the load

2. Ensure that the hardware position limit switches are working properly

3. Perform advanced servo loop tuning

128 Motor Setup


Turbo PMAC Training
PMAC Servo Loop Tuning
Interactive Tuning
Servo Tuning
¾ PMAC’s Servo Algorithm must be configured to properly control any given system
with motors and amplifiers

¾ Configuration is done by adjusting I-Variables (Ixx30 through Ixx35) pertaining to


the PID gains

¾ Ixx68 (Friction Feedforward) is also needed

¾ The process of determining proper values of PID gains is called “Tuning”

130 PMAC Servo Tuning


Turbo PMAC Training
PID Servo Loop
Adjust Servo Algorithm parameters for desired position response, including how
quickly and accurately the motor can move to a target position

Ixx30~Ixx35
Ixx68

Commanded + e(t) (Error) PID ±10V


DAC AMP
Servo
Position Digital Number 16 bit
Algorithm ±32,767 DAC Bits
-
M

Actual Position
Enc

e(t) = Commanded Position – Actual Position

¾ Ixx30 Proportional Gain (Kp) ¾ Ixx34 Integration Mode


¾ Ixx31 Derivative Gain (Kd) ¾ Ixx35 Acceleration Feedforward (Kaff)
¾ Ixx32 Velocity Feedforward (Kvff) ¾ Ixx68 Friction Feedforward (Kfff)
¾ Ixx33 Integral Gain (Ki)

131 PMAC Servo Tuning


Turbo PMAC Training
Steps for Tuning
1. Perform the DAC Calibration as described in the Motor Setup section

2. Set Ixx34 (Motor xx PID Integration Mode) – can be changed on the fly as needed
=1, position error integration is performed only when Motor xx is not commanding a move
(when desired velocity is zero)
=0, position error integration is performed always

3. Using the Step Response, tune the following parameters in this order:
1.Proportional Gain, Kp (Ixx30)
2.Derivative Gain, Kd (Ixx31)
3.Integral Gain, Ki (Ixx33)
4. Using the Parabolic Move, tune the following parameters, not necessarily in this
order:
¾Velocity Feedforward, Kvff (Ixx32)
¾Acceleration Feedforward, Kaff (Ixx35)
¾Friction Feedforward, Kfff (Ixx68)

• When tuning the feedforward gains, set Ixx34=1 so that the


dynamic behavior of the system may be observed without
integrator action.
• Setting Kvff = Kd (Ixx32 = Ixx31) is a good place to start when
Note tuning Kvff.

132
Turbo PMAC Training
Interactive Tuning
¾ Interactive Tuning can be accessed in PMAC Tuning Pro2

Interactive Tuning
for Position

133 PMAC Servo Tuning


Turbo PMAC Training
¾ Use the controller gains obtained from Auto Tuning as the starting point for
Interactive Tuning

¾ Change one gain at a time to adjust the response

¾ Different types of moves are available for tuning purposes

Move size
PID gains

Move types

Data to plot
Filter

134 PMAC Servo Tuning


Turbo PMAC Training
Step Tuning (Ixx30, Ixx31, Ixx33)

Position
½ to ¼ rev.
Commanded
Profile

Note:
The intent is to operate within the linear range of the system.
This is usually a step size approx. ½ to ¼ revolution

Overshoot and Oscillation


Position Offset
Cause:
Too much Proportional gain or Cause:
too little Damping Friction or Constant Force
Fix: Fix:
Decrease Kp (Ixx30) Increase Ki (Ixx33)
Increase Kd (Ixx31) Increase Kp (Ixx30)

Sluggish Response Physical System Limitation


Cause: Cause:
Too much Damping or Limit of the Motor/Amplifier/Load
too little Proportional gain and gain combination
Fix: Fix:
Increase Kp (Ixx30) or Evaluate Performance and
Decrease Kd (Ixx31)
maybe add Kp (Ixx30)

135 PMAC Servo Tuning


Turbo PMAC Training
Parabolic Tuning (Ixx32-Ixx35, Ixx68)

Velocity Acceleration
Commanded Commanded
Profile Profile

Following Error Profile (F.E.)

High Vel./F.E. Correlation High Vel./F.E. Correlation

Cause: Damping Cause: Friction


Fix: Increase Kvff (Ixx32) Fix:
Add Friction Feedforward (Ixx68)
and/or turn on Integral Gain
(Ixx33, Ixx34)

High Acc./F.E. Correlation


High Acc./F.E. Correlation
Cause:
Cause: Inertial Lag
Physical System Limitation
Fix:
Fix:
Increase Kaff (Ixx35)
Use softer acceleration
or add more Ixx68

136 PMAC Servo Tuning


Turbo PMAC Training
Parabolic Tuning (Ixx32-Ixx35, Ixx68)

Velocity Acceleration
Commanded Commanded
Profile Profile

Following Error Profile (F.E.)


Negative Vel./F.E.
Correlation High Vel./F.E. Correlation
Cause:
Too much Velocity Cause: Damping & Friction
Feedforward Fix:
Fix: Increase Kvff first (Ixx32)
Decrease Kvff (Ixx32) Possibly adjust Ixx68

Negative Acc./F.E. High Vel./F.E. & Acc./F.E.


Correlation Correlation
Cause:
Too much acceleration Cause:
Feedforward Inertial Lag & Friction
Fix: Fix:
Decrease Kaff (Ixx35) Increase Kaff (Ixx35)
Possibly adjust Ixx68
137 PMAC Servo Tuning
Turbo PMAC Training
Tuning Exercise
¾ In the Terminal Window, set Ixx30 through Ixx39 to 0. This will clear the servo loop
tuning for Motor xx.

// Reset PID gains of Motor 1 ~ 4


I130..139=0 ; Set Motor 1 PID gains to 0
I230..239=0 ; Set Motor 2 PID gains to 0
I330..339=0 ; Set Motor 3 PID gains to 0
I430..439=0 ; Set Motor 4 PID gains to 0

Turbo PMAC Script

¾ Launch PMAC Tuning Pro2 from Tool menu. Tune all available PMAC motors
interactively for minimum following error.

¾ Use previous slides as references to change servo tuning I-Variables to obtain better
performance.

138 PMAC Servo Tuning


Turbo PMAC Training
Well-Tuned Step Response

Commanded Position

Zero Overshoot Actual Position

Zero Steady-State Error

139 PMAC Servo Tuning


Turbo PMAC Training
Well-Tuned Parabolic Move
Commanded Velocity
Actual Velocity
Following Error

Following error negligible


(< 2 cts) for entire trajectory
and centered about zero

140 PMAC Servo Tuning


Turbo PMAC Training
PMAC Servo Control Algorithm
PMAC PID and Notch Filter
1− z −1 Kaff

+ +
1− z −1 Kvff Ʃ
Notch filter

+ +
+ 1+ n z + n z
−1 −2

Ʃ Ʃ
Reference
Kp 1 2
Output to DAC
Position 1+ d z + d z
−1 −2

- + - 1 2

IM

Ki Kd

1− z −1
1− z −1
Velocity Loop Feedback

Position Loop Feedback

¾ PID Parameters ¾ Notch Filter


Kp Ixx30, Proportional gain Coefficients
Kd Ixx31, Derivative gain n1 Ixx36
Kvff Ixx32, Velocity feedforward gain n2 Ixx37
Ki Ixx33, Integral gain d1 Ixx38
IM Ixx34, Integration mode d2 Ixx39
Kaff Ixx35, Acceleration feedforward gain
142 PMAC Servo Control Algorithm
Turbo PMAC Training
PMAC Extended Servo Algorithm
1− z−1 Ixx68

R(z)
−1 KS(k 0 + L + k 3z −3 )
Input ref. h0 + h1(1− z )
1 + 4(L1z −1 + L + L 3 z −3 )

+ + + + +
Ʃ Ʃ TS(t 0 + L + t 4 z −4 ) Ʃ
1
Ʃ
Ixx69 Ʃ
32 ⋅ Ixx08 s0 U(z)
- - 1 + 8(r1z −1 + L + r4 z − 4 ) 1 + d1 z + d 2 z − 2
−1
+ 215
+ +
Output
s1(1− z−1)

Enc. #1
32 ⋅ Ixx08
Feedback #1
+ Enc. #2
+
Ʃ f0 Ʃ GS(g0 + g1 (1 − z −1 )) ¾ Extended Servo
-
-
Algorithm Parameters
f1(1− z−1)
s0 ~ s1 L1 ~ L3
f0 ~ f1 k0 ~ k3
Enc. #1
h0 ~ h1 KS
32 ⋅ Ixx08
Enc. #2 r1 ~ r4 d1 ~ d2
t0 ~ t4 g0 ~ g2
Feedback #2 TS GS

Note: Must be tuned by an external algorithm (e.g. pole placement).


143 PMAC Servo Control Algorithm
Turbo PMAC Training
Proportional Control
K
Fixed Lumped mass with
moment of inertia J1
Torsional
Spring T Θ J
ζ : Damping Ratio
ω0 : Natural Frequency
d 2Θ K Θ : Angular Displacement
T = K • Θ = − J 2 , ω 0= , ζ =0 Τ : Input Torque
dt J K: Spring Constant
J: Moment of Inertia
P: Period of Oscillation
Θ [rad] t: Time

Example Response: t [sec]

P
=1/ ω0
144 PMAC Servo Control Algorithm
Turbo PMAC Training
Proportional Control
T(t)
Ref. + e(t)
+ 1 Θ(t)
KP KC KA KT
J ∫ ∫
- -
Kd

d 2Θ
T (t ) = K p • K C • K A • KT • e(t ) − K p • K C • K A • KT • Θ(t ) = J • 2
dt
KC: DAC Conversion Gain
K p • K C • K A • KT
KA: Amplifier Gain
KT: Motor Torque Constant ω0 = , ζ =0
J

This is an undamped Simple Harmonic Oscillator (SHO)

Thus, the proportional gain KP correlates with spring stiffness.

Higher KP → higher stiffness

145 PMAC Servo Control Algorithm


Turbo PMAC Training
Derivative Control
Torsional
Spring K J

Lumped mass with


Θ moment of inertia J
Fixed
T
Torsional c
Damper

ζ : Damping Ratio
dΘ d 2Θ K c ω0 : Natural Frequency
T = K •Θ+c• = − J • 2 , ω 0= , ζ= KJ
dt dt J 2 Θ : Angular Displacement
Τ : Input Torque
C: Damping Coefficient
K: Spring Constant
Θ [rad]
J: Moment of Inertia
t: Time

Example Response:
t [sec]

146 PMAC Servo Control Algorithm


Turbo PMAC Training
Ref. Input

e(t) T(t)
+ + 1 Θ
J ∫∫
KP KC KA KT
- -
d
Kd
dt

dΘ d 2Θ
T (t ) = −K p • KC • K A • KT • Θ(t ) − K p • KC • K A • KT • Kd • =J• 2
dt dt
This is a damped SHO.

K p • K C • K A • KT K K p • K C • K A • KT
ω0 = , ζ = d
J 2 J
KC: DAC Conversion Gain
KA: Amplifier Gain
KT: Motor Torque Constant

147 PMAC Servo Control Algorithm


Turbo PMAC Training
Integral Control
Moment of
Pulley Attached to Inertia J
Motor Shaft
Θ
Without the integral, the governing equation is:
Rope in
r Tension
T (t ) = ( K P • K C • K A • KT ) • e(t ) = m • g • r

T(t)
Lumped
mass

mg
Ref.
Input
e(t) T(t)
+ + 1
J ∫∫
+
KP KC KA KT +
- - m•g•r Θ
d
Kd
KC: DAC Conversion Gain dt
KA: Amplifier Gain
KT: Motor Torque Constant
148 PMAC Servo Control Algorithm
Turbo PMAC Training
Adding the Integral

Ref.
Input e(t) T(t)
+ + 1 Θ
J ∫∫
+
KP KC KA KT
- + +
-
Ki ∫
m•g•r

d
Kd
dt

dΘ(t )
T (t ) = ( K P • K C • K A • K T ) • [ K i ∫ e(t )dt + e(t ) − Θ(t ) − K d ] = m• g •r
dt

Therefore as t → ∞, e(t)→ 0

KC: DAC Conversion Gain


KA: Amplifier Gain
KT: Motor Torque Constant

149 PMAC Servo Control Algorithm


Turbo PMAC Training
Steady State Errors Due to Constant
Speed Trajectory Tracking
dΘ d 2Θ
Θ d friction
Response (assuming = Vd =•0):t , = Vd , 2
=0
dt dt
Position

Vd

Reference trajectory Actual


(ramp input), Θd=Vdt Trajectory

ess = KdΘ

Steady state error

Time
150 PMAC Servo Control Algorithm
Turbo PMAC Training
Block Diagram without Kvff


ess= Kd
e(t) T(t)
Θd=Vdt
dt
Θ
+ + 1
J ∫∫
KP KAKcKT
- -

d
Kd
dΘ dt
Kd
dt

KC: DAC Conversion Gain


KA: Amplifier Gain
KT: Motor Torque Constant

151 PMAC Servo Control Algorithm


Turbo PMAC Training
Purpose of Velocity Feedforward
Selecting Kvff = Kd Æ ess= 0

No steady state error due to constant velocity tracking

Position

Vd

ess = 0

Steady state error


Reference
trajectory (ramp
input), Θd=Vdt

Actual
Trajectory
Time

152 PMAC Servo Control Algorithm


Turbo PMAC Training
Block Diagram with Kvff

d
Kvff
dt
T(t)
Θd=Vdt ess= 0
Θ
+ + 1
J ∫∫
KP KAKcKT
- -

d
Kd
dt

Kd
dt KC: DAC Conversion Gain
KA: Amplifier Gain
KT: Motor Torque Constant

Typically, setting Kvff = Kd is a good starting place for tuning the


servo loop.
Note

153 PMAC Servo Control Algorithm


Turbo PMAC Training
Purpose of Acceleration Feedforward
¾ In general, the trajectories contain higher order time functions:

Θ d (t ) = c 0 + c1 • t + c 2 • t 2
¾ Example: Constant Jerk Trajectory
By choosing:

J1
K aff = → e(t ) = 0
K P • K C • K A • KT

J1 d 2Θd J1 • d 2Θ d
T (t ) = ( ) (K P • K C • K A • KT ) =
K P • K C • K A • K T dt 2
dt 2

¾ This results in no following error for the Ideal system; i.e.:

d 2Θ d d 2Θ
¾ Since
2
= 2 → Θ d = Θ → No Following Error
dt dt

154 PMAC Servo Control Algorithm


Turbo PMAC Training
Acceleration Feedforward: Kaff

d2
K af f
dt 2

d
K vff
dt

Θd=Vdt T(t) Θ
+ + 1
J ∫∫
KP KAKcKT
- -
d
Kd
dΘ dt
Kd
dt

KC: DAC Conversion Gain


KA: Amplifier Gain
KT: Motor Torque Constant

155 PMAC Servo Control Algorithm


Turbo PMAC Training
Servo Loop Modifier I-Variables
Ixx59: Motor xx User-Written Servo/Phase Enable
= 0: Use standard PID phase algorithms
= 1: Use custom servo, standard phase algorithms
= 2: Use standard PID, custom phase algorithms
= 3: Use custom servo, phase algorithms

Ixx60: Motor xx Servo Cycle Extension Period [Servo Cycles]


Loop closed every (Ixx60+1) servo interrupts
Useful for slow, low-resolution axes
Useful for process control “axes”

Ixx63: Motor xx Integration Limit [(Ixx33 / 219) counts * servo cycles]


Maximum integrated error accumulated
When negative, killed on saturation

Ixx64: Motor xx Deadband Gain Factor


Controls the effective gain within the deadband zone

Ixx65: Motor xx Deadband Size [1/16 count]


Defines the size of the position error band, measured from zero error, within which there
will be changed or no control effort, for the PMAC feature known as deadband
compensation.

156 PMAC Servo Control Algorithm


Turbo PMAC Training
Deadband Compensation

Deadband
Deadband width set by Ixx65 in units of 1/16 count

Output of

Filter
Proportional Gain Set by
value of Ixx30 n > 0 provides stiffer servo when
near in-position
n = 0 disables any deadband effect
Desired Position n < 0 reduces gain when near in-position
(n=-16 provides true deadband)
n<-16 provides negative gain when near

n= =16
Two stable in-position (This is of no known use)

n
0
positions only n=-16
e(t) [Following Error]

n=
Dead Band Gain Control:

-3
2
⎛ n + 16 ⎞
Deadband Gain = ⎜ ⎟Ixx30 , where n = Ixx64
⎝ 16 ⎠
DEAD BAND
DEAD BAND
Deadband
Gain

NO GAIN DISCONTINUITIES
n=16

n=0 Ixx30
n=-16
e(t) [Following Error]
157 PMAC Servo Control Algorithm
Turbo PMAC Training
Servo Loop Modifier I-Variables (cont.)
Ixx67: Motor xx Position Error Limit [1/16 Count]
Limits error that filter “sees”

Ixx68: Motor xx Friction Feedforward [16-bit DAC Bits]


Compensates for dry (Coulumb) friction

Ixx69: Output Command (DAC) Limit [16-bit DAC Bits]


Limits output of filter
Acts as torque (current) limit if commutating

158 PMAC Servo Control Algorithm


Turbo PMAC Training
Servo Loop Modifiers
α: Phase angle in Phase A
β: Phase angle in Phase B

"Friction Sin(α)
Phase A Bias
Command Feedforward"
Velocity
1
1-Z-1
-1 Ixx29
Sin(α−β)
Phase B Bias
Position Ixx68
Error Limit

Input
Deadband "Big Step” Output
Ixx79
Compensation Limit Limit DAC Bias
Commanded (Ixx01=1)
Position +
+ + KP
+
- + - +
Ixx02
Ixx64,65 Ixx67 Ixx69 Bit 16 Ixx29
Actual Integration =1
Position Mode
KD
Integration
Cmd Vel = 0? Ixx79
Limit
Ixx34
Ixx29
Ki
Motor Position

Ixx63

Load Position

159 PMAC Servo Control Algorithm


Turbo PMAC Training
Closing a Force Loop around a
Position Loop

Force Loop
Output Command
(to open register) Motor 2 (Position Loop)
Commanded (this is usually a
Force + velocity command)
Trajectory
PID Σdt
- Master Position Loop
Position Output Command
Actual Signal (to open register)
Force Commanded +
Signal Position +
Motor 1 (Force Loop) PID DAC AMP
Trajectory
- M Motor
Actual
Position
Signal ENC1
E Encoder

SG Strain Gage
ADC1

See the “Cascading Servo Loops” section of the Turbo PMAC User
Manual for detailed information on how to configure this type of
hybrid control.
Note

160 PMAC Servo Control Algorithm


Turbo PMAC Training
Jog Commands
What is a Jog Command?

¾ A “jog” command is a closed-loop, constant velocity (set by Ixx22 in cts/msec)


move for a single motor

¾ For simple, point-to-point moves

¾ Every jog command is an online command

¾ Jog commands are not associated with any particular coordinate system

¾ Jog commands are associated with the currently addressed motor, which can be
changed by using #{motor number}; e.g., #1 selects motor 1
Can also use the Address#P command, where P is a P-Variable containing the number
of the motor you want to address, to select the motor within a PLC or motion program (see
Turbo SRM for more details)

162 Jog Commands


Turbo PMAC Training
Basic Jog Commands
Command Description

J+ Jog positive indefinitely


J- Jog negative indefinitely
J/ Jog stop (closed-loop stop)
J= Jog back to last programmed position
J={constant} Jog to specified absolute position (cts)
Jog specified incremental distance relative to current
J^{constant} actual position (cts)
Jog specified incremental distance relative to present
J:{constant} commanded position (cts)

¾ Variables Ixx19 through Ixx22 control jog parameters


¾ These parameters may be changed on the fly, but do not take effect until the
next jog command is issued

163 Jog Commands


Turbo PMAC Training
Variable Jog Commands

Command Description
J=* Jog to position (in counts) specified in the variable jog register
Jog the incremental distance specified in the variable jog register
J^+ relative to present actual position
Jog the incremental distance specified in the variable jog register
J:* relative to present commanded position

¾ Mxx72 is the suggested M-Variable for the variable jog register. Write to it
before using variable jog commands.

Example:
P1 = 2000
M172 = P1+500 ; Put move location into variable jog register
#1J=* ; Motor 1 jogs to 2500 counts
Turbo PMAC Script

164 Jog Commands


Turbo PMAC Training
Jog Move Trajectory
Desired Velocity Zero = 0
In Position = 0
Move Timer Active = 1

Max Acc. < Ixx19


“J+” “J/”
Velocity
Move Timer Active = 0

Move Timer Active = 1

Max Acc. < Ixx19

Ixx22 Desired Velocity Zero = 1


In Position = 1
Move Timer Active = 0

Time
Ixx21 Ixx21 Ixx21 Ixx21
Ixx20 Ixx20
Ixx92 Ixx92

¾ Ixx19 can override Ixx20 and Ixx21.


¾ Ixx92 is Jog Move Calculation Time.
Note
165 Jog Commands
Turbo PMAC Training
Jog Move Hands-On

¾ Try all of the jog commands covered in this section on your demo box in the Terminal
Window of PeWin32Pro2

¾ Try changing Ixx19, Ixx20, Ixx21 and Ixx22 settings and observe how each of them
affects the jog

Remember that if you change any jog parameters, you must issue a
new jog command before the change takes effect.
Note
166 Jog Commands
Turbo PMAC Training
Triggered Jog Moves (Homing)
Triggered Jog Moves
¾ Moves that occur after a preconfigured trigger signal and move relative to
trigger-captured position

¾ Three types of triggered moves:


Homing search move
On-line jog-until trigger
Program move-until-trigger (Rapid mode)

¾ Two types of triggers:


Input trigger: Encoder index and/or flag
Error trigger: Warning following error exceeded

¾ Two methods of position capture:


Hardware capture: Immediate; encoder counter only
Software capture: Up to 1 background cycle delay

168 Triggered Jog Moves (Homing)


Turbo PMAC Training
Input Trigger vs. Error Trigger

¾ Input Trigger (flag and/or index edge)


Setting bit 1 of Ixx97 to 0 selects input trigger
Ixx25 specifies address of index and flag set
I7mn2 selects use/polarity of flag and/or index
I7mn3 selects which flag to use
Flag “capture” status bit = 1 is the trigger status
ÆSuggested M-Variable Mxx17

¾ Error Trigger (warning following error (WFE))


Setting bit 1 of Ixx97 to 1 selects error trigger
Ixx12 sets magnitude of WFE limit
Must select “software capture” Ixx97 bit 0 = 1
Motor WFE status bit = 1 is trigger status
ÆSuggested M-Variable Mxx41

169 Triggered Jog Moves (Homing)


Turbo PMAC Training
Hardware Capture vs. Software Capture

¾ Hardware Capture
Setting bit 0 of Ixx97 to 0 (default) selects hardware capture
Requires input trigger, not error trigger
Requires position feedback through encoder counter
Requires position and flags from same hardware channel
Captures exact count at any speed in hardware as soon as triggered

¾ Software Capture
Setting bit 0 of Ixx97 to 1 selects software capture
Permits input trigger or error trigger
Any type of position feedback
Potential capture error proportional to speed
Captures position after PMAC background tasks notice the trigger

170 Triggered Jog Moves (Homing)


Turbo PMAC Training
More Homing I-Variables
¾ Ixx26 - Motor xx Home Offset [1/16 ct]
Specifies the difference between the zero position of sensors for the motor and the motor’s own
zero “home” position.
An easy way to set this value is to write a PLC to wait for the user to position the motor as
desired, and then capture the home offset positions when the user sets a flag.

¾ Ixx23 - Motor xx Home Speed and Direction [cts/msec]


Establishes the commanded speed and direction of a homing-search move for Motor xx.
Positive value – positive homing direction.
Negative value – negative homing direction.

171 Triggered Jog Moves (Homing)


Turbo PMAC Training
Triggered Jog Move Commands
¾ Home
Can be issued online or from within a motion program
Jogs the motor until it receives the trigger user selects
Direction and speed of move set in Ixx23

¾ {jog command}^{constant}
Will jog using the jog command in {jog command} as normal and will complete as
normal unless PMAC encounters the trigger

If PMAC encounters the trigger, the motor will move to the position equal to the captured
position in counts plus the number of counts in {constant}

¾ {axis}{data}^{data}
Will move using the move command in {axis}{data} and will complete as normal
unless PMAC encounters the trigger

If PMAC encounters the trigger, the motor will move to the position equal to the captured
position in user units plus the number of user units in {data}
Must be in Rapid mode for this to work

172 Triggered Jog Moves (Homing)


Turbo PMAC Training
Triggered Jog Move Trajectory
Speed
Home Complete = 1
Home Search in Progress = 0
Trigger Move = 0
Home Complete = 0
Home Search In Progress = 1 Ixx92
Trigger Move = 1

Ixx22 (jog) Net distance from


≤ Ixx19 Ixx23 (home) trigger position
Ixx16, Ixx22 (rapid) (Ixx26, ^{distance})

Time

Ixx21 Ixx21
Ixx21
Ixx20 Ixx22 Desired Velocity Zero = 1
Ixx23 In Position = 1
Trigger Occurs
Ixx16 (when FE in range)
Hardware-Based Position Capture Occurs

If Ixx97 = 0 or 2: PMAC Firmware Processes Ixx21 Ixx21 Ixx21


Hardware Position Capture Already Stored.
If Ixx97 = 1 or 3: PMAC Firmware Performs Ixx20 Ixx20
Software Position Capture.

Post Trigger Move Starts

Ixx16: Motor xx Maximum Program Velocity Ixx23: Motor xx Home Speed and Direction
Ixx19: Motor xx Maximum Jog/Home Acceleration Ixx26: Motor xx Home Offset
Ixx20: Motor xx Jog/Home Acceleration Time Ixx92: Motor xx Jog Move Calculation Time
Ixx21: Motor xx Jog/Home S-Curve Time Ixx97: Motor xx Position Capture & Trigger Mode
Ixx22: Motor xx Jog Speed

173 Triggered Jog Moves (Homing)


Turbo PMAC Training
Homing Hands-On

¾ Set up the motors on your demo box to home based upon:


Home and Index (Encoder Channel C)
-Lim and Index
Warning Following Error

Disable position limits (Ixx24 = $20001 for our demo racks) while
homing to –Lim and Index, then Home, then reenable the limits
(Ixx24 = $1 for our demo racks) to prevent the motor from stopping
prematurely. See the PLC training for an exercise on this.
Note

¾ Test each setting with the Home command

Setting these up will require using the Turbo SRM extensively. Try
looking at Ixx97, Ixx25, I7mn2, I7mn3, and Ixx12 to set up the trigger
settings.
Note

174 Triggered Jog Moves (Homing)


Turbo PMAC Training
Coordinate Systems
Motors, Axes, and Coordinate Systems
Motors, Axes, Coordinate System

¾ Motors
Turbo PMAC can control up to 32 motors at the same time
Attributes are specified in terms of raw counts and milliseconds

¾ Axes
Motion is commanded through the use of axes
Each axis can have up to 8 motors assigned to it
Axes can only be specified by letters [X,Y,Z], [U,V,W], and [A,B,C]
Attributes are in terms of user-specified units

¾ Coordinate System (C.S.)


Turbo PMAC can support up to 16 coordinate systems
A coordinate system can have up to 9 axes assigned to it
Synchronizes motion between axes, and motors in groups
A coordinate system can run a motion program; A motor itself can NOT run a motion
program

176
Turbo PMAC Training
Axis Types

¾ Axis Types
Cartesian Axes
[X,Y,Z] as first set and [U,V,W] as secondary set of linear axes
Only [X,Y,Z] can support cutter radius compensation, circular interpolation, and
matrix axis transformation
Feedrate Axes
By default, [X,Y,Z] are the feedrate axes
Use command “FRAX” to define other feedrate axes
Rotary Axes
Only for [A,B,C] axes
Permits Rollover defined by Ixx27

¾ Axis Definition Categories


One motor to one axis, or to one linear combination of axes
Multiple motor to one axis (Gantry System)
Phantom Axis: An axis with no motor assigned to it

177 Coordinate System


Turbo PMAC Training
Motors, Axes, C.S. Relationship
Multiple motors to one axis Linear combination of axes
One motor to one axis and and
Phantom axis one-to-one

Motor 1 Motor 2 Motor 3 Motor 4 Motor 5 Motor 6 Motor 7 Motor 8 Motor 9 Motor 10

X Y Z X Y Z X Y Z

C.S.1 C.S.2 C.S.3

Motion Motion
Program 1 Program 2
~~~~~ ~~~~~
One C.S. Two C.S.s’
~~~~~ ~~~~~ running
running
one program the same program

178 Coordinate System


Turbo PMAC Training
Axis and C.S. Definition

¾ Define a coordinate system


Clear all previous definition with following commands
Undefine ; Clear axis definition of current addressed C.S.
Undefine All ; Clear axis definition of all C.S.
#n->0 ; Assign all motors to zero (undefined) axes
Now address a C.S. and assign motors to axes in that C.S.

¾ Preliminary Example (No Scale Factor)


// Axis and Coordinate System Definition
Undefine All ; clear all axis definition of all C.S.
&1 ; address C.S. 1 using “&”
#1->X ; address Motor 1 using “#”
; assign Motor 1 to X axis using “->”
&2 ; address C.S. 2
#2->X ; assign Motor 2 to X axis in C.S. 2
#3->Y ; assign Motor 3 to Y axis in C.S. 2

Turbo PMAC Script

It is generally not recommended to make an axis definition statement


with no scale factor. This example does so only for simplicity’s sake
in demonstrating the syntax.
Note

179 Coordinate System


Turbo PMAC Training
Axis Definition Statement

#1->10000X+5000
Address motor 1
Assign to
Axis X with 10000 scale factor
and Offset 5000 counts

¾ Linear combination of axes is also legal


// Axis and Coordinate System Definition
#1->1000X+500Y ; Motor 1 assigned to Axes XY linear combination

Turbo PMAC Script

¾ Axis definition works as a unit transformation


Motor Position always has unit in counts
Axis unit is user defined, such as inches or millimeters
Scale factor can be viewed as counts per user unit

180 Coordinate System


Turbo PMAC Training
Axis Definition Statement

Legal Statement Illegal Statement


This is NOT permitted.
&1 The two motors will &1 A motor cannot perform two
different motions at the same
#1->X act as X-axes in
#1->X time in a program.
independent
&2 coordinate systems. #1->Y The first axis definition will
be cancelled out by the
#2->X second.

&1 This is NOT permitted.


&1 The motors will act A motor will receive
on identical X-axis #1->X
#1->X conflicting commands while
trajectories, as in a &2 running two program.
#2->X gantry system. The second coordinate
#1->X definition will be rejected.

181 Coordinate System


Turbo PMAC Training
Axis Definition Examples

Motor #2 Y (inch) ¾ Assuming 10,000 counts = 1 inch


¾ O’ is Motor Origin (unit in counts)
¾ O” is Axis Origin (unit in inches)
Translation

4” 2” ¾ Translation Example
O” X (inch) // Translation Axis Definition

Motor #1 #1->10000X+40000
O’ #2->10000Y+20000

Motor #2 Turbo PMAC Script


Rotation
) ¾ Rotation Example
ch
( in
Y

// Rotation Axis Definition


(in

// 10000*sin(45)=7071.07
ch
)

#1->7071.07X-7071.07Y
#2->7071.07X+7071.07Y
45º Turbo PMAC Script
Motor #1
O’=O”
182 Coordinate System
Turbo PMAC Training
Quick Data Gathering
Please follow the instructor as he or she leads you through the
basics of gathering and plotting a jog move
Motion Programs
Outline
¾ Purpose of Motion Programs

¾ How to Write Motion Programs

¾ How to Run Motion Programs

185 Motion Programs


Turbo PMAC Training
What is a Motion Program?
¾ Two different types exist: Rotary Buffer and Fixed Buffer – this section will discuss
only Fixed Buffer motion programs

¾ Intended for commanding moves to motors; i.e., coordinating synchronous motion

¾ Must run in a coordinate system

¾ PMAC can hold 224 motion programs at a time

¾ A motion program can be run in multiple coordinate systems simultaneously (up to


16)

¾ Can call subprograms and optionally pass arguments thereto

¾ Can perform mathematical, logical, and I/O related operations like PLCs

¾ Uses same flow control logic syntax as a PLC

186 Motion Programs


Turbo PMAC Training
Procedure for Making the Program

Step 1: Define coordinate system with axis definitions (see PMAC Coordinate Systems
section of the training to learn how to do this)
Step 2: Create opening and closing brackets of the program
Step 3: Select the move mode (Linear, Circle1, Circle2, Spline1, Spline2, Rapid,
or PVT)
Step 4: Select absolute (Abs) or incremental (Inc) position programming modes
Step 5: Configure appropriate speed, acceleration, and time settings
Step 6: Program the moves
Step 7: Download the motion program
Step 8: Execute the program with &n Bm R, where n is the coordinate system number
you defined in step 1, and m is the motion program number you defined in step
2. Make sure the motors in that C.S. are in closed-loop mode first.

187 Motion Programs


Turbo PMAC Training
Outline of a Motion Program
// Step 1: Define Coordinate System (C.S.) and Axis Definitions
&1 ; Select C.S. #1
#1->1000X ; Assign motor 1 to the X axis w/ 1000 counts per user unit
#2->500Y ; Assign motor 2 to the Y axis w/ 500 counts per user unit

// Step 2: Create opening bracket of motion program


Open Prog 1 Clear ; Opening bracket, defining this as Prog 1

// Step 3: Define Move Mode


Linear ; Select linear move mode

// Step 4: Define Position Programming Modes


Abs ; Selects absolute position programming mode

// Step 5: Define Speed, Acceleration, and Move Time Parameters


TA 125 ; 125 ms acceleration time
TS 35 ; 35 ms S-Curve time
TM 1000 ; 1000 ms move time before deceleration
; Total move time is TM + TA = 1125 ms
; Note: Can also use feedrate (F) rather than TM
// Step 6: Program the Moves
X 10 Y 20 ; Move X to 10 user units, move Y to 20 user units
// Create closing bracket of motion program
Close ; Closing bracket
Turbo PMAC Script

All that remains are steps 7 and 8, which are just to download the program and then type
#1J/#2J/ &1 B1 R in the Terminal Window

188 Motion Programs


Turbo PMAC Training
Step 2: Open and Closing Brackets
¾ All motion programs must have an opening statement and a closing statement, e.g.:
Open Prog 1 Clear
// Program content
Close
Turbo PMAC Script

189 Motion Programs


Turbo PMAC Training
Step 3: Move Mode

¾ Linear: Linear interpolated blended moves

¾ PVT: Moves with specified endpoint position and


velocity and specified move time

¾ Circle1, Circle2: Move in a circular motion with specified center or radius,


and end point

¾ Spline1, Spline2: Move using cubic spline interpolator

¾ Rapid: Move using a PMAC-sequenced jog move

190 Motion Programs


Turbo PMAC Training
Step 4: Position Mode

¾ Abs
Use absolute positioning, i.e., relative to origin of coordinate system

¾ Inc
Use incremental positioning, i.e., relative to previous axis position

191 Motion Programs


Turbo PMAC Training
Step 5: Move Parameters
For Linear, Circle1, and Circle2 moves, specify:
Acceleration time (TA) in ms
S-Curve time (TS) in ms
Move time (TM) in ms, or feedrate [user units/Isx90] (F) if feedrate axis (selected by
FRAX)

For Spline1 and Spline2 modes, specify:


TA (I42=1) or TM (I42=0, recommended)

For PVT moves, specify:


Position, velocity, and time (see PVT Mode section of the training)

For Rapid moves, specify:


Ixx20 – Acceleration Time [msec]
Ixx21 – S-Curve Time [msec]
Ixx22 – Jog Speed [cts/msec]
Example: Setting Up a Linear Move
Linear ; Select linear move mode
Abs ; Selects absolute position programming mode

TA 125 ; 125 ms acceleration time


TS 35 ; 35 ms S-Curve time
TM 1000 ; 1000 ms move time from start of move to onset of deceleration

Turbo PMAC Script

192 Motion Programs


Turbo PMAC Training
Move Parameters Explained
TA: Commanded acceleration time between blended moves (Linear and
Circle1/Circle2 mode), and from and to a stop for these moves.

TS: Specifies the time, at both the beginning and end of the total acceleration time, in
Linear and Circle1/Circle2 mode blended moves that is spent in S-
curve acceleration.

TM: Establishes the time to be taken by subsequent Linear and


Circle1/Circle2, mode moves.

F: Sets the commanded velocity for upcoming Linear and Circle1/Circle2


mode blended moves [(user length units)/Isx90]

Velocity Velocity
TM

Time Time
TS TS
TA TA
TA
Area is move distance

The effect of each of these commands on each Move Mode will be described
more in detail in each subsequent Move Mode section of the training.
Note
193 Motion Programs
Turbo PMAC Training
Feedrate Command
¾ Commands
F {velocity} ; Feedrate (velocity) defintion
Frax(Axes) ; Vector feedrate axes definition

¾ F{velocity} specifies velocity for feedrate axes (tool tip)


Velocity unit: (User distance unit / User time unit)
User distance unit: Defined in Axes Definition
User time unit: Defined in Isx90, C.S.x feedrate time unit, msec

Example:
If user distance unit is in inches, and Isx90=1000, then
F 5 means setting tool tip move velocity as 5 inches/sec

Distance
F=
TM
Move time of a move statement can be defined by F or TM. Either one will
reset previous move time definition.
Note

194 Motion Programs


Turbo PMAC Training
¾ Frax(Axes) specifies which axes are in feedrate calculation
When multiple axes are involved in a move, such as a tool tip in an XYZ Cartesian
coordinate system, the distance calculation needs to be specified as a vector length for
the move time calculation
Any non-feedrate axis move statement(s) on the same line as the feedrate axes’ move
statement(s) will complete in the same amount of time
Example:
Frax(X,Y,Z) (default) means distance is calculated from Axes X, Y, and Z

Distance = X 2 + Y 2 + Z 2

195 Motion Programs


Turbo PMAC Training
Vector Feedrate Axes Example
Inc ; Incremental Move
Frax (X,Y) ; Feedrate Axes [X,Y]
X 3 Y 4 F 10 ; Move distance X=3 Y=4, with speed 10 unit/sec

Turbo PMAC Script


5
Distance = 3 2 + 4 2 = 5 ; Move Time = = 0.5 sec
Velocity 10
calculation 3 4
Vx = = 6 unit/sec; Vy = = 8 unit/sec
0.5 0.5

Inc ; Incremental Move


Frax (X,Y) ; Feedrate Axes [X,Y]
X 3 Y 4 Z 12 F 10 ; Move distance X=3 Y=4, with speed 10 unit/sec,and
; Z=12
Turbo PMAC Script
5
Velocity Distance = 3 2 + 4 2 = 5 ; Move Time = = 0.5 sec
10
calculation 3 4 12
Vx = = 6 unit/sec; Vy = = 8 unit/sec; Vz = = 24 unit/sec
0.5 0.5 0.5

Inc ; Incremental Move


Frax (X,Y,Z) ; Feedrate Axes [X,Y,Z]
X 3 Y 4 Z 12 F 10 ; Move distance X=3 Y=4 Z=12, with speed 10 unit/sec

Turbo PMAC Script


13
Velocity Distance = 3 2 + 4 2 + 122 = 13 ; Move Time = = 1.3 sec
10
calculation 3 4 12
Vx = = 2.31 unit/sec; Vy = = 3.08 unit/sec; Vz = = 9.23 unit/sec
1.3 1.3 1.3

196 Motion Programs


Turbo PMAC Training
Step 6: Programming the Move
¾ There are 9 axes per Coordinate System:
X, Y, Z, A, B, C, U, V, and W

¾ To command an axis to move, just write the axis letter and then either a numeric literal
immediately thereafter or a parentheses with a numerical statement therein; e.g.:
X 10 ; Move the X-axis 10 user units
Y(Sin(P1)) ; Move the Y-axis Sin(P1) user units
Turbo PMAC Script

¾ Can command several moves simultaneously by writing them on the same line; e.g.:

U 30 V 40 W 10 ; Command U to move 30 user units, V 40 units, and W 10 units


Turbo PMAC Script

197 Motion Programs


Turbo PMAC Training
Steps 7-8: Downloading and Running
¾ Once written in the Editor window (from PeWin32Pro2 click FileÆNew File), click the
“Download” button to download to PMAC

¾ Finally, type &n Bm R in the terminal window to start the program. Note that all
motors in the coordinate system must be in closed-loop mode before running the
program
One can easily put a motor into closed loop mode with #nJ/, where n is the motor number

198 Motion Programs


Turbo PMAC Training
Delay
¾ Delay{data}
Waits the duration {data} in milliseconds
If Delay comes after a blended move, the TA deceleration time from the move occurs
within the Delay time, not before it
If the specified Delay time is less than the acceleration time currently in force (TA or
2*TS), the entire delay will occur during the acceleration, effectively not occurring at
all.
The actual time for Delay does vary with a changing time base (current % value, from
whatever source)
PMAC precomputes upcoming moves (and the lines preceding them) during a Delay

¾ Example:
Delay 1000 ; Delay 1000 msec before continuing motion program
P1000=35
Delay(P1000+45) ; Delay 80 msec before continuing
Turboprogram
PMAC Script

The Delay command will not cause loss of synchronicity with the
master signal when using external time base.
Note

199 Motion Programs


Turbo PMAC Training
Dwell
¾ Dwell{data}
Waits the duration {data} in milliseconds
If the previous servo command was a blended move, there will be a TA time deceleration to a
stop before the dwell time starts
Dwell is not sensitive to a varying time base – it always operates in real time (as defined by
I10)
Turbo PMAC does not precompute upcoming moves (and the program lines before them
during the Dwell; it waits until after it is done to start further calculations, which it
performs in the time specified by I11 or Ixx92

¾ Example:
Dwell 1000 ; Dwell 1000 msec before continuing motion program
P1000=10
Dwell(P1000*5) ; Dwell 50 msec before continuing program

Turbo PMAC Script

Use of any Dwell command, even a Dwell 0, while in external time


base will cause a loss of synchronicity with the master signal.
Caution

200 Motion Programs


Turbo PMAC Training
Wait
¾ While(Condition)Wait
Halts program execution until Condition goes false
Allows indefinite pauses without the need for repeated use of a servo command (as in
Delay and Dwell)
Permits a faster resumption of the program upon the While condition going false than if
EndWhile was used
The program timer is halted when using Wait, but still allows the “in-position” bit to go true
(which can be used to trigger an action, or the next move)

¾ Example:

While(M11=0) Wait ; Pause here until Machine Input 1 goes high


Turbo PMAC Script

The Wait command will not cause loss of synchronicity with the
master signal when using external time base.
Note

201 Motion Programs


Turbo PMAC Training
Double Jump-Back Rule
PMAC will not blend through subsequent moves if it encounters two or more
EndWhile statements in between:

Open Prog 2 Clear Open Prog 2 Clear


P1=1 P1=1
While (P1<11) While (P1<11)
P2=0 P2=0
While (P2<360) While (P2<350)
P3=10+P1*Cos(P2) P3=10+P1*Cos(P2)
X(P3) X(P3)
P2=P2+10 P2=P2+10
EndWhile EndWhile
P1=P1+1 P3=10+P1*Cos(P2)
EndWhile X(P3)
Close P1=P1+1
Turbo PMAC Script EndWhile
Close
Turbo PMAC Script

Blending stops each time inner loop is Putting a move between the two
exited: two EndWhile encountered EndWhile commands makes blending
before next move. continuous throughout entire example.

202 Motion Programs


Turbo PMAC Training
Motion Program Precalculation
PMAC plans “n” moves ahead for Blended Moves

2 3 4

1
Execute "R"

n+2 n+3 n+4 time


1 n n+1
Calculate

How big is “n”? Can be 0, 1, or 2 as follows:


¾0 for Rapid moves and Dwell between moves of any mode
¾1 if segmentation is on (Isx13 > 0) (includes cutter radius compensation)
¾1 if blending is disabled (Isx92 = 1)
¾2 if segmentation is off (Isx13 = 0, includes acceleration limits enabled)
¾As big as necessary when using Special Lookahead (in Advanced Training)

203 Motion Programs


Turbo PMAC Training
Motion Program Precalculation
¾ PMAC looks zero moves ahead (no blending) if:
Isx92=1 or Msx84 = 0
Rapid
Home
Dwell
S
PSET
Wait
If PMAC does not blend, it will wait I11
msec before next move

"S"
"R"
Execute

time
I11 I11 DWELL I11
time
Calculate

204 Motion Programs


Turbo PMAC Training
Synchronous M-Variables
¾ Because of how PMAC performs lookahead for numerical calculations that are not
necessarily related to moves, normal M-Variables may be executed before the user
expects

¾ To force M-Variable statements to occur at the beginning of the next move, use a
synchronous M-Variable

¾ Just like a normal M-Variable statement but with == rather than = in the assignment
expression

¾ Example:
Open Prog 3 Clear
Linear Abs TA 300 TM 1500 TS 150 ; Define motion parameters
M1==1 ; Machine output 1 will go high just as the X 30 move starts
X 30 ; Move X-axis to 30 user units
M1==0 ; Machine output 1 will go low just as the Y 40 move starts
M2==1 ; Machine output 2 will go high just as the Y 40 move starts
Y 40
M2==0 ; Machine output 2 will go low as the program finishes
Dwell 0 ; This dwell 0 is necessary to force M2==0 to occur
; (dwell 0 acts like a sequenced move here, forcing M2==0 to occur)
Close
Turbo PMAC Script

205 Motion Programs


Turbo PMAC Training
Simple Move Example

/************* Set-up and Definitions **************/


End Gat; End any presently active gathers
Del Gat; Erase any defined gather buffer
&1 ; Coordinate System 1
Close ; Make sure all buffers are closed
#1->1000X ; Assign motor 1 to the X-axis - 1 program unit
; of X is 1000 encoder counts of motor #1

/************* Motion Program Text *****************/

Open Prog 1 Clear ; Open buffer for program entry, Program #1


Linear ; Blended linear interpolation move mode
Abs ; Absolute mode - moves specified by position
TA 500 ; Set 1/2 sec (500 msec) acceleration time
TS 0 ; Set no S-curve acceleration time
F 5 ; Set feedrate (speed) of 5 units/sec
X 10 ; Move X-axis to position 10
Dwell 500 ; Stay in position for 1/2 sec (500 msec)
X 0 ; Move X-axis to position 0
Close ; Close buffer - end of program
Turbo PMAC Script

To run this program:


#1J/ &1 B1 R ; Close loop, C.S. #1, point to Beginning of Program 1, Run

Turbo PMAC Script

206 Motion Programs


Turbo PMAC Training
Simple Move Example

6000 12000

4000 10000
Motor 1 Speed [cts/sec]

Motor 1 Position [cts]


2000 8000

0 6000
0 1 2 3 4 5

-2000 4000

-4000 Speed 2000


Position
-6000 0

Time [sec]

207 Motion Programs


Turbo PMAC Training
A More Complex Move Example

//*************** Set-up and Definitions ****************//


Undefine All
End Gat
Del Gat
Close
&2 ; Coordinate system 2
#2->1000X ; 1 unit of X is 1000 counts of motor 2
//****************** Motion Program Text ****************//
Open Prog 2 Clear ; Open buffer for entry, Program #2
Linear ; Blended linear interpolation move mode
Inc ; Incremental mode - moves specified by distance
TA 500 ; 1/2 sec (500 msec) acceleration time
TS 250 ; 1/4 sec in each half of S-curve
P133=0 ; Initialize a loop counter variable
While (P133<3) ; Loop until condition is false (3 times)
X 10 ; Move X-axis 10 units (= 10,000 cts) positive
Dwell 500 ; Hold position for 1/2 sec
X-10 ; Move X-axis back 10 cm negative
Dwell 500 ; Hold position for 1/2 sec
P133=P133+1 ; Increment loop counter
EndWhile ; End of loop
Close ; Close buffer - end of program

Turbo PMAC Script


To run this program:

#2J/ &2 B2 R ; Close loop, C.S. 2, point to Beginning of Program 2, Run

Turbo PMAC Script

208 Motion Programs


Turbo PMAC Training
A More Complex Move Example

15000 Speed 12000

Position

10000 10000
Motor 2 Speed [cts/sec]

Motor 2 Position [cts]


5000 8000

0 6000
0 2 4 6 8 10 12 14

-5000 4000

-10000 2000

-15000 0

Time [sec]

209 Motion Programs


Turbo PMAC Training
Move Modes
Linear Move Mode
Circular Move Mode
Rapid Move Mode
Spline Move Mode
PVT Move Mode
Linear Move Mode

¾ Commands:
Linear ; Linear Move Mode
TM {constant} ; Move Time (msec); Distance = Velocity * TM
TA {constant} ; Acceleration Time (msec); Default value = Isx87
TS {constant} ; S-Curve Time (msec); Default value = Isx88
F {constant} ; Feedrate (user unit/user time); Tool tip velocity
; Move Time = Distance / F
Abs / Inc ; Absolute / Incremental endpoint specification

Example:
Linear ; Linear move mode
TM 1000 TA 500 TS 0 ; Move time 1000 msec, Acc. Time 500 msec, No S-Curve Time
Abs ; Absolute endpoint mode
X 20 Y 10 ; Go to X=20, Y=10

Turbo PMAC Script

211 Move Modes


Turbo PMAC Training
Linear Move Trajectory
¾ Velocity Profile
For each move, total move time is usually TM+TA (see Rules)
Velocity profile is under the constraints of :
Maximum program velocity Ixx16
Maximum program acceleration Ixx17

Velocity Velocity

TM

Time Time
TA TA TS TS

Area is move distance TA

212 Move Modes


Turbo PMAC Training
Move Rules
TA and TM
Equal Distance

TM TM TM
TA TA TA
TM > TA TM = TA TM < TA
Total Time = TM + TA Total Time = TM + TA = 2 * TA Total Time = 2 * TA

TA and TS

TS TS TS TS TA
TA TA TS TS
TA > 2*TS TA = 2 * TS TA < 2 * TS
Total Acc. Time = TA Total Acc. Time = TA = 2 * TS Total Acc. Time = 2 * TS

213 Move Modes


Turbo PMAC Training
Linear Move Blending
¾ PMAC can perform move blending between sequential linear and circular
moves

¾ Blending is not used if:


Moves are separated by a Dwell command
Two backward jumps in the program from either Goto or Endwhile
Move Blending disabled (Isx92=1)

Y Blending Disable Y Blending Enable

X X

214 Move Modes


Turbo PMAC Training
Linear Move Blending

Velocity
Blending OFF

Total Time = TM1 + TM2 + 2•TA

Time
½TA TM1 TA TM2 ½TA

Velocity Blending ON

Total Time = TM1 + TM2 + TA

Time
½TA TM1 + TM2 ½TA

215 Move Modes


Turbo PMAC Training
Circular Move Mode
¾ Commands:
Move segmentation time
Isx13, C.S. x segmentation time, must be greater than 0 to use Circular Move Modes
Unit in msec, usual values from 5 to 10 msec

Interpolation plane definition


Normal {vector}{data} ; Vector: [I,J,K] for Axes [X,Y,Z]
Normal I10 J 10 K -5 ; [10,20,-5] is the normal vector of the plane

End point definition mode


Abs / Inc ; Absolute / Incremental end point

Center point definition mode


Abs / Inc ; Absolute / Incremental center point

Circle direction
Circle 1 / Circle 2 ; Clockwise / Counter-clockwise

Circle Commands
X{X Pos.} Y{Y Pos.} Z{Z Pos.} I{data} J{data} K{data}
X{X Pos.} Y{Y Pos.} Z{Z Pos.} R{Radius}

In order to use Circle1 or Circle2 modes,


Isx13 must be greater than 0.
Note
216 Move Modes
Turbo PMAC Training
Interpolation Plane
¾ Command: Normal {vector} {data}
Once the normal vector of the plane is determined, the right-hand rule determines which
direction is clockwise

¾ Common vector assignment example (clockwise)

Z Z Z

X Y X Y X Y

Normal K -1 Normal I -1 Normal J -1


Z Z Z

X Y X Y
X Y

Normal K 1 Normal I 1 Normal J 1

217 Move Modes


Turbo PMAC Training
Circular Move Examples
Y End Y
(25,30) Normal K-1
Normal K-1
Center Abs(X,Y)
Abs(X,Y)
(15,20) Start Inc(R)
Inc(R)
Circle1 (25,20) Circle2
F 10 TM 1000
I X 15 Y 10 I -10
Center X 25 Y 30 I 20 J 5
(30,10)
End
Start J (15,10)
(10,5)
I
X X

Y Y
Normal K-1 Circle2
Abs(X,Y) TM 2000
Inc(R) R<0 X 0 Y 10 R 10
Center Circle1 End
(20,20) F 25 (0,10)
X 30 Y 10 I -10 J 10
Circle2
J If Start and End points are TM 2000
I the same, the command R>0 X 0 Y 10 R -10
Start, End can also be just :
(30,10) Start
(10,0)
X I -10 J 10 X
R>0 , path is less than 180°
R<0 , path is greater than 180°
NOT be used for full circle
Starting point is specified from previous move. After Circle1 or
Circle2 command, only End point, Center/Radius are needed
Note
218 Move Modes
Turbo PMAC Training
Rapid Move Mode
Rapid Move Mode provides a point-to-point (jog), PMAC-sequenced move

¾ Commands
Rapid ; Rapid Move Mode, minimum time P2P
Abs / Inc ; Endpoint / Distance specification
Ixx16 / Ixx22 ; Maximum Speed specification
Ixx19 / Ixx20,Ixx21 ; Rate / Acceleration Time
X{data}^{data} ; Move until trigger (Triggered Move)
!X{data}Y{data} ; Altered destination, Abs mode

¾ Trajectory
NO BLENDING with other moves
If acceleration time are matched, it’s a straight line
If Isx79=0, all motors are slowed down to match longest move time
If Isx79=1, each motor goes with it’s own max. speed

219 Move Modes


Turbo PMAC Training
Rapid Move Trajectory
¾ Trajectory from point 1 to point 2
A Isx79=1, Short axis (Y) with full speed
B Isx79=0, Short axis speed reduced, acceleration rate match
C Isx79=0, Short axis speed reduced, acceleration time match

2
A

C Rapid
INC
X 20 Y 10

Turbo PMAC Script

1
X

220 Move Modes


Turbo PMAC Training
Spline Move Mode
Spline Move Modes provide cubic splines (cubic in terms of the position-vs.-time
equations) to blend together a series of points on an axis.

Position, Velocity, and Acceleration are continuous at move boundaries

¾ Two types of cubic spline move modes


Spline1 ; Uniform non-rational cubic B-spline
Spline2 ; Non-uniform non-rational cubic B-spline

¾ Commands
I42 = 0 / 1 ; Move time specified by TM / TA
TM / TA ; Segment move time
Spline1 / Spline2 ; Uniform / Non-uniform move time
Abs / Inc ; Absolute / Incremental endpoint

¾ Trajectory
At the beginning and end of a series of spline moves, a zero-distance with TM/TA time
period is added (see Figs.)
Spline between segments is performed

221 Move Modes


Turbo PMAC Training
Cubic Spline Move Trajectory
V V

TA (added) TA TA (added) time TA (added) TA TA TA (added) time

One Programmed Segment Two Programmed Segments

TA (added) TA TA TA TA (added) time

Three Programmed Segments

In examples above, I42 = 1, and TA time is used.


Spline1 is used for uniform time segment cubic B-spline.
Note

222 Move Modes


Turbo PMAC Training
Cubic Spline Move Trajectory
If segment were
done at constant
velocity:
Δ
Velocity Vc = P
TA
No velocity or acceleration
discontinuities at segment
boundaries

TA TA TA TA TA TA Time
(added) (added)

All segments are the same duration (TA) for Spline1 mode (shown
in this example). In examples above, I42 = 1, and TA time is used.
Note
223 Move Modes
Turbo PMAC Training
Simple Spline Mode Example
Undefine All
End Gat
Del Gat
Close
&1
#1->1000X ; 1000 counts is 1 user unit for X axis
#2->1000Y ; 1000 counts is 1 user unit for Y axis
I42 = 0 ; Use TM to adjust Spline move time

Open Prog 3 Clear

Home 1,2 ; Home motors 1 and 2


Abs ; Absolute position programming
Spline1 TM 1000 ; Set up move mode and move time
X 1 Y -1 ; Move X to 1 user units, Y to -1 user units
X 2 Y -2 ; Move X to 2 user units, Y to -2 user units
X 3 Y -3 ; Move X to 3 user units, Y to -3 user units
Dwell 0 ; Do not blend into next move

Spline2 TM 250 ; Set up move mode and move time


Dwell 0 ; Do not blend into next move
X 2 Y -2 ; Move X to 2 user units, Y to -2 user units
TM 100 ; Adjust move time on the fly
X 1 Y -1 ; Move X to 1 user units, Y to -1 user units
TM 10 ; Adjust move time on the fly
X 0 Y 0 ; Move X to 0 user units, Y to 0 user units

Close
Turbo PMAC Script

224 Move Modes


Turbo PMAC Training
Simple Spline Mode Example
4
Transition point from
3 Spline1 mode to
Spline2 mode
Axis Position [user units]
2

0
0 1 2 3 4 5 6
-1

-2 X Axis
Y Axis
-3

-4
Time [seconds]
Using Spline2 to decelerate permits more control over the deceleration profile, allowing the
user to adjust TM on the fly while still maintaining a smooth, continuous motion.

225 Move Modes


Turbo PMAC Training
PVT Move Mode
PVT stands for Position-Velocity-Time
PVT Move Mode lets users specify exact position and velocity at the boundaries of moves

¾ Commands
I42 = 0 or 1 ; Move time specified by TM / TA
PVT {Time} ; PVT move with Move Time
; If no Time specified, uses TM / TA
TM / TA ; Segment move time if no PVT time specified
; Not used if PVT{Time} is specified
Abs / Inc ; Absolute / Incremental endpoint

{Axis}{Position}:{Velocity}
; Move statement, endpoint position and
; velocity specified

¾ Trajectory
Useful for creating arbitrary profiles
Generate Hermite-Spline path

In order to use PVT, blending must be enabled


(Isx92 = 0).
Note

226 Move Modes


Turbo PMAC Training
PVT Move Trajectory
Velocity P0(previous) P1(specified)
V0(previous) V1(specified)
A0(calculated) A1(calculated)

P: Cubic Position
V: Parabolic Velocity
A: Linear Acceleration
T: Move Time
T
Time

Velocity Velocity Velocity

ΔP=(1/2)VT ΔP=(2/3)VT ΔP=(1/3)VT


V V V

Common
Time Time Time
Segment T T T
Velocity Velocity Velocity
Shapes ΔP1=1/6VT
ΔP=VT ΔP=(1/2)(V1+V2)T ΔP2=(5/6)VT
V V2 V
V1
1/2V

Time Time Time


T T T 2T

227 Move Modes


Turbo PMAC Training
PVT Move Example
Velocity
(Unit / sec)

1000
900

500

1 2 3 4 5
Time
(msec)
200 300 400 600 1100
Undefine All
End Gat
Del Gat
Close
&1 ; Address C.S. 1
#1->100X ; 100 counts is 1 user unit for X axis
Open Prog 4 Clear ; Open Program 4 buffer and clear
Inc ; Incremental endpoint definition
PVT 200 ; PVT mode with move time T=200 msec
X 133.333:1000 ; Move 1: ΔP=133.333, V=1000
PVT 100 ; Change PVT move time to T=100 msec
X 100:1000 ; Move 2: ΔP=100, V=1000
X 96.667:900 ; Move 3: ΔP=96.667, V=900
PVT 200 ; Change PVT move time to T=200 msec
X 140:500 ; Move 4: ΔP=140, V=500
PVT 500 ; Change PVT move time to T=500 msec
X 83.333:0 ; Move 5: ΔP=83.333, V=0
Close ; Close program buffer
Turbo PMAC Script
228 Move Modes
Turbo PMAC Training
Machine I/O
¾ I/O is processed through specific I/O base addresses in PMAC

¾ Each accessory I/O card has a base address


From base address, I/O addresses are set
Addresses can be read from or written to with M-Variables

Amplifier
Power Block
Machine IO
Connection with
Machine I/O
Analog / Digital

Communication Command output


with user interface To
Amplifier
User Interface Delta Tau
Motion Controller Electrical Current
Through Motor Leads

Motor

Feedback Data

230 Machine I/O


Turbo PMAC Training
Addressing for ACC-11E
¾ Where does one find addressing setup for ACC-11E?
Website: www.deltatau.com/manuals
Under Accessory
ACC-11E (in the right-hand side window)
¾ Base address of ACC-11E is set by jumpers
Default base address is $078C00
The 48 I/O addresses are defined as follows:
Y:$078C00,0,8 I/O bits 0 – 7
Y:$078C01,0,8 I/O bits 8 - 15
Y:$078C02,0,8 I/O bits 16 - 23
Y:$078C03,0,8 I/O bits 24 - 31
Y:$078C04,0,8 I/O bits 32 – 39
Y:$078C05,0,8 I/O bits 40 - 47
Y:$078C07,0,8 Control Word

231 Machine I/O


Turbo PMAC Training
Assigning M-Variables to I/O Points

¾ Each bit represents an I/O point which can be assigned to an M-Variable


Read Inputs
Insert M7000 in watch window and toggle Input 1 switch on UMAC
Write Outputs
Type M7024=1 in terminal window and see Output 1 turned on

Download these M-Variable definitions to use ACC-11E at base address $78C00:


M7000->Y:$078C00,0,1 ; ACC-11E Input 1, bit 0
M7001->Y:$078C00,1,1 ; ACC-11E Input 2, bit 1
M7002->Y:$078C00,2,1 ; ACC-11E Input 3, bit 2
M7003->Y:$078C00,3,1 ; ACC-11E Input 4, bit 3
M7004->Y:$078C00,4,1 ; ACC-11E Input 5, bit 4
M7005->Y:$078C00,5,1 ; ACC-11E Input 6, bit 5
M7006->Y:$078C00,6,1 ; ACC-11E Input 7, bit 6
M7007->Y:$078C00,7,1 ; ACC-11E Input 8, bit 7

M7024->Y:$078C03,0,1 ; ACC-11E Output 1, bit 24


M7025->Y:$078C03,1,1 ; ACC-11E Output 2, bit 25
M7026->Y:$078C03,2,1 ; ACC-11E Output 3, bit 26
M7027->Y:$078C03,3,1 ; ACC-11E Output 4, bit 27
M7028->Y:$078C03,4,1 ; ACC-11E Output 5, bit 28
M7029->Y:$078C03,5,1 ; ACC-11E Output 6, bit 29
M7030->Y:$078C03,6,1 ; ACC-11E Output 7, bit 30
M7031->Y:$078C03,7,1 ; ACC-11E Output 8, bit 31
Turbo PMAC Script

232 Machine I/O


Turbo PMAC Training
Setting Control Word
¾ Need to set Control Word = $7 at every power-up to properly configure I/O points; i.e.,
bits 0-23 as inputs and bits 24-47 as outputs:

M19->Y:$078C07,0,8
Open PLC 10 Clear
M19=$7
Disable PLC 10
Close
Turbo PMAC Script

Control Word for ACC-11E (M19->Y:$078C07,0,8)


Hex ($) 0 7
Binary 0 0 0 0 0 1 1 1
Bit # 7 6 5 4 3 2 1 0

Register I/O bits 24-31 set to I/O bits 0-7 set to read only
Select read/write I/O bits 8-15 set to read only
Bits I/O bits 32-39 set to I/O bits 16-23 set to read
read/write only
I/O bits 40-47 set to
Different I/O cards will require their Control
read/write
Words to be set specifically based on the card’s
Note specific I/O configuration.

233 Machine I/O


Turbo PMAC Training
Other I/O Hardware
¾ Brick Series
// Inputs:
M1->Y:$78800,0,1 ; Brick Series Input 01
M2->Y:$78800,1,1 ; Brick Series Input 02
M3->Y:$78800,2,1 ; Brick Series Input 03
M4->Y:$78800,3,1 ; Brick Series Input 04
M5->Y:$78800,4,1 ; Brick Series Input 05
M6->Y:$78800,5,1 ; Brick Series Input 06
M7->Y:$78800,6,1 ; Brick Series Input 07
M8->Y:$78800,7,1 ; Brick Series Input 08
M9->Y:$78801,0,1 ; Brick Series Input 09
M10->Y:$78801,1,1 ; Brick Series Input 10
M11->Y:$78801,2,1 ; Brick Series Input 11
M12->Y:$78801,3,1 ; Brick Series Input 12
M13->Y:$78801,4,1 ; Brick Series Input 13
M14->Y:$78801,5,1 ; Brick Series Input 14
M15->Y:$78801,6,1 ; Brick Series Input 15
M16->Y:$78801,7,1 ; Brick Series Input 16

//Outputs:
M33->Y:$078802,0,1 ; Brick Series Output 1
M34->Y:$078802,1,1 ; Brick Series Output 2
M35->Y:$078802,2,1 ; Brick Series Output 3
M36->Y:$078802,3,1 ; Brick Series Output 4
M37->Y:$078802,4,1 ; Brick Series Output 5
M38->Y:$078802,5,1 ; Brick Series Output 6
M39->Y:$078802,6,1 ; Brick Series Output 7
M40->Y:$078802,7,1 ; Brick Series Output 8
Turbo PMAC Script

234 Machine I/O


Turbo PMAC Training
Other I/O Hardware
¾ Brick Series
// Inputs:
M17->Y:$78803,0,1 ; Brick Series Input 17
M18->Y:$78803,1,1 ; Brick Series Input 18
M19->Y:$78803,2,1 ; Brick Series Input 19
M20->Y:$78803,3,1 ; Brick Series Input 20
M21->Y:$78803,4,1 ; Brick Series Input 21
M22->Y:$78803,5,1 ; Brick Series Input 22
M23->Y:$78803,6,1 ; Brick Series Input 23
M24->Y:$78803,7,1 ; Brick Series Input 24
M25->Y:$78804,0,1 ; Brick Series Input 25
M26->Y:$78804,1,1 ; Brick Series Input 26
M27->Y:$78804,2,1 ; Brick Series Input 27
M28->Y:$78804,3,1 ; Brick Series Input 28
M29->Y:$78804,4,1 ; Brick Series Input 29
M30->Y:$78804,5,1 ; Brick Series Input 30
M31->Y:$78804,6,1 ; Brick Series Input 31
M32->Y:$78804,7,1 ; Brick Series Input 32

//Outputs:
M41->Y:$078805,0,1 ; Brick Series Output 09
M42->Y:$078805,1,1 ; Brick Series Output 10
M43->Y:$078805,2,1 ; Brick Series Output 11
M44->Y:$078805,3,1 ; Brick Series Output 12
M45->Y:$078805,4,1 ; Brick Series Output 13
M46->Y:$078805,5,1 ; Brick Series Output 14
M47->Y:$078805,6,1 ; Brick Series Output 15
M48->Y:$078805,7,1 ; Brick Series Output 16
Turbo PMAC Script

235 Machine I/O


Turbo PMAC Training
Other I/O Hardware
¾ Turbo Clipper
M0->Y:$78400,0 ; Clipper Digital Output M01
M1->Y:$78400,1 ; Clipper Digital Output M02
M2->Y:$78400,2 ; Clipper Digital Output M03
M3->Y:$78400,3 ; Clipper Digital Output M04
M4->Y:$78400,4 ; Clipper Digital Output M05
M5->Y:$78400,5 ; Clipper Digital Output M06
M6->Y:$78400,6 ; Clipper Digital Output M07
M7->Y:$78400,7 ; Clipper Digital Output M08
M8->Y:$78400,8 ; Clipper Digital Input MI1
M9->Y:$78400,9 ; Clipper Digital Input MI2
M10->Y:$78400,10 ; Clipper Digital Input MI3
M11->Y:$78400,11 ; Clipper Digital Input MI4
M12->Y:$78400,12 ; Clipper Digital Input MI5
M13->Y:$78400,13 ; Clipper Digital Input MI6
M14->Y:$78400,14 ; Clipper Digital Input MI7
M15->Y:$78400,15 ; Clipper Digital Input MI8
M32->X:$78400,0,8 ; Clipper Direction Control bits 0-7 (1=output, 0 = input)
M34->X:$78400,8,8 ; Clipper Direction Control bits 8-15 (1=output, 0 = input)
M40->X:$78404,0,24 ; Clipper Inversion control (0 = 0V, 1 = 5V)
M42->Y:$78404,0,24 ; Clipper J9 port data type control (1 = I/O)
Open PLC 1 Clear
M32=$FF ; Bits 0-8 are assigned as output
M34=$0 ; Bits 9-16 are assigned as input
M40=$FF00 ; Define inputs and outputs
M42=$FFFF ; All lines are I/O type
Disable PLC 1 ; Disable PLC 1 (scanning through once on power-up/reset)
Close
Turbo PMAC Script

236 Machine I/O


Turbo PMAC Training
PMAC PLC Programs

237
Turbo PMAC Training
What is a PLC?
¾ PLC normally stands for “Programmable Logic Controller”

¾ A PMAC PLC program is a general-purpose program that runs in PMAC that can run
either in background time (for PLC and PLCC) or foreground time (PLC0 and PLCC0)

¾ Scans through as fast as processor speed allows before the next servo interrupt

¾ Ideal for any task that is asynchronous to motion program sequences and for jogging
and homing routines

¾ Some common uses for PLC programs:


Monitoring inputs, setting outputs
Changing gains
Monitoring card status
Commanding actions
Sending messages
Jogging motors
Configuring hardware
Starting or stopping motion programs

238 PLC Programs


Turbo PMAC Training
Different Types of PLCs
Background PLCs:
¾ PLC (numbered 1-31, 31 total available):
Uncompiled; i.e., interpreted by PMAC
Slower than PLCC, but can be uploaded easily from PMAC
PMAC scans completely to the end of one PLC once each background cycle, or if the PLC is in a
While loop presently, scans to the end of the loop once each background cycle

¾ PLCC (numbered 1-31, 31 total available):


Compiled; more efficient and flexible than uncompiled PLCs
Can operate 10-30x faster than PLCs when programmed properly
PMAC scans through all background PLCCs (1-31) each background cycle

Foreground PLCs:
¾ PLC0 and PLCC0
Special priority PLCs – will execute top to bottom at the end of every Real Time Interrupt (RTI)
Execute every real-time interrupt as long as the tasks from the previous RTI have been completed
Keep these short to prevent starving background of time or tripping Watchdog timer

239 PLC Programs


Turbo PMAC Training
What Makes a PLCC So Much Faster?
¾ The faster execution of the compiled PLCs comes from two factors:
From the elimination of interpretation time
From the capability of the compiled PLC programs to execute integer arithmetic
See “Optimization for Speed” on page 380 of the Turbo PMAC User Manual

¾ Floating-point operations in compiled PLC programs run two to three times faster
than in interpreted PLC programs; integer (including Boolean) operations run 20 to
30 times faster in compiled form

¾ Can use L-Variables for fast integer arithmetic – just replace your M-Variable
definitions using L-Variables

¾ L- and F-Variables are pointers linked at compile time, rather than at runtime like M-
Variables are

240 PLC Programs


Turbo PMAC Training
Background PLC/PLCC
Execution Order
Execution order:

PLC1
PLCC1, 2, 3, 4..
PLC2
PLCC1, 2, 3, 4..
PLC3
PLCC1, 2, 3, 4..

PLC0 and PLCC0 are at a higher priority level and can interrupt any of the
background PLC's
Every PLCC scans through between each PLC scan
Uncompiled: PLC1, 2, 3…31
Compiled: PLCC1, 2, 3, 4…31

241 PLC Programs


Turbo PMAC Training
Writing and Downloading a PLC
¾ All PLCs must have an opening statement and a closing statement, e.g.:
Open PLC 1 Clear
// PLC Contents
Close
Turbo PMAC Script

Open PLCC 1 Clear


// PLCC Contents
Close
Turbo PMAC Script

¾ Once written in the Editor window (from PeWin32Pro2 click FileÆNew File), click the
“Download” button to download to PMAC

242 PLC Programs


Turbo PMAC Training
Enabling and Disabling a PLC
¾ Set I5 to permit the PLC types you plan to use:

I5 Setting Setting Meaning


0 Foreground PLCs off; background PLCs off
1 Foreground PLCs on; background PLCs off
2 Foreground PLCs off; background PLCs on
3 Foreground PLCs on; background PLCs on

¾Enable PLC n
Enables PLC number n
¾Enable PLCC n Global commands: can be used in
Enables PLCC number n terminal window, within a PLC/PLCC,
or within a motion program
¾Disable PLC n
Disables PLC number n
¾Disable PLCC n
Disables PLCC number n

243 PLC Programs


Turbo PMAC Training
Deleting PLCs

¾ To delete one PLC, type “Open PLC n Clear Close”; e.g.:


Open PLC 1 Clear Close ; Delete PLC 1
Turbo PMAC Script
¾ To delete all PLCs, type “Clear All PLCs”
Clear All PLCs ; Deletes all uncompiled PLCs
Turbo PMAC Script
¾ To delete a PLCC, type “Delete PLCC n”; e.g.:
Delete PLCC 1 ; Delete PLCC 1
Turbo PMAC Script

244 PLC Programs


Turbo PMAC Training
Operators and Comparators

¾ Mathematical Operators: ¾ Comparators:


+ (addition) = (equal to)
- (subtraction) > (greater than)
* (multiplication) < (less than)
/ (division) ~ (approximately equal to [within 0.5])
% (modulo, remainder) != (not equal to)
& (bit-by-bit AND) !> (not greater than, less than or equal to)
| (bit-by-bit OR) !< (not less than, greater than or equal to)
^ (bit-by-bit XOR) !~ (not approximately equal to [not within 0.5])
¾ Logical Operators:
Or (logical OR)
And (logical AND)

245 PLC Programs


Turbo PMAC Training
Useful Floating Point Functions
SIN (trigonometric sine)
COS (trigonometric cosine)
TAN (trigonometric tangent)
ASIN (trigonometric arc sine)
ACOS (trigonometric arc cosine)
ATAN (trigonometric arc tangent)
ATAN2 (special 2-argument, 4-quadrant arc tangent)
ABS (absolute value)
INT (greatest integer within 0.5)
EXP (exponentiation)
LN (natural logarithm)
SQRT (square root)

246 PLC Programs


Turbo PMAC Training
Program Flow Control Logic
¾ For conditional branching, use:
If(Condition)
Else
EndIf

¾ Example:
If (P134 > 0)
// Tasks
Else
// Other Tasks
EndIf
Turbo PMAC Script

¾ For conditional looping, use:


While(Condition)
EndWhile

¾ Example:
While(M135 != M189)
// Tasks
EndWhile
Turbo PMAC Script

247 PLC Programs


Turbo PMAC Training
My First PLC
¾ Write a PLC to increment a P-Variable. Example:
Open PLC 1 Clear
P1 = P1 + 1
Close
Turbo PMAC Script
¾ Type I5=2 Enable PLC 1 in the Terminal Window

¾ Put the P-Variable in Watch Window and watch it increment

248 PLC Programs


Turbo PMAC Training
Macro Statements
¾ Can redefine any variable or number in PMAC to have a useful name

¾ Use of macros is highly recommended for all programs

¾ Just issue #define Macro_Name Variable_Name

¾ Example:
#define Loop_Counter P133 ; Names P133 as “Loop_Counter” for this file
Open PLC 1 Clear
Loop_Counter = 1000
While(Loop_Counter > 0)
Loop_Counter = Loop_Counter – 1
EndWhile
Disable PLC 1
Close
Turbo PMAC Script

249 PLC Programs


Turbo PMAC Training
Writing a Delay
¾ Turbo PMAC has two timer variables, Isx11 and Isx12 that can be used to write precise
delays of a certain duration

¾ Just write a value in servo cycles to these variables and use a while loop to wait until
the variable becomes 0

¾ One can multiply the desired wait duration in ms by 8388608/I10 to get the wait
duration in servo cycles to write to the timer variable

¾ 32 Timer I-Variables total are available (see next slide)

¾ Example:
I5111=1000*8388608/I10 While(I5111>0) EndW ; Delay 1000 ms
I5112=500*8388608/I10 While(I5112>0) EndW ; Delay 500 ms
Turbo PMAC Script

250 PLC Programs


Turbo PMAC Training
Timer Tables
Timer Number Timer I-Variable Timer Number Timer I-Variable
1 I5111 17 I5911
2 I5112 18 I5912
3 I5211 19 I6011
4 I5212 20 I6012
5 I5311 21 I6111
6 I5312 22 I6112
7 I5411 23 I6211
8 I5412 24 I6212
9 I5511 25 I6311
10 I5512 26 I6312
11 I5611 27 I6411
12 I5612 28 I6412
13 I5711 29 I6511
14 I5712 30 I6512
15 I5811 31 I6611
16 I5812 32 I6612

251 PLC Programs


Turbo PMAC Training
Timer Delay PLC
¾ Write a PLC to enable Machine Output 1 for 1 second, then disable for 1 second, and
repeat indefinitely. Example:
Open PLC 2 Clear
M1 = 1 ; Activate machine output 1
I5111=1000*8388608/I10 While(I5111>0) EndW ; Delay 1000 ms
M1 = 0 ; Disable machine output 1
I5111=1000*8388608/I10 While(I5111>0) EndW ; Delay 1000 ms
Close
Turbo PMAC Script
¾ Type Enable PLC 2 in the Terminal Window

¾ Watch your Output LEDs on your Demo Rack as the outputs enable/disable

252 PLC Programs


Turbo PMAC Training
Issuing Online Commands
¾ Use CMD"{Command}" to issue an online command from within a PLC

¾ Need to have one iteration of a WHILE loop occur in order to force PMAC into
housekeeping so that the CMD will execute. This is critical if one uses a sequence of
CMD commands whose execution order matters.

¾ Example: Starting to Gather and then Calling a Motion Program Using a PLC

M5180->X:$002040,0,1 ; &1 Program-running bit


Open PLC 3 Clear
CMD"End Gat"
CMD"Del Gat"
CMD"Def Gat"
CMD"Gat"
I5111=1*8388608/I10 While(I5111>0) EndW ; Delay 1 ms to force CMD execution
CMD"&1 B1 R" ; Run program 1 in C.S. 1
I5111=1*8388608/I10 While(I5111>0) EndW ; Delay 1 ms to force CMD execution
While(M5180 = 1)EndWhile ; Wait for program to finish running
CMD"End Gat"
Disable PLC 3
Close
Turbo PMAC Script

One can just run this PLC whenever desired in order to start gathering, run motion
program 1 in C.S. 1, and then stop gathering.

253 PLC Programs


Turbo PMAC Training
Edge Triggered vs. Level Triggered
¾ Level Triggered Example:
Open PLC 2 Clear
If(M11=1) ; If machine input 1 is high
M1=1 ; Activate machine output 1
Else
M1=0 ; Deactivate machine output 1
EndIf
Close
Turbo PMAC Script
¾ Edge Triggered (Latching) Example:
P11 = M11 ; Set initial latch state equal to initial input state
Open PLC 3 Clear
If(M11=1) ; If machine input 1 is high
If(P11=0) ; If machine input 1 was previously low
M1=1 ; Activate machine output 1
P11=1 ; Latch internal machine input 1 signal
EndIf
Else ; If machine input 1 is low
If(P11=1) ; If previous switch state was high
M1=0 ; Deactivate machine output 1
P11=0 ; Delatch internal machine input 1 signal
EndIf
EndIf
Close
Turbo PMAC Script

One should always use Edge Triggered logic when sending online commands for
jogging, homing or anything that causes motion using the CMD command. This
prevents the command from being dangerously sent repeatedly.
WARNING
254 PLC Programs
Turbo PMAC Training
Arrays
¾ Can index arrays by using the variable notation P(), M(), Q(), L(), and F()

¾ Within the parentheses, put a numeric literal or an expression that will evaluate to the
desired array index

¾ Examples:
P1 = 15 ; P1 is the array index variable in this case
Q1 = 30
P(P1) = 5 ; Same as P15 = 5
M(P1) = 5 ; Same as M15 = 5
P(Q1) = 2 ; Same as P30 = 2
Turbo PMAC Script

255 PLC Programs


Turbo PMAC Training
Indirect Addressing
¾ Can dynamically change the address to which an M-Variable is pointing within a PLC

¾ Can be used to greatly generalize PLCs

¾ Example:
M0->L:$6000 ; Point M0 to address of P0
M1->Y:$4000,0,16 ; Point M1 to the definition word of M0;
; i.e., the part of M0’s word that tells M0 where to point
M0 = 5 ; Same as P0 = 5
M1 = M1 + 1 ; Increments index by 1; now M0 points to P1
M0 = 6 ; Same as P1 = 6
M1 = M1 + 1 ; Increments index by 1; now M0 points to P2
M0 = 8 ; Same as P2 = 8

Turbo PMAC Script


¾ This technique can be useful to dynamically determine the addresses to which to
point inside a PLC

¾ One must use this technique if he or she desires to manually read the gather buffer
from within PMAC

256 PLC Programs


Turbo PMAC Training
Proper Jogging and Homing

¾ When using a PLC to jog a motor, one can wait for the jog to finish before advancing
in the PLC by polling these two bits until they both become 1:
Mxx33: Motor xx Desired-velocity-zero bit
Mxx40: Motor xx Background in-position bit

¾ When using a PLC to home a motor, one should poll these three bits until they all
become 1 before advancing:
Mxx33: Motor xx Desired-velocity-zero bit
Mxx40: Motor xx Background in-position bit
Mxx45: Motor xx Home-complete bit (use for homing only)

257 PLC Programs


Turbo PMAC Training
Example: Homing and Jogging
Motor #1
¾ This example homes motor 1, waits for it to finish, and then jogs motor 1 to 2000 cts
absolute
M133->X:$0000B0,13,1 ; #1 Desired-velocity-zero bit
M140->Y:$0000C0,0,1 ; #1 Background in-position bit
M145->Y:$0000C0,10,1 ; #1 Home-complete bit

End Gat
Del Gat
Close
Open PLC 4 Clear
CMD"#1HM" ; Home the motor
I5111=1*8388608/I10 While(I5111>0) EndW ; Force CMD execution before continuing
While(M133 = 0 or M140 = 0 or M145 = 0)EndWhile ; Poll status bits
CMD"#1J=2000" ; Jog to 2000 cts absolute
I5111=1*8388608/I10 While(I5111>0) EndW ; Force CMD execution before continuing
While(M133 = 0 or M140 = 0)EndWhile ; Poll status bits
// Put subsequent code here
// that will execute only after the J=2000 move has completed
Disable PLC 4
Close
Turbo PMAC Script

258 PLC Programs


Turbo PMAC Training
Example: Jog PLC with I/O
¾ This example will jog the Motor #1 forward if machine input 1 is high, and closed-loop
stop the motor when low.
Open PLC 5 Clear
If(M11=1) ; Machine input 1 is high
If(P11=0) ; Machine input 1 latch was low
P11=1 ; Bring machine input 1 latch high
CMD"#1J+" ; Jog forward
EndIf
Else ; Machine input 1 is low
If(P11=1) ; Machine input 1 was high
P11=0 ; Bring machine input latch low
CMD"#1J/" ; Stop jogging
EndIf
EndIf
Close
Turbo PMAC Script

One should always use edge-triggered logic for jogging and homing in
PLCs, which is what this PLC example uses.
Note

259 PLC Programs


Turbo PMAC Training
PLC Quiz
1. Name four types of PLC programs
2. Which I-Variable determines whether a PLC program will run or not?
3. How does one make PLCs 2, 3, and 10 run automatically at power up or reset?
4. How does one make the Y-Axis move from a PLC program?
5. How does one know whether a PLC is active or not?

260 PLC Programs


Turbo PMAC Training
Time to Practice!
¾ Write a PLC to read the machine input switches (inputs 1-8) from input M-Variables on
your demo rack and activate an LED in response while the switch is closed using the
corresponding output M-Variables for outputs 1-8

¾ Write a PLC to jog motor 1 forward (J+) while one of the tactile switches is held,
backward (J-) while another is held, to closed-loop stop when released (J/), and to
home (HM) when another is pressed, using CMD commands and delays to force the CMD
execution.

¾ Write a PLC to home the motor based on –Lim and Index (Channel C) flags. In the
PLC, disable the position limits (Ixx24 = $20001 for our demo racks), home the motor,
wait for the home to finish, then reenable the limits (Ixx24 = $1 for our demo racks).
Test it using the –Lim flag on your rack’s input panel. Refer to the Turbo SRM entries
for Ixx97, Ixx25, I7mn2, I7mn3, and Ixx12 for more information on homing settings.

261 PLC Programs


Turbo PMAC Training
Additional Exercises
¾ Write a PLC that uses the timer to turn on and off lights at a timed interval of your
choice. Use the countdown timers (Isx11 and Isx12) for this assignment.

¾ Write a PLC that will turn on various lights based upon the pressing of a switch. Use
a latch (edge triggered) to turn on a light based upon the pressing of a momentary
switch. Keep the light on until the switch is pressed again. The next time the switch
is pressed the light should go off.

262 PLC Programs


Turbo PMAC Training
PMAC Data Gathering
What is Data Gathering?
¾ PMAC can acquire data from any of its memory addresses at a sampling
period as low as the servo period (I5049)

¾ Can sample up to 48 addresses, each 24 or 48 bits wide, at once (specified by


I5001-I5048; masked by I5050 and I5051)

¾ PMAC can upload gathered data to the host software to generate plots and
tables to be used for analysis

¾ Useful for:
System Identification
Servo Loop Tuning
Program Debugging
Machine Debugging
Maintenance
Designing Filters

264 Data Gathering


Turbo PMAC Training
Gathering Commands

Command Abbreviation Description


Delete Gather Del Gat Erases the data gathering buffer
Define Gather Def Gat Sets up a data gathering buffer
[{constant}] using all open memory or of the
specified [{constant}] size
Gather Gat Start data gathering on the next
servo interrupt
End Gather End Gat Stop data gathering
List Gather List Gat Report back to the host the
contents of the data gather buffer

265 Data Gathering


Turbo PMAC Training
PMAC Plot Pro2
From within PeWin32Pro2, click ToolsÆPMAC Plot Pro2:

266 Data Gathering


Turbo PMAC Training
Quick Plot
Quick Plot allows the user to configure basic gather and plot settings if only motor data
needs to be gathered

Click here to select which


motors’ data
to gather
Add/remove Issues “Def Gat”
plot items for vertical Issues “Gat”
axes
Issues “End Gat”

Uploads gathered
data to host
Plots selected data

Load saved plot Select which item


configuration to plot on
horizontal axis
267 Data Gathering
Turbo PMAC Training
Specify Motors to Gather
The Motors to Gather Screen, from clicking “Motors to Gather…” on the previous
screen, lists basic gather settings for motor data

Motor Number
Calculated Commanded Data
Measured Data Sets gather period
Output Commands (I5049, in units of
servo cycles)

268 Data Gathering


Turbo PMAC Training
Detailed Plot
Detailed Plot gives the user more control over what to gather and how to plot it

Select gather Issues “Def Gat”


addresses
Issues “Gat”
Data processing
Issues “End Gat”
Plot settings
Uploads gathered
data to host
Plots selected data

Select different plots


that have been
configured

Open plot Load


Save plot Load saved gathered data
config. config.
269 Data Gathering
Turbo PMAC Training
Exporting Plot Data
After clicking “Plot Data” on the “Quick Plot” or “Detail Plot” tabs, click on “Save Plot
File” to export the raw data

270 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Open PMAC Plot Pro2 and then go to the Quick Plot tab.

¾ Click “Motors to Gather…” and then select “Commanded” data from Motor 1, and a
gather period of 1, then click “OK”

271 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ On the Quick Plot screen, choose to plot “Mtr 1 Cmd Pos” on the Left Plot Axis by
clicking on it and then “Add to Left”.

¾ Then, minimize the window, open a new Editor window, and download the code on the
next slide to PMAC.

272 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
/********************* Set-up and Definitions *********************/
Undefine All ; Undefine all coordinate definitions
End Gat; End any data gathering that might be happening presently
Del Gat; Erase any defined gather buffer
Close ; Make sure all buffers are closed
&1 ; Coordinate System 1
#1->1000X ; Assign motor 1 to the X-axis - 1 program unit
; of X is 1000 encoder counts of motor #1

/********************* Motion Program Text *************************/


Open Prog 1 Clear ; Open buffer for program entry, Program #1
Linear ; Blended linear interpolation move mode
Abs ; Absolute mode - moves specified by position
TA 500 ; Set 1/2 sec (500 msec) acceleration time
TS 0 ; Set no S-curve acceleration time
F 5 ; Set feedrate (speed) of 5000 units(cts)/sec
CMD"End Gat" ; Stop gathering
CMD"Del Gat" ; Deletes the gather buffer
CMD"Def Gat" ; Allocates all the available memory as gather buffer
Dwell 0 ; Force CMD lines to execute
CMD"Gat" ; Starts gathering of the data
Dwell 0 ; Force CMD lines to execute
X 10 ; Move X-axis to position 10000
Dwell 500 ; Stay in position for 1/2 sec (500 msec)
X 0 ; Move X-axis to position 0
Dwell 0 ; Force CMD lines to execute
CMD"End Gat" ; Send On-line command to stop data gathering
Dwell 0 ; Force CMD lines to execute
Close ; Close buffer - end of program
Turbo PMAC Script
273 Data Gathering
Turbo PMAC Training
Gathering within a Motion Program
¾ Run the program by entering &1 b1 r into the Terminal window

¾ Bring the PMAC Plot Pro2 back up and click “Upload Data”

¾ Then, click “Plot Data”, and the following plot should load:

Click “Edit Titles” to adjust


the axis titles to make them
match the titles on this
example

274 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Open PMAC Plot Pro2 and then go to the Detail Plot tab, then click “Item to
Gather”

275 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Set the “Gather Period” field to 1, then select only Source 1 by enabling the check box
next to the first >> button. Disable all other sources by clearing their check boxes.

¾ Click the first >> button

276 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Select the “M-Variable” radio button, then type “161” in the “Variable Number” Field,
and click the -> button.
¾ Click “OK”

¾ Back on the “Address to Gather” screen, which should now look like the screen on
the previous slide, click “OK”

277 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Back in the Detail Plot tab, then click “Scaling and Processing”

278 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Double-click “A) Src 1…”

279 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Make sure that all of the fields on your screen match up with these, most importantly,
the Scale Factor field

¾ Then, click “OK” on this screen as well as on the “Scaling and Processing” screen

280 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Back in the Detail Plot tab, then click “Item to Plot”

281 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Click on the first item and then click “Edit”

282 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Configure all of the fields to match this example and then click “OK”, and then “OK”
again on the “Configure Items to Plot” screen

283 Data Gathering


Turbo PMAC Training
Gathering within a Motion Program
¾ Run your program by typing “&1 b1 r” into the Terminal window.

¾ Then, return to the Detail Plot tab and click “Upload Data”

¾ Select the “Motor 1 Cmd Pos vs. Time” plot under the “Selected Plot” list, and then
click “Plot Data” to get the following plot:

Adjust axis titles


with this button
to match this
example

Click here to
hide/show legend

284 Data Gathering


Turbo PMAC Training
Final PLC and Motion Program
Exercises

285
Turbo PMAC Training
The following exercises provide suggested program flow charts. Each step is numbered, and
these numbers are repeated in the comments of corresponding example code which is in the
appendix of this document. The idea is to do by yourself what comes easy enough, and refer to
the examples for help as needed or desired thereby individualizing the level of difficulty.

Exercise 1: Indexing a Motor


Problem:
You have been asked to use PMAC in an indexing application, PMAC must index motor #1, which
drives a leadscrew, a distance of 10 cm, pause at this location for 4 seconds then return to its
original location. Each of the moves must take place in 1 second.

Hardware:
2000 counts per revolution encoder
5:1 gear reduction
1 cm/rev pitch leadscrew
Set Isx92=0 to enable blending

286 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 1: Indexing a Motor
Suggested Flow Chart:

287 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 2: Indexing a Motor
¾ Now, make your program satisfy these requirements:
The desired motion profile has been changed. The system must now move from its zero
location to 10 cm, pause for 4 seconds and then move to 20 cm in 2 more seconds and
pause for 1 second. It then must return to 0 cm in 1.5 seconds.

This machine will be sold to a European company which will write some new programs
for it. They only want to program in centimeters so your programs must also use
centimeters.

A feedrate override switch has also been added to the system. Your programmed pauses
must now change as the feedrate override changes. This means that a 1.5 second pause
will last 3 seconds at 50% feedrate override. Use CMD"%50" in a PLC which checks
machine input 1 for feedrate override.

288 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 2: Indexing a Motor
Suggested Flow Charts:

289 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 3: Conditional Branching

Problem:
The European Company is having a lot of success with your machine and your boss now
has some extra R&D money. He wants you to write another application based on the
same platform. 2 input switches have been connected to PMAC’s machine inputs 1 and
2. He wants these switches to control the motion of the stages as follows:
If machine input 1 is on, the stages should move from 0 cm to 10 cm at a speed
of 1 cm/sec, pause for 1 second then return to 0 cm at the same speed and pause
for 100 milliseconds until looking for the next input.

If machine input 2 is on, the stages should move from 0 cm to -10 cm at a speed
of 2 cm/sec, pause for 1 second, and then return to 0 cm at the same speed and
pause for 100 milliseconds until looking for the next input.

If both machine inputs 1 and 2 are on, or if neither are on, the stages should not
move from 0 cm and should pause for 100 milliseconds until looking for the next
input.

290 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 3: Conditional Branching
Suggested Flow Charts:

291 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 3: Conditional Branching
Suggested Flow Charts (Continued):

292 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 4: X, Y Plotter
Your boss wants you to program his PMAC X, Y plotter to draw the following shape. The
plotter he has is fragile so you cannot move the tool tip faster that 1 inch per second. Both of
the plotter motors have encoders with 500 pulses per revolution and leadscrews that give 1
inch per revolution.

10 inches

10 inches
He wants the shape to be drawn whenever he pushes a button on his desk. Furthermore, he
wants a light to be on while the shape is being drawn and wants the light to be otherwise off.

293 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 4: X, Y Plotter
Suggested Flow Charts:

294 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 5: Mixed Move Modes
¾ Home the motors to quadrature Channel C high
¾ Move three motors (motors 1-3) using Rapid to the starting location (X 5 Y 2 Z 1)
¾ Activate the spindle via CMD"#4J+" (motor 4) and wait until it is up to speed
¾ Cut a complete circle of radius 1 in the X-Y plane using Circle1 mode
¾ PVT move to X 1 Y 1 Z 3 in 1 second with ending speed of 3 user units/s
¾ Rapid to X 0 Y 0 Z 0 and stop spindle (CMD"#4J/")

295 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 5: Mixed Move Modes
Suggested Flow Charts:

296 Final PLC and Motion Program Exercises


Turbo PMAC Training
Exercise 5 Resulting Plot
8000

7000 Motor 1 Position [cts]


Motor 2 Position [cts]
Motor 3 Position [cts]
6000
Motor x Position [cts]

5000

4000

3000

2000

1000

0
-0.5 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5
Time [sec]

297 Final PLC and Motion Program Exercises


Turbo PMAC Training
TURBO PMAC TRAINING
Advanced Topics
Memory and I/O Map
Turbo PMAC Memory Register
X-Memory Y-Memory
8 bits 8 bits 8 bits 8 bits 8 bits 8 bits

$000000
Internal DSP
Memory
$001FFF
$002000
Fixed-Use Calculation Registers
$003FFF
$004000
M-Variable Registers
$005FFF
$006000 External Static
Standard P-Variable Registers Memory
$007FFF (Flash-Backed)
$008000

$009FFF
Standard Q-Variable Registers
$00A000

$03FFFF
User Program and Buffer Storage
$050000
Optional Battery-Backed RAM Registers Optional
$060000 Memory
$063FFF
DPRAM DPRAM
$070000

$0701FF
Bus Interface ICs
$078000
$07B31F
Servo, MACRO, I/O ICs

300 Memory & I/O Map


Turbo PMAC Training
Turbo PMAC Memory Register
¾ Memory register map provides the addresses of all data processed and/or stored in
PMAC

¾ Available User Register


M-, P-, and Q-Variable registers
User Program and Buffer Storage registers
Open registers: X/Y:$0010F0 - $0010FF (set to 0 on power-up), for general use

¾ Data access
Frequently used data are usually accessed by suggested M-variables
If the data in need is not accessible by a suggested M-Variable, the user needs to define an
M-Variable pointing to the data register in order to access the data

301 Memory & I/O Map


Turbo PMAC Training
Register Use Example
¾ Tool tip instantaneous command velocity (XY Plane)
In Motor Register D:$000x86/06 is the “Motor present desired velocity
X-register is whole counts: multiply by 3/(Ixx08*32) to get cts/msec at %100
Y is fractional data: multiply by 3/(Ixx08*32)/16777216 to get units of cts/msec
// Suggested M-variables
M191->L:$0000CF ; #1 X/U/A/B/C-Axis scale factor (cts/unit)
M292->L:$000150 ; #2 Y/V-Axis scale factor (cts/unit)

// Memory Map (Turbo SRM) under Motor Registers


M160->X:$000086,0,24,S ; #1 instant cmd vel register
M260->X:$000106,0,24,S ; #2 instant cmd vel register
M1060->Y:$000086,0,24,U ; #1 instant cmd vel register (Fractional)
M2060->Y:$000106,0,24,U ; #2 instant cmd vel register (Fractional)

// C.S.1 Feedrate Time unit


I5190=60000 ; time unit in minutes

&1 ; address C.S. 1


I5=I5|2 ; turn on PLC activation

// Scale Instantaneous Commanded Velocity to in/min


// And add fractional data (shift 24-bit), 2^24=16777216
Open PLC 1 Clear
Q10=((M160*3/(I108*32))*60000)/M191 ; in/min
Q11=((M260*3/(I208*32))*60000)/M292 ; in/min
Q12=(((M1060*3/(I108*32))*60000)/M191)/16777216 ; in/min(Fractional)
Q13=(((M2060*3/(I208*32))*60000)/M292)/16777216 ; in/min(Fractional)
Q14=Q10+Q12 ; add fraction to whole counts
Q15=Q11+Q13 ; add fraction to whole counts
Q16=(SQRT(Q14*Q14+Q15*Q15)) ; calculate tip cmd velocity
Close

Turbo PMAC Script

302 Memory & I/O Map


Turbo PMAC Training
Dual Port RAM
¾ Dual Port RAM, DPR, or DPRAM
Used in applications that require the controller (PMAC) and the host (PC) to simultaneously
access/share information (Register Mapping needed)
A control scheme that requires external data acquisition to be processed by PC and then
shared with PMAC
Data can be downloaded to or read from PMAC repeatedly at high speed

¾ DPRAM Memory Map


Host Address Offset DPRAM Function Turbo PMAC Address
0x000 Control Panel Function $060000
0x006A Motor Data Reporting Buffer $06001A
0x0676 Background Data Reporting Buffer $06019D
0x0E9E DPRAM ASCII Command Buffer $0603A7
0X0F42 DPRAM ASCII Response Buffer $0603D0
0X1046 Background Variable Read Buffer Control $060411
0X104C Background Variable Write Buffer Control $060413
0X1050 Binary Rotary Program Buffer Control $060414
0X113E DPRAM Data Gathering Buffer Control $06044F
0X1140 Variable-Sized Buffers and Open Use Space $060450
0X3FFC/0XFFFC End of (8k x 16) / (32k x 16) DPRAM $060FFF/$063FFF

303 Memory & I/O Map


Turbo PMAC Training
Kinematics
What is Kinematics?
Forward
Kinematics Motion Program
Motor Axis
Commanded
Position Position
Axis Position
Inverse
Kinematics

¾ Kinematics is the relationship between motor positions and axis positions


Forward kinematics uses motor positions as input to calculate axis positions (tool-tip
location, user units)
Inverse kinematics uses axis positions as input to calculate motor positions (units of counts)

¾ Motion program programming is based on axis position


Users only need to specify the axis trajectory (tool-tip trajectory)
PMAC automatically calculates motor positions via inverse kinematics

305 Kinematics
Turbo PMAC Training
Kinematics Setup
There are two ways to set up axis definitions:

¾ Axis Definition Equations: #n->1000X


Example: #1->1000X
Inverse equation: #1 (motor position) = 1000 X (axis position)
Forward equation: X (axis position) = (1/1000) #1 (motor position)
Only need to specify Axis Definition as inverse kinematics, and then PMAC automatically
inverts the definition to compute motor position

¾ Forward and Inverse Kinematic Subroutines: #n->I


If the relationship between motor positions and axis positions is not linear, simple Axis
Definitions can NOT be used

Need Kinematic Subroutines to specify the nonlinear relationship between motors and axes

Before the execution of a motion program, forward kinematics executes only once to make sure
where the axis starting point is. Can force execution of forward kinematics with the PMATCH
command

Once the axis starting point is established, PMAC uses inverse kinematics to compute
commanded the motor positions

306 Kinematics
Turbo PMAC Training
Reserved Variables for Position
Calculations
¾ If Kinematic Subroutines are used, the following P-Variables and Q-Variables are
reserved for position calculations in Kinematic Subroutines:
P1 through P32 are reserved for positions of motor 1 through 32
Q1 through Q9 are reserved for axis positions in each coordinate system as follows:

Reserved Axis Reserved Axis Reserved Axis


Q-Variable Letter Q-Variable Letter Q-Variable Letter
Q1 A Q4 U Q7 X
Q2 B Q5 V Q8 Y
Q3 C Q6 W Q9 Z

Forward
Kinematic
Subroutines
Motor Position Axis Position Motion Program
Commanded
P1 to P32 Q1 to Q9 Axis Position
Inverse
Kinematic
Subroutines

307 Kinematics
Turbo PMAC Training
Kinematics Subroutines
Setup Example:
// Coordinate system 1, Forward and Inverse kinematics setup sample
&1 ; Addressing Coordinate System 1
Open Forward Clear ; Open & clear forward kinematic buffer
;Q1=f1(P1,P2) ; Axis A position in terms of motor 1&2 positions
;Q2=f2(P1,P2) ; Axis B position in terms of motor 1&2 positions
Close ; Close forward kinematic buffer
Open Inverse Clear ; Open & clear inverse kinematic buffer
;P1=g1(Q1,Q2) ; Motor 1 position in terms of Axis A&B positions
;P2=g2(Q1,Q2) ; Motor 2 position in terms of Axis A&B positions
Close ; Close inverse kinematic buffer

I5150=1 ; Enable C.S.1 kinematic calculation


I5113=10 ; Enable segmentation (10 ms segmentation time)
#1->I ; Define motor 1 using inverse kinematic subroutine
#2->I ; Define motor 2 using inverse kinematic subroutine

Turbo PMAC Script


Step 1: Specify the coordinate system using the subroutines (e.g. &1)
Step 2: Define forward and inverse kinematics subroutines
Use Open Forward/Inverse to write kinematics, Close at the end
f1, f2, g1, g2 are just example function names for simplicity – user must
replace with his or her subroutines/algorithms
Users need to specify kinematic equations
Step 3: Activate kinematics subroutines and segmentation
Isx50=1 enables C.S. kinematic calculation, Isx13 specifies the
segmentation time in ms
Use #n->I in the Axis Definition for each motor using kinematics
308 Kinematics
Turbo PMAC Training
Kinematics Example
Example: 2-axis shoulder-elbow (SCARA) robot.
Tool tip is defined in XY coordinates
A and B are defined as angles in degrees
L1 = 4 inches, L2 = 3 inches

Forward Kinematics:
Express [X,Y] in terms of [A,B]
Y
[X,Y] X = L1cos(A) + L 2cos(A + B)
Y = L1sin(A) + L 2sin(A + B)
B
L2 Inverse Kinematics:
Express [A,B] in terms of [X,Y]
L1 A ⎛ X 2 + Y 2 − L21 − L22 ⎞
B = +cos ⎜⎜−1
⎟⎟
X ⎝ 2L L
1 2 ⎠
⎛ X 2 + Y 2 + L2 − L2 ⎞
A = atan2(Y, X) − cos ⎜ −1 1 2 ⎟
⎜ 2L X + Y ⎟2 2
⎝ 1 ⎠

Note: For cos-1 function, only positive angles are used

309 Kinematics
Turbo PMAC Training
Forward/Inverse Kinematics
End Gat
Del Gat
Close

// Kinematics Assignments
#define KinPosX Q7 ; X-axis pos in mm for kinematics
#define KinPosY Q8 ; Y-axis pos in mm for kinematics
#define Mtr1Pos P1 ; Motor #1 pos. in cts for kinematics
#define Mtr2Pos P2 ; Motor# 2 pos. in cts for kinematics

// Definitions And Substitutions


#define Length1 Q91 ; Linkage 1 length (inches)
#define Length2 Q92 ; Linkage 2 length (inches)
#define Mtr1SF Q93 ; Motor #1 Scale Factor, Counts/User units (deg)
#define Mtr2SF Q94 ; Motor #2 Scale Factor, Counts/User units (deg)
#define TempA Q95 ; Temporary holding register for A calculation (deg)
#define TempB Q96 ; Temporary holding register for B calculation (deg)
#define Xsq_p_Ysq Q97 ; X^2+Y^2
#define L1sq_p_L2sq Q98 ; L1^2+L2^2
#define L1sq_s_L2sq Q99 ; L1^2-L2^2
#define TempCosB Q100 ; cos(B) value
Length1=4 ; Linkage 1 length, 4 inches --UserInput
Length2=3 ; Linkage 2 length, 3 inches --UserInput
Mtr1SF=2000/360 ; Motor #1, cts/deg --UserInput
Mtr2SF=2000/360 ; Motor #2, cts/deg --UserInput
L1sq_p_L2sq=Length1*Length1+Length2*Length2
L1sq_s_L2sq=Length1*Length1-Length2*Length2

// Status Flags
#define Mtr1HmComp M145 ; Motor #1 Home-complete bit (suggested M-variable)
#define Mtr2HmComp M245 ; Motor #2 Home-complete bit (suggested M-variable)
#define CS1_RunTimeError M5182 ; Coordinate System 1 run-time-error bit (suggested M-variable)
Mtr1HmComp->Y:$0000C0,10,1 ; #1 Home-complete bit
Mtr2HmComp->Y:$000140,10,1 ; #2 Home-complete bit
CS1_RunTimeError->Y:$00203F,22,1 ; &1 Run-time-error bit

Turbo PMAC Script

310 Kinematics
Turbo PMAC Training
Forward/Inverse Kinematics
Undefine all
&1 ; Addressing Coordinate System 1

// ============================== Forward Kinematics ====================================== //


Open Forward Clear

If(Mtr1HmComp=1 and Mtr2HmComp=1) ; Homed?


TempA=Mtr1Pos/Mtr1SF ; Motor 1 position in deg
TempB=Mtr2Pos/Mtr2SF ; Motor 2 position in deg
KinPosX=Length1*cos(TempA)+Length2*cos(TempA+TempB)
KinPosY=Length1*sin(TempA)+Length2*sin(TempA+TempB)
Else
CS1_RunTimeError=1 ; Abort and set runtime if not homed
Endif

Close
// ======================================================================================== //

// ============================ Inverse Kinematics ======================================== //


Open Inverse Clear

Xsq_p_Ysq=KinPosX*KinPosX+KinPosY*KinPosY
TempCosB=(Xsq_p_Ysq-L1sq_p_L2sq)/(2*Length1*Length2)
If (ABS(TempCosB)<0.9998) ; Valid solution with 1 degree error?
Q0=KinPosX ; Q0 is atan2 function denominator, KinPosY is numerator
TempA=atan2(KinPosY)-acos((Xsq_p_Ysq+L1sq_s_L2sq)/(2*Length1*sqrt(Xsq_p_Ysq)))
TempB=acos(TempCosB)
Mtr1Pos=Mtr1SF*TempA
Mtr2Pos=Mtr2SF*TempB
Else
CS1_RunTimeError=1 ;Abort and set runtime if impossible solution
Endif

Close
// ======================================================================================== //

Turbo PMAC Script

311 Kinematics
Turbo PMAC Training
Motion Program
Rectangular Trajectory (inside valid tool tip range)
End Gat
Del Gat
Close

&1 ; Address Coordinate System 1


I5150=1 ; Isx50 Coordinate System x Kinematic Calculations Enable
I5113=10 ; Isx13 Coordinate System x Segmentation Time (msec)
#1->I ; Use kinematics to calculate Motor #1 position
#2->I ; Use kinematics to calculate Motor #2 position

Open Prog 1 Clear

Linear ; Linear move mode


Abs ; Absolute move modal
TA 100 ; Acceleration time 100 msec
TS 0 ; S-curve time 0 msec
TM 1000 ; Move time 1000 msec
X 1.5 Y 0 ; Go to starting position X=1.5 Y=0

CMD "EndGat" ; End previous gathering


CMD "DelGat" ; Delete gathering buffer (release buffer)
CMD "DefGat" ; Define gathering buffer
CMD "Gat" ; Start gathering data

X 2 Y 0 ; Go to X=2 Y=0
Dwell 0 ; Stop 0 msec, stop blending
X 4 Y 0 ; Go to X=4 Y=0
Dwell 0 ; Stop 0 msec, stop blending
X 4 Y 3 ; Go to X=4 Y=3
Dwell 0 ; Stop 0 msec, stop blending
X 2 Y 3 ; Go to X=2 Y=3
Dwell 0 ; Stop 0 msec, stop blending
X 2 Y 0 ; Go to X=2 Y=0
Dwell 1000 ; Wait for 1000 msec

CMD "EndG" ; End gathering data

Close
Turbo PMAC Script

312 Kinematics
Turbo PMAC Training
Position Reporting PLC
PLC Position Reporting prevents potential overlapping use and register
conflicts for reporting (Watch Window, reporting to host, etc.)/plotting
purposes. Do not use P1-P32 or Q1-Q9 in this PLC:
#define Actual_X P1001
#define Actual_Y P1002
#define Actual_A P1003
#define Actual_B P1004
#define Actual_Mtr1Pos M162
#define Actual_Mtr2Pos M262
#define CMD_X P2001
#define CMD_Y P2002
#define CMD_A P2003
#define CMD_B P2004
#define CS_Number P2005
#define CMD_Mtr1Pos M161
#define CMD_Mtr2Pos M261
#define Length1 Q91 ; Linkage 1 length (inches)
#define Length2 Q92 ; Linkage 2 length (inches)
#define Mtr1SF Q93 ; Motor#1 Scale Factor, Counts/User units (deg)
#define Mtr2SF Q94 ; Motor#2 Scale Factor, Counts/User units (deg)
Actual_Mtr1Pos->D:$8B
Actual_Mtr2Pos->D:$10B
CMD_Mtr1Pos->D:$88
CMD_Mtr2Pos->D:$108

Open PLC 10 Clear


CS_Number=1
Address&CS_Number ; Select Coordinate System 1
Actual_A=Actual_Mtr1Pos/(I108*32*Mtr1SF)
Actual_B=Actual_Mtr2Pos/(I208*32*Mtr2SF)
Actual_X=Length1*cos(Actual_A)+Length2*cos(Actual_A+Actual_B)
Actual_Y=Length1*sin(Actual_A)+Length2*sin(Actual_A+Actual_B)
CMD_A=CMD_Mtr1Pos/(I108*32*Mtr1SF)
CMD_B=CMD_Mtr2Pos/(I208*32*Mtr2SF)
CMD_X=Length1*cos(CMD_A)+Length2*cos(CMD_A+CMD_B)
CMD_Y=Length1*sin(CMD_A)+Length2*sin(CMD_A+CMD_B)
Close

Turbo PMAC Script

313 Kinematics
Turbo PMAC Training
Example Test Result
Using the Plot Tool to plot Commanded and Actual XY position

Commanded Motion Actual Motion

Plot the commanded motion


Make sure Motors are tuned well
to make sure kinematics is
to avoid nonsensical results
working properly

314 Kinematics
Turbo PMAC Training
Velocity Kinematics
Forward
Kinematics Motion Program
Motor Axis
Commanded
Velocity Velocity
Axis Velocity
Inverse
Kinematics

¾ Used only for PVT moves


¾ Kinematics is the relationship between motor velocities and axis velocities
Forward kinematics uses motor positions and velocities as input to calculate axis velocities
(tool-tip velocity, user units)
Inverse kinematics uses axis positions and velocities as input to calculate motor velocities
(units of counts/msec)

¾ Motion program programming is based on axis position, velocity, and time


Users only need to specify the axis position and velocity trajectories (tool-tip trajectories)
PMAC automatically calculates motor positions and velocities via inverse kinematics

315 Kinematics
Turbo PMAC Training
Reserved Variables for Velocity
Calculations
¾ If Kinematic Subroutines are used, the following P-Variables and Q-Variables are
reserved for velocity calculations in Kinematic Subroutines:
P101 through P132 are reserved for velocities of motor 1 through 32
Q10 is reserved to indicate when to use velocity kinematics
=0 when PVT not in use
=1 when PVT in use
Q11 through Q19 are reserved for axis speeds in each coordinate system as follows:
Reserved Axis Reserved Axis Reserved Axis
Q-Variable Letter Q-Variable Letter Q-Variable Letter
Q11 A Q14 U Q17 X
Q12 B Q15 V Q18 Y
Q13 C Q16 W Q19 Z

Forward
Kinematic
Subroutines
Motor Velocity Axis Velocity Motion Program
Commanded
P101 to P132 Q11 to Q19 Axis Velocity
Inverse
Kinematic
Subroutines

316 Kinematics
Turbo PMAC Training
Velocity Kinematics Example
Example: 2-axis shoulder-elbow (SCARA) robot.
Tool tip is defined in XY coordinates
A and B are defined as angles in degrees
L1 = 4 inches, L2 = 3 inches

Y
[X,Y] & = −L A
X & & & ( )
1 sin (A ) − L 2 A + B sin (A + B )

B & =L A
Y & cos(A ) + L A
1 2 (
& +B )
& cos(A + B)
L2

L1 A [
&B = L2 X cos ( A + B ) + Y sin ( A + B )
& & ]
X L1 L2 sin (B )
& − XX& − YY&
A=
L1 L2 sin (B )
Example Velocity Kinematics Code:
See Turbo PMAC User Manual, pp 265-266.
317 Kinematics
Turbo PMAC Training
PMAC Position Compare
What is Position Compare?
¾ Provides a fast (MHz sampling rate, output rise time in nanoseconds) and accurate
digital output on the EQUn pin of the Servo I.C. in use, where n is the channel number
of the position compare in use
¾ Output is based on the actual position counter – when the hardware counter in the I.C.
becomes equal to the compare register, the output toggles immediately
¾ Often, this output is used to trigger a measurement device or to fire a laser, for
example
¾ Hardware function – no delays in capture; accurate to exact count
¾ Can set up to output a single pulse at a specified capture position, or automatically
increment the capture position to continue to give pulses at programmed intervals

Fractional resolution can be used for position compare as well if


special techniques are used. This section of the presentation only
covers whole count captures.
Note

319 Position Compare


Turbo PMAC Training
Manually Controlling EQUn Output
¾ Example: For Motor #1
¾ Put M116 into a Watch Window; this is the
EQU1 state.
¾ Set desired initial output state to 1 by typing this
in the Terminal Window:

M112=1 M111=1
Turbo PMAC Script
¾ The EQU1 state should now be high; i.e., M116=1 and the EQU1 pin should be putting
+5 V out

320
Turbo PMAC Training
Manually Controlling EQUn Output
¾ Reset the output to zero by typing this in the Terminal Window:

M112=0 M111=1
Turbo PMAC Script

¾ The EQU1 state should now be low; i.e., M116=0 and the EQU1 pin should be putting 0
V out

¾ It can be useful to control the state of EQUn manually using synchronous M-Variables
in a motion program

321 Position Compare


Turbo PMAC Training
Setting Up Position Compare for
Single Pulse Output
1. Convert axis position to motor position, and then to encoder position

2. Set Compare A (Suggested M-Variable Mxx08) and Compare B (Suggested M-Variable


Mxx09) registers to desired values

3. Set Auto-Increment (Suggested M-Variable Mxx10) register to zero

4. Write a 0 to “Position Compare Direct-Write Initial State” (Suggested M-Variable


Mxx12) register, then write a 1 to the “Direct-Write Enable Bit” (Suggested M-Variable
Mxx11) register

5. Move the motor as desired

322 Position Compare


Turbo PMAC Training
Step 1: Converting to Encoder Values
Since position compare functions only in encoder hardware counts, one must convert
from axis position to motor position and then to encoder position as follows:

PE = PM + CH Use this result to program Compare


A, Compare B, and Auto-Increment
PM = (FS ) ⋅ PA + K A registers

K A = (Mxx64) / (Ixx08 ⋅ 32)


C H = Mxx73 + Ixx26 / 16
PE : Encoder position [counts]
PM : Motor position [counts] Set FS to Mxx91 if using X/U/A/B/C
CH : Home compensation [counts] axes, to Mxx92 if using Y or V axes, or
PA : Axis position [user units] to Mxx93 if using Z or W axes
KA : Axis offset [counts]
FS: Axis scale factor [counts/user unit]
Mxx91: Motor xx X/U/A/B/C-Axis scale factor (cts/user unit)
Mxx73: Motor xx Encoder home capture position (cts)
Mxx64: Motor xx Position bias (1/[Ixx08*32] cts)
Ixx26: Motor xx Home Offset (1/16 ct)

323 Position Compare


Turbo PMAC Training
Step 1: Converting to Encoder Values
¾ The equations on the previous page can be implemented in a PLC to calculate the
exact encoder value needed whenever needed.
¾ Example: Preparing an Encoder Value to Use for Motor #1
#define PE P1000 ; Encoder Position [cts]
#define PM P1001 ; Motor Position [cts]
#define CH P1002 ; Home Compensation Value [cts]
#define PA P1003 ; Desired Axis Position for Compare [user units] – User Input
#define KA P1004 ; Axis Offset [counts]
#define Mtr1AxisScaleFactor M191
#define Mtr1HomeCapPos M173
#define Mtr1PosBias M164
#define Mtr1HomeOffset I126
#define Mtr1PosSF I108

I5 = 2 ; Enable Background PLCs


Open PLC 2 Clear
CH = Mtr1HomeCapPos + Mtr1HomeOffset/16
KA = Mtr1PosBias/(Mtr1PosSF*32)
PM = Mtr1AxisScaleFactor*PA+KA
PE = PM + CH ; Encoder Position Value [cts] – Output for User Use
; Now PE can be used for programming Compare A, Compare B,
; or Auto-Increment registers
Disable PLC 2
Close
Turbo PMAC Script

Now just set PA and enable the PLC whenever you want to calculate PE!
324 Position Compare
Turbo PMAC Training
Step 2: Writing to Compare Registers
¾ The EQUn compare output will toggle at Compare A (the front end) and toggle again at
Compare B (the back end)
Thus if EQUn started low, it would be high for the whole region between Compare A and
Compare B, and vice versa

¾ Determine the axis positions at the front and back ends, and then use the process in
Step 1 to convert to encoder values

¾ Then, write the result of the front end into Compare A and the result of the back end
into Compare B

325 Position Compare


Turbo PMAC Training
Example Application
¾ Example: 13” Lead Screw with Pitot Tube on Motor #1
Need to set up position compare to activate EQU1 when the centerline of the Pitot tube is
between 4 and 10 inches on the stage to sample the air pressure in the region from 4”-10”.

Home
Switch
Location
Stage with
Instrument 3.0” Lead Screw

Servo Motor (Motor #1)


Gear Ratio: 1 rev/inch
Encoder: 2000 cts/rev X-Axis [in.]
4 10
Instrument Centerline
Front edge Back edge
0

326 Position Compare


Turbo PMAC Training
Initial Manual Setup Steps
¾ Since the stage is 3.0” wide, the home offset (Ixx26) must be set to 1.5” so the stage
will move into the flange without crushing it. Since the stage must move past the
home switch, Ixx26 must be set with a negative number.

¾ At 1 rev/inch and 2000 cts/rev, 1.5” will be 3000 cts, but since Ixx26 is in units of 1/16
counts, we need to multiply by 16. Type into the Terminal:
I126 = -3000*16 ; Motor 1 home offset (1/16 cts)
Turbo PMAC Script

¾ To make sure the stage starts out at the zero position, type into the Terminal:
#1HM ; Home motor 1
Turbo PMAC Script

327 Position Compare


Turbo PMAC Training
Unit Conversion in Position Window
¾ To watch the position of the X-Axis in inches, open up a Position Window
(ViewÆPosition in PeWin32Pro)

¾ Right-click the window and select “Position and Velocity Units”, and select 2000 Cts
Per Unit with 3 Decimal Places, Position Units of “in”, Time Units of sec, Velocity Units
of in/sec, and then click “Apply”. This will produce inches as the unit for Motor #1

328 Position Compare


Turbo PMAC Training
Step 2: Writing to Compare Registers
¾ Example: 10” Lead Screw with Pitot Tube
In the example, the front edge will be at 4”, and the back edge at 10”
These are axis units (user units) that need to be converted to encoder units (hardware counts)
To convert these values, just set PA (P1003) to your axis value and then enable PLC 2 and store
the value; e.g., in the Terminal Window, type:

P1003 = 4 ; Front edge (inches)


Enable PLC 2 ; Now PE result will be in P1000
P2000 = P1000 ; Store front edge (hardware counts) in P2000
P1003 = 10 ; Back edge (inches)
Enable PLC 2 ; Now PE result will be in P1000
P2001 = P1000 ; Store back edge (hardware counts) in P2001
Turbo PMAC Script

Now write the values to Compare A (Mxx08) and Compare B (Mxx09) and zero the Auto-
Increment register (Mxx10) as follows in the Terminal Window:

M108 = P2000 ; Set Compare A value


M109 = P2001 ; Set Compare B value
M110 = 0 ; Zero the Auto-Increment register

Turbo PMAC Script

329 Position Compare


Turbo PMAC Training
Step 3: Direct-Write Initial-State
¾ One can set the initial state of the EQUn output using Suggested M-Variable Mxx12
To set EQUn low (0 V output), set Mxx12=0
To set EQUn high (+5 V output), set Mxx12=1

¾ The value set Mxx12 is set once the user sets Suggested M-Variable Mxx11=1

¾ In this example, the Pitot tube centerline starts below the 4” mark

¾ Want the instrument to be OFF outside the 4”-10” region, and ON inside it, so one
must set EQUn low initially by typing this into the Terminal Window:
M112=0 M111=1
Turbo PMAC Script

330 Position Compare


Turbo PMAC Training
Step 4: Move the Motor
¾ Now the Single Pulse Output is set up – just need to move the motor to trigger the
pulse
¾ Jog the motor from the home position to the end of the stage by using a jog to 12
inches
At 1 rev/inch and 2000 cts/rev, 12 inches will be at 24000 cts
¾ Want to set the jog to be only 0.1 inch/second to get a smooth sampling of the air
pressure profile, which is 0.4 cts/msec, to which one should set I122
¾ Type in the Terminal:

I122 = 0.4 ; cts/msec – Motor #1 jog speed


#1J=24000 ; Jog to end of traverse
Turbo PMAC Script

Should be able to watch M116 to


see it go high when the axis crosses
4” and go low again after it crosses
10”, and vice versa on the way back

331 Position Compare


Turbo PMAC Training
Example Motion Program
¾ Can manually enable/disable EQUn output in a motion program as well. This example
turns ON at 4”, OFF at 10” when moving forward, and vice versa when moving
backward:

End Gat
Del Gat
Close

&1
Undefine All
#1->2000X

#define Enc1Counter M101


#define Mtr1PosCompA M108
#define Mtr1PosCompB M109
Mtr1PosCompA=8000000 ; Set CompA away from Encoder Counter
Mtr1PosCompB=Mtr1PosCompA ; Set CompB away from Encoder Counter

#define Mtr1PosCompArm M111 ; =1 to arm


#define Mtr1PosCompState M112 ; =0 Off, =1 On
Mtr1PosCompState=0 Mtr1PosCompArm=1 ; Make sure EQU is Off

Turbo PMAC Script

332 Position Compare


Turbo PMAC Training
Example Motion Program
Open Prog 1 Clear
Home 1
ABS
Linear
TA 50
TS 20
TM 950
CMD"End Gat"
CMD"Del Gat"
CMD"Def Gat"
CMD"Gat"
X 4
Dwell 0
Mtr1PosCompState==1 Mtr1PosCompArm==1 ; Manually Enable EQU1 Output
X 10
Dwell 0
Mtr1PosCompState==0 Mtr1PosCompArm==1 ; Manually Disable EQU1 Output

X 12
Dwell 0
CMD"End Gat"
Dwell 0
Close
Turbo PMAC Script

Add this to the code from the previous slide and run it by typing into the Terminal #1J/ &1
B1 R. Watch M116 in the Watch window to see it alternate as the motor moves.

333 Position Compare


Turbo PMAC Training
Example Motion Program Plot
12 1

0.9
X-Axis Commanded Position [inches]

10
0.8

M116 (EQU1 Pin Output State)


0.7
8
0.6

6 0.5

X-Axis Cmd. Pos. 0.4


M116 (EQU1 Output)
4
0.3

0.2
2
0.1

0 0
0 0.5 1 1.5 2 2.5 3
Time [sec]

334 Position Compare


Turbo PMAC Training
Example PLC
¾ Can also do position compare with a PLC. This example sets the front edge at 4” and
the back edge at 10”:
End Gat
Del Gat
Close
&1
Undefine All
#1->2000X
#define Mtr1PosCompA M108
#define Mtr1PosCompB M109
Mtr1PosCompA=8000000 ; Set CompA away from Encoder Counter
Mtr1PosCompB=Mtr1PosCompA ; Set CompB away from Encoder Counter
#define Mtr1PosCompArm M111 ; =1 to arm
#define Mtr1PosCompState M112 ; =0 Off, =1 On
Mtr1PosCompState=0 Mtr1PosCompArm=1 ; Make sure EQU1 is Off
// User Defined
#define PE P1000
#define PA P1003
#define EdgeA P8000 ; User Defined
EdgeA=4 ; Turn On @ 4 inches
#define EdgeB P8001 ; User Defined
EdgeB=10 ; Turn Off @ 10 inches
I5=2 ; Enable Background PLCs
Open PLC 1 Clear
CMD"#1HM"
I5111=10*8388608/I10 While(I5111>0) EndW ; Wait for motor to start moving
While(M133=0 or M140=0 or M145=0) EndW ; Wait for home to complete
Turbo PMAC Script

335 Position Compare


Turbo PMAC Training
Example PLC
PA = EdgeA
Enable PLC 2 I5111=10*8388608/I10 While(I5111>0) EndW ; Wait for PLC 2 to run
Mtr1PosCompA=PE
PA = EdgeB
Enable PLC 2 I5111=10*8388608/I10 While(I5111>0) EndW ; Wait for PLC 2 to run
Mtr1PosCompB=PE
Mtr1PosCompState=0 Mtr1PosCompArm=1 ; Make sure EQU1 is OFF Initially

I5111=10*8388608/I10 While(I5111>0) EndW ; 10 msec delay


CMD"#1J=24000" ; Jog to 12 inches
CMD"End Gat"
CMD"Del Gat"
CMD"Def Gat"
CMD"Gat"
I5111=10*8388608/I10 While(I5111>0) EndW ; Force CMDs
While(M133=0 or M140=0) EndW ; Wait for move complete (status bits are set)
CMD"End Gat"
I5111=10*8388608/I10 While(I5111>0) EndW ; 10 msec delay
Mtr1PosCompA=8000000 ; Set CompA away from Encoder Counter
Mtr1PosCompB=Mtr1PosCompA ; Set CompB away from Encoder Counter
Disable PLC 1 ; Run Once
Close
Turbo PMAC Script

Add this code to that of the previous page, and then run the PLC by typing #1J/ Enable
PLC 1 in the Terminal Window.

336 Position Compare


Turbo PMAC Training
Example PLC Plot
12 1

0.9
X-Axis Commanded Position [inches]

10
0.8

M116 (EQU1 Pin Output State)


0.7
8
0.6
X-Axis Cmd. Pos.
6 M116 (EQU1 Output) 0.5

0.4
4
0.3

0.2
2
0.1

0 0
0 0.5 1 1.5 2
Time [sec]

337 Position Compare


Turbo PMAC Training
Setting Up Position Compare for
Auto-Incrementing
1. Convert axis position motor position, and then to encoder position

2. Write auto-increment encoder value into the “Auto-Increment” register (Suggested


M-Variable Mxx10)

3. Write the encoder value at the front edge of the position compare interval into
“Compare A” register (Suggested M-Variable Mxx08) and the back edge of the
position compare interval minus the auto-increment value into “Compare B” register
(Suggested M-Variable Mxx09)

4. Write a 0 to “Position Compare Direct-Write Initial State” (Suggested M-Variable


Mxx12) register and write a 1 to the “Direct-Write Enable Bit” (Suggested M-Variable
Mxx11) register

5. Move the motor as desired

338 Position Compare


Turbo PMAC Training
Step 2: Auto-Increment
¾ When using Auto-Increment, PMAC will automatically add the value in Suggested M-
Variable Mxx10 to the back edge (Mxx09) value every time the motor reaches the front
edge (Mxx08), and will add Mxx10 to Mxx08 (the front edge) every time the encoder
reaches the back edge of the region

¾ Using this feature, one can automatically activate the output of EQUn at regular
intervals instead of needing to set up the single pulse repeatedly

339 Position Compare


Turbo PMAC Training
Example Application
¾ Example: 12” Lead Screw with Laser on Motor #1
Need to set up position compare to activate EQU1 for 1.0” intervals with a 0.5” pitch to
perforate paper with a laser
Home
Switch
Location
Stage with Instrument
3.0” Lead Screw

Servo Motor (Motor #1)


Gear Ratio: 1 rev/inch
Encoder: 2000 cts/rev
X-Axis [in.]
10
Instrument Centerline 0
Lasing regions

This example assumes that PLC 2 (the example PLC given earlier
used to convert Axis Position to Encoder Position) with its associated
Macro definitions is still in PMAC.
Note

340 Position Compare


Turbo PMAC Training
Magnified View of X-Axis
¾ Need to set Auto-Increment (Mxx10) register to set up each subsequent position
compare interval

Mxx10

B0 A0 B1 A1 X-Axis [in.]

12
2” 2.5” 3.5” 4”
0 Laser will be
ON in this
Mxx08: region
Back
Mxx09 = B1 − Mxx10
Front edge of Front edge
edge of first of next
Mxx09 first lasing lasing
lasing region region
Laser region
starting
point

This diagram is in inches for the sake of clarity.


Convert from axis position to encoder counts before setting Mxx08,
Mxx09, Mxx10.
Note

341 Position Compare


Turbo PMAC Training
Initial Manual Setup Steps
¾ Since the stage is 3.0” wide, the home offset (Ixx26) must be set to 1.5” so the stage
will move into the flange without crushing it. Ixx26 is negative because the stage
moves past the flange home switch.

¾ At 1 rev/inch and 2000 cts/rev, 1.5” will be 3000 cts. Type into the Terminal:
I126 = -3000 ; Motor 1 home offset (cts)
Turbo PMAC Script

¾ To make sure the stage starts out at the zero position, type in the Terminal:

#1HM ; Home motor 1


Turbo PMAC Script

¾ Now move the stage such that the laser begins between 2” (B0) and 2.5” (A0) before
activating the position compare. Type into the Terminal:

!X 2.25 ; Move X-Axis to 2.25” (between 2.0” and 2.5”)


Turbo PMAC Script

342 Position Compare


Turbo PMAC Training
Step 2: Auto-Increment
¾ When the encoder reaches the value set in Mxx08, PMAC will add the value in Mxx10
to Mxx09

¾ Thus, Mxx10 must be set such that when the encoder reaches the front edge, the
Mxx09 will be incremented so that the back edge is in the correct location to form the
end of the active region

¾ In our example, Mxx10 needs to be set to 1.5” to accomplish this. Type into the
Terminal:
M110 = 1.5*2000 ; Set Auto-Increment register (1.5 in. *2000 cts/in = 3500 cts)

Turbo PMAC Script

Convert the Axis Position directly to Encoder Position using only the
axis scale factor (FS) for Mxx10 because it is an incremental value;
i.e., the home offset terms are not needed because Mxx10 is relative to
terms (Mxx08 and Mxx09) that consider them already.
Note

343 Position Compare


Turbo PMAC Training
Step 3: Writing to Compare Registers
¾ Set Mxx08 (Compare A) to the encoder position value of the front edge of the first
region where you desire EQUn to be active
For our example, type into the Terminal:

P1003 = 2.5 ; Inches


Enable PLC 2 ; Convert to encoder counts
M108 = P1000 ; Set Compare A
Turbo PMAC Script

¾ Set Mxx09 equal to the encoder position value of the back edge of the first active
region minus Mxx10

Mxx09 = B1 − Mxx10
Compare B Back edge of first active
region Auto-Increment Value

For our example, type into the Terminal:


P1003 = 3.5 ; Inches
Enable PLC 2 ; Convert to encoder counts
M109 = P1000 – M110 ; Set Compare B
Turbo PMAC Script

344 Position Compare


Turbo PMAC Training
Step 4: Direct-Write Initial-State
¾ One can set the initial state of the EQUn output using Suggested M-Variable Mxx12
To set EQUn low (0 V output), set Mxx12=0
To set EQUn high (+5 V output), set Mxx12=1

¾ The value set Mxx12 is set once the user sets Suggested M-Variable Mxx11=1

¾ In this example, the laser centerline starts below the 2.5” mark

¾ Want the instrument to be OFF outside the first region, and ON inside it
(X [2.5”,3.5”)), so one must set EQUn low initially by typing this into the Terminal
Window:
M112=0 M111=1
Turbo PMAC Script

345 Position Compare


Turbo PMAC Training
Step 5: Move the Motor
¾ Jog the motor from the home position to the end of the stage by using a jog to 12
inches
At 1 rev/inch and 2000 cts/rev, 12 inches will be at 24000 cts

¾ Want to set the jog to be only 2.0 inch/second to completely perforate the paper with
the laser, which is 8 cts/msec, to which one should set I122

¾ Type in the Terminal:

I122 = 8 ; cts/msec – Motor #1 jog speed


#1J=24000 ; Jog to end of traverse
Turbo PMAC Script

Should be able to watch M116 to see it go


high when the axis crosses 2.5” and go
low again at 3.5”, then go high again at 4”
and low again at 5”, etc.

346 Position Compare


Turbo PMAC Training
Example Motion Program
¾ Will move X-Axis from 0 to 12 inches, turning the laser ON and OFF between 2.5” and
3.5”, 4” and 5”, 5.5” and 6.5”, etc.:

End Gat
Del Gat
Close

&1
Undefine All
#1->2000X

#define PE P1000 ; Encoder Position [cts]


#define PA P1003 ; Desired Axis Position for Compare [user units] – User Input

#define Enc1Counter M101


#define Mtr1PosCompA M108
#define Mtr1PosCompB M109
#define Mtr1AutoInc M110
#define Mtr1AxisScaleFactor M191
Mtr1PosCompA=8000000 ; Set CompA away from Encoder Counter
Mtr1PosCompB=Mtr1PosCompA ; Set CompB away from Encoder Counter

#define Mtr1PosCompArm M111 ; =1 to arm


#define Mtr1PosCompState M112 ; =0 Off, =1 On
Mtr1PosCompState=0 Mtr1PosCompArm=1 ; Make sure EQU is Off

I126 = -3000 ; Motor 1 home offset (cts)


Turbo PMAC Script

347 Position Compare


Turbo PMAC Training
Example Motion Program
Open Prog 2 Clear
Home 1
ABS
Linear
TA 50
TS 20
TM 950

X 2.25 ; Inches (move to initial pos. between Comp. B and Comp. A)


Dwell 0
// Set up Position Compare
PA = 1.5 Dwell 10; Inches
Mtr1AutoInc = PA*Mtr1AxisScaleFactor ; Convert and set Auto-Inc.

PA = 2.5 Dwell 10; Inches


Enable PLC 2 Dwell 10; Convert to encoder counts
Mtr1PosCompA = PE Dwell 10; Set Compare A

PA = 3.5 Dwell 10; Inches


Enable PLC 2 Dwell 10; Convert to encoder counts
Mtr1PosCompB = PE - Mtr1AutoInc Dwell 10; Set Compare B
Turbo PMAC Script

Add this to the code from the previous slide.

348 Position Compare


Turbo PMAC Training
Example Motion Program
Mtr1PosCompState==0 Mtr1PosCompArm==1 ; Make sure EQU1 is Off
Dwell 0
CMD"End Gat"
Dwell 0
CMD"Del Gat"
Dwell 0
CMD"Def Gat"
Dwell 0
CMD"Gat"
Dwell 0
X 12 ; Move to 12 inches
Dwell 0
CMD"End Gat"
Dwell 0
Close

Turbo PMAC Script

Add this to the code from the previous slide and run it by typing into the Terminal #1J/
&1 B2 R. Watch M116 in the Watch window to see it alternate as the motor moves.

349 Position Compare


Turbo PMAC Training
Example Motion Program Plot
12 1

X-Axis Commanded Position [inches] 0.9


10
0.8

M116 (EQU1 Pin Output State)


0.7
8
0.6

6 0.5

0.4
4
0.3

0.2
2
0.1

0 0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time [sec] X-Axis Cmd. Pos.
M116 (EQU1 Output)

350 Position Compare


Turbo PMAC Training
Example PLC
End Gat
Del Gat
Close

&1
Undefine All
#1->2000X

#define PE P1000 ; Encoder Position [cts]


#define PA P1003 ; Desired Axis Position for Compare [user units] – User Input

#define Enc1Counter M101


#define Mtr1PosCompA M108
#define Mtr1PosCompB M109
#define Mtr1AutoInc M110
#define Mtr1AxisScaleFactor M191
Mtr1PosCompA=8000000 ; Set CompA away from Encoder Counter
Mtr1PosCompB=Mtr1PosCompA ; Set CompB away from Encoder Counter

#define Mtr1PosCompArm M111 ; =1 to arm


#define Mtr1PosCompState M112 ; =0 Off, =1 On
Mtr1PosCompState=0 Mtr1PosCompArm=1 ; Make sure EQU is Off

I126 = -3000 ; Motor 1 home offset (cts)


I122 = 8.0 ; cts/msec – Motor #1 jog speed
Turbo PMAC Script

351 Position Compare


Turbo PMAC Training
Example PLC
Open PLC 1 Clear
CMD"#1HM"
I5111=10*8388608/I10 While(I5111>0) EndW ; Wait for motor to start moving
While(M133=0 or M140=0 or M145=0) EndW ; Wait for home complete (status
bits are set)

CMD"#1J=4500"
; Jog to 2.25 inches
I5111=10*8388608/I10 While(I5111>0) EndW ; 10 msec delay
While(M133=0 or M140=0) EndW ; Wait for jog to complete (status bits are set)

// Set up Position Compare


PA = 1.5
Mtr1AutoInc = PA*Mtr1AxisScaleFactor ; Convert to encoder counts and set Auto-Inc.

PA = 2.5
Enable PLC 2 I5111=10*8388608/I10 While(I5111>0) EndW ; Wait for PLC 2 to run
Mtr1PosCompA = PE

PA = 3.5
Enable PLC 2 I5111=10*8388608/I10 While(I5111>0) EndW ; Wait for PLC 2 to run
Mtr1PosCompB = PE - Mtr1AutoInc

Turbo PMAC Script

352 Position Compare


Turbo PMAC Training
Example PLC
Mtr1PosCompState=0 Mtr1PosCompArm=1 ; Make sure EQU is OFF Initially
I5111=10*8388608/I10 While(I5111>0) EndW ; 10 msec delay
CMD"#1J=24000" ; Jog to 12 inches
CMD"End Gat"
CMD"Del Gat"
CMD"Def Gat"
CMD"Gat"
I5111=10*8388608/I10 While(I5111>0) EndW ; Wait for motor to start moving
While(M133=0 or M140=0) EndW ; Wait for move to complete (status bits are set)
CMD"End Gat"
I5111=10*8388608/I10 While(I5111>0) EndW ; Force CMD to execute
Mtr1PosCompA=8000000 ; Set CompA away from Encoder Counter
Mtr1PosCompB=Mtr1PosCompA ; Set CompB away from Encoder Counter
Disable PLC 1 ; Run Once
Close
Turbo PMAC Script

Put all the code from this and the previous two slides together, download to PMAC, then run by
typing #1J/ Enable PLC 2 into the Terminal Window. You can monitor the EQU1 output
by watching M116 in a Watch Window.

353 Position Compare


Turbo PMAC Training
Example PLC Plot
12 1

X-Axis Commanded Position [inches] 0.9


10
0.8

M116 (EQU1 Pin Output State)


0.7
8
0.6

6 0.5

0.4
4
0.3

0.2
2
0.1

0 0
0 0.5 1 1.5 2 2.5 3
Time [sec] X-Axis Cmd. Pos.
M116 (EQU1 Output)

354 Position Compare


Turbo PMAC Training
Evolution of
Controller / Amplifier Interface

355
Turbo PMAC Training
Closed Loop Servo
Desired Position (Motion Program Input)
Desired Velocity (±10V)
Desired Torque (± 10V)
Desired Phase Current (Sine Wave)
Desired PWM Values (1 to 15 kHz)
+
+ A
Trajectory Position + Velocity Current Power Current
Generator
Commutator + - B
- Filter - Filter Filter Block C Sensors
Interpolation -
ADC
d
dt
ADC

Actual Actual Actual


Position Velocity Rotor Angle Actual
Phase Current Gear
Ratio
E Motor

Load

Load Position
(Position) (Velocity) (Torque) (Commutation) (PWM) Feedback

PMAC2
PMAC
SMCC
MCC PWM
Amplifier
MACRO
SERCOS

Classic Amplifier
356
Turbo PMAC Training
Tasks in Different Types of Amplifiers
1. Closing position loop (always inside controller)
2. Closing velocity loop
3. Commutation
4. Closing current loop
5. Powering (always inside amplifier)

Amplifier Tasks inside Tasks inside Command Type Signal Type


(Controller to Amplifier) (Controller to
Type Controller Amplifier Amplifier)

Velocity 1 2, 3, 4, 5 Desired Velocity ± 10 V DAC


Mode Command

Torque 1, 2 3, 4, 5 Desired Torque ± 10 V DAC


Mode Command

Sine Wave 1, 2, 3 4, 5 Desired Analog Two


Input Voltage Command Sinewave
Voltage
(DAC A&B)
Power 1, 2, 3, 4 5 3 Phase Voltage PWM Top
Block Command and Bottom
(Direct PWM)

357 Evolution of Controller/Amplifier Interface


Turbo PMAC Training
Velocity-Mode Amplifiers

¾ Velocity loop and current loop closed in amplifier

¾ Commutation performed in motor (brush DC) or amplifier (brushless)

¾ Velocity-loop parameters are load dependent and must be set by machine builder

¾ Typically analog velocity loop closure


Gains not subject to digital limitations
Gains not easily adjustable during application

358 Evolution of Controller/Amplifier Interface


Turbo PMAC Training
Torque-Mode Amplifiers
¾ Current loop closed in amplifier

¾ Commutation performed in motor (brush DC) or amplifier (brushless)

¾ Velocity loop must be closed in controller


Subject to digital limitations

¾ Amplifier tasks not load-dependent


Can be set by amp manufacturer

359 Evolution of Controller/Amplifier Interface


Turbo PMAC Training
Sinewave-Input Amplifiers

¾ Velocity loop, commutation performed in controller (e.g. PMAC)

¾ Two analog voltage commands for phase currents

¾ Phase current loops closed in amplifier

¾ Almost always analog current loop

¾ Typically linear modulated power transistors

360 Evolution of Controller/Amplifier Interface


Turbo PMAC Training
Power-Block Amplifiers
¾ Velocity loop, commutation, current loop performed in controller (e.g. PMAC)

¾ 3-phase voltage commands sent to amplifier, encoded as top & bottom PWM pairs

¾ These are actual on/off commands for power transistors

¾ Actual phase current values reported back as serial digital words

361 Evolution of Controller/Amplifier Interface


Turbo PMAC Training
Commutation

362
Turbo PMAC Training
Electromagnetic Force
S
(South Pole)

Conductor
B (Armature)
(Magnetic Field) i

L F (Force)

N
(North Pole)

F = (i × B )L
363 Commutation
Turbo PMAC Training
DC Brush Motor Commutation

¾ Commutation occurs automatically inside the motor by mechanical brushes passing over
the coils on the rotor
¾ Field on stator, Armature on rotor

Stator (Field)
Stator (Field)
N
N Rotor (Armature)
N Rotor (Armature)
N

Commutator
S (Brush)
S
S
S

DC Brush DC Brush
(Permanent Magnet) (Wound Field)
364 Commutation
Turbo PMAC Training
DC Brushless (AC Synchronous)
Motor Commutation
Phase A
Ia Stator (Armature)

Rotor (Field)

N
Phase B
S

Ib Ic=-(Ia+Ib)

Phase C

Id
Rotor
Iq Angle DC Brushless
Ib
Ic (3 Phase,1 Pole Pair)

Ia Itotal
Id (Magnetization Current) = 0
Iq (Quadrature current) = Desired Torque
Park-Clark Phasing : To find rotor magnetic orientation
Transformation (Rotor Angle)
365 Commutation
Turbo PMAC Training
3-Phase, 2-Pole Pairs Commutation
A A A A A A A

C
C

C
B

B
C

C
C
B

B
A A A A A A A

Half Mechanical Revolution


0° 30° 60° 90° 120° 150°
High 180° High
A Off Off
Low Low
High High

B Off Off
Low Low
High High

C Off Off
Low Low

0° 60° 120° 180° 240° 300°


360°
Full Commutation Cycle
366 Commutation
Turbo PMAC Training
AC Induction (AC Asynchronous)
Commutation

Phase A Phase A
Ia

Phase B Phase B
N
Ib

S
Phase C Phase C
Ic

AC Induction AC Induction
Stationary (No Current) Rotating (Current Induced)

367 Commutation
Turbo PMAC Training
AC Induction Vector Analysis
¾ No permanent magnet on rotor, No phasing
¾ Direct current (Ixx77) needed for magnetizing rotor conductors
¾ Slip Frequency Gain (Ixx78) : Difference between input phase frequency and mechanical
rotation frequency

Ia

Id Rotor
Ib Iq Angle
Ic
Ia Itotal
Ib Ic=-(Ia+Ib)
Park-Clark
Transformation
Id (Magnetization Current) ≠0
Iq (Qaudrature current) = Desired Torque

368 Commutation
Turbo PMAC Training
AC Induction Setup
¾ Two Methods (Refer to Geo Brick User Manual):
No Encoder (Micro-Stepping), with Encoder
¾ Ixx77 is set to achieve desired Torque and Speed

¾ Ixx78 is set to achieve desired acceleration to rated speed

369 Commutation
Turbo PMAC Training
Stepper Motor

370 Commutation
Turbo PMAC Training
PMAC/PMAC2 Commutation with
Analog Current Loop

DC AC
Magnetization
I d' I a' + Va va
Current DAC PI PWM
Direct Current
Ix77 Command dq - Ia

to
Phase A Current Loop
abc
I q'
Torque Command I b' + Vb vb
from Position/ DAC PI PWM E
Velocity Servo Quadrature
- Ib
Current Command
Θe -
Phase B Current Loop -
Ixx78 SG -
- Vc vc
PWM
- +
+ Balance Loop
Θr
1/s
+
PMAC Amplifier

371 Commutation
Turbo PMAC Training
PMAC2 Commutation with Digital
Current Loop
DC AC

Vd va
Id + + Va
Magnetization
Current Direct Current PI PWM
Ix77 Command - -
dq Vb vb
to E
P PWM
abc

Vq Vc
vc
PWM
Direct Current Loop
Θ
Iq + + Id Ia ia
from Position/ PI ADC
Velocity Servo Quadrature
Current Command - abc
-
P to
Iq dq Ib ib
ADC
Quadrature Current Loop
Θe
+ + Θr
SG 1/s
Ixx78
PMAC Amplifier

372 Commutation
Turbo PMAC Training
PMAC2 Digital PWM Generation (Per
Phase)
New Command Loaded
Ixx66 at Counter Turnaround
I7m00+1
PWM
Command

PWM PWM
Command Counter
Range Range Time
Servo
4 x I7m00+6
Interrupt
PWM_CLK Generated
Cycles PWM
Up/Down Here
Counter Clock is 120MHz Counter
-I7m00-2
-Ixx66

PWM
Top Signal

PWM
Bottom Signal
Deadtime
(I7m04)
373 Commutation
Turbo PMAC Training
PMAC Position Following
What is Position Following?

¾ PMAC can tell one motor to follow the encoder of another motor to try to match its
position

¾ The commanded position of the follower motor follows the actual position of the
master motor

¾ Can adjust Ixx07 and Ixx08 of each motor to create an electronic gearing relationship

375 PMAC Position Following


Turbo PMAC Training
Position Following Block Diagram
Ixx05 Master (HW) Position Address
Encoder Conversion Ixx06 Following Enable & Mode
Table Ixx07 Master Scale Factor
Ixx05 Ixx08 Position Loop (Load) Scale Factor
Ixx09 Velocity Loop (Motor) Scale Factor
HW

Ixx06
$3501-$35C0 Can be
Ixx07 changed
on the fly
Trajectory
Command CP + + FE + To DAC
Ixx08 PI
Can be changed on
- -
Should not be
the fly, but doing so is AP changed on Actual
not suggested for D the fly Motor
inexperienced users Position
Ixx09

Ixx08
Actual
Load
Position

376 PMAC Position Following


Turbo PMAC Training
Setting Up Position Following
1. Kill the follower and master motors.

2. Set Ixx05 of the follower equal to the Processed Data Address of the encoder
conversion table (ECT) entry of the master (must be an X register).

3. Set Ixx06 = 1 to enable normal mode following or set Ixx06 = 3 to enable offset mode
following.

4. Set Ixx07, Motor xx Master Scale Factor, to the desired value (application dependent)
for electronic gearing.

5. Set Ixx08, Motor xx Position Scale Factor, to the desired value (application
dependent) for electronic gearing.

6. Set Ixx09 = Ixx08 if Ixx03 = Ixx04.

7. Retune Kp and Kd if Ixx08 or Ixx09 were changed.

377 PMAC Position Following


Turbo PMAC Training
Setting Ixx05
¾ Look in the encoder conversion table (ECT) (ConfigureÆEncoder Conversion Table)
and identify the entry number corresponding to the encoder you want your follower to
follow.

In this example screen, ECT entry 1 is


1/T extension of motor 1’s incremental Processed
encoder Data Address

¾ Set Ixx05 to the Processed Data Address of the desired entry.


¾ The addresses are given by @I8000-@I8191 for lines 1 to 192 of the ECT, respectively.
¾ For example, to set I205 to point to the output of entry 1:
I205=@I8000 ; Motor 2 master position is ECT entry 1 output address
; same as I205=$3501 in this example

Turbo PMAC Script

378 PMAC Position Following


Turbo PMAC Training
Normal Mode vs. Offset Mode
¾ Ixx06 can take these values for different following modes:

Ixx06 Setting Description


0 Following disabled, normal mode
1 Following enabled, normal mode
2 Following disabled, offset mode
3 Following enabled, offset mode

¾ Normal mode: Follower motor’s commanded position for a programmed move is


calculated as the programmed position minus the master position. Reported
position is actual position. Follower motor’s coordinate system is absolute.
¾ Offset mode: Follower motor’s commanded position for a programmed move is
simply the programmed position. The reported position is the actual position
minus the master position. Follower motor’s coordinate system is attached to the
encoder position of the master motor.

379 PMAC Position Following


Turbo PMAC Training
Electronic Gearing
Mechanical Analogy:

ΔPm: Master Displacement

ΔPf: Follower Displacement

Number of Teeth on Master


Gear: Ixx07
Number of Teeth on
Follower Gear: Ixx08

380 PMAC Position Following


Turbo PMAC Training
Electronic Gearing
Position change of

⎛ Ixx07 ⎞
follower

ΔPf = ⎜ ⎟ΔPm
⎝ Ixx08 ⎠
Position change of master

¾ For this position-following function, Ixx07 and Ixx08 can be thought of as the number
of teeth on meshing gears in a mechanical coupling.

¾ Ixx07 may be changed on the fly to permit real-time changing of the gear ratio, but
Ixx08 may not (unless the user modifies the servo loop gains on the fly as well, but
doing so while the servo loop is closed is not recommended).

¾ Ixx08 should therefore be set to a large enough value to get the required resolution of
ratio changes.

If the user changes Ixx08 or Ixx09, the user must retune Kp and Kd,
respectively. The motor could behave erratically if not retuned.
WARNING

381 PMAC Position Following


Turbo PMAC Training
Retuning Kp and Kd
¾ If modifying Ixx08, change Kp (Ixx30) and Kd (Ixx31) as such:

Ixx08old Ixx08new
K p ,new = K p ,old K d , new = K d , old
Ixx08new Ixx08old

¾ If modifying Ixx09, change Kd (Ixx31) as such:

Ixx09old
K d , new = K d , old
Ixx09new

These modifications are only if the user wants to preserve the tuning
that existed before configuring the Master/Follower setup; i.e.,
alternatively, the user can manually retune all of the servo
algorithm’s gains after enabling following.
Note
382 PMAC Position Following
Turbo PMAC Training
Position Following Setup Example
¾ In this example, motor 2 is following motor 1 using Normal Mode settings with a gear
ratio of 2 master revolutions to 1 follower revolution:
#define MaxSF 8388607 ; Maximum scale factor value
#define PrevIxx08 P133 ; Store previous Ixx08 for user calculations
#define PrevIxx09 P134 ; Store previous Ixx09 for user calculations
#define RatioIxx08 P135 ; Ratio of new Ixx08 over old Ixx08
#define RatioIxx09 P136 ; Ratio of new Ixx09 over old Ixx09
#1k#2k ; Kill motors 1 and 2
I205=@I8000 ; Set motor 2 to use ECT output of motor 1’s
; 1/T extension entry at its master position
I206=1 ; Enable normal following for motor 2
I207=MaxSF/2056 ; Set master scale factor to 1/2056 max scale factor
PrevIxx08=I208 ; Store previous I208 value
PrevIxx09=I209 ; Store previous I209 value
I208=I207*2 ; Set follower scale factor to 2*master S.F.
; This allows follower displacement to be 1/2 the master
; displacement
I209=I208 ; Set Ixx09=Ixx08 since Ixx03=Ixx04
RatioIxx08=I208/PrevIxx08 ; Compute ratio of old to new Ixx08
RatioIxx09=I209/PrevIxx09 ; Compute ratio of old to new Ixx09
I230=I230/RatioIxx08 ; Retune Kp
I231=I231*RatioIxx08/RatioIxx09 ; Retune Kd
Turbo PMAC Script

383 PMAC Position Following


Turbo PMAC Training
Use Master-Follower If:
¾ Too expensive for tight control of an axis
E.g. high power spindle or conveyor motor

¾ Too difficult for tight control of an axis

¾ Writing a master/follower motion program is substantially easier (slaving to


commanded position recommended here)
Examples: coil winding, thread cutting

384 PMAC Position Following


Turbo PMAC Training
Coordination vs. Slaving
¾ “Coordination” consists of programming all axes identically, rather than using
position following

¾ Use coordination instead of position following when:

¾ You have good control of all axes

¾ No axis is predominant in function


If you cannot decide which should be master, coordinate!

¾ Easy to describe simultaneous motion


I.e. start, stop, turn together

385 PMAC Position Following


Turbo PMAC Training
Noise Issues to Consider
¾ If the source (master) motor encoder signal is very noisy or erratic, the target
(follower) motor will track that noise exactly and even amplify it if the electronic
gearing intends to amplify the motion

¾ Can filter some of this noise with encoder conversion table-based filters, but
generally one should use time-based slaving instead if master motor has a noisy
encoder signal

¾ Can also assign two motors identical axis definitions and have PMAC compute the
moves for each motor identically (Coordination)
This takes slightly more computational power but can be less noisy than position following

386 PMAC Position Following


Turbo PMAC Training
Position Following Hands-On
¾ On your demo boxes, according to the procedure given herein, set up motor #2
as the follower and motor #1 as the master, and then jog motor 1.

¾ Try different master/follower ratios using Ixx07 for motor #2.

387 PMAC Position Following


Turbo PMAC Training
Coordinate System
Transformation

388
Turbo PMAC Training
Axis Matrix Transformation
Y

Scaling
Y'
X
X'
θ, Rotation

Displacement

¾ Matrix Transformation can only be used with Axes [X,Y,Z]

¾ By specifying Displacement vector and Rotation/Scaling matrix, it is convenient to


program the same trajectory in different locations

¾ Very useful for repeated trajectory patterns

389 C.S. Transformation


Turbo PMAC Training
Rotation Matrix and Displacement
Transformation Equation

⎡ X ' ⎤ ⎡ Q ( n) Q(n + 1) Q(n + 2)⎤ ⎡ X ⎤ ⎡ Q(m) ⎤


⎢ '⎥ ⎢ ⎥ ⎢ Y ⎥ + ⎢ Q(m + 1) ⎥
Y
⎢ ⎥ ⎢ = Q ( n + 3) Q ( n + 4 ) Q ( n + 5) ⎥⎢ ⎥ ⎢ ⎥
⎢ Z ⎥ ⎢⎣Q(n + 6) Q(n + 7) Q(n + 8) ⎥⎦ ⎢⎣ Z ⎥⎦ ⎢⎣Q(m + 2)⎥⎦
'
⎣ ⎦
Displacement vector
Original coordinate
Rotation/Scaling matrix
Transformed coordinate

¾ Once the transformation is defined, every move thereafter will be forced to go through
the transformation; i.e., PMAC will transform the X, Y, Z positions the user programs
and then commands the motors using the transformed vectorial result

¾ The transformation can be changed on the fly

¾ Elements of matrices and vectors are defined by Q-Variables

390 C.S. Transformation


Turbo PMAC Training
Setup Commands
Online Commands

Def Tbuf {#} ; Define how many matrix buffers needed


Delete Tbuf ; Delete all matrix buffers

Motion Program Commands

Tselect {#} ; select which matrix buffer to use

Tinit ; initialize the matrix by setting it as identity matrix

Qn={values} ; assign Q-Variable into the selected buffer

ARot {n} ; assign Q(n)-Q(n+8) to Abs. Rotation Matrix

IRot {n} ; assign Q(n)-Q(n+8) to Inc. Rotation Matrix

ADis {m} ; assign Q(m)-Q(m+8) to Abs. Displacement Vector

IDis {m} ; assign Q(m)-Q(m+8) to Inc. Displacement Vector

391 C.S. Transformation


Turbo PMAC Training
Rotation Example

¾ Cutting four squares as shown in the following figure

¾ Specification
Motor 1 for X Axis, and Motor 2 for Y Axis
Starting from origin
Set (X,Y)=(1,0) as the corner of the first (0.5)*(0.5) square and cut it
Rotate the square clockwise for 45º, 90º, and 135º (45º apart) and cut
Go back to origin at the end of every move

¾ Use IRot {n} function


Y 1 1.5

0.5

392 C.S. Transformation


Turbo PMAC Training
Example Program
1st half of program: 2nd half of program:
Undefine All ; Undefine all axis definition CMD"Def Gat" ; Online command: Define Gat buffer
End Gat ; End data gathering CMD"Gat" ; Online command: Start Gathering
Del Gat ; Delete data gathering buffer While (P10>0) ; While loop with index condition
&1 ; Addressing C.S. 1
#1->1000X ; Motor 1 assigned to Axis X X 0 Y 0 ; Go to (X,Y)=(0,0)
#2->1000Y ; Motor 2 assigned to Axis Y Dwell 0 ; Stop for 0 msec, Stop blending
Delete Tbuf ; Delete transformation buffer X 1.5 Y 0 ; Go to (X,Y)=(1.5,0)
Define Tbuf 1 ; Define 1 transformation buffer Dwell 0 ; Stop for 0 msec, Stop blending
X 1.5 Y 0.5 ; Go to (X,Y)=(1.5,0.5)
Open Prog 2 clear ; Open&clear buffer for program 2 Dwell 0 ; Stop for 0 msec, Stop blending
Linear ; Linear move mode X 1 Y 0.5 ; Go to (X,Y)=(1,0.5)
Abs ; Absolute move mode Dwell 0 ; Stop for 0 msec, Stop blending
TA 100 ; Set 100 msec acceleration time X 1 Y 0 ; Go to (X,Y)=(1,0)
TS 0 ; Set 0 msec S-Curve time Dwell 0 ; Stop for 0 msec, Stop blending
F 5000 ; Set feedrate of 5000 cts/sec X 0 Y 0 ; Go to (X,Y)=(0,0)
Dwell 1000 ; Stop for 1000 msec, Stop blending
Tsel 1 ; Select transformation buffer 1
Tinit ; Initialize transformation matrix IRot 20 ; Use Q20~Q28 for Incremental Rotation
Q20=cos(45) Q21=sin(45) Q22=0 ; Setup Q20~Q22
Q23=-sin(45) Q24=cos(45) Q25=0 ; Setup Q23~Q25 P10=P10-1 ; Index counting down
Q26=0 Q27=0 Q28=1 ; Setup Q26~Q28 EndWhile ; End while loop
P10=4 ; While Loop index number Dwell 0 ; Stop for 0 msec
Dwell 0 ; Stop program for 0 msec CMD"EndG" ; End data gathering
CMD"End Gat" Dwell 0
CMD"Del Gat" Close ; Close Program 2 buffer

Turbo PMAC Script

Turbo PMAC Script


Save & Download the program (both halves) to PMAC.
In the Terminal Window, type &1 B2 R to run the program.

393 C.S. Transformation


Turbo PMAC Training
Rotation and Translation Example

¾ Cutting four squares as shown in the following figure

¾ Specification
From previous example, after the first cut shape, translate and rotate the cut
shape simultaneously.
Incremental displacement: [-0.5, 0, 0]T
Incremental rotation: 45º apart

¾ Use IRot {n} and IDis {n} functions

Y 1 1.5

0.5

394 C.S. Transformation


Turbo PMAC Training
Example Program
1st half of program: 2nd half of program:
Undefine All ; Undefine all axis definition CMD "DefGat" ; Online command: Define Gathering buffer
End Gat ; End data gathering CMD "Gat" ; Online command: Start Gathering
Del Gat ; Delete data gathering buffer While (P10>0) ; While loop with index condition
&1 ; Addressing C.S. 1
#1->1000X ; Motor 1 assigned to Axis X X 0 Y 0 ; Go to (X,Y)=(0,0)
#2->1000Y ; Motor 2 assigned to Axis Y Dwell 0 ; Stop for 0 msec, Stop blending
Delete Tbuf ; Delete transformation buffer X 1.5 Y 0 ; Go to (X,Y)=(1.5,0)
Define Tbuf 2 ; Define 1 transformation buffer Dwell 0 ; Stop for 0 msec, Stop blending
X 1.5 Y 0.5 ; Go to (X,Y)=(1.5,0.5)
Open Prog 3 clear ; Open&clear buffer for program 2 Dwell 0 ; Stop for 0 msec, Stop blending
Linear ; Linear move mode X 1 Y 0.5 ; Go to (X,Y)=(1,0.5)
Abs ; Absolute move mode Dwell 0 ; Stop for 0 msec, Stop blending
TA 100 ; Set 100 msec acceleration time X 1 Y 0 ; Go to (X,Y)=(1,0)
TS 0 ; Set 0 msec S-Curve time Dwell 0 ; Stop for 0 msec, Stop blending
F 50 ; Set feedrate of 50 user unit/sec X 0 Y 0 ; Go to (X,Y)=(0,0)
Dwell 1000 ; Stop for 1000 msec, Stop blending
Tsel 1 ; Select transformation buffer 1
Tinit ; Initialize transformation matrix IRot 20 ; Use Q20~Q28 for Incremental Rotation
Q20=cos(45) Q21=sin(45) Q22=0 ; Setup Q20~Q22 IDis 30 ; Use Q30~Q32 for incremental Displacement
Q23=-sin(45) Q24=cos(45) Q25=0 ; Setup Q23~Q25
Q26=0 Q27=0 Q28=1 ; Setup Q26~Q28 P10=P10-1 ; Index counting down
EndWhile ; End while loop
Tsel 2 ; Select transformation buffer 2 Dwell 0 ; Stop for 0 msec
Tinit ; Initialize transformation matrix CMD "EndG" ; End data gathering
Q30=-0.5 Q31=0 Q32=0 ; Set Q30~Q32 Close ; Close Program 2 buffer

X 0 Y 0 ; Move motor to starting point Turbo PMAC Script


P10=4 ; While Loop index number
Dwell 0 ; Stop program for 0 msec

Turbo PMAC Script

Save & Download the program (both halves) to PMAC.


In the Terminal Window, type &1 B3 R to run the program.

395 C.S. Transformation


Turbo PMAC Training
PMAC Time Base Control
Time Base Operation Principle
¾ A PMAC motion trajectory is usually defined as a position vs. time function

¾ The operating principle of Time Base Control is to replace time with master position to
create a position vs. position trajectory function

¾ The relationship between real time and the nominal master position is called the Real-
Time Input Frequency (RTIF).

¾ RTIF (cts/msec): nominal speed of master position (i.e. when Feedrate = 100%)

Velocity
TM

RTIF = 2 cts/msec

Time (msec)
TA TA
0 500 1000 1500
Master Position (cts)
0 1000 2000 3000

397 Time Base Control


Turbo PMAC Training
Time Base Operation Principle
¾ After the RTIF is determined , the real speed of the master position will become an
input comparing to RTIF to determine the Feedrate. This is called the Input
Frequency (IF)

¾ IF (cts/msec): Real speed of master encoder

IF
%= × 100
RTIF
¾ % Feedrate of a time-base-controlled coordinate system is determined by the
IF/RTIF ratio, which means that when the master is speeding up, the motion of that
coordinate system will also speed up accordingly

¾ Question:
How does PMAC use this information to change %Feedrate?

398 Time Base Control


Turbo PMAC Training
PMAC Feedrate
¾ PMAC %Feedrate calculation and Isx93

On power-on, reset ($$$), or commanding %100, the value of I10 will be copied once
to the addresses specified by Isx93, Coordinate System x Time Base Control Address.
Let the value in Isx93 address be VIsx93, and then the Feedrate value is determined by
the following equation:
VIsx93
%= × 100
I10
If Isx93 is pointing to an address which contains the value of the related calculation
result from IF and RTIF, then the Feedrate will change according to that result.

¾ From the previous slide:

VIsx93 IF IF ⋅ I10
= ⇒ VIsx93 =
I10 RTIF RTIF
399 Time Base Control
Turbo PMAC Training
RTIF and TBSF

N
2
TBSF =
RTIF

IF ⋅ I10 IF ⋅ I10 ⋅ TBSF


VIsx93 = = N
RTIF 2
400 Time Base Control
Turbo PMAC Training
Setting Up Time Base
1. Determine desired Real Time Input Frequency (RTIF)
2. Compute Time Base Scale Factor (TBSF )
3. Compute Move Time Scale Factor (MTSF)
4. Create Encoder Conversion Table (ECT) entry for Normal Time-Base
5. Set Isx93 to the output address of the ECT time-base entry
6. Set Isx94 (time-base slew rate) to the desired value

401 Time Base Control


Turbo PMAC Training
Example Application

A machine needs to be built to periodically cut a web of material moving on a conveyor belt.
The cutting speed needs to be proportional to the belt speed in order to cut correctly. Thus,
one can make the cutting action (slave) look to the encoder on the belt as the master position
register in order to proportionally change the speed that the cutter moves.

Cutter Servo Motor

Web Pulled Along

Line Encoder: 500 lines/rev


Line Servo Motor Encoder: 500 lines/rev
Speed Diameter of Cutter and Line Roller: 6 inches
Maximum Line Speed: 350 inch/min
Encoder

402 Time Base Control


Turbo PMAC Training
Setting Up Time Base
1. Determine desired Real Time Input Frequency (RTIF) based on the Input
Frequency (IF) one wants to use in order to produce 100% feed rate in the
follower’s coordinate system

2. Compute Time Base Scale Factor (TBSF )

3. Compute Move Time Scale Factor (MTSF)

4. Create Encoder Conversion Table (ECT) entry for Normal Time-Base

5. Set Isx93 to the output address of the ECT time-base entry

6. Set Isx94 (time-base slew rate) to the desired value

403 Time Base Control


Turbo PMAC Training
Real-Time Input Frequency
¾ Real-Time Input Frequency (RTIF) - units of count/msec

¾ Determines how PMAC interprets the passage of time based off of the master
position

¾ E.g., if RTIF = 32 cts/msec, 32 cts of the master position register must elapse for
PMAC to think that 1 msec has elapsed

¾ Use RTIF to derive the Time-Base Scale Factor (TBSF) in units of msec/count,
which one puts into the Time-Base Encoder Conversion Table Entry

404 Time Base Control


Turbo PMAC Training
Web Cutter RTIF Computation
¾ The RTIF will be the nominal web speed that is used for 100% feed rate

From x4 encoder decode

350 inch 1 min 500 lines 4 counts 1 second 1 rev = 0.619 cts/ms
1 min 60 sec 1 rev 1 line 1000 ms 6π inch = RTIF

¾ In PMAC, this is computed as:


#define RTIF P400
RTIF = 350/60*500*4/1000/6/3.141592654 ; cts/ms
Turbo PMAC Script

405 Time Base Control


Turbo PMAC Training
Computing TBSF
1. Determine RTIF as such:
RTIF = fi = input freq. for which you desire 100% feed rate

2. Compute TBSF as:

N
2
TBSF =
RTIF
where N = 17 for normal time-base
N = 14 for triggered time-base

3. Round TBSF to nearest integer

4. Adjust programmed motion times based on the differences between desired RTIF
and computed TBSF by using the Move Time Scale Factor (MTSF - see slide after
next)

406 Time Base Control


Turbo PMAC Training
Limitations on TBSF

1. Must be an integer.
2. This must hold:

2 ⋅ ( fs ) N
TBSF <
max[ f i ]
where N = 17 for normal time-base
N = 14 for triggered time-base
fs = Servo Frequency [Hz]
fi = Input Frequency [cts/sec] (the speed at which Master
Position is changing)

407 Time Base Control


Turbo PMAC Training
Web Cutter TBSF Computation
¾ In PMAC, one can compute TBSF as:
#define RTIF P400
#define Two_to_the_N P402
#define TBSF P403
#define the_N P404
#define Rounded_TBSF P405
#define NormalTBN 17 ; for Normal Timebase
#define TriggeredTBN 14 ; for Triggered Timebase

RTIF = 350/60*500*4/1000/6/3.141592654 ; cts/ms


the_N = NormalTBN ; for Normal Timebase
Two_to_the_N = Exp(the_N*Ln(2)) ; Raises 2 to the power of 17
TBSF = Two_to_the_N/RTIF
Rounded_TBSF = Int(TBSF + 0.5) ; Round to integer

Turbo PMAC Script

408 Time Base Control


Turbo PMAC Training
Adjusting Programmed Move Times
¾ After computing the TBSF, one must multiply all programmed move times by this
Move Time Scale Factor (MTSF):

⎛ int (TBSF + 0.5) ⋅ RTIF ⎞


MTSF = 1 + ⎜1 − ⎟
⎝ ⎠
N
2

¾ Neglecting to do this will cause your move times to be incorrect by the percentage
amount that you rounded the TBSF to make the TBSF value an integer

409 Time Base Control


Turbo PMAC Training
Web Cutter MTSF Computation
#define RTIF P400
#define MTSF P401
#define Two_to_the_N P402
#define TBSF P403
#define the_N P404
#define Rounded_TBSF P405
#define NormalTBN 17 ; for Normal Timebase
#define TriggeredTBN 14 ; for Triggered Timebase

RTIF = 350/60*500*4/1000/6/3.141592654 ; cts/ms


the_N = NormalTBN ; for Normal Timebase
Two_to_the_N = Exp(the_N*Ln(2)) ; Raises 2 to the power of 17
TBSF = Two_to_the_N/RTIF
Rounded_TBSF = Int(TBSF + 0.5) ; Round to integer
MTSF = 1+(1-Rounded_TBSF/TBSF)

Turbo PMAC Script


¾ The result will be MTSF = 1.0000067815
¾ Then, all subsequent programmed move times must simply be multiplied by this
value in order for the scaled move speeds and times to be correct

410 Time Base Control


Turbo PMAC Training
Setting Up Time Base ECT Entries
Configuring normal time-base ECT entry (ConfigureÆEncoder Conversion Table) in a
UMAC with motor 4’s encoder as Master Position register

Download
Entry when
Finished

Specify Master Position Register

Choose Timebase Conversion Type Specify TBSF (this is just an example)


(Normal Time-Base Here)

411 Time Base Control


Turbo PMAC Training
Setting Isx93
¾ Identify the entry number corresponding to “Timebase scaled conversion with scaled
differentiation” of the desired encoder

In this example screen, ECT


entry 5 is Timebase Processed
Conversion with Scaled Data Address
Differentiation of motor 4’s
encoder

¾ Set Isx93 to the Processed Data Address of the desired entry


¾ The addresses are given by @I8000-@I8191 for lines 1 to 192 of the ECT, respectively.
¾ For example, to set I5193 to point to the output of entry 5:

I5193=@I8005 ; C.S. 1 Time Base Control Address is ECT entry 5 output

Turbo PMAC Script

Time-base ECT entries occupy two lines. This is why Isx93 points to
@I8005 here rather than @I8004.
Note
412 Time Base Control
Turbo PMAC Training
Setting Isx94
¾ Isx94 - Coordinate System x Time Base Slew Rate

¾ Defines the maximum rate at which the % value can slew to the new hardware-
determined value and the actual rate of change is determined by the hardware.

¾ To keep synchronous to a hardware input frequency, as in a position-lock cam, Isx94


should be set high enough (maximum value is 8388607) that the limit is never
activated

2 ⋅10 ⋅ Rs (I10) ⋅10 ⋅ Rs−5 −5


23 2
Isx94 = 2
= 23
fs 2
Rs: Desired slew rate in units of %/second
fs: Servo frequency in units of KHz
Example: Changing 100% feedrate in 1 second
fs = 2.259 kHZ (default), Rs = (100%)/second, then
I5194=I10*I10*100/8388608/100000 // =1644, Coordinate system 1 Time Base
// Slew Rate
Turbo PMAC Script
413 Time Base Control
Turbo PMAC Training
Returning to Web Cutter Example
¾ Nominal web speed = 50 inch/sec

¾ With x4 encoder decode, set RTIF = I422 = 0.619 cts/ms

¾ Motor 4 is the belt motor jogging along

¾ Make the cut in 750 ms

¾ Wait 500 ms

¾ Return to the starting cut position in 1220 ms

414 Time Base Control


Turbo PMAC Training
Example Motion Program
// Macro definitions
#define RTIF P400
#define MTSF P401
#define Two_to_the_N P402
#define TBSF P403
#define the_N P404
#define Rounded_TBSF P405

// Motor Settings
I422 = 0.619 ; Nominal web speed (cts/msec)
I116 = 100 ; Max cutter speed (cts/msec)
I117 = 2 ; Max cutter accel. (cts/msec^2)

// Time base setting calculations


the_N = 17 ; for normal time-base
RTIF = I422 ; cts/msec – matches base jog speed of motor 4
Two_to_the_N = Exp(the_N*Ln(2)) ; Raises 2 to the power of 17
TBSF = Two_to_the_N/RTIF ; Time base scale factor
Rounded_TBSF = Int(TBSF + 0.5) ; Round to integer
MTSF = 1+(1-Rounded_TBSF/TBSF) ; Move time scale factor

// Coordinate system definitions


&2 ; Put motor 4 into coordinate system 2
#4->X
&1 ; Put motor 1 into coordinate system 1
#1->1000X ; 1000 cts per user unit for X axis

Turbo PMAC Script

415 Time Base Control


Turbo PMAC Training
Example Motion Program
// Time-base configuration I-Variables
I8004 = $483504 ; Set time-base value to come from encoder 4
I8005 = Rounded_TBSF ; Set time-base scale factor
I5193 = $3506 ; Set master position register to be
; time-base scaled differentiation, encoder 4
I5194 = 8388607 ; Set slew rate to maximum rate

Open Prog 13 Clear


Home 1 ; Home motor 1
Linear Abs ; Set move mode
TA 100 ; Acceleration time (msec)
TS 50 ; S-curve time (msec)
While(M11=1) ; Cut as long as machine input 1 is true
TM (750*MTSF) ; Cut move time, scaled (msec)
X 10 ; Perform actual cut move
Delay 500 ; Hold - part of return
TM(1220*MTSF) ; Return move time, scaled (msec)
X 0 ; Actual return move
Delay 500 ; Hold; part of return
EndWhile
Close
Turbo PMAC Script
¾ Make sure you download this code along with the code from the previous slide
¾ Now start motor 4 by typing #4J+ in the Terminal window, then run the program by
typing #1J/ &1 B13 R
¾ Try changing I422, then typing #4J+ again, to see how the cutting speed of Motor 1
changes accordingly

416 Time Base Control


Turbo PMAC Training
Triggered Time Base
¾ Triggered time base waits until it receives the trigger from the master before actually
initiating time-base control

¾ Uses a different ECT entry

¾ Configure the trigger with Ixx97, Ixx25, I7mn2, I7mn3, and Ixx12

¾ Must freeze the time base from within the motion program until the appropriate time to
start waiting for the trigger

¾ A PLC then arms the time-base to start waiting for the trigger

¾ Once the trigger initiates, the time-base control continues just like in the normal time-
base configuration

See the “Triggered Jog Moves (Homing)” section of the Turbo PMAC
Training to learn how to configure hardware and software triggers.
Note

417 Time Base Control


Turbo PMAC Training
Setting Up Triggered Time Base
1. Determine desired Real Time Input Frequency (RTIF) based on the Input Frequency (IF)
one wants to use in order to produce 100% feed rate in the follower’s coordinate
system
2. Compute Time Base Scale Factor (TBSF )
3. Compute Move Time Scale Factor (MTSF)
4. Create Encoder Conversion Table (ECT) entry for Triggered Time-Base
5. Set Isx93 to the output address of the ECT time-base entry
6. Set Isx94 (time-base slew rate) to the desired value
7. Configure desired trigger settings with Ixx97, Ixx25, I7mn2, I7mn3, and Ixx12 (see
Homing section of the training for more details)
8. Point an M-Variable to bits 20-24 of the ECT entry input address
9. In the motion program, write a $9 to this M-Variable
10. In a PLC, wait for $9 in this M-Variable, and then write a $B thereto to arm time base
(reading $A thereafter indicates that time base is active)

418 Time Base Control


Turbo PMAC Training
Triggered Time Base ECT Entries
Configuring triggered time-base ECT entry (ConfigureÆEncoder Conversion Table)
in a UMAC with Quadrature Encoder 4 as Master Position register

Download
Entry when
Finished

Specify Master Position Register

Choose Timebase Conversion Type Specify TBSF (this is just an example)


(Triggered Time-Base Here)

419 Time Base Control


Turbo PMAC Training
Setting Isx93
¾ Identify the entry number corresponding to “Triggered timebase conversion” of the
desired encoder

In this example screen, Processed


ECT entry 5 is Timebase Data
Conversion with Scaled Address
Differentiation of motor
4’s encoder

¾ Set Isx93 to the Processed Data Address of the desired entry.


¾ The addresses are given by @I8000-@I8191 for lines 1 to 192 of the ECT, respectively.
For example, to set I5193 to point to the output of entry 5:

I5193=@I8005 ; C.S. 1 Time Base Control Address is ECT entry 5 output

Turbo PMAC Script

Time-base ECT entries occupy two lines. This is why Isx93 points to
@I8005 here rather than @I8004.
Note
420 Time Base Control
Turbo PMAC Training
Freezing and Arming Time-Base
¾ The motion program must freeze the time-base and wait until it is appropriate to enter
the time-base control mode
¾ A PLC must arm the time-base to begin waiting for the trigger from the master once
the appropriate time has come
¾ Point an M-Variable to bits 20-24 of the ECT entry input address
Example: If Time-base ECT Entry is Entry 5:
M199->Y:$3505,20,4 ; Time-base control address is input of entry 5 of ECT
Turbo PMAC Script

¾ In the motion program, write $9 to this M-Variable to freeze time-base


¾ In a PLC, write $B to this M-Variable to arm time-base so that it starts looking for the
trigger to occur
¾ Reading a value of $A in this M-Variable indicates that the time-base is active.

421 Time Base Control


Turbo PMAC Training
Triggered Time Base Example
¾ Motor #1, the A axis, in C.S. must be slaved to Motor #4

¾ The A axis must wait for the index pulse of the master and 45 degrees past it

¾ Must accelerate up to top speed over the next 36 degrees of the master, run at speed
for 144 degrees of the master, and decelerate over 36 degrees of the master

¾ Move must cover one full revolution of the A axis

Hardware:
Rotary Axis Encoder: 500 lines/rev
Load Gearing: 3:1
Master Encoder: 500 lines/rev on Servo I.C. 2 Channel 4
Typical Rotation Rate: 60 rpm

422 Time Base Control


Turbo PMAC Training
Triggered Time Base Example
¾ Computing RTIF:

60 rev 1 min 500 lines 4 counts 1 second


= 2 cts/ms
1 min 60 sec 1 rev 1 line 1000 ms = RTIF

¾ Now follow the same steps used for normal time base to compute TBSF and MTSF:

// Macro Definitions
#define RTIF P400
#define MTSF P401
#define Two_to_the_N P402
#define TBSF P403
#define the_N P404
#define Rounded_TBSF P405
#define Vd P406 ; Motor #4 nominal speed [deg/msec]
// Time base setting calculations
the_N = 14 ; for triggered time-base
I422 = 60/60*500*4/1000 ; cts/msec
RTIF = I422 ; cts/msec – matches base jog speed of motor 4
Two_to_the_N = Exp(the_N*Ln(2)) ; Raises 2 to the power of 17
TBSF = Two_to_the_N/RTIF ; Time base scale factor
Rounded_TBSF = Int(TBSF + 0.5) ; Round to integer
MTSF = 1+(1-Rounded_TBSF/TBSF) ; Move time scale factor

Turbo PMAC Script

423 Time Base Control


Turbo PMAC Training
Triggered Time Base Example
¾ Additional setup (include this with the code on previous slide):

// Set-up and Definitions


I7242=1 ; ENC 4 capture trigger on rising edge of index pulse
I8004=$AF8218 ; Add triggered time base entry to end of default
; conversion table
; process $A is triggered time-base, running (post-trigger);
; $78218 points to IC 2 Encoder 4 registers
I8005=Rounded_TBSF ; Scale factor is 800 decimal, result is at address $3506
I5193=@I8005 ; Set master position register to be
; time-base scaled differentiation, encoder 4
I5194 = 8388607 ; Set slew rate to maximum rate
M199->Y:$3505,20,4 ; Method digit of conversion table entry 5, line 1
; =$9 frozen, $B armed, $A running
Vd = I422*360/2000 ; Motor #4 nominal speed [deg/msec]

Undefine All
&2 ; Address Coordinate System 2
#4->X ; Put the Master Motor into a different coordinate system than the slave

&1 ; Address Coordinate System 1


#1->16A ; Motor 1 is A-axis in C.S. 1; 3* (2000 cts/rev)*(1 rev)/(360 deg)

Turbo PMAC Script

424 Time Base Control


Turbo PMAC Training
Triggered Time Base Example
¾ Motion program (include this with the code on the previous two slides):

End Gat
Del Gat
Close
Open Prog 12 Clear
Enable PLC 10
While(M11=1) ; While machine input 1 is high
Dwell 0 ; Stop lookahead in program
M199=$9 ; Freeze time-base
Dwell 0
Linear ; Linear move mode
Inc ; Incremental move specification
TA(36/Vd) ; 36 degrees of master takes (36/Vd) msec
TS 0 ; No S-curve
Delay(45/Vd*MTSF) ; 45 degrees of master takes (45/Vd) msec
TM((36+144)/Vd*MTSF) ; 36+144 deg of master takes ((36+144)/Vd) msec
A 360 ; One full revolution of slave axis (deg)
EndWhile
Disable PLC 10
Close
Turbo PMAC Script

425 Time Base Control


Turbo PMAC Training
Triggered Time Base Example
¾ Now write and download a PLC that arms the time base at the appropriate time
(include with previous three slides’ code):

End Gat
Del Gat
Close
I5=2 ; Permit background PLCs to run
Open PLC 10 Clear
If (M199=$9) ; Has time-base been frozen?
M199=$B ; Then arm for trigger
EndIf
Close
Turbo PMAC Script

¾ Now start motor 4 jogging by typing #4J+ in the Terminal Window, and then start the
program by typing #1J/ &1 B12 R in the Terminal Window
¾ Try changing I422 and then issuing #4J+ again to observe how the rotation rate of
motor #1 changes proportionally

426 Time Base Control


Turbo PMAC Training
PMAC Lookahead
What is Lookahead?
¾ Algorithm that computes several moves ahead in motion programs

¾ Checks for violations of motor limits:


Position (software overtravel) limits (Ixx13, Ixx14)
Velocity limits (Ixx16)
Acceleration limits (Ixx17)

¾ When violation is detected, motion is slowed at problem point without altering the
position trajectory

¾ Algorithm recalculates motion leading up to problem point to keep all motion within
limits

¾ Lookahead permits acceleration and deceleration over multiple move blocks

¾ Lookahead permits deceleration into tight corner and acceleration out of it

428 PMAC Lookahead


Turbo PMAC Training
Setting Up Lookahead
1. Set Ixx13 and Ixx14, Motor xx Positive and Negative Software Position Limits,
respectively, in units of counts
2. Set Ixx16, Motor xx Maximum Program Velocity (cts/ms), and Ixx17, Maximum
Program Acceleration (cts/ms2), to desired values
3. Set Isx13, C.S. x Segmentation Time (ms), as low as needed to get the correct
precision in the motion
4. Compute and set Isx20, C.S. x Lookahead Length
5. Compute NT, the lookahead buffer size
6. Delete gather buffer, rotary buffer, compensation table buffer, and then finally
lookahead buffer
7. Define the lookahead buffer

To set the I-Variables in Steps 1-2, please refer to the Turbo SRM, as
this procedure is just an outline. The Turbo SRM gives extensive
descriptions of each variable as well as how to set each variable
mentioned in the setup steps here.
Note

429 PMAC Lookahead


Turbo PMAC Training
Setting Isx13
¾ Isx13 - Coordinate System x Segmentation Time [ms]
All Linear and Circle1/Circle2 mode trajectories are created by computing
intermediate segment points with a coarse interpolation algorithm every Isx13 milliseconds,
then executing a fine interpolation using a cubic spline algorithm every servo cycle

Typical values of Isx13 for segmentation mode are 5 to 20 msec, integer values only

The smaller the value, the tighter the actual motor position will fit to the commanded position
trajectory, but the more computation is required for the moves, and the less is available for
background tasks

If Isx13 is set too low, Turbo PMAC will not be able to do all of its move calculations in the
time allotted, and it will stop the motion program with a run-time error

430 PMAC Lookahead


Turbo PMAC Training
How Much Lookahead is Needed?
¾ Compute number of segments by using largest stopping time obtained from max velocity
(Ixx16) divided by max acceleration (Ixx17) of all motors

Coordinate System x
Lookahead Length
4⎛ ⎡ Ixx16 ⎤ ⎞
[# segments]
⎜⎜ max ⎢ ⎥ ⎟⎟
3⎝ ⎣ Ixx17 ⎦ xx ⎠
Isx 20 =
(2)(Isx13)
Segmentation Time [ms]

¾ Size the lookahead buffer to hold this number of segments plus the number of segments
through which one desires to reverse

431 PMAC Lookahead


Turbo PMAC Training
Move Reversal/Retrace
¾ Oversized lookahead buffer provides “history” of trajectory
¾ Position information in buffer is reversible (unlike actual motion program)
¾ The ‘<’ command causes reversal along path
¾ Reverse operation obeys same limits as forward operation
¾ Reversal length limited only by buffer memory
¾ Can only reverse in continuous blended sequence
¾ Quick stop in either direction with ‘\’ command
¾ Forward operation again by ‘>’, ‘R’, or ‘S’
¾ Seamless continuity into new parts of program
¾ No synchronous M-variable assignments are executed either during a reversal or during
the forward execution over the reversed part of the path

432 PMAC Lookahead


Turbo PMAC Training
Reverse Segments
¾ # of reverse segments NR one will need to retain can be computed by:

Largest desired distance


through which to
D reverse (user units)

NR =
Isx13 ⋅ max[ Ixx16]xx ⋅ K
Conversion factor from
counts to user units (user unit/ct)

¾ Minimum number of total segments (NT ) needed for the lookahead buffer is then:

N T = N R + Isx 20
433 PMAC Lookahead
Turbo PMAC Training
Defining the Lookahead Buffer
Then, use NT when defining the lookahead buffer:

Define Lookahead {NT},{# Sync. M-Vars}

From previous slide’s


calculations Count the number of
synchronous M-Variables your
program uses and put the
number here

Example: NT = 200 with 50 synchronous M-Variables

Define Lookahead 200,50


Turbo PMAC Script

434 PMAC Lookahead


Turbo PMAC Training
Deleting and Defining Buffers
¾ Lookahead buffers must be defined from high-numbered coordinate system to low-
numbered coordinate system, and deleted from low-numbered coordinate system to
high-numbered coordinate system

¾ Deletion process:
Del Rot
Del Gat
Del Comp
Del Look
Turbo PMAC Script

¾ Now you can define the lookahead buffer.

Example: NT = 10 with 5 synchronous M-Variables:

Define Lookahead 10,5


Turbo PMAC Script

435 PMAC Lookahead


Turbo PMAC Training
Lookahead Example Program

Undefine All
/******************************Setup and Definitions*************************/
&1 ; Enter coordinate system 1
#1->1000X ; Assign motor 1 to X axis; 1000 cts = 1 user unit
#2->1000Y ; Assign motor 2 to Y axis; 1000 cts = 1 user unit
I5049 = 10 ; gather every 10 servo cycles
I5000 = 1 ; Store gather in RAM and do not permit wrap-around
I5113 = 5 ; Enable segmentation; compute every 5 ms
I5192 = 0 ; Enable blending
I116 = 50 ; Set motor 1 max vel. to 50 ct/s
I117 = .5 ; Set motor 1 max accel. to 50 ct/s^2
I216 = 50 ; Set motor 2 max vel. to 50 ct/s
I217 = .5 ; Set motor 2 max accel. to 50 ct/s^2
I5120 = 4/3/2*I116/I117/I5113 ; Compute number of lookahead segments needed
End Gat
Del Gat
Del Rot
Del Comp
Del Look
Close
Define Lookahead 13,50 ; Define lookahead buffer based on the number in I5120

Turbo PMAC Script

PMAC Lookahead
Lookahead Example Program
Add this to the code from the previous slide:

/****************************Motion Program********************************/
Open Prog 1 Clear
Home 1,2 ; Home motors 1 and 2
Linear Abs ; Set linear absolute move
CMD"End Gat" ; End gathering
CMD"Del Gat" ; Delete contents of gather buffer
CMD"Def Gat" ; Define gather buffer
Dwell 0
CMD"Gat" ; Begin gathering
Dwell 0
F 50 X 10 Y 10 ; Feedrate 50 user units/sec, move X 10 and Y 10 user units
X 0 Y 20 ; Move to X 0 and Y 20 user units
Dwell 0 ; Do not blend to next command
CMD"End Gat" ; End gathering
Dwell 0 ; Do not blend to next command
Close
Turbo PMAC Script

Now run the program by typing #1J/#2J/ &1 B1 R in the Terminal Window

437 PMAC Lookahead


Turbo PMAC Training
25 40

Without 30

Motor Commanded Position [user

Motor Commanded Velocity [user


Lookahead: 20
20

10
15

units/sec]
units]
Mtr. 1 Cmd. Pos.
0
Mtr. 2 Cmd. Pos.
Mtr. 1 Cmd. Vel.
10
Mtr. 2 Cmd. Vel. -10

-20

5 Motor 2 slows
-30
down for the
0 -40 corner. Total move
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7

Time [sec]
time is longer, but
commanded
25 40 position trajectory
is identical.
With 30

Motor Commanded Velocity [user


20
Motor Commanded Position [user

Lookahead: 20

15
10
Mtr. 1 Cmd. Pos.

units/sec]
Mtr. 2 Cmd. Pos.
units]

Mtr. 1 Cmd. Vel.


10 Mtr. 1 Cmd. Vel. 0

-10
5

-20

0
-30
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7

-5 -40

Time [sec]

438 PMAC Lookahead


Turbo PMAC Training
Lookahead Hands-On
¾ Program a simple move with motors 1 and 2 without lookahead, with motor 1 assigned
to X and motor 2 to Y; e.g.:
Linear
Inc
F50
X10 Y10
X0 Y20
Turbo PMAC Script

¾ Gather and plot position and velocity data for motors 1 and 2
¾ Now compute the Isx20 you need and define an appropriate lookahead buffer using
Isx13 = 5 (ms); e.g.:
Define Lookahead 273, 50 ; Buffers 273 blocks and 50 synchronous M-Variables

Turbo PMAC Script


¾ Run the same motion program again; gather and plot the velocity data for motors
1 and 2
¾ Compare the difference between the two velocity profiles
¾ Try starting a program with the S command, then step backward through the program
move by move by typing < into the Terminal Window and forward with >. The program
must be already running for these commands to work

439 PMAC Lookahead


Turbo PMAC Training
Subprograms and Subroutines
G, M, T, and D Codes
Call and GoSub Commands
Passing Parameters
What are Subprograms and
Subroutines?
¾ Subprogram:
A program that a main motion program can call at any time
Can pass parameters to the subprograms, thereby making them like general purpose motion
functions
Any program can be a subprogram and is written just like any other program, e.g.:

Open Prog 1000 Clear


// Subprogram Contents
Close
Turbo PMAC Script

¾ Subroutine:
A line or set of lines within a motion program
A motion program can call a subroutine repeatedly using the GoSub command within the
motion program and jumps back to the command immediately following the GoSub when
Return is encountered

441 Subprograms and Subroutines


Turbo PMAC Training
When Should I Use Them?

¾ When a repetitive task needs to be repeated; one can just call a subprogram or
subroutine each time, rather than rewriting the same motion lines repeatedly

¾ When a modular program is needed that has reusable subroutines that can receive
arguments

¾ When one wants to use PMAC just like a CNC tool, sticking to standard G-Code
definitions
The machine tool designer writes Program 1000 to implement the G-Codes as he or she
wishes, allowing customization and enhancements.

M, T, and D codes are similarly implemented:


M: Program 1001
T: Program 1002
D: Program 1003

Delta Tau provides a sample file implementing all of the standard G-Codes.

442 Subprograms and Subroutines


Turbo PMAC Training
Important Commands
¾ N{data} or O{data} – Label a line with the number in {data}. Must do this before
using GoSub, GoTo, or Call on these lines

¾ Return – Return to parent (calling) program or end motion program

¾ GoSub{data} – Go to line in {data} in the same motion program; return to the line
following GoSub after encountering Return

¾ GoTo{data} – Go to line in {data} in the same motion program and continue on;
does not return to line following the GoTo after encountering Return

¾ Call{Program #}.{Line #} – Calls line number in {Line #} in motion program in


{Program #}.
{Line #} can be up to 5 digits long, and the user must fill in zeros for each place not already
occupied by a nonzero digit; e.g., line 1 would be listed as 00001, line 100 as 00100, etc.

Example
Open Prog 10 Clear
Call300 ; Calls program 300, starting at the beginning of the program
Call800.00100 ; Calls program 800, starting at line N100
Call32.00001 ; Calls program 32, starting at line N1
Close
Turbo PMAC Script

443 Subprograms and Subroutines


Turbo PMAC Training
Important Commands
¾ Can also pass arguments to the sub program; e.g:
Open Prog 3 Clear
Call700 X10 Y20 Z30 ; Call all of Prog 700, passing 10 into argument X,
; 20 into argument Y and 30 into argument Z
Close
Turbo PMAC Script
¾ Here, no moves are executed; the values are only passed into the X, Y, and Z arguments.

¾ Read{data} – Reads arguments passed to it via the Call command. Each argument must
be a letter, and each argument’s value is then put into a Q-Variable, starting with A at Q101,
B at Q102, etc., excluding N and O. E.g.:

Open Prog 700 Clear


Read(X,Y,Z)
If (Q100 & $800000 > 0) PSET X(Q124)
If (Q100 & $1000000 > 0) PSET Y(Q125)
If (Q100 & $2000000 > 0) PSET Z(Q126)
Return
Close
Turbo PMAC Script
¾ This will read the values in X, Y, and Z, put them into Q124-126, and process them using
PSET

444 Subprograms and Subroutines


Turbo PMAC Training
Passing Arguments to Subroutines
¾ When a subroutine receives an argument with a Read command which was passed
to it in the Call statement in the parent program, it will store the input in Q-
Variables corresponding to the letter used:
The A argument reads into Q101 (Q100 + 1 for 1st letter of alphabet)
The B argument reads into Q102 (Q100 + 2 for 2nd letter of alphabet)
.
.
.
The Y argument reads into Q125 (Q100 + 25 for 25th letter of alphabet)
The Z argument reads into Q126 (Q100 + 26 for 26th letter of alphabet)
¾ Example
Open Prog 1 Clear
Call 500 D10E20 ; Pass 10 into argument D and 20 into argument E
Close

Open Prog 500 Clear


Read (D,E) ; sets Q104 to 10 when Prog 1 calls this program
; sets Q105 to 20 when Prog 1 calls this program

Close
Turbo PMAC Script

445 Subprograms and Subroutines


Turbo PMAC Training
Important Commands
¾ G{data} – Turbo PMAC interprets this statement as a Call 10n0.({data’}*1000)
command, where n is the hundreds digit of {data}, and {data’} is the value of
{data} without the hundreds digit (modulo 100 in mathematical terms)

¾ M{data} – Same as G{data} but Call 10n1.({data’}*1000)

¾ T{data} – Same as G{data} but Call 10n2.({data’}*1000)

¾ D{data} – Same as G{data} but Call 10n3.({data’}*1000)

¾ Prelude – Permits automatic insertion of a subprogram call before each subsequent


motion command; e.g.:

Prelude1 Call10 ; Insert a Call10 before subsequent moves


X 10 Y 20 ; Implicit Call10 before this move
X 20 Y 30 ; Implicit Call10 before this move
Prelude0 ; Deactivate Prelude1’s automatic Call insertion
Turbo PMAC Script

446 Subprograms and Subroutines


Turbo PMAC Training
Important Commands

¾ GoSub 300
Jumps to: N 300 of same motion program,
¾ Call 500
Jumps to: Prog 500, at the top (N0)
¾ Call 500.1
Jumps to: Prog 500, label N10000
¾ Call 500.12
Jumps to: Prog 500, label N12000
¾ Call 500.12345
Jumps to: Prog 500, label N12345
¾ On-line command B700
Points to: Prog 700, N0, ready to run
¾ On-line command B700.34
Points to: Prog 700, N34000, ready to run

447 Subprograms and Subroutines


Turbo PMAC Training
Subroutine Parameter Pass Check
¾ Bit (n-1) of Q100 set to 1 if the “nth” letter successfully passed an argument in the last
Read statement. E.g.:
If(Q100 & 16>0) is true when “E” (5th letter) has been passed, indicating that bit 4 is high

¾ Q100 set to 0 at beginning of READ

¾ Successful read of letter value sets corresponding bit of Q100 to 1

Z Y F E D C B A Letter
0 0 0 1 1 0 0 0 Q100

25 24 5 4 3 2 1 0 Bit #
25 24
2 2 32 16 8 4 2 1 Bit Value (Dec)
2000000 1000000 20 10 8 4 2 1 Bit Value (Hex)

448 Subprograms and Subroutines


Turbo PMAC Training
G, M, T, and D Codes
For RS-274 compatible motion programs
G 73 is equivalent to
CALL 1000.73000

M 3 is equivalent to
CALL 1001.03000

T 01 is equivalent to
CALL 1002.01000

D 12 is equivalent to
CALL 1003.12000

449 Subprograms and Subroutines


Turbo PMAC Training
G, M, T, and D Codes
¾ System designer writes custom routines in Prog 1000 to Prog 1003

¾ Then, part programmers and machine operators can treat system as regular “G-Code”
machine

¾ Prog 1000 and up can be password protected to protect proprietary code from
unauthorized access

450 Subprograms and Subroutines


Turbo PMAC Training
G Code Program Example
//******************* Setup and Definitions ******************//
End Gat
Del Gat
Del Trace
Undefine All
&1
#1->1000X
#2->1000Y
#3->1000Z
;#4 is cutter motor and will jog while cutting

//****************** Part Program Text **********************//


; Note that the part program does not need to know
; how the G-codes and M-codes are executed
Open Prog 5 Clear ; Prepare motion program 5 for entry
Home 1..4 ; Home motors 1-4
G17 G90 ; XY plane, absolute move spec
G97 S1800 ; Set spindle speed of 1800 rpm
F 500 ; Cutting speed 500 mm/min
G00 X 10.00 Y 5.00 ; Rapid move to (10, 5)
M03 ; Start spindle
G04 P2.0 ; Wait 2 seconds
G01 Z 0 ; Lower cutter
X 30.25 Y 5.00 ; Linear XY move
G03 X 35.25 Y 10.00 J 5 ; CCW arc move
G01 X 35.25 Y 50.10 ; Linear move
G03 X 30.25 Y 55.10 I-5 ; CCW arc move
G01 X 10.00 Y 55.10 ; Linear move
G03 X 5.00 Y 50.10 J-5 ; CCW arc move
G01 X 5.00 Y 10.00 ; Linear move
G03 X 10.00 Y 5.00 I 5 ; CCW arc move
G01 Z 5 M05 ; Cutter up, stop
G00 X 0 Y 0 ; Back to home
Close Turbo PMAC Script
451 Subprograms and Subroutines
Turbo PMAC Training
G Code Program Example
Open Prog 1000 Clear ; prepare buffer 1000 for entry
Rapid Return ; G00 Rapid mode (N0 is implied)
N01000 Linear Return ; G01 Linear interpolation mode
N02000 Circle1 Return ; G02 CW circle mode
N03000 Circle2 Return ; G03 CCW circle mode
N04000 Read(P) ; G04 Dwell for P seconds
If (Q100 & 32768 > 0) ; P parameter specified?
Dwell (Q116*1000) ; PMAC specifies dwell in msec
EndIf
Return
N17000 Normal K-1 Ret ; G17 Specify XY plane
N18000 Normal J-1 Ret ; G18 Specify ZX plane
N19000 Normal I-1 Ret ; G19 Specify YZ plane
N90000 Abs Ret ; G90 Absolute mode
N91000 Inc Ret ; G91 Incremental mode
N97000 Read(S) ; G97 Spindle speed set
If (Q100 & 262144 > 0) ; S parameter specified?
I422=Q119/30 ; #4 jog speed in cts/msec
EndIf
Return
Close
Open Prog 1001 Clear ; Prepare buffer 1001 for entry
N03000 CMD "#4J+" Ret ; Start spindle clockwise (closed loop)
N04000 CMD "#4J-" Ret ; Start spindle counterclockwise (closed loop)
N05000 CMD "#4J/" Ret ; Stop spindle
Close
Turbo PMAC Script

Put this code into the same file as the code given on the previous page;
it all belongs together.
Note
452 Subprograms and Subroutines
Turbo PMAC Training
G Code Program Example
Now run the program by typing &1 B5 R in the terminal window. If you want, you can
gather the positions of motors 1 and 2 to see a plot with the following motion profile:

60000
Motor 2 Actual Position [cts]

50000

40000

30000

20000

10000

0
0 5000 10000 15000 20000 25000 30000 35000 40000
Motor 1 Actual Position [cts]

453 Subprograms and Subroutines


Turbo PMAC Training
Compensation Tables
Types of Compensation

¾ PMAC can perform table-based correction to compensate for imperfections in


the system by linearly interpolating between table entries and subtracting the
offsets

Position Compensation
Standard Lead Screw compensation
Cross-axis compensation
2D planar compensation

Backlash Compensation
Position error depends on motor direction
Defined by Ixx85, Ixx87, and the table

Torque Compensation
Compensate servo output as a function of position

¾ I51: Compensation Table Enable

I51 = 0 ; Disable all compensation tables


I51 = 1 ; Enable all compensation tables

455 Compensation Tables


Turbo PMAC Training
¾ Standard lead screw compensation, Δx = F(x)
Get linear encoder accuracy (almost) with rotary encoder
Characterized system with linear sensor

COMMAND:
Define Comp 200,#1,#1,10000
Δx Δx Δx Δx

M Table Length
Source Motor
Target Motor
Table Span (cts)

¾ Cross-axis compensation, Δy = F(x)


Useful for bowed lead screws
Can be used to build electronic cam tables

COMMAND:
Define Comp 100,#1,#2,10000
Note:
If Source and Target motors are the same,
M Δy Δy Δy Δy Command can also be:

#1 Define Comp 200,10000

456 Compensation Tables


Turbo PMAC Training
¾ 2D Planar compensation table, Δz = F(x,y)

Raw Position Data


z, #3 Compensated Data

y, #2

x, #1 Δz

Define Comp 15.20,#1,#2,#3,20000,15000

Table # of rows 2nd motor span in cts


Table # of columns 1st motor span in cts
1st source motor Target motor
2nd source motor

457 Compensation Tables


Turbo PMAC Training
1D Compensation Table Example
Define Comp 8,#1,#2,4000 ; Table of 0~8 entries over 4000 cts,
; motor 1 as source, motor 2 as target

160 ; Correction at 4000/8 = 500 cts is 160/16 = 10 cts


-80 ; Correction at 1000 counts is -5 counts
-120 ; Correction at 1500 counts is -7.5 counts
-80 ; Correction at 2000 counts is -5 counts
0 ; Correction at 2500 counts is 0 counts
80 ; Correction at 3000 counts is 5 counts
40 ; Correction at 3500 counts is 2.5 cts
0 ; Correction at 4000 (and 0) cts is zero

Turbo PMAC Script


Implied correction value 0 at first position

Position 0 500 1000 1500 2000 2500 3000 3500 4000 (cts)
Position Error 0 -10 5 7.5 5 0 -5 -2.5 0 (cts)

Note:
Corrections between entry counts are linearly interpolated.
Compensation table will roll over after 4000 counts.

458 Compensation Tables


Turbo PMAC Training
2D Compensation Table Example

Define Comp 4.5,#1,#2,#3,50000,40000 ; Define a table with 5 rows,


; 6 columns. Motor 1 & 2 as
; sources with 50k & 40k cts span
38 45 -22 -35 0 ; Correction Row 0, Columns 1-5

24 56 13 -34 -8 24 ; Correction Row 1, Columns 0-5

18 43 -9 -65 32 18 ; Correction Row 2, Columns 0-5

-6 28 22 -38 12 -6 ; Correction Row 3, Columns 0-5

0 38 45 -22 -35 0 ; Correction Row 4, Columns 0-5

Turbo PMAC Script

Note:
With an implied correction value of 0 for the
zeroth entry, Rows 0 and 4 are identical,
as are Columns 0 and 5.
Implied correction value 0

459 Compensation Tables


Turbo PMAC Training
Backlash Compensation

¾ Ixx85 – Motor xx Backlash Take-up Rate


Units: 1/16 count / per background cycle
Rate of change of backlash on reversal
Set as high as possible without rough transition

¾ Ixx86 – Motor xx Backlash Size


Backlash Size (angular)
Unit: 1/16 count
Different motor directions have different
position errors
Added hidden position change on reversal

¾ Ixx87 – Motor xx Backlash hysteresis


Unit: 1/16 count ΔX: Horizontal
Required size of reversal before backlash change
Component of Backlash
Set non-zero to prevent dithering

460 Compensation Tables


Turbo PMAC Training
Defining the Table
¾ Command :
#x Define BLComp{# entries},{count span}
Position-dependent backlash
Added to Ixx86 backlash
Table backlash is zero at motor zero position
Used with Comp Table for bi-direction compensation
Holds difference between positive-going and negative-going compensation

¾ Example:

#1 Define BLComp 8, 4000

Count span
Number of entries
Define backlash compensation
Motor number

461 Compensation Tables


Turbo PMAC Training
Compensation Results
Error
Uncompensated move data

Reverse Position Error

Forward Position Error

Position

462 Compensation Tables


Turbo PMAC Training
Compensation Results
Error
Compensated move data

Backlash compensation ACTIVE


Lead screw compensation INACTIVE

Position

463 Compensation Tables


Turbo PMAC Training
Compensation Results
Error
Compensated move data

Backlash compensation ACTIVE


Lead screw compensation ACTIVE

Position

464 Compensation Tables


Turbo PMAC Training
Torque Compensation Table
¾ Command
#x Define TComp{#entries},{count span}
Adjust servo output as function of position
Compensate for motor cogging torque
Automatic rollover – define for one cycle
Find settings by required steady state servo output at each point
Make sure integral gain enabled
Move, settle to in-position, read servo output

¾ Compensation Results
Actual velocity Following Error Command
Before Compensation After Compensation

465 Compensation Tables


Turbo PMAC Training
DELTA TAU
DATA SYSTEMS, INC.
thanks you for attending
TURBO PMAC TRAINING

Turbo Clipper

MACRO Fiber Optic Ring

Adv900 CNC Console

Turbo PMAC PCI


Brick Controller Geo Brick Drive Geo Brick LV

Turbo Clipper Drive

PeWin32Pro2
Turbo PMAC VME UMAC

Please let the instructor know if you have any additional questions
about the training topics or about your application before you leave.
APPENDIX
The following example code is for exercises in the Final Program and PLCs Exercises section
starting on page 285.

Exercise 1: Indexing a Motor


End Gather
Delete Gather
Close
&1
#1->10000X ;I 2000*5 cts for 1 cm
Open Prog 1 Clear ;1
Home 1 ;2 Home motor #1
CMD"Def Gat" ;3 Define Gathering Buffer
Dwell 0
CMD"Gat" ;4 Start Gathering
Dwell 0
Linear ;5
Abs
TM 900 ;6
TA 100 ;7
X 10 ;8 Move 10 user units (cm) in 1 sec
Dwell 4000 ;9 Wait for 4 sec
X 0 ;10 Move to origin in 1 sec
CMD"End Gather" ;11 End Gathering
Close ;12

467 Appendix
Turbo PMAC Training
Exercise 2: Indexing a Motor
End Gather
Delete Gat
Close

&1
#1->10000X ;I 2000*5 cts for 1 cm
Open Prog 1 Clear ;1
Home 1 ;2 Home motor #1
CMD"Def Gat" ;3 Define Gathering Buffer
Dwell 0
CMD"Gat" ;4 Start Gathering
Dwell 0
Linear ;5
Abs ;5
TM 900 ;6
TA 100 ;7
X 10 ;8 Move to 10 user units (cm)
Dwell 4000 ;9 Wait for 4 sec
TM 1900 ;10
TA 100
X 20 ;11 Move to 20 user units (cm)
Dwell 1000 ;12 Wait for 1 sec
TM 1400 ;13
TA 100 ;13
X 0 ;14 Move to origin in 1.5 sec
CMD"End Gat" ;15 End Gathering
Close ;16
M7000->Y:$078C00,0,1 ;Input 0 of ACC-11E
P7000=M7000 ;I Latch P7000 to initial M7000 value
Open PLC 1 Clear ;1
If (M7000=1 and P7000=0) ;2
CMD"%50" P7000 = 1 ;3&4 Issue feedrate override and latch P7000
Else If (M7000=0 and P7000=1);5
CMD"%100" P7000 = 0 EndIf ;6&7 Restore feedrate and delatch P7000
EndIf
Close ;8
468 Appendix
Turbo PMAC Training
Exercise 3: Conditional Branching
Undefine All
End Gat
Del Gat
Close

&1
#1->10000X ;I 2000*5 cts for 1 cm
Open Prog 1 Clear ;1
Home 1 ;2 Homing the motor #1
CMD"Def Gat" ;3 Define Gathering Buffer
Dwell 0
CMD"Gat" ;4 Start Gathering
Dwell 0
Linear ;5
Abs ;5
F 1 ;6 Move at rate of 1 user unit/sec
X 10 ;7 Move 10 user counts (cm)
Dwell 1000 ;8 Wait for 1 sec
X 0 ;9
Dwell 100 ;10
CMD"End Gat" ;11 End Gathering
Close ;12

469 Appendix
Turbo PMAC Training
Exercise 3: Conditional Branching
Open Prog 2 Clear ;1 Open PLC 1 Clear ;1
Home 1 ;2 Home motor #1 If (M7000=1 and M7001=0 and Latch1=0);2
CMD"Def Gat" ;3 Define Gat Buffer CMD"B1 R“ ;3
Dwell 0 Latch1=1 ;4
CMD"Gat" ;4 Start Gathering If(Latch2=1) ;5
Dwell 0 Latch2=0 ;6
Linear ;5 EndIf
Abs ;5 EndIf
F 2 ;6 If(M7000=0 and M7001=1 and Latch2=0) ;7
X-10 ;7 Move 10 user counts (cm) CMD"B2 R“ ;8
Dwell 1000 ;8 Wait for 1 sec Latch2=1 ;9
X 0 ;9 If(Latch1=1) ;10
Dwell 100 ;10 Latch1=0 ;11
CMD"End Gat" ;11 End Gathering EndIf
Close ;12 EndIf
#define Latch1 P8000 ;I
#define Latch2 P8001 ;I If(M7000=1 and M7001=1) ;12
Latch1=0 Latch2=0 ;II Assume 0 initially I5111=100*8388608/I10 ;13
While(I5111>0) EndWhile ;13
EndIf
Turbo PMAC Script If(M7000=0 and M7001=0) ;14
I5111=100*8388608/I10 ;15
While(I5111>0) EndWhile ;15
EndIf
Close ;16
Turbo PMAC Script

Put this code before that code when copying to your Editor Window.

470 Appendix
Turbo PMAC Training
Exercise 4: X, Y Plotter
End Gat
Del Gat
Close
M7000->Y:$078C00,0,1 ;Input 0
M7024->Y:$078C03,0,1 ;Output 0
&1
#1->2000X ;I 2000 cts for 1 inch
#2->2000Y ;II 2000 cts for 1 inch
Open Prog 1 Clear ;1
Linear ;2
Abs ;2
X 0 Y 0 ;3 Move to (0,0)
F 1 ;4 Feedrate of 1 user unit per second
CMD"Def Gat" ;5 Define Gathering Buffer
Dwell 0
CMD"Gat" ;6 Start Gathering
Dwell 0
X 10 Y 0 ;7 Move to (10,0) user counts (inch)
X 10 Y 10 ;8 Move to (10,10) user counts (inch)
X 0 Y 10 ;9 Move to (0,10) user counts (inch)
X 0 Y 0 ;10 Move to (0,0) user counts (inch)
X 10 Y 10 ;11 Move to (10,10) user counts (inch)
Dwell 0
CMD"End Gather" ;12 End Gathering
M7024=0 ;13
Close ;14
M7000->Y:$078C00,0,1 ; Input 0
M7024->Y:$078C03,0,1 ; Output 0
P7000=M7000 ;I Latch P7000 to initial value of M7000
Open PLC 1 Clear ;1
If (M7000=1 and P7000=0) ;2
CMD"B1 R" P7000=1 ;3,4 Run motion program 1 and latch P7000
M7024=1 Else If(M7000=0 and P7000=1) P7000=0 EndIf ;5,6,7 Delatch P7000
EndIf
Close ;8
471 Appendix
Turbo PMAC Training
Exercise 5: Mixed Move Modes
Undefine All
&1
#1->1000X ;I
#2->1000Y ;I
#3->1000Z ;I
; #4 will be cutter, jogging
I5113 = 5 ;II Enable segmentation, with 5 ms segmentation time
I5192 = 0 ;III Enable blending

Open Prog 10 Clear ;1


Home 1,2,3 ;2
If(M433 = 0) // If cutter is spinning ;3
#4J/ ;4 Stop cutter if running
While(M433 = 0 or M440 = 0)Wait ;5,6 Wait for cutter to stop
EndIf
Rapid X 5 Y 2 Z 1 ;7 Move to start position
#4J+ ;8 Activate spindle
I5111 = 3000*(8388608/I10) ;9 Wait 3 seconds
While(I5111>0)Wait
F 5 ;10 Feedrate of 5 user units/s
Normal K-1 ;11 Define normal to X-Y plane
Dwell 0
Circle1 I 1 ;12 Do circular move
P10 = SQRT(3) ;13 Compute required ending speed to
;achieve vectorial speed of 3 user units/s
Dwell 0
PVT 1000 X 1:(P10) Y 1:(P10) Z 3:(P10) ;14 Perform PVT move
Dwell 0
Rapid X 0 Y 0 Z 0 ;15 Move to origin
#4J/ ;16 Deactivate spindle
Dwell 0
Close ;17

472 Appendix
Turbo PMAC Training

You might also like