Turbo Pmac User Manual
Turbo Pmac User Manual
Turbo Pmac User Manual
^2 Turbo PMAC
^4 3Ax-602264-TUxx
Table of Contents
USING THIS MANUAL .............................................................................................................................................1
What is in this Manual ..............................................................................................................................................1
Other Manuals to Use................................................................................................................................................1
Turbo PMAC Software Reference Manual ...........................................................................................................1
Hardware Reference Manuals ..............................................................................................................................1
UMAC Quick Reference Guide .............................................................................................................................1
PMAC Executive Program Manual ......................................................................................................................1
Software Development Package Manuals.............................................................................................................2
TURBO PMAC FAMILY OVERVIEW ...................................................................................................................3
Turbo PMAC vs. Non-Turbo PMAC ........................................................................................................................3
Turbo PMAC vs. Turbo PMAC2 ..............................................................................................................................3
Turbo PMAC is a Computer .....................................................................................................................................3
What Turbo PMAC Does..........................................................................................................................................4
Executing Motion Programs .................................................................................................................................4
Executing PLC Programs .....................................................................................................................................4
Servo Loop Update ...............................................................................................................................................4
Commutation Update ............................................................................................................................................4
Housekeeping........................................................................................................................................................4
Communicating with the Host...............................................................................................................................4
Task Priorities.......................................................................................................................................................5
Key Hardware Components ......................................................................................................................................5
CPU Section..........................................................................................................................................................5
Machine Interface ICs...........................................................................................................................................8
Communications Ports........................................................................................................................................12
Key Software Components......................................................................................................................................13
Operational Firmware........................................................................................................................................13
Bootstrap Firmware............................................................................................................................................13
Motors, Axes, and Coordinate Systems...............................................................................................................13
User Programs....................................................................................................................................................14
Turbo PMAC Configurations..................................................................................................................................15
Board-Level Designs...........................................................................................................................................15
UMAC Rack-Mounted Designs...........................................................................................................................15
QMAC Boxed Design..........................................................................................................................................16
TURBO PMAC/PMAC2 SYSTEM CONFIGURATION AND AUTO-CONFIGURATION ............................17
CPU Clock Frequency.............................................................................................................................................17
Turbo PMAC2 System Clock Source .....................................................................................................................18
Default Clock Source ..........................................................................................................................................18
IC Clock Generation Facilities ...........................................................................................................................18
Typical Clock-Source ICs ...................................................................................................................................19
External Clock Sources.......................................................................................................................................19
Distribution of Clock Signals..............................................................................................................................19
Missing Clock Signals.........................................................................................................................................20
Re-Initialization Actions .....................................................................................................................................20
User-Customized Clock-Source Specification ....................................................................................................21
Normal Reset Actions..........................................................................................................................................22
MACRO IC Selection .............................................................................................................................................22
Dual-Ported RAM IC Selection ..............................................................................................................................23
System Configuration Status Reporting ..................................................................................................................23
Servo IC Configuration.......................................................................................................................................23
MACRO IC Configuration ..................................................................................................................................23
DPRAM IC Configuration ..................................................................................................................................24
CPU Section Configuration ................................................................................................................................24
UBUS Accessory Board Identification................................................................................................................24
Table of Contents i
Turbo PMAC User Manual
ii Table of Contents
Turbo PMAC User Manual
iv Table of Contents
Turbo PMAC User Manual
Table of Contents v
Turbo PMAC User Manual
Direction Control..............................................................................................................................................199
Inversion Control..............................................................................................................................................200
Alternate Uses...................................................................................................................................................200
Turbo PMAC Analog Input (JANA) Port .............................................................................................................200
Hardware Characteristics ................................................................................................................................200
Multiplexing Principle ......................................................................................................................................201
De-multiplexing I-Variables .............................................................................................................................201
UMAC Digital I/O Boards ....................................................................................................................................202
Addressing UMAC I/O Boards .........................................................................................................................202
Setting up UMAC I/O Boards ...........................................................................................................................203
MAKING AN APPLICATION SAFE ...................................................................................................................207
Following Error Limits..........................................................................................................................................207
Fatal Following Error Limit.............................................................................................................................207
Warning Following Error Limit........................................................................................................................207
Integrated Following Error Protection.............................................................................................................208
Position (Overtravel) Limits..................................................................................................................................208
Hardware Overtravel Limit Switches ...............................................................................................................208
Software Overtravel Limit Variables ................................................................................................................209
Velocity Limits......................................................................................................................................................210
Vector Velocity Limit ........................................................................................................................................210
Motor Velocity Limit.........................................................................................................................................210
Acceleration Limits ...............................................................................................................................................211
Command Output Limits.......................................................................................................................................211
2
Integrated Current (I T) Protection.......................................................................................................................211
Amplifier Enable and Fault Lines .........................................................................................................................213
Encoder-Loss Detection ........................................................................................................................................213
User-Written Safety Algorithms ...........................................................................................................................215
Watchdog Timer....................................................................................................................................................215
Actions on Watchdog Timer Trip ......................................................................................................................215
Diagnosing Cause of Watchdog Timer Trip .....................................................................................................215
Hardware Stop Command Inputs ..........................................................................................................................216
Host-Generated Stop Commands ..........................................................................................................................216
Program Checksums..............................................................................................................................................217
Firmware Checksum .........................................................................................................................................217
User-Program Checksum..................................................................................................................................217
Communications Data Integrity ............................................................................................................................218
EXECUTING INDIVIDUAL MOTOR MOVES .................................................................................................219
Jogging Move Control...........................................................................................................................................219
Jog Acceleration ...............................................................................................................................................219
Jog Speed ..........................................................................................................................................................219
Jog Commands..................................................................................................................................................221
Triggered Motor Moves ........................................................................................................................................222
Types of Triggered Moves.................................................................................................................................222
Types of Trigger Conditions .............................................................................................................................222
Capturing the Trigger Position.........................................................................................................................223
Post-Trigger Move............................................................................................................................................224
Homing Search Moves ......................................................................................................................................224
Jog-Until-Trigger Moves ..................................................................................................................................231
Motion Program Move-Until-Trigger...............................................................................................................232
Open-Loop Moves.................................................................................................................................................233
TURBO PMAC COMPUTATIONAL FEATURES.............................................................................................235
Computational Priorities .......................................................................................................................................235
Single Character I/O.........................................................................................................................................235
Commutation Update ........................................................................................................................................235
vi Table of Contents
Turbo PMAC User Manual
Table of Contents ix
Turbo PMAC User Manual
x Table of Contents
Turbo PMAC User Manual
Table of Contents xi
Turbo PMAC User Manual
Actually, the Pewin32 Pro package is a suite of software programs, including step-by-step tutorial setup
programs, tuning programs (interactive and auto-tuning), and plotting programs.
The Pewin32 Pro suite automates or simplifies many of the setup steps that are explained in detail for
low-level setup in this manual. Utilize the Pro Suite tools for automated setup wherever possible.
Software Development Package Manuals
Delta Tau offers several software development packages to enable the quick and easy development of
front-end software for communications with the Turbo PMAC and interface with the machine operator.
Each of these packages has its own manual.
The two most commonly used packages are the PComm32 Pro (PMAC Communications Library for 32-
bit Windows, Pro suite) library of communications routines, and the PHMI (PMAC Human-Machine
Interface) GUI development package.
Task Priorities
These tasks are ordered in a priority scheme that has been optimized to keep applications running
efficiently and safely. While the priority levels are fixed, the frequency at which various tasks are
performed is under user control. See Computational Features for more details.
Key Hardware Components
A Turbo PMAC controller is a combination of a computer processor section and specialized interface
circuitry for motion, I/O, and communications. Different configurations of Turbo PMAC controllers
provide different combinations of these components. The following block diagram shows the basic
possibilities for combinations of the concepts in PMAC and Turbo PMAC control systems.
Serial Communications
Interface
y RS-232
and / or
y RS-422 Servo Interface
Circuitry
y PMAC(1)–style ICs
y PMAC2–style ICs
y PMAC(1)–style connectors
y PMAC2–style connectors
I/O Interface CPU y Mini / Lite / (full)
Circuitry
y Non-Turbo: DSP5600x
(16-bit addressing)
y PMAC(1)-style y Turbo: DSP5630x
y PMAC2-style (24-bit addressing) MACRO Ring
Interface
y PMAC2 Ultralite
y ACC-24P
Bus Communications y ACC-5E (UMAC)
Interface
CPU Section
The computer portion of a Turbo PMAC is often called the CPU (central processing unit). It consists of a
microprocessor, memory, and associated support circuitry. In most Turbo PMAC configurations, the
CPU is on a separate circuit board from the interface circuitry – a piggyback board on top of expansion-
slot controllers, or a dedicated board in the case of the rack-mounted UMAC controllers. However, in the
Lite and Ultralite controllers, this circuitry is integrated into the main circuit board.
Processor
Turbo PMAC controllers use a processor from Motorola’s DSP56300 family of digital signal processors
(DSPs). A DSP is a special type of microprocessor optimized for fast and repeated mathematical
operations of the type found commonly in audio, video, and motion control. They provide a more cost-
effective solution to these specific types of computations than do general-purpose microprocessors.
Different members of the DSP56300 family are used depending on the CPU option ordered for the Turbo
PMAC.
• Option 5Cx (the x specifies the external memory size – see below) provides an 80 MHz DSP56303
with 8k 24-bit words of internal memory. This is the default processor.
• Option 5Dx provides a 100 MHz DSP56309 with 34k 24-bit words of internal memory.
• Option 5Ex provides a 160 MHz DSP56311 with 128k 24-bit words of internal memory. These
options require firmware revision V1.939 or newer.
• Option 5Fx (expected release in 3rd quarter 2003) provides a 240 MHz DSP56321 with 192k 24-bit
words of internal memory. These options require firmware revision V1.940 or newer.
Not all of these options are available in all Turbo PMAC configurations.
Note:
Just because a processor is capable of operating at a particular frequency does not
mean that it will actually be operating at that frequency. The value of Turbo
PMAC variable I52 at power-up/reset controls what the operating frequency of the
processor will be: 10 MHz * (I52+1). The default value of I52 is 7, for 80 MHz
operation, regardless of the CPU speed option ordered. The TYPE command will
show the frequency at which the CPU is actually operating.
To locate the CPU part number, issue the CPU on-line command. Turbo PMAC will respond with the
part number (e.g. 56311). Internally, global status bits X:$000006 bit 21 and Y:$000006 bit 21 (part of
the ??? global status query word) indicate which type of CPU is present.
Active Memory
Turbo PMAC uses static RAM (SRAM) ICs for its active memory. This type of RAM is faster and more
robust than the dynamic RAM (DRAM) that forms the bulk of the PC’s memory. (SRAM ICs are used
for the PC’s fast cache memory bank.)
As with any RAM ICs, the contents of these SRAM ICs (as well as memory registers internal to the DSP,
and memory-mapped registers in the ASICs) are lost when power is removed. Settings that should be
retained through a power-down must first be copied to non-volatile flash memory with the SAVE
command.
The Motorola DSPs employ a Harvard architecture, which uses separate memory banks for program
(compiled or assembled machine code instructions) storage and data (everything else, including
interpreted program commands) storage. This is in contrast to the more common von Neumann
architecture that the PC uses, in which any memory can be used for program or data storage.
The standard memory configuration for a Turbo PMAC (Option 5x0, where “x” specifies the CPU speed,
as explained above) provides 128k 24-bit words of program memory, and 128k 24-bit words (organized
as 64k 48-bit words) of data memory, in addition to what is internal to the DSP. This is the default
configuration. With the standard memory configuration, the total addressable memory is the sum of
memory internal to the DSP and the external memory in the SRAM ICs; getting a DSP with more internal
memory adds to your total memory capacity.
If the extended memory configuration is ordered (Option 5x3), the Turbo PMAC comes with a total of
512k 24-bit words of program memory, and 512k 24-bit words (organized as 256k 48-bit words) of data
memory. With the extended memory configuration, the total addressable memory is limited by the
addressing space of the DSP; getting a DSP with more internal memory does not add to the total memory
capacity (although it does substitute faster internal memory for slower external memory).
Status variable I4908 contains the address of the next register past last word of unreserved data memory.
If no UBUFFER has been defined, this is the address one greater than the last word of data memory.
With the standard memory configuration, no UBUFFER is defined on re-initialization. With the extended
memory configuration, a UBUFFER of 65,536 words – from X/Y:$030000 - $03FFFF – is defined
automatically on re-initialization.
Flash Memory
Turbo PMAC’s non-volatile memory storage is contained in a flash-memory IC. Flash-memory ICs
retain their contents without applied power. However, they are relatively slow in access times, so Turbo
PMAC does not use the flash IC in ongoing operation. Instead, during power-up/reset, it copies the
contents of the flash memory into fast SRAM so the processor can access it quickly. The flash memory is
only written to upon a SAVE command, or when new firmware is downloaded.
The flash memory provides non-volatile storage for both the firmware created by Delta Tau, and the
programs, variable values, and other settings created by the user. The flash memory IC is sized
depending on the active memory capacity so as to be able to store the entire contents of the active
memory. Status variables I4904 and I4909 both contain information as to what size of flash memory is
present.
Copying user settings to flash memory with the SAVE command takes several seconds during which some
other tasks, including several safety checks, are not performed; this should not be done while the machine
is in actual operation. As Turbo PMAC is copying saved data from flash memory to active SRAM during
a power-up/reset, it is evaluating the checksum of this data and comparing it to the checksum calculated
during the last SAVE operation. If there is a discrepancy, it will revert the settings in active memory to
factory default values, as if the card had been re-initialized, and set the Flash Read Error (a.k.a. “EAROM
error) status bit at X:$000006 bit 21, part of the ??? global status query word.
Optional Battery-Backed Parameter Memory
If Option 16A is ordered, the Turbo CPU section is provided with an additional bank of 32k 24-bit words
(mapped as 16k 48-bit words) of data-memory SRAM that is battery-backed (BBRAM) and can be used
for parameter storage. Typically, this memory bank is used to store machine-state information without
the need for a lengthy SAVE command.
The low-power SRAM that can be powered from batteries for lengthy periods is slower than the SRAM
ICs used for the main memory, so the user should be aware that significant use of this memory bank
might incur a noticeable computational speed penalty. P-variable and/or Q-variable storage can be moved
from fast main memory to the battery-backed memory by changing I46 from its default value of 0. This
provides automatic retention of the variable values at the cost of slower access. More commonly,
registers in the BBRAM are just accessed with M-variable as pointers. BBRAM registers start at
X/Y:$050000.
Although the expected average battery life for the lithium battery that retains this memory is five years or
more, a yearly replacement schedule is recommended. There is a super-capacitor capable of retaining the
contents of the memory for several minutes without the battery, so a battery change can be done without
power applied to the controller.
Turbo PMAC register X:$00003F contains the address of the end register of BBRAM. It will report a
value of $050000 if there is no BBRAM present. It will report a value of $054000 if the Option 16A
BBRAM is present. It will report a value of $060000 if extended BBRAM is present (Turbo PMAC
designs support this but it is not being sold at this time).
HOME 1-
+LIMIT 1-
PMAC 4-LIMIT 1-
FAULT 1-
4
CUSTOM 4
AENA 1-4
EQU 1-4
SELECTABLE-FREQUENCY CLOCK INPUTS LD
ENCODER DAC 1
SAMPLE SERVO PHASE
LD
DAC 2 4
ANALOG
OUTPUTS.
INPUT
FLAGS 16 BIT
LD
FLAG DAC 3 RESOLUTION
A CONTROL
B ENCODER 1
C OUTPUT
FLAGS
SERIAL LD
A DAC 4
DAC SHIFT REGISTERS (4) DATA OUT
B ENCODER 2
C
4 OPTO
ENCODER ISOLATION
INPUTS A DSP-GATE
1
B ENCODER 3 SERIAL
C 4
DATA IN ADC 2
ANALOG
ADC SHIFT REGISTERS (4) MUX
16 BIT 3 INPUTS
A
B 4
ENCODER 4
C
CLOCK
ANALOG
CONTROL
ENCODER MUX
CONTROL
ACCESSORY BOARD
CONTROL
24-BIT 16-BIT
DATA BUS ADDRESS BUS
The DSPGATE1 IC also has on-board software-configurable clock generation circuitry. It can generate
the servo and phase clocks for the entire Turbo PMAC system (only one IC will do this; the others will
accept these as inputs). It also generates the clock signals that drive its own circuitry: DAC, ADC, PWM
and PFM (pulse-frequency-modulation).
9
Flag 1 ADCIN1 A,B 2
2
9
Flag 2 ADCIN2 A,B 2
2
9
Flag 3 ADCIN3 A,B 2
2
9
Flag 4 ADCIN4 A,B 2
2
Encoder/Flag Output/ADCIN
Status & Control Control 2
2 Clock, PLL
24-bit 6-bit
DATA BUS ADDRESS BUS
Turbo PMAC variable I4902 reports how many MACRO ICs are present, and at which addresses. I4903
reports which type each MACRO IC is, a DSPGATE2 or a MACROGATE (see below). Variables I20 –
I23 specify the addresses of the four MACRO ICs that are automatically configured with I-variables. The
following table summarizes this configuration:
MACRO IC # I Variables Usual Base Address Usual Type
0 I6800 – I6849 $078400 DSPGATE2
1 I6850 – I6899 $079400 MACROGATE
2 I6900 – I6949 $07A400 MACROGATE
3 I6950 – I6999 $07B400 MACROGATE
DSPGATE2 MACRO IC
The DSPGATE2 IC provides both MACRO-ring functions and general-purpose I/O functions. The I/O
functions are described in the next section. For the MACRO ring, the DSPGATE2 provides a 16-node bi-
directional interface. Of these nodes, eight can be used as servo nodes, each of which can transfer all of
the command and feedback data required for the servo and commutation of a motor. Six of the nodes can
be used for general-purpose I/O, each node supporting 72 bits of hard real-time I/O in each direction.
Two of the nodes are for non-real-time communications, including broadcast mode in which a master
controller can talk to all of its slave devices simultaneously.
Turbo PMAC2 Ultralite controllers come standard with a single DSPGATE2 IC, for a 16-node MACRO
interface. The UMAC Acc-5E also comes standard with a single DSPGATE2 IC.
MACROGATE MACRO IC
The MACROGATE IC provides the same 16-node MACRO-ring interface as does the DSPGATE2 IC,
but it does not have the I/O capability of a DSPGATE2. Subsequent optional MACRO ICs (Options 1U1,
1U2, and 1U3) on a Turbo PMAC2 Ultralite are MACROGATE ICs.
I/O ICs
The Turbo PMAC CPU accesses general-purpose digital I/O through a variety of I/O interface ICs. On
Turbo PMAC boards, these are modern equivalents of the classic 8255 IC design originally made by
Intel. These ICs are addressed by a Turbo PMAC CPU at Y:$078800 – Y:$078803.
On Turbo PMAC2 boards, and UMAC I/O boards, these are Delta Tau-designed I/O ASICs, as described
below.
DSPGATE2 I/O IC
The DSPGATE2 IC provides both MACRO-ring functions and general-purpose I/O functions. The
MACRO functions are described in the previous section. Each board-level Turbo PMAC2 board and the
UMAC’s Acc-5E board use the DSPGATE2 to support the non-servo I/O ports. These ports are:
• The JTHW multiplexer port
• The JIO general-purpose I/O port
• The JDISP display port
• The JHW handwheel port
The DSPGATE2 IC on a board-level Turbo PMAC2 is addressed at Y:$078400 – Y:$07843F. On a
UMAC Acc-5E board with the address DIP-switches in the default configuration, the DSPGATE2 IC is
addressed at this same location.
IOGATE I/O IC
The IOGATE IC is used to access general-purpose digital I/O on most of the UMAC I/O boards. It
provides 48 I/O points, addressed as 6 bytes in consecutive registers. Different boards use different
buffers and drivers around the IOGATE to provide the specific I/O features desired. While on the
IOGATE itself, each I/O point is individually selectable as to direction, on most of the I/O boards, each
point’s direction is fixed by the external circuitry for that point. The IOGATE must be set up at power-
on/reset to support the particular direction configuration of the board it is used on.
Potentially, up to 16 boards with the IOGATE or similar ICs can be installed in a UMAC system. The
following table shows the possible addresses of these boards:
DIP Base DIP Base DIP Base DIP Base
Switch Address Switch Address Switch Address Switch Address
0 $078C00 4 $079C00 8 $07AC00 12 $07BC00
1 $078D00 5 $079D00 9 $07AD00 13 $07BD00
2 $078E00 6 $079E00 10 $07AE00 14 $07BE00
3 $078F00 7 $079F00 11 $07AF00 15 $07BF00
Communications Ports
Turbo PMAC controllers provide multiple communications ports. These ports can be used
simultaneously, permitting the use of a second port for debugging while the primary port is used in the
actual application, or of a second port for an operator pendant.
Bus Ports
Each configuration of the Turbo PMAC supports a bus port for fast parallel communications. These
utilize the host port on the DSP, and optionally dual-ported RAM for communications through shared
memory. The buses can be either the traditional backplane buses, or the newer wire buses.
The backplane buses currently supported are:
• ISA (or the PC/104 stack version)
• PCI
• VME
Axes
Generally, motions in a Turbo PMAC system are commanded through the use of axes. An axis in Turbo
PMAC consists of the software structures for programmed moves. Axes are specified by letter (A, B, C,
U, V, W, X, Y, and Z), and their attributes are specified in terms of user-specified units (e.g. millimeters,
inches, degrees, seconds, minutes).
Axes are assigned to motors through axis definition statements or kinematic subroutines. While there is
usually a one-to-one mapping between axes and motors (e.g. Motor 1 assigned to the X-axis and Motor 2
assigned to the Y-axis), this does not have to be the case. Multiple motors can be assigned to a single
axis, as in a gantry configuration; there can be no motors assigned to an axis, creating a virtual axis; or
there can be a complex relationship of multiple motors to multiple axes in a kinematic algorithm.
An axis belongs to a coordinate system (see below). Up to 9 axes may be used in a single coordinate
system, one of each letter name.
Coordinate Systems
The coordinate system is Turbo PMAC’s structure for achieving tightly coordinated motion of multiple
motors. Turbo PMAC supports up to 16 separate coordinate systems. A motor is assigned to an axis in a
particular coordinate system. Multiple axes in the same coordinate system that are commanded on the
same line of a motion program are automatically coordinated.
To make the motion of more than one motor coordinated, assign them to axes in the same coordinate
system. To have independent motion of motors (i.e. starting stopping, and changing speeds at arbitrary
times with respect to each other, assign the motors to axes in separate coordinate systems.
User Programs
Turbo PMAC users can install several types of programs into the controller, each type with a specific
purpose.
Motion Programs
Turbo PMAC motion programs provide an easy way to specify sequences of coordinated motion and the
execution of any calculations that are synchronous with the programmed motions. The motion program
language combines features of the RS-274 standard G-code machine-tool programming language, which
is good for specifying sequences of coordinated motion, and BASIC, which is good for the associated
math and logic.
PLC Programs
PLC programs in Turbo PMAC are intended for actions and calculations that are asynchronous to the
programmed motion. PLC programs repeatedly scan in the fashion of regular programmable logic
controllers. They can be used for I/O control as a dedicated PLC would be, but because they have direct
access to all registers in Turbo PMAC, they have many other uses as well.
Turbo PMAC programs can either be written in a BASIC-like text language, or in IEC-1131 ladder logic
or sequential function charts (extended memory option and special PC software required). Text PLC
programs can be run either as interpreted code, or as compiled code for greater efficiency. See the User
Manual section on PLC programs for more details.
User-Written Servo and Phase Algorithms
Virtually all users will be able to utilize Turbo PMAC’s built-in servo-loop-closure and phase-
commutation algorithms. However, it is possible for the user to install custom algorithms for either or
both of these to accomplish tasks not possible with the standard algorithms. Some people will use these
algorithms simply for high-speed, high-priority I/O or calculations by activating them on an otherwise
unused motor.
User-written servo algorithms can be written either in the high-level PMAC language (for ease of use) or
in DSP56300 assembly language (for maximum efficiency). User-written phase algorithms must be
written in assembly language. See the User Manual sections on commutation and servo loops for details.
System clock frequencies such as the phase and servo clocks, plus the clock frequencies driving hardware
circuits, are generated directly from the clock-crystal frequency through a Servo IC or a MACRO IC and
are not dependent on the CPU operating frequency. These clock frequencies are covered in the following
sections.
Turbo PMAC2 System Clock Source
In a Turbo PMAC2 system, the system phase and servo clocks, which interrupt the processor and latch
key input and output data for the servos, come from one (and only one) of the Servo ICs or MACRO ICs
in the system, or possibly from an external source. There must be a unique source of the phase and servo
clocks for an entire Turbo PMAC2 system. This section explains how to specify that clock source. A
later portion of this section, Setting System Clock Frequencies, explains how to set the frequencies once
the source has been determined.
Default Clock Source
The factory-default source for these clock signals is appropriate in almost all applications. Only in
specialized cases will another source be used. The Turbo Setup program will walk you through the setup
of the frequencies for the source selected. Setting the frequencies is discussed in the next section.
Note:
A Turbo PMAC board uses fixed, discrete logic to generate its phase and servo
clocks. If accessory boards with Servo ICs or MACRO ICs that can generate their
own clock signals are added to a Turbo PMAC, they must be set up to use the
Turbo PMAC’s phase and servo clock signals. Turbo PMAC systems also do
support external clock sources in the same way that Turbo PMAC2 systems do.
UMAC Systems
In UMAC systems (including Compact UMAC), the phase and servo clocks are shared across the UBUS
backplane board among the different 3U-format cards inserted into that backplane. Each card has buffer
ICs for these signals as they interface to the backplane. On cards that are potential sources of the phase
and servo clock signals, such as the Acc-24E/C axis boards or the Acc-5E MACRO board, these buffers
can be configured as either inputs or outputs.
On each UMAC board that could be a clock source, there is a jumper that controls the configuration of the
clock-direction buffers. In one setting, the board can only input the clock signals. This setting is required
for the UMAC MACRO, in which the clock signals always come from the MACRO interface board. It is
permissible, but not recommended, for boards in UMAC Turbo systems that will be not be generating
their own phase and servo clock signals. This setting is not permissible for the UMAC board that is
generating the system phase and servo clocks.
In the other setting, the direction of the clock-signal buffers can be reversed by the Turbo CPU. This
setting is required for the board that is generating the system clocks; it is recommended for the other
boards as well (so the source can be changed without moving any buffers). At power-up/reset, the CPU
will configure the buffers the board containing the Servo IC or MACRO IC that is specified by I19 to
generate the system clocks as outputs to the UBUS backplane; it will configure the buffers on all other
boards to be inputs from the UBUS backplane.
Missing Clock Signals
If the phase and/or servo clock signals are not present, this is a serious failure, and the Turbo PMAC
system will not be able to operate properly. This section explains how Turbo PMAC systems respond to
such a failure.
Board-Level Turbo PMACs
On board-level Turbo PMACs, if the CPU does not receive the phase and servo clock signals at any time,
the watchdog timer will immediately trip and shut down the system completely. If this happens
immediately at power-up/reset due to improper configuration of the clock-source setup, install the re-
initialization jumper and power up the system again to restore a valid clock source from one of the on-
board Servo ICs or MACRO ICs.
UMAC Systems
In a UMAC system (including Compact UMAC), if the CPU does not receive any phase or servo clock
signals over the UBUS backplane immediately after configuring the clock source, it will go into a special
mode in which it generates its own phase and servo clocks at the factory default frequencies of 9.03 kHz
and 2.26 kHz, respectively. In this case, it sets the global status bit No hardware clocks found at
X:$000006 bit 3 to 1.
This mode is intended to keep the system alive to permit the user to set up the clock configuration
information properly for their setup. It is not intended for the UMAC to be able to do actual control in
this mode. In firmware revisions V1.940 and newer, no motor can be enabled if this error bit is set, with
the Turbo PMAC reporting an ERR018 to an enabling command if I6 is set to 1 or 3.
If the UMAC CPU stops receiving the phase or servo clock signals after this time, the watchdog timer
will trip and immediately shut down the system completely.
Re-Initialization Actions
On re-initialization of a Turbo PMAC2 ($$$*** command, or power-on/reset with re-initialization
jumper E3 ON), the CPU searches all possible locations of Servo ICs and MACRO ICs to see which are
present. If the system is not set up for an external clock source, it then makes a decision as to which of
these ICs it will use to generate the system’s phase and servo clocks, using the first IC that it finds in the
following list:
I4903 is also a collection of 16 independent bits, each reporting the type of MACRO IC at one of the 16
possible locations. A bit value of 1 indicates a DSPGATE2 IC; a bit value of 0 indicates a
MACROGATE IC (or no IC present if the corresponding bit of I4900 is 0).
While it is possible for up to 16 MACRO ICs to be installed in a Turbo PMAC system, only four of these
can be supported at any time by automatic firmware functions. I20 – I23 contain the base addresses of
these four ICs. When the system is re-initialized, these variables are set to values for the four ICs found
with the lowest base addresses.
DPRAM IC Configuration
On power-up/reset, the Turbo PMAC CPU automatically tests for the presence of all possible dual-ported
RAM ICs and reports the results in I4904. I4904 is a collection of eight independent bits, each reporting
the presence of a DPRAM IC at one of the eight possible locations. Only one of these ICs can be
supported at any time by automatic firmware functions. I24 contains the base address of this IC.
CPU Section Configuration
On power-up/reset, the Turbo PMAC automatically tests for the configuration of its own CPU section and
reports the results in I4908. I4908 is a 36-bit value reporting the CPU type, active memory size, DPRAM
size, battery-backed RAM size, flash memory size, presence of auxiliary serial port, part number, and
vendor ID.
UBUS Accessory Board Identification
The Turbo PMAC can report detailed information about accessory boards installed on the UBUS
expansion port in UMAC Turbo systems. This information is reported in variable I4910 – I4965. Each is
a 36-bit variable with the following contents:
Vendor ID: 8 bits
Options present: 10 bits
Revision number: 4 bits
Card ID (part number): 14 bits
Each variable can report one part or all parts of this information, depending on the setting of I39. If I39 is
set to 5, the variable reports the base address of the accessory board instead.
I4910 – I4925 report this information for the 16 possible accessory boards with Servo ICs, such as the
Acc-24E2, 24E2A, 24E2S, and 51E.
I4926 – I4941 report this information for the 16 possible accessory boards with MACRO ICs, such as the
Acc-5E.
I4942 – I4949 report this information for the 8 possible accessory boards with DPRAM ICs, such as the
Acc-54E USB/Ethernet interface.
I4950 – I4965 report this information for the 16 possible accessory boards with I/O ICs, such as the Acc-
14E, 28E, 36E, 53E, and 59E. (The Acc-9E, 10E, 11E, and 12E I/O boards currently cannot provide this
information.)
Setting System Clock Frequencies
The phase clock and servo clock signals set the heartbeat for the entire Turbo PMAC system,
synchronizing both hardware and software operations. While the factory default frequencies – 9.04 kHz
for the phase clock and 2.26 kHz for the servo clock – are suitable for most applications, some
applications will either require changes, or could benefit from changes in one or both of these frequencies.
The hardware tasks that are driven by the phase and servo clock signals include:
• Latching of encoder counters
• Latching of parallel feedback registers
• Strobing of A/D converters and latching of resulting data
• Output to D/A converters
PWM Max
Count
PWM Dead Time/
PFM Pulse Width 8
DT / PW
24 6 40 MHz
1
Data Address
3
Encoder Sample n = 0 - 7 1 SLCK
Clock Control 2n
PFM n=0-7 1 PFMCLK
Clock Control 2n
DAC n=0-7 1 DACCLK
Clock Control 2n
ADC n=0-7 1 ADCCLK
Clock Control 2n
Int/Ext Phase
Int/Ext Servo
Phase n = 0 - 15 1 PHASE
Clock Control 2n
Servo n = 0 - 15 1 SERVO
Clock Control 2n
External External
Phase Servo
At the default value of 3 (divide by 4) and the default phase clock frequency of 9.04 kHz, this sets a servo
clock frequency of 2.26 kHz (442 µsec period). The following diagram shows the relationship between
the PWM counter, whose frequency is set by the I7m00/I6800 Max Count parameter, the resulting
MaxPhase clock signal, and the Phase and Servo clock signals that are derived from MaxPhase.
PMAC2 Clock Signal Example
+ Max
Count
PWM
Counter t
- Max
Count
Max
Phase
Phase
Servo
Bit
The table shown in an above section and in the Hardware Reference Manual for the 3U MACRO
Station’s SW1 switch setting provides a starting point for the Turbo PMAC2’s I6841/I6891/I6941/I6991
value. Additional bits of these I-variables may be set to 1 if I/O nodes are enabled or if more than one 3U
MACRO station is commanded from a single MACRO IC.
I70/I72/I74/I76: MACRO IC 0/1/2/3 Node Auxiliary Function Enable
I70, I72, I74, and I76 are 16-bit I-variables (bits 0 - 15) in which each bit controls the enabling or
disabling of the auxiliary flag function for the MACRO node number matching the bit number for
MACRO ICs 0, 1, 2, and 3, respectively. A bit value of 1 enables the auxiliary flag function; a bit value
of 0 disables it. If the function is enabled, PMAC automatically copies information between the MACRO
interface flag register and RAM register $00344n, $00345n, $00346n, and $00347n (where n is the IC’s
node number 0 – 15) for MACRO ICs 0, 1, 2, and 3, respectively.
Note that Turbo PMAC MACRO node numbers (as opposed to individual MACRO IC node numbers) go
from 0 to 63, with board nodes 0 – 15 on MACRO IC 0, board nodes 16 – 31 on MACRO IC 1, board
nodes 32 – 47 on MACRO IC 2, and board nodes 48 – 63 on MACRO IC 3.
Each MACRO node n that is used for servo functions should have the corresponding bit n of I70, I72,
I74, or I76 set to 1. Ixx25 for the Motor x that uses Node n should then address $00344n, $00345n,
$00346n, or $00347n, not the address of the MACRO register itself (see below). If Register 3 of a
MACRO node n is used for other purposes, such as direct I/O, the corresponding bit n of I70, I72, I74, or
I76 should be set to 0, so this copying function does not overwrite these registers.
Typically, non-servo I/O functions with a MACRO Station do not involve auxiliary flag functions, so this
flag copy function should remain disabled for any node used to transmit I/O between the Turbo PMAC2
and the MACRO Station. If any auxiliary communications is done between the Turbo PMAC2 and the
MACRO Station on Nodes 14 and/or 15, bits 14 and 15 of these variables must be set to 0.
Examples:
I70=$3 ; Enabled for MACRO IC 0 Nodes 0 and 1
I72=$30 ; Enabled for MACRO IC 1 Nodes 4 and 5
I74=$3300 ; Enabled for MACRO IC 2 Nodes 8,9,12,13
I76=$3333 ; Enabled for MACRO IC 3 Nodes 0,1,4,5,8,9,12,13
I78 must be set greater than 0 if any auxiliary communications is desired with a MACRO Station. This
reserves Node 15 for the Type 1 Auxiliary Communications. A value of 32 is suggested. If I78 is set
greater than 0, bit 15 of I70, I72, I74, and I76 must be set to 0, so Node 15 is not used for flag transfers also.
I79: MACRO Master/Master Auxiliary Communications Timeout
If I79 is set greater than 0, the MACRO Type 1 Master/Master Auxiliary Communications protocol using
Node 14 is enabled. Turbo PMAC implements this communications protocol using the MACROMASTER
(MM), MACROMSTREAD (MMR), and MACROMSTWRITE (MMW) commands. Only the Turbo PMAC that is
the “ring controller” can execute these commands; other Turbo PMACs that are masters on the ring can
respond to these commands from the ring controller.
If this function is enabled, I79 sets the “timeout” value in PMAC servo cycles. In this case, if the Turbo
PMAC does not get a response to a Node 14 master/master auxiliary communications command within
I79 servo cycles, it will stop waiting and register a “MACRO auxiliary communications error,” setting Bit
5 of global status register X:$000006.
I79 must be set greater than 0 if any auxiliary communications is desired with a MACRO Station. A
value of 32 is suggested. If a value of I79 greater than 0 has been saved into PMAC’s non-volatile
memory, then at subsequent power-up/resets, bit 14 of I70 is set to 0, the node-14 broadcast bit (bit 14 of
I6840) is set to 1, and activation bit for node 14 (bit 14 of I6841) is set to 1, regardless of the value saved
for these variables. This reserves Node 14 of MACRO IC 0 for the Type 1 Master/Master Auxiliary
Communications.
I80, I81, I82: MACRO Ring Check Period and Limits
If I80 is set to a value greater than zero, Turbo PMAC will monitor for MACRO ring breaks or repeated
MACRO communications errors automatically. A non-zero value sets the error detection cycle time in
Turbo PMAC servo cycles. Turbo PMAC checks to see that “sync node” packets (see I6840 and I6841)
are received regularly, and that there have not been regular communications errors.
The limits for these checks can be set with variables I81 and I82. If less than I82 sync node packets have
been received and detected during this time interval, or if I81 or more ring communications errors have
been detected in this interval, Turbo PMAC will assume a major ring problem, and all motors will be shut
down. Turbo PMAC will set the global status bit “Ring Error” (bit 4 of X:$000006) as an indication of
this error.
Turbo PMAC looks for receipt of sync node packets and ring communications errors once per real-time
interrupt – every (I8 + 1) servo cycles). The time interval set by I80 must be large enough that I82 real-
time interrupts in PMAC can execute within the time interval, or false ring errors will be detected.
Remember that long motion program calculations can cause skips in the real-time interrupt. Typically
values of I80 setting a time interval of about 20 milliseconds are used. I80 can be set according to the
formula:
I80 = Desired cycle time (msec) * Servo update frequency (kHz)
For example, with the default servo update frequency of 2.26 kHz, to get a ring check cycle interval of 20
msec, I80 would be set to 20 * 2.26 ≅ 45.
MACRO Node Addresses
The MACRO ring operates by copying registers at high speed across the ring. Therefore, each Turbo
PMAC2 master controller on the ring communicates with its slave stations by reading from and writing to
registers in its own address space. MACRO hardware handles the data transfers across the ring automatically.
Starting in Turbo firmware version 1.936, the base addresses of the up to 4 MACRO ICs must be
specified in I20 – I23, for MACRO IC 0 – 3 respectively. Before this, the base addresses were fixed at
$078400, $079400, $07A400, and $07B400, respectively. Only UMAC Turbo systems can support any
other configuration, and only rarely will another configuration be used.
The following table gives the addresses of the MACRO ring registers for Turbo PMAC2 controllers.
Note:
It is possible, although unlikely, to have other addresses in a UMAC Turbo system.
In these systems, the fourth digit does not have to be 4; it can also take the values
5, 6, and 7.
Register Addresses for MACRO IC 0 with I20=$078400 (default)
Turbo PMAC2 Addresses: MACRO IC 0
Node # Reg. 0 Reg. 1 Reg. 2 Reg. 3
0 Y:$078420 Y:$078421 Y:$078422 Y:$078423
1 Y:$078424 Y:$078425 Y:$078426 Y:$078427
2 X:$078420 X:$078421 X:$078422 X:$078423
3 X:$078424 X:$078425 X:$078426 X:$078427
4 Y:$078428 Y:$078429 Y:$07842A Y:$07842B
5 Y:$07842C Y:$07842D Y:$07842E Y:$07842F
6 X:$078428 X:$078429 X:$07842A X:$07842B
7 X:$07842C X:$07842D X:$07842E X:$07842F
8 Y:$078430 Y:$078431 Y:$078432 Y:$078433
9 Y:$078434 Y:$078435 Y:$078436 Y:$078437
10 X:$078430 X:$078431 X:$078432 X:$078433
11 X:$078434 X:$078435 X:$078436 X:$078437
12 Y:$078438 Y:$078439 Y:$07843A Y:$07843B
13 Y:$07843C Y:$07843D Y:$07843E Y:$07843F
14 X:$078438 X:$078439 X:$07843A X:$07843B
15 X:$07843C X:$07843D X:$07843E X:$07843F
Register Addresses for MACRO IC 1 with I21=$079400 (default)
Turbo PMAC2 Addresses: MACRO IC 1
Node # Reg. 0 Reg. 1 Reg. 2 Reg. 3
0 Y:$079420 Y:$079421 Y:$079422 Y:$079423
1 Y:$079424 Y:$079425 Y:$079426 Y:$079427
2 X:$079420 X:$079421 X:$079422 X:$079423
3 X:$079424 X:$079425 X:$079426 X:$079427
4 Y:$079428 Y:$079429 Y:$07942A Y:$07942B
5 Y:$07942C Y:$07942D Y:$07942E Y:$07942F
6 X:$079428 X:$079429 X:$07942A X:$07942B
7 X:$07942C X:$07942D X:$07942E X:$07942F
8 Y:$079430 Y:$079431 Y:$079432 Y:$079433
9 Y:$079434 Y:$079435 Y:$079436 Y:$079437
10 X:$079430 X:$079431 X:$079432 X:$079433
11 X:$079434 X:$079435 X:$079436 X:$079437
12 Y:$079438 Y:$079439 Y:$07943A Y:$07943B
13 Y:$07943C Y:$07943D Y:$07943E Y:$07943F
14 X:$079438 X:$079439 X:$07943A X:$07943B
15 X:$07943C X:$07943D X:$07943E X:$07943F
Note:
With the MACRO station, only nodes that map into Turbo PMAC2 Y registers (0,
1, 4, 5, 8, 9, 12, and 13) can be used for servo control. These nodes are unshaded
in the above table. The nodes that map into X registers (2, 3, 6, 7, 10, 11, and 14)
can be used for I/O control. Node 15 is reserved for Type 1 auxiliary
communications. Node 14 is often reserved for broadcast communications.
2. The last-saved user configuration – variable values and definitions, user programs, tables, and buffers
– are loaded from the flash memory into active memory and registers. During this loading, the
checksums of the saved data are evaluated. If the checksum for the saved I-variables does not match
the data, all I-variables in active memory are returned to their factory default values. If the checksum
for the programs and buffers does not match the data, all of these programs and buffers are
completely cleared from active memory.
3. The basic configuration of the system – memory capacity, ASIC presence, location, and type – is
checked and logged. Counters in all ASICs are cleared.
4. All motors with Ixx80 bit 0 set to 1 are enabled.
5. All existing PLC programs whose operation is permitted by the saved value of I5 are activated.
Actions on Reset with Re-Initialization
If any of the above methods for resetting is used when the Turbo PMAC is configured for re-initialization,
the actions described in this section will occur. A Turbo PMAC is configured for re-initialization when
both of the following conditions are true:
1. The re-initialization jumper (E51 on a Turbo PMAC, E3 on a Turbo PMAC2) IS installed.
2. The four bootstrap mode jumpers for the CPU (E4 – E7 on the piggyback Turbo CPU board, E20 –
E23 on UMAC and UMAC-CPCI CPU boards) are in their standard configuration (outer two jumpers
off, inner two jumpers on).
For a Turbo PMAC configured in this manner, when digital power is applied, or the hardware reset line is
released to go high, or the $$$ software reset command is given, the following actions occur:
1. The installed firmware is loaded from the flash memory into active memory.
2. The factory default I-variables are loaded from firmware into active memory and registers. (The last
saved values in flash are not lost; they are simply not used.) The last saved user programs, table and
buffers are loaded into active memory, but none will be active because of the default I-variable
settings. If the checksum for the programs and buffers does not match the data, all of these programs
and buffers are completely cleared from active memory.
3. The basic configuration of the system – memory capacity, ASIC presence, location, and type – is
checked and logged. The CPU will make some decisions about default I-variable values based on this
configuration information. Counters in all ASICs are cleared.
4. Because of the default I-variable configuration, no motors are enabled, and no programs are activated.
Actions on Reset for Firmware Reload
If any of the above methods for resetting is used when the Turbo PMAC is configured for firmware
reload, the actions described in this section will occur. A Turbo PMAC is configured for firmware reload
when the four bootstrap mode jumpers for the CPU (E4 – E7 on the piggyback Turbo CPU board, E20 –
E23 on UMAC and UMAC-CPCI CPU boards) are in their firmware-reload configuration (first jumper
OFF, last three jumpers ON).
For a Turbo PMAC configured in this manner, when digital power is applied, or the hardware reset line is
released to go high, or the $$$ software reset command is given, only the bootstrap firmware is loaded
into active memory. At this point, it is ready to accept the download of new operational firmware into its
flash memory through either the main serial port or a bus port that operates through the host port of the
DSP (not VME or DPRAM).
The PMAC Executive program, when it establishes communications with a Turbo PMAC reset into this
mode, will detect that the Turbo PMAC is in bootstrap mode and ready to accept new firmware
automatically. It will ask for the name of the file containing the firmware to download.
Updating the firmware will cause Turbo PMAC to revert to default I-variables. Make sure the
configuration is backed up before the new firmware is downloaded.
If writing a custom application to perform this function, detect that the Turbo PMAC is in bootstrap mode
by sending the ? query command. In this mode, it will respond with the string BOOTSTRAP PROM
instead of a hexadecimal status word. Sending the <CTRL-O> character will prepare the Turbo PMAC
for the downloading of the binary firmware file. Wait at least five seconds after sending this character to
make sure that the flash IC is ready to accept data. Sending the <CTRL-R> command will take the Turbo
PMAC out of bootstrap mode and cause it to take the actions of a normal reset.
Re-Initialization and Clear Command
The $$$*** command causes a reset and full re-initialization of Turbo PMAC. In addition to loading
default I-variable values, it also clears out all of the buffers in active RAM: motion program, PLC
program, tables, etc.
Some users will always have the card set up to re-initialize and clear during the reset cycle; they then
download all parameter settings and programs immediately after each cycle. The logic behind this
strategy is that the same startup sequence of operations is used even if a new replacement board has just
been put in. It is also useful for those applications that do not wish to rely in any way on Turbo PMAC’s
own non-volatile flash storage.
For a complete re-initialization of Turbo PMAC to known state, the following commands can be added:
P0..8191=0
Q0..8191=0
M0..8191->*
UNDEFINE ALL
Remember that these commands directly affect only active memory (RAM). To copy new settings into
non-volatile flash memory, use the SAVE command.
The values of I54 and the baud rates they produce are:
I54 Baud Rate I54 Baud Rate I54 Baud Rate I54 Baud Rate
0 600 4 2400 8 9600 12 38,400
1 900 5 3600 9 14,400 13 57,600
2 1200 6 4800 10 19,200 14 76,800
3 1800 7 7200 11 28,800 15 115,200
The baud rates produced by odd-number settings of I54 are only exact if the CPU frequency is an exact
multiple of 30 MHz (technically, of 29.4912 MHz). This is because the baud rates are created by dividing
the CPU frequency by (256 * N), where N is an integer taken from a lookup table. The frequency is not
an exact match for odd settings of I54 and CPU frequencies that are not multiples of 30 MHz. For lower
baud rates of this type, the error is not significant. However, serial communications at 115,200 baud is
possible only if the CPU is running at an exact multiple of 30 MHz (actually an exact multiple of 29.4912
MHz). So to communicate at this rate, run an Option 5Cx 80 MHz CPU at 60 MHz, an Option 5Dx 100
MHz CPU at 90 MHz, and an Option 5Ex 160 MHz CPU at 150 MHz by setting I52 to a lower value than
the CPU is capable of.
It is possible to download new operational firmware through the main serial port (see Resetting Turbo
PMAC).
Auxiliary Serial Port
If Option 9T for the Turbo PMAC is ordered, directly or as part of an option package (as for the PMAC
Ladder programming environment), a second serial port is provided on the Turbo PMAC. This port is
required for programming and monitoring the PMAC Ladder IEC-1131 PLC programs.
Auxiliary Port Baud Rate
The baud rate for the auxiliary serial port is set by variable I53. At power-up reset, Turbo PMAC sets the
active baud-rate-control register based on the setting of I53 and the CPU speed as set by I52, as the baud-
rate frequency is divided down from the CPU’s operational frequency. The factory default baud rate is
38,400. If you wish to change the baud rate, you must change the setting of I53, copy this new setting to
non-volatile memory with the SAVE command, then reset the Turbo PMAC. Then you must re-establish
communications at the new baud rate. The values of I53 and the baud rates they produce are:
I53 Baud Rate I53 Baud Rate I53 Baud Rate I53 Baud Rate
0 600 4 2400 8 9600 12 38,400
1 900 5 3600 9 14,400 13 57,600
2 1200 6 4800 10 19,200 14 76,800
3 1800 7 7200 11 28,800 15 115,200
The baud rates produced by odd-number settings of I53 are only exact if the CPU frequency is an exact
multiple of 30 MHz (technically, of 29.4912 MHz). This is because the baud rates are created by dividing
the CPU frequency by (256 * N), where N is an integer taken from a lookup table. The frequency is not
an exact match for odd settings of I53 and CPU frequencies that are not multiples of 30 MHz. For lower
baud rates of this type, the error is not significant. However, serial communications at 115,200 baud is
only possible if the CPU is running at an exact multiple of 30 MHz (actually an exact multiple of 29.4912
MHz). So to communicate at this rate, run an Option 5Cx 80 MHz CPU at 60 MHz, an Option 5Dx 100
MHz CPU at 90 MHz, and an Option 5Ex 160 MHz CPU at 150 MHz by setting I52 to a lower value than
the CPU is capable of.
The following table shows how the jumpers (Turbo PMAC boards) or DIP switches (Turbo PMAC2) set
the base address on the ISA or PC/104 port. A PMAC jumper that is OFF or a PMAC2 DIP-switch that is
OPEN adds the associated bit value to the base address; a jumper that is ON or a DIP-switch that is
CLOSED adds nothing to the base address value.
Address Bit # 15 14 13 12 11 10 9 8 7 6 5 4
PMAC1 Jumper x x x x E91 E92 E66 E67 E68 E69 E70 E71
PMAC2 Switch 12 11 10 9 8 7 6 5 4 3 2 1
Bit Val (Dec) 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16
Bit Val (Hex) $8000 $4000 $2000 $1000 $800 $400 $200 $100 $80 $40 $20 $10
Default Jumper - - - - ON ON OFF ON ON ON ON OFF
Default Switch CLS CLS CLS CLS CLS CLS OPN CLS CLS CLS CLS OPN
PCI Bus
The PCI bus interface comes standard on board-level Turbo PMAC controllers with the –PCI suffix (e.g.
Turbo PMAC-PCI, Turbo PMAC2-PCI). The UMAC-CPCI Turbo CPU board has been designed to
accept a daughter board that implements the Compact PCI interface, a rack-mounted version of the PCI
bus (equivalent electrically and in software), but as of this writing the CPCI daughter board has not been
implemented.
The basic communications on the PCI bus goes through the host port on the Turbo PMAC’s CPU. Dual-
ported RAM is an optional addition to this bus interface (see below). The address of the host port
communications in the I/O space of the PCI bus is selected by the host computer’s operating system.
Recent Microsoft Windows operating systems do this on a plug-and-play basis. The design of the PCI
bus interface on Turbo PMACs was implemented to be as much as possible like the older ISA bus
interface, to minimize any transition problems from users changing over from ISA. Other than the
automatic address setting, the software interface to the PCI bus on Turbo PMACs is identical to that for
the ISA bus.
VME Bus
The VME bus interface comes standard on board-level Turbo PMAC controllers with the –VME suffix
(e.g. Turbo PMAC-VME, Turbo PMAC2-VME). It is a slave interface on the bus, and can be used with
16, 24, and 32-bit addressing on the bus. The address, bus width, and other details of the interface are set
by the values of Turbo PMAC variables I90 – I99 at power-up/reset. The factory default setting is for 24-
bit addressing, with a base address of $7FA000 on the VME bus.
The most basic communications on the VME bus goes through a set of 16 mailbox registers in the VME
interface IC on the Turbo PMAC, each capable of holding one character. Note that unlike the other
buses, this communications does not go through the Turbo CPU’s host port, so it is not possible to
download new operational firmware in bootstrap mode to the Turbo PMAC over the VME bus. Dual-
ported RAM is an optional addition to this bus interface (see below), but one that is virtually always used.
If DPRAM is present, usually it is easier to send text commands through the DPRAM, and the mailbox
registers are typically not used.
The following table shows how I90 – I99 should be set for 24-bit and 32-bit addressing (16-bit is almost
never used), with and without dual-ported RAM. The values in the table are for a mailbox base address
on the bus of $abcdef00, and a DPRAM base address of $abg00000 (a and b are not used in 24-bit
addressing).
I Variable I90 I91 I92 I93 I94 I95 I96 I97 I98 I99
24-bit, no DPRAM $29 $04 * $cd $ef ** ** * $60 $10
24-bit, w/ DPRAM $29 $04 * $cd $ef ** ** $0g $E0 $90
32-bit, no DPRAM $39 $04 $ab $cd $ef ** ** * $60 $10
32-bit, w/ DPRAM $39 $04 $ab $cd $ef ** ** $0g $E0 $90
• DPRAM Coordinate System and Global Background Data Reporting: I49 and I50
• DPRAM Background Variable Buffers: I55
• DPRAM Binary Rotary Buffer Foreground Transfer: I45
It is possible to have multiple DPRAM ICs in some Turbo PMAC systems, especially in UMAC systems.
However, only one of these ICs can be used at any given time with any of the automatic data structures.
Turbo PMAC variable I24 determines which of the DPRAM ICs will support these automatic functions
by specifying the base address of this IC in Turbo PMAC’s own address space. On re-initialization of the
Turbo PMAC, I24 is set to the address of the first DPRAM IC found (the one with the lowest base
address). I4904 shows which DPRAM ICs have been found by the Turbo PMAC CPU.
The DPRAM IC associated with the main bus communications port has a base address of $060000 in
Turbo PMAC’s memory map. DPRAM ICs that are accessed by the Turbo PMAC CPU over the JEXP or
UBUS expansion port, such as those on the Acc-54E USB/Ethernet communications card for the UMAC,
can have base addresses of $06C000, $06D000, $06E000, $06F000, $074000, $075000, $076000, or
$077000.
Giving Commands to Turbo PMAC
Turbo PMAC is fundamentally a command-driven device, unlike other controllers that are register driven.
Turbo PMAC can do things if ASCII command text strings are issued and generally Turbo PMAC
provides information to the host in ASCII text strings.
Note:
If the Option 2 dual-ported RAM is present, Turbo PMAC can be commanded by
writing values to specific registers in the DPRAM and Turbo PMAC can provide
information by placing binary values in these registers, but the ASCII commands
must be sent to Turbo PMAC that cause it to take the proper action when these
values are received and to place the values in these registers.
Turbo PMAC Processing of Commands
When Turbo PMAC receives an alphanumeric text character over one of its ports, it does nothing but
place the character in its command queue. It requires a control character (ASCII value 1 to 31) to cause it
to take some actual action. The most common control character used is the carriage return (<CR>; ASCII
value 13), which tells Turbo PMAC to interpret the preceding set of alphanumeric characters as a
command and to take the appropriate action.
Other control characters cause Turbo PMAC to take an action independent of the alphanumeric characters
sent before it. These control characters can be sent in the middle of a line of alphanumeric command
characters without disturbing the flow of the command. Turbo PMAC will respond first to the control-
character command, storing the text string until the <CR> character is received.
Command Acknowledgement
The exact nature of Turbo PMAC’s acknowledgement of commands and its data response is controlled by
I-variables I3, I4, and I9, with I3 as the most important. If I3 is 1, PMAC acknowledges a valid
alphanumeric command by sending the line-feed (<LF>; ASCII value 10) character back to the host. If
I3 is 2 or 3, it uses the <ACK> character (ASCII value 6) instead. If I3 is 0, it does not provide any
acknowledging character. Regardless of the setting of I3, Turbo PMAC responds to an invalid command
by returning the <BELL> character (ASCII value 7).
When working interactively with Turbo PMAC in a dumb terminal mode, it is often nice to use the <LF>
as acknowledgement because it spaces commands and responses on the terminal screen automatically.
Data Response
When the command received requires a data response, Turbo PMAC will precede each line of the data
response with a line feed character if I3 is set to 1 or 3. It will not do so if I3 is set to 0 or 2. Turbo
PMAC will terminate each line of the data response with a carriage-return character regardless of the
setting of I3. For these commands, the command acknowledgement character – <LF> or <ACK> – is sent
after the data response, serving as an end-of-transmission character. For computer parsing of the
response, it is nice to have the <ACK> serve as a unique EOT character.
Data Integrity
Variable I4 determines some of the data integrity checks Turbo PMAC performs on the communications,
the most important of which is a line-by-line checksum. The Writing a Host Communications Program
section covers this feature in detail.
Data Response Format
Variable I9 controls some aspects of how Turbo PMAC sends data to the host. Its setting determines
whether Turbo PMAC lists program lines back to the host in long or short form, whether it reports I-
variable values and M-variable definitions as full command statements or not, and whether address I-
variable values are reported in decimal or hexadecimal form.
On-Line (Immediate) Commands
Many of the commands given to Turbo PMAC are on-line commands; that is, they are executed
immediately by Turbo PMAC, to cause some action, change some variable, or report some information
back to the host. The command itself is thrown away after executing (so cannot be listed back), although
its effects may stay in Turbo PMAC.
Some commands, such as P1=1, are executed immediately if there is no open program buffer, but are
stored in the buffer if one is open. Other commands, such as X1000 Y1000, cannot be on-line
commands; there must be an open buffer – even if it is a special buffer for immediate execution. These
commands will be rejected by Turbo PMAC (reporting an ERR005 if I6 is set to 1 or 3) if there is no
buffer open. Still other commands, such as J+, are on-line commands only, and cannot be entered into a
program buffer (unless in the form of CMD"J+", for instance).
Types of On-Line Commands
There are four basic classes of on-line commands:
• Port-specific commands, which only affect the action of subsequent commands on the same port;
• Motor-specific commands, which affect only the motor that is currently addressed by the host;
• Coordinate-system-specific commands, which affect only the coordinate system that is currently
addressed by the host;
• Global commands, which affect the card regardless of any addressing modes. In the reference section
of the manual, each command is classified into one of these types under the Scope descriptor.
Note:
Each program that can use the COMMAND statement to issue on-line commands
from within the card has its own motor and coordinate system addressing,
independent of which motor and coordinate system the host is addressing.
Changing a port’s addressing modes does not affect the program’s mode, or vice
versa.
Port-Specific Commands
To maintain truly independent communications among the multiple communications ports, it is necessary
for certain commands that affect subsequent commands to only affect commands on the same port. For
this reason, addressing commands – #n for motors and &n for coordinate systems – as well as buffer
OPEN and CLOSE commands, affect only subsequent commands on the same port.
Motor-Specific Commands
A motor is addressed for a port by a #n command, where n is the number of the motor, with a range of 1
to 32, inclusive. This motor stays the one addressed by this port until another #n is received by the card
over the same port. For instance, the command line #1J+#2J- tells Motor 1 to jog in the positive
direction, and Motor 2 to jog in the negative direction (like most commands, the jog command does not
take effect until the carriage return character is received, so both axes start acting on the command at
roughly the same time in this case).
There are only a few types of motor-specific commands. These include the jogging commands, a homing
command, an open loop command, and requests for motor position, velocity, following error, and status.
Note:
An on-line motor action command, such as jogging, homing, open-loop output, is
not permitted if the addressed motor is in a coordinate system that is running a
motion program, even if the motion program is not directly commanding any axis
assigned to that motor. Such a command will be rejected with an error.
Coordinate-System-Specific Commands
A coordinate system is addressed for a port by an &n command, where n is the number of the coordinate
system, with a range of 1 to 16, inclusive. This coordinate system remains the one addressed until
another &n command is received by the card over the same port. For instance, the command line
&1B6R&2B8R tells Coordinate System 1 to run Motion Program 6 and Coordinate System 2 to run
Motion Program 8.
There are a variety of types of coordinate-system-specific commands. Axis definition statements act on
the addressed coordinate system, because motors are matched to an axis in a particular coordinate system.
Since it is a coordinate system that runs a motion control program, all program control commands act on
the addressed coordinate system. Q-variable assignment and query commands are also coordinate system
commands, because the Q-variables themselves belong to a coordinate system.
Note that a command to a coordinate system can affect several motors if more than one motor is assigned
to that coordinate system. For instance, if motor 4 is assigned to coordinate system 1, a command to
coordinate system 1 to run a motion program can start motor 4 moving.
Global Commands
Some on-line commands do not depend on which motor or coordinate system is addressed. For instance,
the command P1=1 sets the value of P1 to 1 regardless of what is addressed. Among these global on-line
commands are the buffer management commands. Turbo PMAC has multiple buffers, one of which can
be open at a time. When a buffer is open, commands can be entered into the buffer for later execution.
Control character commands (those with ASCII values 0 - 31D) are always global commands. Those that
do not require a data response act on all cards on a serial daisy-chain. These characters include carriage
return <CR>, backspace <BS>, and several special-purpose characters. This allows, for instance,
commands to be given to several locations on the card in a single line, and have them take effect
simultaneously at the <CR> at the end of the line (&1R&2R<CR> causes both Coordinate Systems 1 and 2
to run).
Typically, these signals are at 5V TTL/CMOS levels, whether single-ended or differential. The input
circuits are powered by the main 5V supply for the controller, but they can accept up to +/-12V between
the signals of each differential pair, and +/-12V between a signal and the GND voltage reference.
Differential encoder signals can enhance noise immunity by providing common-mode noise rejection.
Modern design standards virtually mandate their use for industrial systems, especially in the presence of
PWM power amplifiers, which generate a great deal of electromagnetic interference.
Hardware Setup
This section describes Turbo PMAC encoder hardware interface in general terms. Consult the Hardware
Reference Manual for your particular configuration for details.
Turbo PMAC’s encoder interface circuitry employs differential line receivers, but is configured at the
factory to accept either single-ended or differential encoders. In this configuration, the main (+) line is
pulled up to 5V, and the complementary (-) line is tied to 2.5V with a voltage divider. With a single-
ended encoder, the single signal line for each channel is then compared to this reference voltage as it
changes between 0 and 5V.
Note:
When using single-ended TTL-level digital encoders, the complementary line input
should be left open, not grounded or tied high; this is required for PMAC's
differential line receivers to work properly.
It is possible to pull the complementary line as well to 5V. On most Turbo PMAC boards, this is done by
changing the setting of a 3-point jumper for the encoder channel. On Turbo PMAC2 boards and systems
(including UMAC), this is done by reversing a SIP resistor pack in its socket.
PMAC Encoder Input Circuitry
Encoder Sampling Clock Frequency: E34 – E38, I7m03, I6803, MI903, MI907
After the front-end processing through the differential line receivers, the quadrature encoder inputs are
sampled by digital logic in the Turbo PMAC Servo IC or MACRO IC at a rate determined by the
frequency of the SCLK encoder sample clock” which is user settable. The higher the SCLK frequency,
the higher the maximum permissible count rate; the lower the SCLK frequency, the more effective the
digital delay noise filter is.
Each encoder input channel has a digital delay filter consisting of three cascaded D-flip-flops on each
line, with a best two-of-three voting scheme on the outputs of the flip-flops. The flip-flops are clocked by
the SCLK signal. This filter does not pass through a state change that only lasts for one SCLK cycle; any
change this narrow should be a noise spike. In doing this, the filter delays actual transitions by two SCLK
cycles – a trivial delay in virtually all systems.
If both the A and B channels change state at the decode circuitry (post-filter) in the same SCLK cycle, an
unrecoverable error to the counter value will result. The ASIC hardware notes this problem by setting
and latching the “encoder count error” bit in the channel’s status word. The problem can also be detected
by capturing the count value each revolution on the index pulse and seeing whether the correct number of
counts have elapsed.
Encoder Digital Delay Filter
The SLCK frequency must be at least four times higher than the maximum encoder cycle (line) frequency
input, regardless of the quadrature decoding method used (with the most common times-4 decode, the
SCLK frequency must be at least as high as the count rate). In actual use, due to imperfections in the
input signals, a 20 – 25% safety margin should be used.
The default SCLK frequency of 9.83 MHz is acceptable for virtually all applications. It can accept
encoder signal cycle frequencies of up to about 2 MHz (8 MHz count rates) – with safety margin – and
still provide decent digital filtering. This frequency may be changed by factors of two, up to 19.66 or
39.32 MHz on most designs, or down to as low as 1.25 MHz or 306 kHz on most designs. On some
designs, an external SCLK signal can be provided. If very high encoder count rates are required, the
SCLK frequency may have to be raised; if better filtering is required to prevent count errors, the SCLK
frequency may have to be lowered.
Signal Format
Digital hall sensors provide three digital signals that are a function of the position of the motor, each
nominally with 50% duty cycle, and nominally one-third cycle apart. (This format is often called 120o
spacing. Turbo PMAC has no automatic hardware or software features to work with 60o spacing.) This
format provides six distinct states per cycle of the signal. Typically, one cycle of the signal set
corresponds to one electrical cycle, or pole pair, of the motor. These sensors, then, can provide absolute
(if low resolution) information about where the motor is in its commutation cycle, and eliminate the need
to do a power-on phasing search operation.
Hardware Setup
If just used for power-up commutation position feedback, typically the hall sensors are wired into the U,
V, and W supplemental flags for a PMAC2-style interface channel. These are single-ended 5V digital
inputs on all existing hardware implementations. They are not optically isolated inputs; if isolation is
desired from the sensor, this must be done externally.
Note:
In the case of magnetic hall sensors, the feedback signals often come back to the
controller in the same cable as the motor power leads. In this case, the possibility
of a short to motor power must be considered; safety considerations and industrial
design codes may make it impermissible to connect the signals directly to the
Turbo PMAC TTL inputs without isolation.
If used for servo position and velocity feedback (PMAC2-style Servo ICs only), the three hall sensors are
connected to the A, B, and C encoder inputs, so that the signal edges can be counted. As with quadrature
encoders, these inputs can be single-ended or differential. They are not optically isolated inputs; if
isolation is desired from the sensor, this must be done externally. There may be applications in which the
signals are connected both to U, V, and W inputs (for power-on commutation position) and to A, B, and C
inputs (for servo feedback).
Turbo PMAC Hardware-Control Parameter Setup
Hall Sensor Demux Control: I7mn5, I68n5, MI915
If the hall sensors are connected to the channel’s U, V, and W inputs, you must make sure that bit 1 of the
channel’s Hall Sensor Demux Control variable is set to the default of 0. If this bit is set to 1, the
information in the U, V, and W bits of the channel’s status register is de-multiplexed from the C-channel
of the encoder input based on the states of the A and B inputs, as with Yaskawa incremental encoders.
This variable is I7mn5 for Servo ICs, I68n5, for MACRO ICs, and node-specific variable MI915 on a
MACRO Station.
Encoder Decode Control: I7mn0, I68n0, MI910
If the hall sensors are wired into the encoder inputs A, B, and C, the decoding of the signal is determined
by a channel-specific I-variable. For (PMAC2-style) Servo ICs, this is I7mn0 (for Servo IC m Channel
n). For MACRO IC 0 Channel n* on a Turbo PMAC (a handwheel port encoder), this is I68n0. For
encoder channels on a MACRO Station, this is node-specific variable MI910.
For the 3-phase hall sensors, the decode must be set to times-6 decode, which derives six counts per
signal cycle, one for each signal edge. This requires a variable value of 11 or 15. The difference between
these two values is the direction sense – which direction of motion causes the counter to count up.
Remember that for a feedback sensor, the sensor’s direction sense must match the servo-loop output’s
direction sense – a positive servo output must cause the counter to count in the positive direction –
otherwise a dangerous runaway condition will occur when the servo loop is closed.
Power-Up Phasing Usage
The most common use of these hall sensors with a Turbo PMAC2 is to establish an approximate absolute
position for the phase commutation algorithms. In this case, motor variable Ixx81 contains the address of
the flag register for these U, V, and W inputs. Ixx91 must be set to a value from $800000 to $FF0000;
the actual value is dependent on the direction and phasing of the sensors relative to the motor
commutation cycle.
Conversion Table Processing Setup – Turbo PMAC Interface
If the hall sensors are connected to the encoder inputs on Turbo PMAC and therefore to the encoder
counter, the count information should be processed in the conversion table with the 1/T-extension method
(method digit $0) as for a quadrature encoder. The sub-count estimation of this method is particularly
important here because of the low resolution of the sensors. For details of setting up the encoder
conversion table to process hall sensors used as encoders, consult the section Setting up the Encoder
Conversion Table section in this manual and the specification for variables I8000 – I8191 in the Software
Reference Manual.
Note:
If the hall sensors are used for ongoing commutation feedback, probably it will be
better to use the extended result data from the conversion table instead of the raw
counter information that usually is used with encoders. This will provide smoother
commutation. In this case, there will be 6 * 32 = 192 counts per commutation
cycle instead of just 6.
Hardware Setup
The sine and cosine channels of the encoder are connected either as single-ended or differential inputs
(differential is strongly recommended) into the interpolator accessory according to the instructions for the
interpolator. Optionally, the index channel may be connected as well. Consult the hardware reference
manual of the particular accessory for details.
If connecting a low-resolution interpolator into a Turbo PMAC or accessory with PMAC-style Servo ICs,
the fractional-count data is brought into the Servo IC at TTL levels on the flag signals for the channel
numbered one higher than that of the encoder signal itself. Normally, these signals are 12-24V isolated
flags to use the interpolator, the isolators must be removed and replaced with conducting shunts.
Turbo PMAC Hardware-Control Parameter Setup
Encoder Sampling Clock Frequency: E34 – E38, I7m03, MI903, MI907
For the low-resolution interpolator, the Turbo PMAC’s SCLK encoder-sampling clock drives the analog
conversion on the interpolator, as well as the encoder functions in the Servo IC. This clock must be set to
a frequency of 2.46 MHz. If the interpolator is connected to a Turbo PMAC or accessory with PMAC-
style Servo ICs, this frequency is set by jumpers on the PMAC or accessory: of the E-points E34 – E38,
there should only be a jumper on E36.
If the low-resolution interpolator is connected to a Turbo PMAC2 or accessory with PMAC2-style Servo
ICs, Servo IC m’s variable I7m03 sets this frequency. If it is connected into a MACRO Station, Station
variable MI903 or MI907 sets this frequency. These variables also set other clock frequencies, but if the
other frequencies are left at their default (as they usually are), setting the SCLK frequency to 2.46 MHz
simply requires changing the variable value from its default of 2258 to 2260.
For an Acc-51x high-resolution interpolator, the SCLK signal just drives the sampling of the synthesized
quadrature in the interpolator’s own Servo IC. The default frequency of 9.83 MHz is virtually always
fine. On the Acc-51P, the frequency is set permanently to this value. On high-resolution interpolators
with PMAC2-style Servo ICs (e.g. Acc-51E, Acc-51C), IC variable I7m03 sets this frequency if the
interpolator is connected directly to a Turbo PMAC, or by MACRO Station variable MI903 or MI907 if
the interpolator is installed in a MACRO Station.
Encoder Decode Control: I7mn0, MI910
Both styles of interpolator create a digital quadrature signal from the sine/cosine inputs. This digital
signal goes into the encoder decoding and count circuitry to produce the whole-count data. To match the
whole-count and fractional count resolution properly, the decode-control variable must be set up to times-
4 quadrature decode. This variable is I7mn0 for Servo IC m Channel n in a Turbo PMAC system. On a
MACRO Station, it is node-specific variable MI910.
In addition, the direction sense of the whole-count data must match that of the fractional-count data. For
the low-resolution interpolators, this requires that the decode variable be set to 7. If this value does not
produce the direction sense needed, change the wiring of the encoder into the accessory (exchange sine
and cosine signals, or the plus and minus lines of one channel).
For the high-resolution interpolators, the conversion table will check the direction sense of the encoder
decode at power-up/reset and adjust the direction sense of the fractional data accordingly. This permits
the setting of the direction sense as needed by setting the decode variable to 3 or 7, but if this variable
setting is changed, save the setting and reset the card before the fractional direction sense matches.
Encoder Filter Bypass: I7mn1 (PMAC-style ICs)
If a low-resolution interpolator is connected to a PMAC-style Servo IC, the encoder’s digital delay filter
must be bypassed for both the channel with the encoder signal, and the channel with the flags, in order to
keep the whole-count and fractional-count data properly synchronized. The same is true if using the Acc-
51P high-resolution interpolator with its own PMAC-style Servo IC on board. Bypassing the delay filter
is selected by setting channel variable I7mn1 to 1.
Conversion Table Processing Setup – Turbo PMAC Interface
Sinusoidal encoders wired into a high-resolution (x4096) Acc-51x interpolator connected to a Turbo
PMAC are processed in the Turbo PMAC’s conversion table by a hi-res interpolator entry (method digit
$F), in which the fractional-count data is computed mathematically from the readings of the sine and
cosine A/D converters. The least significant bit (LSB) of the result represents 1/4096 of an encoder line.
A
Decoder/
+ Counter
Comparator
“1 bit A/D” Address Data
B n-bit
+ A/D
Differential n-bit
B
Amplifier A/D
SIN / COS
Analog Signals
Photo
Current
Encoder Controller
Sinusoidal encoders wired into a low-resolution (x128/x256) interpolator connected to a Turbo PMAC are
processed in the Turbo PMACs conversion table by a parallel extension of incremental encoder entry
(method digit $C), in which the fractional-count data has been computed externally in the interpolator’s
look-up table and is just appended to the whole count data by the conversion table. The LSB of the result
represents 1/128 or 1/256 of an encoder line, depending on the setting of the resolution jumper on the
interpolator.
For details of setting up the encoder conversion table to process sinusoidal encoders, consult the section
Setting up the Encoder Conversion Table section in this manual and the specification for variables I8000
– I8191 in the Software Reference Manual.
Encoder Interpolation: Analog SIN/COS Encoders
A
+ n
n-bit
- A/D
B 0 2n - 1
2n - 1
+ n n-1, n bits
n-bit
- A/D
Differential 0
B Flash Arctan
Amplifier SIN / COS Angle
SIN / COS A/D Look-Up
Numbers Number
Analog Signals Converters Table
Photo
Current
Encoder Controller
Hardware Setup
The details of the hardware setup are covered in the hardware reference manual for the R/D converter
board. Fundamentally, the R/D board connects three differential analog signal pairs to each resolver: a
single excitation signal pair, and two feedback signal pairs. It has two different digital connections to the
Turbo PMAC: one for serial absolute position to the JTHW Multiplexer port (common for all channels on
the board, optional in use), and one with synthesized digital quadrature for each channel, connected to a
normal quadrature encoder interface.
Turbo PMAC Hardware-Control Parameter Setup
Encoder Decode Control: I7mn0, I68n0, MI910
To match the resolution and direction sense of the ongoing position information derived from the
synthesized quadrature with absolute position read through the Multiplexer port, set the channel’s encoder
decode variable to 7 (times-4 decode, counterclockwise). If not using absolute position, set the decode
resolution and direction as wanted. For Servo ICs of both PMAC-style and PMAC2-style, this is I7mn0
(for Servo IC m Channel n). For MACRO IC 0 Channel n* on a Turbo PMAC (a handwheel port
encoder), this is I68n0. For encoder channels on a MACRO Station, this is node-specific variable MI910.
Motor offset variable Ixx26 contains the difference between the absolute resolver position and the
resulting motor position (if any).
Scaling the Feedback Units
The Acc-8D Option 7 R/D converter is a 12-bit converter. It reports 4096 separate states per electrical
cycle of the resolver (per mechanical revolution for a typical 2-pole resolver, per half revolution for a 4-
pole resolver). It reports this as a 12-bit binary number if queried for absolute position over the
multiplexer port. For ongoing position, it generates 1024 digital quadrature cycles per electrical cycle,
which creates 4096 counts per cycle after times-4 decode.
Setting Up MLDTs
A Turbo PMAC with PMAC2-style ICs can provide direct interface to magnetostrictive linear
displacement transducers (MLDTs), such as MTS’s Temposonics brand. MLDTs can provide absolute
position information in rugged environments; they are particularly well suited to hydraulic applications.
In this interface Turbo PMAC provides a periodic excitation pulse output to the MLDT, receives the echo
pulse that returns at the speed of sound in the transducer, and very accurately measures the time between
these pulses, which is directly proportional to the distance of the moving member from the stationary base
of the transducer. The timer therefore contains a position measurement.
MLDT Interface Type
MLDTs are available with several different interface formats; for this interface, a format with external
excitation is required, because Turbo PMAC provides the excitation pulse. Usually, this format has an
RS-422 interface, because the excitation and echo pulses are at RS-422 levels. The Turbo PMAC MLDT
interface inputs and outputs are at RS-422 levels.
Some MLDTs come with internal excitation and computation of position, providing a position value in a
format such as Synchronous Serial Interface (SSI) or an analog voltage. In these cases, setting up the
Turbo PMAC interface is dependent only on the data format, not on the underlying principle of the
sensor. Refer to the appropriate feedback-format section for details.
Signal Formats
There are two common signal formats of the external excitation type; MTS calls them RPM and DPM. In
the RPM format there are two short pulses returned from the MLDT: an immediate start pulse, and a
delayed stop pulse.
RPM Signal Format
Pulse Out
Return
Start Stop
Since Turbo PMAC uses the first rising signal edge returned after the falling edge of the output pulse to
latch the timer, the key setup issue in this format is to make sure that the output pulse width is large
enough so that the falling edge of the output pulse occurs after the rising edge of the return line’s start
pulse (see PFM Pulse Width below).
In the DPM format, there is only one long pulse returned from the MLDT.
DPM Signal Format
Pulse Out
Return
Start Stop
The rising edge of the return pulse in the DPM format is the equivalent of the rising edge of the start pulse
in the RPM format. The falling edge of the return pulse in the DPM format is the equivalent to the rising
edge of the stop pulse in the RPM format. Because Turbo PMAC is expecting a rising signal edge to
latch the timer, in this signal format the return signals should be inverted so that the ‘+’ output of the
MLDT is wired into Turbo PMAC’s ‘-’ input, and vice versa.
Hardware Setup
The PULSEn output that is used commonly to command stepper drives is used as the excitation signal for
the MLDT; typically the CHAn input that is part of encoder feedback is used to accept the response. The
PULSEn output is an RS-422 style differential line-drive pair. The CHAn input is an RS-422 style
differential line receiver pair. The use of differential pairs for both inputs and outputs is strongly
encouraged for the common-mode noise rejection it provides.
On some interface boards (e.g. Acc-24E2A, Acc-24E2S), the PULSEn+/- signals are output on lines that
otherwise would be supplemental flag inputs, and jumper(s) must be installed to enable the outputs on
these lines. Consult the user manual for the board for details.
Remember that in the DPM signal format or equivalent (see above), the ‘+’ output of the MLDT should
be wired into the CHAn- input, and the ‘-’ output of the MLDT should be wired into the CHAn+ input.
Turbo PMAC Hardware-Control Parameter Setup
PFM Clock Frequency: I7m03, I6803, MI903, MI907, MI993
The pulse output uses Turbo PMAC’s pulse frequency modulation (PFM) feature. The PFM circuitry
generates periodic output pulses by repeatedly adding a command value into an accumulator. When the
accumulator overflows, an output pulse is generated.
The addition of the command value into the accumulator is performed once per PFM clock (PFMCLK)
cycle. The PFMCLK frequency is governed by I7m03 for the channels on Servo IC m, I6803 for the
supplemental channels on MACRO IC 0, and MI903, MI907, or MI993 for channels on a MACRO
Station. The default frequency of the PFMCLK for all channels is 9.83 MHz; this frequency should be
suitable for all MLDT applications.
PFM Output Frequency: Mxx07, MI926
The pulse output frequency for a channel is controlled by both the PFMCLK frequency and the PFM
command value for the channel, which is the C-output register for that channel. When used for stepper
motor applications, the PFM command value is determined by the instantaneous command velocity and
the gains of the simulated servo loop on Turbo PMAC; Ixx02 tells Turbo PMAC to write this to the PFM
command register.
For MLDT use, we will write to the PFM command register once on power-up/reset with an M-variable.
(If the interface is on a MACRO Station, the Station’s firmware will do this automatically, using the
saved value of node-specific variable MI926.) The suggested M-variable definition for this register is
Mxx07. The following table shows the registers for these suggested definitions:
or:
OutputFreq( kHz )
MI 926 = 16 ,777 ,216 *
PFMCLK _ Freq( kHz )
To produce a pulse output frequency of 1.667 kHz with the default PFMCLK frequency of 9.83 MHz, we
calculate:
1.667
MI 926 = 16 ,777 ,216 * = 2 ,982
9 ,830
Note:
The servo update time for the motor using the MLDT should be at least as high as
the output time set here (the servo frequency should be as low as or lower than the
output frequency).
PFM Pulse Width: I7m04, I6804, MI904, MI908, MI994
The width of the output pulse is controlled by the PFMCLK frequency with I7m04 for the channels on
Servo IC m, I6804 for the channels on MACRO IC 0, or MI904, MI908, or MI994 for the ICs on a
MACRO Station. This I-variable specifies the pulse width as the number of PFMCLK cycles. At the
default PFMCLK frequency of 9.83 MHz, the default value of 15 produces a 1.5-µsec output pulse width.
This should be satisfactory for most MLDT devices. When using the RPM format or equivalent (see
Signal Format, above), the pulse width must be large enough to enclose the rising edge of the returned
start pulse – that is, it must be longer than the delay between the output pulse and the returned start pulse.
PFM Format Select: I7mn6, I68n6, MI916
The output format of channel signals is controlled by variable I7mn6 for Servo IC m Channel n, by I68n6
for MACRO IC 0 Channel n, or by node-specific variable MI916 on a MACRO Station. In order for the
C-register circuitry of Channel n to output a PFM pulse train rather than a PWM pulse train, this variable
must be set to 2 or 3. Most commonly, it will be set to 3, so that the A and B registers for Channel n
output DAC signals rather than PWM.
Note:
One channel of Turbo PMAC cannot be used simultaneously for direct PWM
control of a motor and for MLDT pulse generation. Direct PWM control of a
motor writes to the channel’s A, B, and C registers every phase cycle
automatically.
MLDT Feedback Select: I7mn0, I68n0, MI910
The decoding of the signals on the encoder inputs is controlled by I7mn0 for Servo IC m Channel n, I68n0
for MACRO IC 0 Channel n, or by node-specific variable MI910 for a channel on a MACRO Station. For
proper decoding of the MLDT signal, this variable must be set to 12. With this setting, the pulse timer is
cleared to zero at the falling edge of the output pulse. It then counts up at 117.96 MHz until a rising edge on
the return pulse is received, at which time the timer’s value is latched into a memory-mapped register that
the processor can read. This register is the X-register at the base address of each channel.
Note:
The MLDT feedback uses the same circuitry that would be used for quadrature
encoder feedback on that channel, so an encoder and MLDT cannot be connected
simultaneously to the same channel’s feedback on Turbo PMAC. In this mode, it
is the pulse timer that is used as a position measurement for feedback, not the pulse
counter that is used with encoders. The counter still registers the number of pulses
returned, but does not represent a position measurement here.
Beginning
Motor
Setup
Single Output
Setup Use PMAC to close
current loop?
No Yes
Analog
Sine-Wave Direct PWM
Output?
Output Output
Yes Setup Setup
No
Synchronous
Motor?
No Yes
Slip and
Phase
Magnetization
Referencing
Current Setup
Position/Velocity
Servo Loop
Setup
Amp Enable
Control
Ix02 Ix25
Motor x
Calculation
Registers
This next diagram shows the three-stage process to map between the motor calculation registers and the
servo I/O registers in a MACRO Station over a MACRO ring. The motor address I-variables specify the
first stage only – the mapping between the motor calculation registers and the Turbo PMAC’s own
MACRO node registers. The second step – the mapping between the Turbo PMAC’s MACRO node
registers and the MACRO Station’s MACRO node registers – is covered in the Basic Setup section (and
in the MACRO Station manuals). The third step – the mapping between the MACRO Station’s MACRO
node registers – is covered in the appropriate section of this manual (and in the MACRO Station
manuals). Once this mapping is set up, the motor will operate just as it would with a direct connection.
PMAC / MACRO Station Register Mapping
Servo &
Station SW1 Setting,
Commutation
Conversion Table,
Address
M110x
I-variables
The following table shows the possible addresses for these variables when the flags are accessed through
PMAC2-style Servo ICs.
PMAC2-Style Servo IC Flag Addresses
IC# - Chan# 0-1 0-2 0-3 0-4 1-1 1-2 1-3 1-4
Ixx25/42/43 $078000 $078008 $078010 $078018 $078100 $078108 $078110 $078118
IC# - Chan# 2-1 2-2 2-3 2-4 3-1 3-2 3-3 3-4
Ixx25/42/43 $078200 $078208 $078210 $078218 $078300 $078308 $078310 $078318
IC# - Chan# 4-1 4-2 4-3 4-4 5-1 5-2 5-3 5-4
Ixx25/42/43 $079200 $079208 $079210 $079218 $079300 $079308 $079310 $079318
IC# - Chan# 6-1 6-2 6-3 6-4 7-1 7-2 7-3 7-4
Ixx25/42/43 $07A200 $07A208 $07A210 $07A218 $07A300 $07A308 $07A310 $07A318
IC# - Chan# 8-1 8-2 8-3 8-4 9-1 9-2 9-3 9-4
Ixx25/42/43 $07B200 $07B208 $07B210 $07B218 $07B300 $07B308 $07B310 $07B318
Servo ICs 0 and 1 are on the Turbo PMAC2 itself or on Acc-2E 3U-format stack boards.
Servo ICs 2 – 9 are on Acc-24x2 or Acc-51E boards.
Channels 1 – 4 on odd-numbered Servo ICs are Channels 5 – 8 on the dual-IC boards.
If the flags are accessed through the MACRO ring, the address specified is that of a dedicated image
register in memory for the MACRO node, not the MACRO node flag register itself. The following table
shows the possible addresses for these variables when the flags are accessed through the MACRO ring.
MACRO Ring Flag Addresses
IC# - Node# 0-0 0-1 0-4 0-5 0-8 0-9 0 - 12 0 - 13
Ixx25/42/43 $003440 $003441 $003444 $003445 $003448 $003449 $00344C $00344D
IC# - Node# 1-0 1-1 1-4 1-5 1-8 1-9 1 - 12 1 - 13
Ixx25/42/43 $003450 $003451 $003454 $003455 $003458 $003459 $00345C $00345D
IC# - Node# 2-0 2-1 2-4 2-5 2-8 2-9 2 - 12 2 - 13
Ixx25/42/43 $003460 $003461 $003464 $003465 $003468 $003469 $00346C $00346D
IC# - Node# 3-0 3-1 3-4 3-5 3-8 3-9 3 - 12 3 - 13
Ixx25/42/43 $003470 $003471 $003474 $003475 $003478 $003479 $00344C $00347D
Over/Under flow
Master Pulse
Position
Stepper
+ Accumulator
Drive
Trajectory + Direction
PID Adder
Generation
- PFM Circuit
Decoder/
E
Counter
Note:
The analog output of a PMAC-style Servo IC, used in sign-and-magnitude mode
(Ixx96=1), and passed through a voltage-to-frequency converter, can be used for
the same type of operation. However, it is strongly recommended that the purely
digital method of the PMAC2-style Servo IC be used instead.
Hardware Setup
PMAC2-style Servo ICs, and the DSPGATE2 MACRO IC, have pulse-and-direction outputs for each
channel on the IC. In most configurations of interface and breakout hardware, these signals are accessible
as RS-422-level differential line-driver output pairs. These signals are driven by the value in output
register C for the channel, with the pulse frequency proportional to the value in this register. For this
reason, these outputs are technically known as pulse-frequency-modulated (PFM) outputs.
Alternately, the signals from the C output register can be used as pulse-width-modulated (PWM) outputs,
and commonly form the third-phase command signals for direct-PWM output of brushless motors. Note
that if using the channel for direct-PWM control of a motor, the PFM outputs will not be seen on the same
channel.
For board-level Turbo PMAC2 controllers and 3U-format stack boards (Acc-1E and 2E), the Acc-8S
breakout board usually is the most effective way of bringing out the pulse-and-direction signals. These
signals are available also on the Acc-8A and Acc-8E analog breakout boards and the Acc-8F PWM
breakout boards (as the third-phase PWM).
The pulse-and-direction signals are available on the encoder connectors of the QMAC boxed controller
and of the UMAC Acc-24E2S, Acc-24E2A, and Acc-24E2 axis-interface boards. The outputs use the
same pins as the T, U, V, and W flag inputs for the channel; a jumper must be installed to enable the
outputs on these pins.
Signal Timing
The PULSEn and DIRn signals are driven from the internal PFMCLK signal, whose frequency is controlled
by I7m03 (see below). The width of the pulse is controlled by the PFMCLK frequency and I7m04 (see
below). The output on PULSEn can be high-true (high during pulse, low otherwise) or low-true, as
controlled by I7mn7; the default is high-true. The polarity of the DIRn signal is controlled by I7mn8.
PULSEn and DIRn signals can change only on the rising edge of PFMCLK. If DIRn changes on a pulse,
it will change simultaneously with the front end of PULSEn. Some stepper drives require a setup time on
the DIRn line before the rising edge of PULSEn; these systems can be accommodated by inverting the
PULSEn signal with I7mn7.
The DIRn signal is latched in this state at least until the front end of the next pulse. The PULSEn signal
stays true for the number of PFMCLK cycles set by I7m04. It then goes false and stays false for a
minimum of this same time. This guarantees that the pulse duty cycle never exceeds 50%; the pulse
signal can be inverted with I7mn7 without violating minimum pulse width specifications.
Encoder Conversion Table: The encoder conversion table implemented with variables I8000 – I8191
(MI120 – MI151 on a MACRO Station) does the initial processing of the real or simulated feedback
registers. The default conversion table in Turbo PMAC processes encoder channels with timer-based 1/T
sub-count interpolation, in its first ten entries. These are the ideal settings if real incremental encoder
feedback is used.
However, if the output pulse train is used for simulated feedback, it is best to process the counts without
any sub-count interpolation. This will prevent the PMAC from trying to position between pulses and
create dithering. In the PMAC Executive program Configure Encoder Table window, change the entry
from Incremental with 1/T Interpolation to Incremental with No Interpolation. If writing directly to the
memory location of the table, change the format digit from $0 to $C. The entries for this type of
conversion for the encoder registers of a Turbo PMAC2 system are:
If not getting the proper frequency range, double check the setting of I7m03 that sets the PFMCLK
frequency. Also check the value of Ixx69 that determines the maximum frequency (O100 frequency) at
this PFMCLK frequency.
Executing the Closed-Loop Test
Next, close the loop with a J/ command. The reported position should hold steady, and the reported
velocity should be zero. Set up yotheur jogging I-variables Ixx19 to Ixx22 to get the speeds and
accelerations needed. Issue a J+ command; count up at the rate specified by Ixx22 (watch the units).
Issue a J- command; count down at this same rate.
Now that what PMAC considers to be closed-loop moves are being executed, the servo loop gain
parameters are important. The easiest way to monitor performance is with the position window in the
PMAC Executive Program, configured to display position, velocity, and following error for the current
motor. More detailed analysis can be done with the data gathering plots.
Troubleshooting the Closed-Loop Test
When troubleshooting these jogging moves, it is important to note what PMAC thinks the motor is doing
based on the pulse feedback compared to what the motor is actually doing. For example, if the motor has
stopped, but you see through the position window that PMAC keeps counting position, the motor has
probably stalled. Possibilities here include excessive velocity command, excessive load, and resonance
problems. However, if PMAC is also reporting a stop, something in the PMAC simulated loop has failed,
probably causing a shutdown on excessive following error. The main possibilities here are values set too
low for Ixx30 proportional gain, Ixx32 velocity feedforward, or Ixx69 output limit.
If using the older Type 0 MACRO protocol, add 3 to the value shown in the above table (e.g. $078420
becomes $078423).
Turbo PMAC permits digital closure of the motor current loops, mathematically creating phase voltage
commands from numerical registers representing commanded and actual current values. These numerical
phase voltage commands are converted to PWM format through digital comparison to an up/down
counter that creates a digital saw tooth waveform. The analog current measurements must be converted
to digital form with ADCs before the loop can be closed.
PWM PWM
Command Counter Time
Range Range 4 x I900 [I7m00] + 6
Servo
PWM_CLK Cycles PWM
Interrupt
Counter Clock is 120 MHz Up/Down
I900 - 2 generated
Counter
[I7m00] - 2 here
- Ix66
PWM
Top Signal
PWM
Bottom Signal
Deadtime
(I904 [I7m04])
By directly commanding the on-off states of the power transistors in this manner, Turbo PMAC
minimizes the calculation and transport delays in the servo loop. This permits the use of higher gains,
which in turn permit greater stiffness, acceleration, and disturbance rejection. Also, digital techniques
permit the use of mathematical transformations of the current-loop data, turning measured AC quantities
into DC quantities for loop closure. This technique, explained in the next section, significantly improves
high-speed performance by minimizing high-frequency problems.
Frames of Reference
A very important advantage of the digital current loop is its ability to close the current loops in the field
frame. To understand this advantage, some basic theoretical background is required.
In a motor, there are three frames of reference that are important. The first is the stator frame” which is
fixed on the non-moving part of the motor, called the stator. In a brushless motor, the motor armature
windings are on the stator, so they are fixed in the stator frame.
The second frame is the rotor frame, which is referenced to the mechanics of the moving part of the
motor, called the rotor. This frame, of course, rotates with respect to the stator. For linear brushless
motors, this is actually a translation, but because it is cyclic, we can think of it as a rotation.
The third frame is the field frame which is referenced to the magnetic field orientation of the rotor. In a
synchronous motor such as a permanent-magnet brushless motor, the field is fixed on the rotor, so the
field frame is the same as the rotor frame. In an asynchronous motor such as an induction motor, the field
slips with respect to the rotor, so the field frame and rotor frame are separate.
Working in the Field Frame
The physics of motor operation are best understood in the field frame. A current vector in the stator that
is perpendicular to the rotor field (that is, current in the stator that produces a magnetic field perpendicular
to the rotor magnetic field) produces torque. This component of the stator current is known as quadrature
current. The output of the position/velocity loop servo algorithm is the magnitude of the commanded
quadrature current. For diagnostic purposes on a Turbo PMAC, an “O” command can be used to set a
fixed quadrature current command.
A current vector in the stator that is parallel to the rotor field induces current in the rotor that changes the
magnetic field strength of the rotor (when the stator and rotor field are rotating relative to each other).
This component of the stator current is known as direct current. For an induction motor, this is required
to create a rotor magnetic field. For a permanent-magnet brushless motor, the rotor magnets always
produce a field, so direct current is not required, although it can be used to modify the magnetic field
strength. On Turbo PMAC, parameter Ixx77 for Motor xx determines the magnitude of the direct current.
Analog Loops in the Stator Frame
In an amplifier with an analog current loop, the closure of the loops on the stator windings must be closed
in the stator frame, because the current measurements are in the stator frame, and analog circuitry has no
practical way to transform these. In such a system, the current commands must be transformed from the
field frame in which they are calculated to the stator frame, and converted to voltage levels representing
the individual stator phase current commands. These are compared to other voltage levels representing
the actual stator phase current measurements.
As the motor is rotating, and/or the field is slipping, these current values, command and actual, are AC
quantities. Overall loop gain, and therefore system performance, is reduced at high frequencies (high
speeds). The back EMF phase voltage, which acts as a disturbance to the current loop, is also an AC
quantity. The current loop integral gain or lag filter, which is supposed to overcome disturbances, falls
well behind at high frequencies.
DC AC
Magnetization Id’
Current Ia’ + Va Va
Ix77
DAC PI PWM
Direct Current
- Ia
Command
dq
to Phase A Current Loop
Balance Loop
Θr
1/s
+ +
PMAC Amplifier
Turbo PMAC has a PI (proportional-integral) digital current loop. There is only one set of gains, which
serves for both the direct current loop and the quadrature current loop. Tuning is best done on the direct
current loop, because this will generate no torque, and therefore no movement. The current-loop auto-
tuner in the PMAC Executive program uses the direct current loop to tune. This is valid even for
permanent-magnet brushless motors in which no direct current will be used in the actual application.
Current loop performance is not load-dependent, so the motor does not need to be attached to the load
during the tuning process. For position/velocity loop tuning, the load does need to be attached.
DC AC
Magnetization Id + + Vd Va Va
PI PWM
Current
Direct Current
Ix77
Command - -
dq
P Vb Vb
to PWM E
abc
Vq Vc Vc
PWM
Direct Current Loop
Torque Command Iq + + Θ
from Position/ PI
Velocity Servo Quadrature Id Ia ia
Current - - ADC
abc
Command P to
Iq dq Ib ib
ADC
Hardware Setup
The connection between Turbo PMAC and the direct PWM digital amplifier is made through a Mini-D 36-
pin connector with a standard pin-out defined by Delta Tau. This connector contains the PWM command
signals, the ADC feedback signals, and the amplifier-enable and fault handshake signals. Usually, this
connector is found on an Acc-8F breakout board for board-level Turbo PMAC2s, on Acc-24E2 PWM axis-
interface boards for the UMAC and on the front panel of a QMAC with the PWM option ordered.
Position feedback, from an encoder or possibly a resolver, typically comes directly back to the Turbo
PMAC; there is no need for position feedback in the drive in this mode of operation.
For a three-phase motor, whether delta-wound or (more commonly) Y-wound, each of the three phase
leads of the motor is connected to one of the phase outputs of the amplifier. Exchanging any two of the
three leads switches the direction sense of the outputs; proper matching of this to feedback will be
evaluated in a setup test. Rotating the three motor leads with respect to the amplifier outputs changes the
commutation cycle’s zero point with respect to any absolute sensor’s zero point.
For a DC brush motor driven from a 3-phase power block amplifier, the two motor leads must be
connected between the first and third amplifier outputs, corresponding to the A and C outputs from the
Turbo PMAC.
Turbo PMAC Parameter Setup
Much of the Turbo PMAC interface hardware is software-configurable through I-variables. This section
provides basic information on each of the I-variables that is important in this type of application. There is
a detailed description of each I-variable in the Software Reference Manual.
If using the older Type 0 MACRO protocol, add 1 to the value shown in the above table (e.g. $078422
becomes $078423).
Current Feedback Mask Word: Ixx84
Ixx84 specifies a mask word to tell Turbo PMAC what bits of the registers specified by Ixx82 are to be
used in the current-loop algorithm. This permits the use of ADCs of various resolutions. It also permits
use of the rest of the 18-bit ADC shift register for other information, such as fault codes. Ixx84 is a 24-bit
value that is combined with the feedback word in a bit-by-bit AND operation. The default value of
$FFF000 specifies that the top 12 bits of the feedback words are to be used. Most direct-PWM amplifiers
use 12-bit ADCs, so $FFF000 is the appropriate value for these amplifiers.
PWM Scale Factor: Ixx66
Ixx66, the PWM Scale Factor, scales the output command values so that they use the PWM circuitry
effectively. The result of the current-loop calculations is a fractional value between -1.0 and +1.0. This
value is multiplied by Ixx66 before being written to a PWM command register, where it is digitally
compared to a PWM up/down counter moving between I7m00+1 and -I7m00-2. To utilize the dynamic
range of the PWM circuitry well, Ixx66 should be set slightly greater than I7m00. Typically a value 10%
greater is used, permitting full-on conditions at maximum command values over about 1/6 of the
commutation cycle.
Ixx66 acts as a voltage limit for the motor. If the amplifier is oversized for the motor, exceeding the
maximum permitted voltage for the motor, Ixx66 should be set proportionately less than I7m00 to limit
the maximum possible voltage for the motor. Since Ixx66 is a gain, the current loop must be tuned or
retuned after any change.
Servo Loop Output Limit: Ixx69
Ixx69 is the limit of the output of the position/velocity servo loop, which is the torque (quadrature)
current command input to the digital current loop. As such, it acts as an instantaneous current limit for
the motor. Open-loop O-commands are expressed as a percent of Ixx69.
In most other modes, a value of 32,767 (215-1) for Ixx69 for this parameter is full range. In 3-phase
direct-PWM mode, however, the value of 32,767 corresponds to the full-range readings of the Phase A
and Phase B A/D converters. The mathematics involved in the transformation from the phase currents to
the direct and quadrature currents effectively multiplies the phase values by cos(30o), or 0.866. This
means that the Ixx69 value corresponding to the full-range ADC reading is 32,767*0.866 = 28,377.
Therefore, Ixx69 should never be set to a value greater than 28,377 in direct-PWM mode.
The amplifier manual should specify the level of current that provides full-range feedback from the
ADCs. Then take the instantaneous current limit for the drive or for the motor, whichever is less, and set
Ixx69 according to the following relationship:
InstCurrentLimit
Ixx69 = min 28 ,377 , * 28 ,377
FullRangeCurrent
If the drive outputs analog current readings and the ADCs are on the interface board, the full-range
current value must be calculated from the volts-per-amp gain of the current sensing in the drive and the
full-range voltage into the interface board.
If a non-zero value of Ixx77 magnetization current will be used, for induction motor control or for field
weakening of a permanent-magnet brushless motor, then Ixx69 should be replaced in the above equation
by Ixx69 2 + Ixx77 2 .
In early testing, it may be desirable to set Ixx69 to an artificially low value to prevent accidental
overcurrent commands into the motor.
Continuous Current Limit: Ixx57
Ixx57 specifies the magnitude of the continuous current limit for the motor/drive system for integrated-
current algorithms for thermal protection. If Ixx57 is greater than 0, Turbo PMAC uses I2T protection,
squaring the value of the current before integrating it. This is appropriate when the most temperature-
sensitive component is resistive in nature (such as the motor windings). If Ixx57 is less than 0, Turbo
PMAC uses |I|T protection, just taking the absolute value of the current before integrating it. This is
appropriate when the most temperature-sensitive component has an essentially fixed voltage across it, as
with a fully-on bipolar transistor.
Usually, it is the continuous current rating of the drive that is used for a motor’s Ixx57. Even if its
continuous current rating is somewhat higher than that of the motor, usually its thermal time constant is
so much shorter that the integrated current parameters are set to protect it first. Ixx57 is calculated in a
manner similar to Ixx69:
ContCurrentLimit
Ixx57 = * 28 ,377
FullRangeCurrent
If the phase current sensors and ADCs in the amplifier are set up so that a positive PWM voltage
command for a phase yields a negative current measurement value, Ixx72 must be set to a value less than
1024: 683 for a 3-phase motor, or 512 for a DC brush motor. If these are set up so that a positive PWM
voltage command yields a positive current measurement value, Ixx72 must be set to a value greater than
1024: 1365 for a 3-phase motor, or 1536 for a DC brush motor. The testing described below will show
how to determine the proper polarity.
The direct-PWM algorithms in the Turbo PMAC are optimized for 3-phase motors and will cause
significant torque ripple when used with 2- or 4-phase motors. Delta Tau has created user-written phase
algorithms for these motors; contact the factory if interested in obtaining these.
CAUTION
It is very important to set the value of Ixx72 properly for your system; otherwise
the current loop will have unstable positive feedback and want to saturate. This
could cause damage to the motor, the drive, or both, if overcurrent shutdown
features do not work properly. If unsure of the current measurement polarity in
your drive, consult the Testing PWM and Current Feedback Operation section.
For commutation with digital current loops, the proper setting of Ixx72 is unrelated to the polarity of the
encoder counter. This is different from commutation with an analog current loops (sine-wave control), in
which the polarity of Ixx72 (less than or greater than 1024) must match the encoder counter polarity.
With the digital current loop, the polarity of the encoder counter must be set for proper servo operation.
With the analog current loop, once the Ixx72 polarity match has been made for commutation, the servo
loop polarity match is guaranteed.
Special Instructions for Direct-PWM Control of Brush Motors
A few special settings must be made to use the direct-PWM algorithms for DC brush motors. The basic
idea is to trick the commutation algorithm into thinking that the commutation angle is always stuck at 0
degrees, so current into the A phase is always quadrature (torque-producing) current. This section
summarizes what must be done in terms of variable setup; some of these settings have been discussed
elsewhere as well.
These instructions assume:
• The brush motor’s rotor field comes from permanent magnets or a wound field excited by a separate
means; the field is not controlled by one of the phases of this channel.
• The two leads of the brush motor’s armature are connected to amplifier phases (half-bridges) that are
driven by the A and C-phase PWM commands from Turbo PMAC. The amplifier may have an
unused B-phase half-bridge, but this does not need to be present.
Settings that are the same as for permanent-magnet brushless servo motors with an absolute phase reference:
• Ixx01 = 1 (commutation directly on Turbo PMAC) or Ixx01=3 (commutation over the MACRO ring).
• Ixx02 should contain the address of the PWM A register for the output channel used or the MACRO
Node register 0 (these are the defaults), just as for brushless motors.
• Ixx29 and Ixx79 phase offset parameters should be set to minimize measurement offsets from the A
and B-phase current feedback circuits, respectively.
• Ixx61, Ixx62, and Ixx76 current loop gains are set just as for brushless motors.
• Ixx73 = 0, Ixx74 = 0: These default settings ensure that Turbo PMAC will not try to do a phasing
search move for the motor. A failed search could keep Turbo PMAC from enabling this motor.
• Ixx77 = 0 to command zero direct (field) current.
• Ixx78 = 0 for zero slip in the commutation calculations.
• Ixx82 should contain the address of ADC B register for the feedback channel used (just as for
brushless motors) when the ADC A register is used for the rotor (armature) current feedback. The B
register itself should always contain a zero or near-zero value.
• Ixx81 > 0: Any non-zero setting here makes Turbo PMAC do a “phasing read” instead of a search
move for the motor. This is a dummy read, because whatever is read is forced to zero degrees by the
settings of Ixx70 and Ixx71, but Turbo PMAC demands that some sort of phase reference be done.
(Ixx81=1 is fine.)
• Ixx84 is set just as for brushless motors, specifying which bits the current ADC feedback uses.
Usually, this is $FFF000 to specify the high 12 bits.
Special settings for brush motor direct PWM control:
• Ixx70 = 0: This causes all values for the commutation cycle to be multiplied by 0 to defeat the
rotation of the commutation vector.
• Ixx72 = 512 (90oe) if voltage and current numerical polarities are opposite, or1536 (270oe) if they are
the same. If the amplifier would use 683 (120oe) for a 3-phase motor, use 512 here; if it would use
1365 (240oe) for a 3-phase motor, use 1536 here.
• Ixx96 = 1: This causes Turbo PMAC to clear the integrator periodically for the (non-existent) direct
current loop, which could slowly charge up due to noise or numerical errors and eventually interfere
with the real quadrature current loop.
Settings that do not matter:
• Ixx71 (commutation cycle size) does not matter because Ixx70 setting of 0 defeats the commutation
cycle
• Ixx75 (Offset in the power-on phase reference) does not matter because commutation cycle has been
defeated. Leaving this at the default of 0 is fine.
• Ixx83 (ongoing commutation position feedback address) doesn’t matter, since the commutation has
been defeated. Leaving this at the default value is fine.
• Ixx91 (power-on phase position format) does not matter, because whatever is read for the power-on
phase position is reduced to zero.
Testing PWM and Current Feedback Operation
CAUTION:
On many motor and drive systems, potentially deadly voltage and current levels
are present. Do not attempt to work directly with these high voltage and current
levels unless you are fully trained on all necessary safety procedures. Low-level
signals on Turbo PMAC and interface boards can be accessed much more safely.
Introduction
Most of the time in setting up a direct PWM interface, do not execute all of the steps listed in these
sections (or the Turbo Setup program will do them automatically), but the first time this type of interface
is set up, or if there are problems, these steps will be of great assistance.
All of these tests should be done with the motor disconnected from any loads for safety reasons. All
settings made as a result of these tests are independent of load properties, so will still be valid when the
load is connected.
Before testing any of Turbo PMAC’s software features for digital current loop and direct PWM interface,
it is important to know whether the hardware interface is working properly. We will use PMAC’s M-
variables to access the input and output registers directly. The examples shown here use the suggested M-
variable definitions for Motor 1; for other motors there are equivalent suggested definitions shown in the
Examples section of the manual.
Purpose
The purpose of this set of tests is to confirm the basic operation of the hardware circuits on PMAC, in the
drive, and in the motor and to check the proper interrelationships. Specifically:
• Confirm operation of encoder inputs and decode
• Confirm operation of PWM outputs
• Confirm operation of ADC inputs
• Confirm correlation between PWM outputs and ADC inputs
• Determine proper current loop polarity
• Confirm commutation cycle size
• Determine proper commutation polarity
Preparation
First define the M-variables for the encoder counter, the 3 PWM output registers, the amplifier-enable
output bit, and the two ADC input registers. Using the suggested definitions for Motor 1, utilizing Servo
IC 0, Channel 1, we have:
M101->X:$078001,0,24,S ; Channel 1 Encoder position register
M102->Y:$078002,8,16,S ; Channel 1 PWM Phase A command value
M104->Y:$078003,8,16,S ; Channel 1 PWM Phase B command value
M107->Y:$078004,8,16,S ; Channel 1 PWM Phase C command value
M105->Y:$078005,8,16,S ; Channel 1 Phase A ADC input value
M106->Y:$078006,8,16,S ; Channel 1 Phase B ADC input value
M114->X:$078005,14 ; Channel 1 Amp Enable command bit
Note that the ADC values are declared as 16-bit variables even though typically 12-bit ADCs are used;
this puts the scaling of the variable in the same units as Ixx69, Ixx57, Ixx29, and Ixx79.
It will be useful to monitor these values in the Watch window of the Executive program, so add the
variable names to the Watch window, causing the program to repeatedly query Turbo PMAC for the
values which it will display. The hardware can then be exercised with on-line commands issued through
the Terminal window.
To prepare Turbo PMAC for these tests:
• Set I100 to 0 to deactivate the motor.
• Set I101 to 0 to disable commutation (This allows for manual use of these registers.)
• Make sure that I7000, I7004, I7016, and I7017 are set up properly to provide the PWM signals needed.
• If the Amplifier Enable bit is 1, set it to zero with the command M114=0.
• Set Ixx00 and Ixx01 for all other motors to zero.
If the positive direction of motion is known, check this here. If the direction is incorrect, invert it by
changing I7mn0, usually from 7 to 3, or from 3 to 7. If it is not known yet which direction sense is
needed, change it later, but make another change at that time to maintain the proper commutation polarity
match, usually by exchanging two of the motor phase leads at the drive.
Note:
Because I100 has been set to 0, and I103 may not yet have been set properly, any
change of position will not be reflected in the motor position window.
PWM Output & ADC Input Connection
Make sure before applying any PWM commands to the drive and motor in this fashion that the resulting
current levels are within the continuous current rating of both drive and motor.
First enable the amp, then apply a very small positive command value to Phase A and a very small
negative command value to Phase B with the on-line commands
M114=1 ; Enable amplifier
M102=I7000/50 M104=-I7000/50 M107=0 ; A pos, B neg, C zero
This provides a command at 2% of full voltage into the motor, which should be well within the
continuous current rating of both drive and motor. It is always a good idea to make the sum of these
commands equal to zero so as not to put a net DC voltage on the motor; putting all three commands on
one line causes the changes to happen virtually instantaneously.
With power applied to the drive and the amplifier enabled (M114=1), current readings should be received
in the ADC registers as shown by their M-variables M105 and M106 in the Watch window.
As the M-variables have been defined, +/-32,768 is full current range, which should correspond
approximately to the instantaneous current limit. Make sure that the value read does not exceed the
continuous current limit, usually which is about 1/3 of the instantaneous limit. If the value is well below
the continuous current limit, increase the voltage command to 5% to 10% of maximum. For example:
M102=I7000/10 M104=-I7000/10 M107=0 ; 10% of maximum
PWM/ADC Phase Match
Command values from Turbo PMAC’s Phase A PWM outputs should cause a roughly proportionate
response of one sign or the other on Turbo PMAC’s Phase A ADC input (whatever the phase is named in
the motor and drive). The same is true for Phase B.
If there is no response on either phase, re-check the entire setup, including:
• Is the drive properly wired to Turbo PMAC, either directly or through an interface board?
• Is the motor properly connected to the drive?
• Is the drive properly powered, both the power stage, and the input stage?
• Is the interface board properly powered?
• Is the amplifier enabled (M114=1 on Turbo PMAC and indicator ON at the drive)?
• Is the amplifier in fault condition? If so, why?
If an ADC response is received only on one phase, the phase outputs and inputs may not be properly
matched. For example, the Phase B ADC may be reading current from the phase commanded by the
Phase C PWM output. Confirm this by trying other combinations of commands as shown in the six-step
test below, and checking which ADC responds to which phase command. If there is not a proper match,
change the wiring between Turbo PMAC and the drive. Changing the wiring between drive and motor
will not help here.
• For synchronous motors (and probably for induction motors), the physical change in rotor position
between the initial Step 1 and the return to Step 1 (mark the rotor if necessary) should be equal to 1
pole pair:
• On a 2-pole motor, it should be one full mechanical revolution.
• On a 4-pole motor, it should be one-half mechanical revolution.
• On a 6-pole motor, it should be one-third mechanical revolution.
• On an 8-pole motor, it should be one-fourth mechanical revolution.
• On a 100-pole motor, it should be 7.2o mech.
Executing the Test
For Motor 1 using Servo IC 0, Channel 1 with a 3-phase motor, with 10% voltage commands being
acceptable, the commands could be:
M102=0 M104=I7000/10 M107=-I7000/10 ; Step 1: A0, B+, C-: 0oelec.
M102=I7000/10 M104=0 M107=-I7000/10 ; Step 2: A+, B0, C-: 60oelec.
M102=I7000/10 M104=-I7000/10 M107=0 ; Step 3: A+, B-, C0: 120oelec.
M102=0 M104=-I7000/10 M107=I7000/10 ; Step 4: A0, B-, C+: +180oelec.
M102=-I7000/10 M104=0 M107=I7000/10 ; Step 5: A-, B0, C+: -120oelec.
M102=-I7000/10 M104=I7000/10 M107=0 ; Step 6: A-, B+, C0: -60oelec.
M102=0 M104=I7000/10 M107=-I7000/10 ; Step 1: A0, B+, C-: 0oelec.
This test moves the motor through the commutation cycle in the positive direction if Ixx72 is less than
1024 (i.e. 683); it moves through the cycle in the negative direction if Ixx72 is greater than 1024 (i.e.
1365). On a synchronous motor, we can use the position reading to check the commutation polarity
match; this may be possible on an induction motor as well.
Action To Take
If the rotor position, as reflected by M101, changed in the wrong direction during this test, we could have
a commutation polarity mismatch. With such a mismatch, the motor would lock in (not run away) when
commanded. There are two possible fixes for this mismatch:
1. Reverse the feedback direction sense by changing I7mn0. However, this changes the direction sense
of the axis, which may not be tolerable.
2. Exchange two phase leads between amplifier and motor. Usually, this is done at the screw terminals
on the amplifier. Exchanging any two phases will change the polarity in the same way. However, the
relationship between the sensor zero position and Turbo PMAC’s commutation cycle zero position is
dependent on which two phases are exchanged.
For asynchronous induction motors, if the above test did not cause proper movement try each direction
polarity and see which works. This is described below.
Once the commutation polarity match has been established, the servo polarity match is established
automatically. Check this later by seeing that positive O-commands cause motor position to count in the
positive direction.
Remember that if I7mn0 is changed later to get the physical direction sense needed, exchange motor
phase leads to re-establish the commutation polarity match.
Example
The table of results for a sample run of this test is:
Step M102 (A) M104 (B) M107 (C) Cycle Position Physical Position M101 (counts) M105 (A) M106 (B)
1 +500 0 -500 0oe 4:00 8820 <0 ≈0
2 +500 -500 0 +60oe 3:00 9184 <0 >0
3 0 -500 +500 +120oe 2:00 9501 ≈0 >0
4 -500 0 +500 +180oe 1:00 9845 >0 ≈0
5 -500 +500 0 -120oe 12:00 10218 >0 <0
6 0 +500 -500 -60oe 11:00 10532 ≈0 <0
1 +500 0 -500 0oe 10:00 10869 <0 ≈0
From this test, we can conclude:
• PWM operation is fundamentally working (we got 6 approximately equal steps)
• We have a 4-pole motor because we moved 1/2 revolution
• Current ADC inputs are working: we got proportionate responses
• Sign of current is opposite to sign of voltage, so Ixx72 should be 683.
• We move 2049 counts in one cycle, so 4096 counts per revolution should be correct
• Encoder counter increased, so commutation polarity is correct
Cleaning Up
When done with this section of the testing, write zero values into the command registers and disable the
amplifier with the command:
M102=0 M104=0 M107=0 M114=0
With zero commands into all of the phases of the drive, with the drive either enabled or disabled, the
ADC registers should read nearly zero. Turbo PMAC can compensate for non-zero values with the offset
parameters Ixx79 (A-phase offset) and Ixx29 (B-phase offset). These offset parameters should hold
values of the opposite sign of the phases’ ADC values when there are zero PWM commands. Ixx29 and
Ixx79 magnitudes assume 16-bit values; since we are using 16-bit M-variables to look at the ADC
registers, regardless of the true resolution of the ADCs, we can just read the M-variable values at zero
command and use the opposite values for Ixx79 and Ixx29.
Debugging
With zero commands on the three output registers, you can observe any of the six PWM output signals
with an oscilloscope. All six should have 50% duty cycle (minus the deadtime set by I7m04) at the
frequency set by I7m00. All three top-PWM signals should be in phase with each other. All three
bottom-PWM signals should be in phase with each other, and one-half cycle out of phase with the top
signals. Observing a top and bottom pair, observe the deadtime between the top and bottom on times.
With a positive command into the A-phase, a negative command into the B-phase, and a zero command on
the C-phase, these waveforms should change. On the oscilloscope, observe PWMATOP1 on-time increase,
and PWMABOT1 on-time decrease, while maintaining the deadtime. Similarly, PWMBTOP1 on-time
should decrease, and PWMBBOT1 on-time should increase, maintaining the deadtime between them.
If the analog voltages representing the current measurements are available, these can be probed for
diagnostic purposes. Many direct PWM drives provide analog current measurement outputs and the A/D
conversion is done on an interface board. The probing is easy for these drives. If the A/D conversion is
done inside the drive, access to test points to probe these voltage levels. Consult the drive manual for
location and scaling of these signals.
Ki Back Path
Kpb Proportional
1 - Z-1 Gain
Integral
Gain +
Measured
Kpb = Ix76 x 4 (0.0 < Ix76 < 1.0) Current
Kpf = Ix62 x 4 (0.0 < Ix62 < 1.0) (Id or Iq)
Ki = Ix61 x 4 (0.0 < Ix61 < 1.0)
Usually only one of Ixx62 or Ixx76 is used on a given motor; the other gain is set to 0.0. It is more
common to use Ixx61, the forward-path gain, because it provides greater responsiveness and bandwidth.
If Ixx76 is used instead of Ixx62, only the Ixx61 integral gain term directly connects the current command
to the output, and its integration effect filters the command, reducing responsiveness.
However, if the command from the position/velocity servo loop is noisy, as can be the case with a low-
resolution position sensor, this filtering effect can be desirable, and Ixx76 can provide better performance
than Ixx62.
Analytic Calculation of Current-Loop Gains
With some basic knowledge of motor and amplifier parameters, it is possible to calculate the current-loop
gains directly. It is strongly advised that these computed gains be checked against the values determined
through the auto-tuning or interactive tuning of the Turbo Setup program.
The motor parameters needed are:
• Rpn Motor phase-to-neutral resistance (Ohms)
= Rpp / √3 (Motor phase-to-phase resistance / √3)
• Lpn Motor phase-to-neutral inductance (Henries)
= Lpp / √3 (Motor phase-to-phase inductance / √3)
The amplifier parameters needed are:
• Isat Maximum (saturated) current reading from phase-current A/D converter (Amps).
This is a DC value, not an RMS AC value. This value can be derived from the current-sensor gain Kc
(volts/amp) and the maximum voltage in volts that the A/D-converter can read Vcmax: Isat= Vcmax/Kc.
• VDC DC bus voltage for the amplifier.
This can be derived from the AC RMS supply voltage VAC: VDC=VAC*√2.
Finally, the Turbo PMAC parameter needed is:
• TP Phase-update period (sec)
This can be derived from the phase update frequency fP in kHz: TP=1/(1000*fP)
Next, the following performance specifications for the current loop are required:
• ωn Desired natural frequency of the closed current loop in radians/sec
This can be derived from the desired natural frequency fn in Hz: ωn (rad/s) = 2πfn (Hz).
If the damping ratio (see below) is in the range 0.7 to 1.0, which it should be in most cases, the
desired bandwidth of the current loop basically is equal to the natural frequency. Usually values of
200 Hz to 400 Hz are used.
• ζ Desired damping ratio (dimensionless). A value of 0.7 here yields a step-response overshoot of
about 5%; a value of 1.0 here yields no overshoot.
Now we can compute the proportional current-loop gain Kcp and the integral current-loop gain Kci
according to the formulas:
(2ζω n L pn ) − R pn
K cp = I sat
V DC
TP ω n2 L pn
K ci = I sat
V DC
Finally, to compute the I-variables to represent these gains, we use the formulas:
K cp ∗ PWM max cnt
Ixx62 + Ixx76 =
4 ∗ Ixx66
K ci ∗ PWM max cnt
Ixx61 =
8 * Ixx66
Here, PWMmaxcnt is I7m00 for a channel directly driven by the Turbo PMAC; it is MI900, MI906, or
MI992 for a channel on a MACRO Station.
The proportional gain term is expressed as the sum of two I-variables. Ixx62 is the “forward-path”
proportional gain term, directly responding to changes in the command values; Ixx76 is the “back-path”
proportional gain term, directly responding only to the actual current values. When high position
feedback resolution is used in the position/velocity loop, the quantization noise in the current command is
low, and it is better to use Ixx62. When low position-feedback resolution is used, it is better to use Ixx76.
Tradeoffs between responsiveness and smoothness can be obtained by varying the amount of the
proportional gain term allocated to each of these two variables.
Example:
The motor has a phase-to-phase resistance of 3.0 ohms, and a phase-to-phase-inductance of 39
millihenries. The amplifier phase-current sensors provide their maximum 5-volt output for 17.5 amps of
current, and the ADCs provide their full-range value for an input of 5V. The amplifier operates from an
AC supply voltage of 120Vrms. The Turbo PMAC is operating at the default phase update frequency of
9.03 kHz. A current-loop natural frequency of 200 Hz with a damping ratio of 0.7 is desired. The PWM-
max-count variable is at the default value of 6528, and Ixx66 for the motor is at the recommended value
of 7181 (10% greater).
Lpn = Lpp / √3 = 0.039 / 1.732 = 0.0225 H
Rpn = Rpp / √3 = 3.0 / 1.732 = 1.732 ohms
Isat = Vcmax/Kc = 5.0 / (5.0/17.5) = 17.5 amps
VDC = VAC * √2 = 120 * 1.414 = 170 V
TP = 1 / (1000*fP) = 1 / (1000*9.03) = 0.000110 sec
ωn (rad/s) = 2 π ωn (Hz) = 2 * π * 200 = 1256 rad/sec
Kcp = Isat [(2 ζ ωn Lpn) – Rpn] / VDC = 17.5 [(2 * 0.7 * 1256 * 0.0225)- 1.732] / 170 = 3.89
Kci = Isat Tp ωn2 Lpn / VDC = 17.5 * 0.000110 * 12562 *0.0225 / 170 = 0.401
Ixx62 + Ixx76 = (Kcp * PWMmaxcnt) / (4 * Ixx66) = 3.89 / (4 * 1.1) = 0.884
Ixx61 = (Kci * PWMmaxcnt) / (8 * Ixx66) = 0.401 / (8 * 1.1) = 0.0456
Preparation for Experimental Tuning
Typically the experimental current-loop tuning is done through the Turbo Setup program or the PMAC
Executive program; both create the proper setup for the tests automatically. However, to do the test
manually, follow the instructions in this section.
To prepare Turbo PMAC for this test:
• Set Ixx00 for all other motors to 0 to de-activate them.
• Set Ixx01 for all other motors to 0 to turn off the commutation. This makes sure Turbo PMAC has
enough calculation time to gather data fast enough.
• Set I7m02 to 0 for divide-by-1 to make servo update rate equal to phase update rate. This permits
Turbo PMAC to gather data every phase update.)
To set up the motor under test:
• Set Ixx00 to 1 for the motor under test to activate it.
• Set Ixx01 to 1 for the motor under test to turn on phase/current calculations. These may have been
left at zero from the earlier tests.
• Give the motor a K command to turn off the outputs
• Set Ixx71 to 1 to cripple the commutation algorithm and prevent movement during the test.
• Make sure the other setup I-variables are set as instructed above. I7m02 and Ixx71 only should be
different from what they would be in the final application.
• Start with Ixx62=0.1, Ixx61=0.0, and Ixx76=0.0 as current loop gains.
• Set Ixx77 to 3000 to provide about 10% direct current command.
In the Detailed Plot section of data gathering, specify data gathering at intervals of one servo cycle.
Select for gathering the commanded and actual direct current registers every servo cycle for the motor
under test. The addresses for these registers are found in the following table.
Commanded Direct Current Registers
Motor # 1 2 3 4 5 6 7 8
Address Y:$00B8 Y:$0138 Y:$01B8 Y:$0238 Y:$02B8 Y:$0338 Y:$03B8 Y:$0438
Motor # 9 10 11 12 13 14 15 16
Address Y:$04B8 Y:$0538 Y:$05B8 Y:$0638 Y:$06B8 Y:$0738 Y:$07B8 Y:$0838
Motor # 17 18 19 20 21 22 23 24
Address Y:$08B8 Y:$0938 Y:$09B8 Y:$0A38 Y:$0AB8 Y:$0B38 Y:$0BB8 Y:$0C38
Motor # 25 26 27 28 29 30 31 32
Address Y:$0CB8 Y:$0D38 Y:$0DB8 Y:$0E38 Y:$0EB8 Y:$0F38 Y:$0FB8 Y:$1038
When used through a PMAC-style Servo IC, this requires the single DACs on two consecutive channels.
The higher (even) numbered DAC channel is the A DAC; the lower (odd) numbered DAC channel is the
B DAC.
DAC Output Signals
The A and B DAC outputs should be connected to the phase command inputs on the sine-wave input
amplifier. If the inputs on the amplifier are single-ended, use the DAC+ output only, and leave the
complementary DAC- outputs floating; do not ground them. If the inputs on the amplifier are
complementary, use both the DAC+ and DAC- outputs. In either case, tie the AGND reference voltage
on the output connector to the reference voltage for the amplifier input.
Amplifier-Enable and Fault Interface
On PMAC2-style interface and breakout boards, including the Acc-8A, 8E, and 24E2A, the amplifier-
enable outputs are dry-contact relays. Normally open, normally closed, sinking or sourcing
configurations from 12V to 24V can be chosen. Normally open contacts (closed when enabled) are
recommended for more fail-safe operation.
On PMAC-style boards, the amplifier-enable outputs are optically isolated solid-state drivers with 24V,
100mA capability. On most boards, sinking or sourcing drivers can be chosen by the selection of
socketed driver IC. The factory default is sinking drivers.
The amplifier fault inputs are optically isolated 12V to 24V inputs. On newer designs with surface-mount
ICs, the isolators are AC Optos so sinking or sourcing drivers can be used. On older designs with
through-hole ICs, sinking drivers are required.
Encoder Feedback
Usually, sine-wave control is done with either digital quadrature encoders connected directly into the
controller (the breakout board is just a pass-through for these signals) or analog sine-cosine encoders
processed through an interpolator accessory. When using an interpolated analog encoder for servo
feedback, typically the uninterpolated digital encoder counter is used for the commutation feedback,
which does not require the high resolution of the servo.
Hall-Effect Commutation Flags
PMAC2-style Servo ICs have supplemental flags for each channel labeled T, U, V, and W. The U, V,
and W flags are commonly used for hall-effect commutation signals (or their optical equivalent) that
provide power-up phase position information.
PMAC-style Servo ICs require the use of a second channel’s flags (usually the same channel as the
second DAC) as the supplemental flags for this purpose.
Turbo PMAC Parameter Setup
PMAC2-Style Servo IC Multi-Channel Setup
The PMAC2-style DSPGATE1 Servo ICs have a great deal of flexibility in supporting different hardware
interfaces. This means that there are certain registers that must be set up through I-variables to support
the desired mode of operation. This is not required if PMAC-style Servo ICs are used.
Hardware Clock Frequency Control: I7m03, MI903, MI907
I7m03 (MS{anynode},MI903 or MS{anynode},MI907 on a MACRO Station) determines the
frequency of four hardware clock signals used for the machine interface channels on Servo IC m. These
can probably be left at the default values. The four hardware clock signals are SCLK (encoder sample
clock), PFM_CLK (pulse frequency modulator clock, DAC_CLK (digital-to-analog converter clock), and
ADC_CLK (analog-to-digital converter clock).
Only the DAC_CLK signal is directly used with the sine-wave output, to control the frequency of the
serial data stream to the DACs. The default DAC clock frequency of 4.9152 MHz is suitable for the
DACs on all Delta Tau hardware. Refer to the I7m03 description for detailed information on setting these
variables.
The encoder SCLK frequency should be at least 20% greater than the maximum count (edge) rate that is
possible for the encoder on any axis. Higher SCLK frequencies than this minimum may be used, but
these make the digital delay anti-noise filter less effective.
DAC Strobe Control: I7m05, MI905, MI909
Turbo PMAC generates a common DAC strobe word for each set of four machine interface channels. It
does this by shifting out a 24-bit word each phase cycle, one bit per DAC clock cycle, most significant bit
first. I7m05 (MS{anynode},MI905 or MS{anynode},MI909 on a MACRO Station) contains this
word for the channels on Servo IC m. The default value of $7FFFC0 is suitable for use with the 18-bit
DACs used with the PMAC2-style Servo ICs on Delta Tau interface and breakout boards. A value of
$7FFF00 is suitable for 16-bit DACs.
Individual-Channel Hardware Setup
For each machine interface channel n (n = 1 to 4) of Servo IC m used for sine wave analog outputs, a few
I-variables must be set up properly.
Encoder Decode Control: I7mn0, MI910
I7mn0 (MS{node},MI910 on a MACRO Station) must be set up to decode the commutation encoder
properly. Usually, a value of 3 or 7 is used to provide times-4 decode of a quadrature encoder (4 counts
per encoder line). The difference between 3 and 7 is the direction sense of the encoder; set this variable
so the motor counts up in the direction desired.
The polarity sense of the Ixx72 commutation phase angle parameter must match that of I7mn0 for a
particular wiring; if it is wrong, it will lock into a position rather than generate continuous torque. A test
for determining this polarity match is given below. Remember that if I7mn0 is changed on a working
motor, change Ixx72 as well.
Output Mode Control: I7mn%6, MI916
I7mn6 (MS{node},MI916 on a MACRO Station) must be set to 1 or 3 to specify that outputs A and B
for Channel n are in DAC mode, not PWM. A setting of 1 puts output C (not used for servo or
commutation tasks in this mode) in PWM mode; a setting of 3 puts output C in PFM mode.
Output Inversion Control: I7mn7, MI917
I7mn7 (MS{node},MI917 on a MACRO Station) controls whether the serial data streams to the DACs
on Channel n are inverted or not. The default value of 0 (non-inverted) is suitable for use with the
recommended Acc-8E analog interface board. Inverting the bits of the serial data stream has the effect of
negating the DAC voltage. In a commutation algorithm this is equivalent to a 180o phase shift, which
would produce runaway if the system were working properly before the inversion.
Parameters to Set Up Motor Operation
Several I-variables must be set up for each Motor xx to enable and configure the sine-wave output for that
motor. Of course, Ixx00 must be set to 1 for any active motor, regardless of the output mode for that
motor, and Ixx01 bit 0 must be set to 1 to enable commutation, as covered earlier.
Command Output Address: Ixx02
When using PMAC-style Servo ICs for sine-wave control, Ixx02 must specify the address of an even-
numbered DAC register. In this mode, this will cause the Turbo PMAC to use both this DAC and the
next lower-numbered DAC (which is one address higher). Two channels must be used to commutate one
motor. For example, if the address of Servo IC 0 DAC 4 is specified, Turbo PMAC will use DACs 3 and
4. The following table shows the possible Ixx02 values for this mode:
If using the older Type 0 MACRO protocol, add 1 to the value shown in the above table (e.g. $078420
becomes $078421).
This register normally varies from -Ixx71/2 to +Ixx71/2, although if monitoring it, sometimes it will jump
by Ixx71 units and be temporarily outside this range. This is normal behavior. Access to this register is
useful in many ways for establishing a phase reference. Define the suggested M-variable for the Motor 1
phase position register:
M171->X:$00B4,0,24,S ; Motor 1 phase position (counts*Ixx70)
Add this M-variable to the Watch window.
Current-Command Six-Step Test
The basic technique we will use here, either for a one-time phase reference with an absolute sensor or
power-up phase reference with an incremental sensor, is all or part of the current command six-step test.
This is similar to the voltage command six-step test described above, except the current loops are active.
We use the ADC input offset registers to bias the phase current feedback, and hence the phase command
outputs, to drive the motor as a stepper motor to a particular location in the commutation cycle, usually
the 0o position. Then we can write a 0 to the phase position register.
Ixx29 is the A-phase offset; Ixx79 is the B-phase offset. The third phase is not directly commanded;
Turbo PMAC will command it automatically as part of the digital current loop to balance the first two
phases. For motor 1, the following sequence of commands for the current six-step test, and the expected
results, could be:
#1O0 ; Open loop command of zero magnitude
I179=3000 I129=0 ; Step 1: (A) 0oelec.; (B) 180oelec.
I179=3000 I129=-3000 ; Step 2: (A) -60oelec.; (B) 120oelec.
I179=0 I129=-3000 ; Step 3: (A) -120oelec.; (B) 60oelec.
I179=-3000 I129=0 ; Step 4: (A) 180oelec.; (B) 0oelec.
I179=-3000 I129=3000 ; Step 5: (A) 120oelec.; (B) -60oelec.
I179=0 I129=3000 ; Step 6: (A) 60oelec.; (B) -120oelec.
I179=3000 I129=0 ; Step 1: (A) 0oelec.; (B) 180oelec.
Case (A) is the proper result for all direct PWM setups (Ixx82>0), regardless of the setting of Ixx72. It is
the proper result for sine-wave output setups (Ixx82=0) with Ixx72<1024. Case (B) is the proper result
for sine-wave output setups (Ixx82=0) with Ixx72>1024.
These commands will force about 1/10 of maximum current into phases to drive the motor to known
positions in the phase cycle. Remember to clear the offsets when you are finished with this test:
I179=0 I129=0
Direction-Balance Fine-Phasing Test
The stepper motor phasing test will establish a phase reference typically to within 1 or 2 degrees. This is
adequate for many purposes, but for complete optimization of the motor phase reference, it is necessary to
perform another test, described below. This test finds the best phase reference by making sure that key
performance measures are the same in both directions. Usually the improvement seen in performance
from this fine phasing is better smoothness, not increased torque.
The use of current-loop integrator registers as explained below can be used only in direct PWM systems.
The tests can still be run on sine-wave output systems, but the measurement to be compared in both
directions is the motor velocity. This can simply be read in the position window of the PMAC Executive
Program. This measurement, which is also possible on direct PWM systems, is not quite as sensitive to
phase differences as the measurement explained below, but can still result in an improvement.
This test needs to be performed only once for a given motor. Its purpose is to establish a relationship
between the motor phase angle and an absolute sensor on the motor (e.g. resolver or incremental encoder
index pulse). Most motor manufacturers who mount feedback devices in the factory do not specify a
mounting repeatability tolerance (between motor phase angle and sensor angle) tighter than 1 or 2
degrees, so the results of this test do not necessarily carry from one motor to another of a given design.
Note:
Generally, this test is not appropriate for linear motors, because of the relatively
uncontrolled movement it produces. It should only be done on unloaded rotary
motors. On linear motors, a fine phasing test can be done by adjusting the phase
position register so that no movement occurs when a large value of Ixx77 (e.g.
16,000) is given with an O0 command. The test should start with small values, and
movement quickly stopped with a K command.
Preparation
In the Detailed Plot menu of the data gathering section of the PMAC Executive program, set up to gather
the Direct Integrator Output and Quadrature Integrator Output registers. The gathering period should be
set to about 10 servo cycles. The addresses of the registers for each of the motors is:
Direct Integrator Output Registers
Motor # 1 2 3 4 5 6 7 8
Address Y:$00BC Y:$013C Y:$01BC Y:$023C Y:$02BC Y:$033C Y:$03BC Y:$043C
Motor # 9 10 11 12 13 14 15 16
Address Y:$04BC Y:$053C Y:$05BC Y:$063C Y:$06BC Y:$073C Y:$07BC Y:$083C
Motor # 17 18 19 20 21 22 23 24
Address Y:$08BC Y:$093C Y:$09BC Y:$0A3C Y:$0ABC Y:$0B3C Y:$0BBC Y:$0C3C
Motor # 25 26 27 28 29 30 31 32
Address Y:$0CBC Y:$0D3C Y:$0DBC Y:$0E3C Y:$0EBC Y:$0F3C Y:$0FBC Y:$103C
Make sure the motor is completely at rest. Now multiply the sensor position value read by I170, and
subtract this from the phase position read by M171. (If the motor is moved manually so that M171=0, the
product can be negated). Enter this value into I175 using a statement such as:
I175=M171-(M175*I170)
Finally, set up I181 to read the absolute sensor on subsequent Turbo PMAC resets and store these values
with the SAVE command. Perform another phase reference on this motor.
Using the Test Results for Incremental Index Pulse
For the incremental encoder index pulse, we will use the position capture feature to note where the index
is. Set variable I7mn2 (MS{node},MI912 for a MACRO Station) to 1 if there is a high-true index
pulse, or to 9 if there is a low-true index pulse. (To see which it is, define Mxx19 to its suggested
definition and put it in the Watch window. Generally, if it is 0 there is a high-true pulse.) With a
PMAC2-style Servo IC, to make sure the effective index pulse is only 1 count wide, set I7mn4
(MS{node},MI912 for a MACRO Station) to 1, and I7mn5 (MS{node},MI912 for a MACRO
Station) to the appropriate value for the encoder.
Now assign an M-variable to the encoder flag capture register:
M103->X:$078003,0,24,S ; Encoder 1 flag capture register
Add this to the Watch window. With the motor at rest, note the phase position value in M171 and the
encoder position register in M101. Write these values down. Now turn/push the motor manually in the
direction to home to the machine until M103 changes. The new value is the value of the encoder register
captured at the index pulse.
Subtract your starting M101 value from this new M103 value. Multiply the difference by I170 and add
this to the starting M171 value. The result is the value we will write to the phase position register when
we are settled at the index to refine our initial rough phasing. Mathematically speaking:
IndexPhasePos = I 170 * (IndexM 103 − StartM 101) + StartM 171
Alternately, in a technique that is easier mathematically but harder physically, put M119 in the Watch
window (or the index signal on an oscilloscope) and turn the motor shaft until it stops on the index pulse.
Read the M171 phase position register value. This is the value we will write to the phase position register
when we are settled at the index to refine our initial rough phasing.
Using Hall-Effect Sensors for Phase Reference
Hall-effect sensors or their optical equivalents on a commutation encoder, for a 3-phase motor can be
used for rough phasing on power-up without the need for a phasing search move. This initial phasing
provides reasonable torque, but it will need to be corrected for top operation. Usually the correction is
done when the index pulse is reached, in the same technique that is described above for the correction
after a power-on phasing search move.
Hall-effect sensors usually map out 6 zones of 60oelec. each. In terms of Turbo PMAC’s commutation
cycle, the boundaries should be at 180o, -120o, -60o, 0o, 60o, and 120o. Typically a motor manufacturer
will align the sensors to within a few degrees of this, because these are the proper boundary points if all
commutation is done from the commutation sensors. If mounting the hall-effect sensors, take care to
align the boundaries at these points. The simplest way is to force the motor to the zero degree point with
a current offset (as shown above) and adjust the sensor while watching its outputs to get a boundary as
close as possible to this point.
Preparation
Define M-variables to the hall-effect or equivalent inputs. Suggested definitions for Channel 1 on a
PMAC2-style Servo IC are:
M124->X:$078000,20 ; Channel 1 W flag
M125->X:$078000,21 ; Channel 1 V flag
M126->X:$078000,22 ; Channel 1 U flag
M127->X:$078000,23 ; Channel 1 T flag (not usually hall)
M128->X:$078000,20,4 ; Channel 1 TUVW as a 4-bit value
Make these definitions and add these variables to the Watch window. (Delete other variables that are no
longer monitored.) With the motor killed, move the motor slowly by hand to verify that the inputs
expected to change do change.
Executing the Test
To map the hall-effect sensors, we will use the current-loop six-step test, or a variant of it, to force the
motor to known positions in the commutation cycle, and observe the states of the hall-effect signals. The
current-loop test shown above should force the motor right to the boundaries of the hall-effect zones. If
you use these commands, move the motor by hand a little bit at each point to observe the transition.
Force the motor to the expected mid-point of each hall-effect zone instead (or in addition). To do this, the
command sequence would be:
#1O0 ; Open loop command of zero magnitude
I179=3000 I129=-1500 ; Step 1: (A)-30oelec.; (B)150oelec.
o
I179=1500 I129=-3000 ; Step 2: (A)-90 elec.; (B)90oelec.
o
I179=-1500 I129=-1500 ; Step 3: (A)-150 elec.; (B)30oelec.
o
I179=-3000 I129=1500 ; Step 4: (A)150 elec.; (B)-30oelec.
o
I179=-1500 I129=3000 ; Step 5: (A)90 elec.; (B)-90oelec.
o
I179=1500 I129=1500 ; Step 6: (A)30 elec.; (B)-150oelec.
o
I179=3000 I129=-1500 ; Step 1: (A)-30 elec.; (B)150oelec.
Case (A) is the proper result for all direct PWM setups, regardless of the setting of Ixx72. It is the proper
result for sine-wave output setups with Ixx72<1024. Case (B) is the proper result for sine-wave output
setups with Ixx72>1024.
Remember to clear the offsets when finished with this test:
I179=0 I129=0
It is advisable to create a table listing the values of M124 through M128 for each position. An example
table would be:
Step M179 M129 Cycle Physical M101 M126 M125 M124 M128
Pos. Position (counts) (U) (V) (W) (TUVW)
1 +3000 -1500 -30o 3:30 -9001 0 1 0 2
2 +1500 -3000 -90o 2:30 -9343 1 1 0 6
3 -1500 -1500 -150o 1:30 -9673 1 0 0 4
4 -3000 +1500 +150o 12:30 -10030 1 0 1 5
5 -1500 +3000 +90o 11:30 -10375 0 0 1 1
6 +1500 +1500 +30o 10:30 -10709 0 1 1 3
1 +3000 -1500 -30o 9:30 -11050 0 1 0 2
Note:
If the T flag input is 1, the values of Mx28 will be 8 greater than what is shown in
the table.
The description of Ixx81 in the Software Reference Manual shows the common values of offsets used, for
all the cases where the zero point in the hall-effect cycle is at a 0o, 60o, 120o, 180o, -120o, or -60o point –
where manufacturers generally align the sensors.
Note:
Ixx81 in Turbo is used for address only (i.e. same as Ixx25). Ixx91 in Turbo is
used for bits 16-21, 22 and 23.
Note that Ixx75 is not used for the phase position offset in this method. It can be used to store the final
correction based off fine phasing.
Overall Procedure Summary
The full phase reference then consists of the following steps:
1. Do a rough phase reference using the hall-effect sensors as specified by Ixx81, either automatically
on power-up/reset if Ixx80=1, or on the $ command if Ixx80=0.
2. Do a homing search move on the motor, using the index pulse as part of the home trigger.
3. Wait for the motor to settle “in-position” (following error less than Ixx27) at the home position using
the motor in-position status bit – suggested M-variable Mxx40 – [WHILE(M140=0)...]
4. Force the motor phase position register to the pre-determined value at this point with a command like
Mxx71=Ixx75.
PLC-Based Hall-Effect Reference
Alternately a power-on PLC program could be used to do the hall-effect phasing. This is useful if extra
error trapping is desired, or if sensors of a different format are used.
A program based on the results of our example table would be:
;****************** Set-up and Definitions ********************
CLOSE ; Make sure all buffers are closed
M148->X:$0000C0,8,1 ; Motor 2 phasing error fault bit
M171->X:$0000B4,0,24,S ; Motor 2 phase position register
;****************** Program to do phasing search **************
OPEN PLC 1 CLEAR
M148=1 ; Tentatively set phasing error bit
IF (M128&7=2) ; Hall Effect State 1 (0 to -60 deg)?
M171=I171/-12 ; Set phase angle to -30 deg
P170=1 ; Phasing OK flag
ENDIF
IF (M128&7=6) ; Hall Effect State 2 (-60 to -120 deg)?
M171=I171*-3/12 ; Set phase angle to -90 deg
P170=1 ; Phasing OK flag
ENDIF
IF (M128&7=4) ; Hall Effect State 3 (-120 to -180 deg)?
M171=I171*-5/12 ; Set phase angle to -150 deg
P170=1 ; Phasing OK flag
ENDIF
IF (M128&7=5) ; Hall Effect State 4 (180 to 120 deg)?
M171=I171*5/12 ; Set phase angle to 150 deg
P170=1 ; Phasing OK flag
ENDIF
IF (M128&7=1) ; Hall Effect State 5 (120 to 60 deg)?
M171=I171*3/12 ; Set phase angle to 90 deg
P170=1 ; Phasing OK flag
ENDIF
IF (M128&7=3) ; Hall Effect State 6 (60 to 0 deg)?
The two-guess phasing search is quick and requires little movement. It works well provided that external
loads such as gravity and friction are low. However, if there are significant external loads, it may not
prove to be a reliable phasing-search method (and unreliable phasing search methods can be dangerous);
if this is the case, another method such as the stepper-motor method described below should be used.
The two-guess method is selected by setting Ixx80 to 0 or 1. With Ixx80 at 0, the phasing search is not
executed automatically during the power-on/ reset cycle; a $ command must be used to execute the
phasing search. With Ixx80 at 1, the phasing search will automatically be executed during the power-on
reset cycle; also, it can be subsequently executed with a $ command.
Two parameters must be specified to tell Turbo PMAC how to do this phasing search. Ixx73 specifies the
magnitude of the torque command during each guess, with units of 16-bit DAC bits. Typical values are
2000 to 6000; 4000 (about 1/8 of full range) is a usual starting point. Ixx74 sets the duration of each
torque command and the evaluation of its response, with units of servo cycles. Typical values are 3 to 10;
5 (about 2 msec at the default servo update) is a usual starting point.
Stepper-Motor Phasing Search
The other automatic method of phasing search for a synchronous motor is the stepper-motor method.
This method forces current through particular phases of the motor, as a stepper-motor controller would,
and waits for it to settle. With proper operation, this will be at a known position in the commutation
cycle. This method is equivalent to two steps of the current-loop six-step test described above.
The stepper-motor phasing search requires more movement and more time than the two-guess method,
but it is more reliable in finding the phase accurately in the presence of large external loads.
The stepper-motor method is selected by setting Ixx80 to 2 or 3. With Ixx80 at 2, the phasing search is
not executed automatically during the power-on/reset cycle; a $ command must be used to execute the
phasing search. With Ixx80 at 3, the phasing search will be executed automatically during the power-on
reset cycle (this is not recommended); also, it can be subsequently executed with a $ command.
In this method, Ixx73 controls the magnitude of the current through the phases, with 32,767 representing
full range. Typically a value near 3000, about 1/10 of full range, will be used, although the actual value
will depend on the loads.
Ixx74 controls the settling time for each of the two steps used in the search. In this mode, the units of
Ixx74 are servo cycles*256, about 1/10 sec with the default servo cycle time. Typically a settling time of
1-2 seconds is used.
In the stepper-motor phasing search, Turbo PMAC first forces current to put the motor at the +/-60o point
in the phasing cycle and then waits for the settling time. Then it forces current to put the motor at the 0o
point in the phasing cycle and again waits for the settling time. It checks to see that there has been at least
1/16 cycle (22.5o) movement between the two steps. If there has been, it forces the phase position register
to 0, clears the phasing-search-error motor status bit, and closes the servo loop. If it has detected less
movement than this, it sets the phasing-search-error bit, and disables (kills) the servo loop.
If the stepper motor phasing search is done outside of the power-on/reset cycle, the phasing search
algorithm will fail on detection of an amplifier fault or overtravel limit condition. Turbo PMAC will set
the phasing-search-error bit and disable the servo loop. If done inside the power-on/reset cycle, Turbo
PMAC cannot detect these errors automatically, but the search will likely fail due to lack of movement.
Custom Phasing Search Methods
It may be necessary or desirable to write a custom phasing-search algorithm. Usually these are executed
as Turbo PMAC PLC programs, but often they can be tried and debugged using on-line commands. The
on-line commands are particularly useful if the phasing search is done only in development to establish a
reference for an absolute sensor.
Most custom algorithms are variations on the stepper-motor phasing search method. They use the phase-
current offset values Ixx29 and Ixx79 with an O0 command to force current into particular phases so the
motor will lock at a certain physical position in its phasing cycle. The following table shows the positions
in the phasing cycle created by different combinations of Ixx29 and Ixx79 for 3-phase motors. Usually
the magnitudes of the non-zero values are 2000 to 3000:
Ixx29 =0 <0 <0 =0 >0 >0
Ixx79 >0 >0 =0 <0 <0 =0
(A). Phase Pos. 0oe -60oe -120oe +180oe 120oe 60oe
(B). Phase Pos. +180oe 120oe 60oe 0oe -60oe -120oe
Case (A) shows the resulting positions for all direct PWM systems and for sine-wave output systems with
Ixx72<1024.
Case (B) shows the resulting phase positions for sine-wave output systems with Ixx72>1024.
For example, the following set of on-line commands typed into the terminal window of the Executive
program could be used to force a motor to the zero position in its phasing cycle, set the phase position
register as zero, and enable the motor.
#1O0 ; Enable the motor with open-loop zero magnitude
I129=0 ; No offset on Phase A
I179=3000 ; Positive offset on Phase B to force to 0 deg
M171=0 ; Write zero into phase position register
I179=0 ; No offset on Phase B
J/ ; Close servo loop
The time between typing the commands would provide sufficient delay for settling into position.
The following PLC program is a good starting point for variants on the stepper-motor phasing search
method. Extensions to this program could be to phase two gantry motors simultaneously or to step out of
a position limit. This example uses Ixx73 and Ixx74 as they would be used in the automatic stepper-
motor phasing search method.
;****************** Set-up and Definitions ********************
CLOSE ; Make sure all buffers are closed
M248->X:$000140,8,1 ; Motor 2 phasing error fault bit
M271->X:$000134,0,24,S ; Motor 2 phase position register
;****************** Program to do phasing search **************
OPEN PLC 1 CLEAR
CMD"#2O0" ; Force zero-magnitude open-loop
M248=1 ; Tentatively set phasing error bit
P229=I229 ; Save real Phase A bias
P279=I279 ; Save real Phase B bias
I229=-I273 ; Force negative bias into A
I279=I273 ; Force positive bias into A
I5111=I274*256 ; Starting value for countdown timer
WHILE (I5111>0) ; Wait for prescribed time
ENDWHILE
P271=M271 ; Store phase position at this point
I229=P229 ; Restore real bias to A for 0 deg
I5111=I274*256 ; Starting value for countdown timer
WHILE (I5111>0) ; Wait for prescribed time
ENDWHILE
P271=P271-M271 ; Get difference between two positions
IF (I282>0 OR I272<1024) ; Direct PWM or check analog phase
M271=0 ; Set phase position to zero
ELSE ; Analog system with Ixx72>1024
M271=I271/2 ; Set phase position to 180 deg
Tp =
[2 * I (I 19 − 7 ) + 3]* [I (I 19 − 6 ) + 1]
11796480
where I19 is the Turbo PMAC2 parameter containing the number of the clock direction I-variable for the
Servo IC or MACRO IC that is the source of the phase and servo clocks for the system. Usually I19 is set
to 6807 for a Turbo PMAC2 Ultralite to specify MACRO IC 0 (so I6800 and I6801 set the phase update);
usually it is set to 7007 for a board-level Turbo PMAC2 to specify Servo IC 0 (so I7000 and I7001 set the
phase update); usually it is set to 7207 for a UMAC Turbo to specify Servo IC 2 (so I7200 and I7201 set
the phase update).
Imag_std is the value of the magnetization current parameter Ixx77 that would produce the same rated
speed/torque point as the direct operation off the AC lines. For a first calculation, use a value of 3500
here. Usually, it is close enough. If the value of Ixx77 is set as explained in the next section for this type
of operation, come back and adjust this calculation.
Example:
A 4-pole induction motor has a rated speed of 1740 rpm at a 60 Hz electrical frequency. It is being
controlled from a UMAC Turbo with default clock source and frequency. The electrical frequency is:
cyc rad rad
ω e = 60 * 2π = 377.0
sec cyc sec
The mechanical pole frequency is:
rad rev 1 min rad poles 1 cyc rad
ωm = 1740 * * 2π * 4 * = 364.4
sec min 60 sec cyc rev 2 pole sec
In a UMAC Turbo, the default clock source is Servo IC 2 (I19=7207). The default value for I7200 is
6527, and the default value for I7201 is 0. The phase update time can be calculated as:
Tp =
(2 * 6527 + 3)* (0 + 1) = 0.000111 sec
117964800
Ixx78 can now be calculated as:
3500
Ixx78 = (377.0 − 364.4 )* 0.000111 * = 0.000149
32768
Calculating from Rotor Time Constant
Occasionally, the L/R electrical time constant of the induction motor’s squirrel-cage rotor can be obtained
from the manufacturer (this is distinct from, and much larger than, the L/R electrical time constant of the
stator windings). The Ixx78 slip constant can be calculated easily from this value by the equation:
Tp
Ixx78 =
Tr
where Tp is Turbo PMAC’s phase update time, and Tr is the rotor’s electrical time constant. Remember to
use the same units for both times.
Example
If running with a phase update frequency of 8 kHz and there is a rotor time constant of 0.75 seconds,
calculate:
Tp 0.000125
Ixx78 = = = 0.000167
Tr 0.75
Experimentally Optimizing Slip Constant
For a given magnetization current, the optimum slip constant will maximize the acceleration capabilities
of the motor. Changes from the optimum value of Ixx78 in either direction will degrade performance.
Simple tests employing data gathering while using a low-valued O-command (e.g. O10) to accelerate the
motor, permit easy optimization or verification of optimization of the Ixx78 value. If the best value of
Ixx77 magnetization current has not been selected, use a value of 3000 for these tests.
Setting Ixx77 Magnetization Current
Once there is a good value for the Ixx78 slip constant, find the best value of the Ixx77 magnetization-
current parameter. Ixx77 sets the commanded value for the direct current component in commutation, the
component in phase with the rotor’s measured/estimated magnetic field orientation. Ixx77 determines the
rotor’s magnetic field strength and so the torque constant Kt and back-EMF constant Ke for the motor. If
Ixx77 is not so high that it magnetically saturates the rotor, torque and back-EMF constants will be
proportional to Ixx77.
The higher the value of Ixx77 (before saturation), the more torque is produced per unit of quadrature current
commanded from the servo loop, but the higher the back-EMF generator voltage produced per unit of motor
velocity, so the lower the maximum velocity can be achieved from a given supply voltage. The lower the
value of Ixx77, the less torque is produced per unit of commanded quadrature current, but the lower the
back-EMF voltage produced per unit of velocity, so the higher the velocity that can be achieved.
In most applications, a single value of Ixx77 will be set and left constant for the application. However, it
is possible to change Ixx77 dynamically as a function of speed, lowering it at high speeds so as to keep
the back-EMF under the supply voltage, extending the motor’s speed range. Generally, this technique is
known as field weakening” and can be implemented in a PLC program.
If the Turbo Setup program is not used to set the value of the Ixx77 magnetization-current parameter, it is
best to do so experimentally. With a good value of Ixx78 set, simply issue a low-valued O-command
(e.g. O10) at each of several settings of Ixx77 and observe the end velocity the unloaded motor achieves.
This can be done by watching the real-time velocity read-out in the Executive program’s position
window. If using the data gathering feature, also note the rate of acceleration to that speed.
This velocity is known as the base speed for the motor for that setting. Typically, a value of 3200 to 3500
for Ixx77 will achieve the approximately a base speed equivalent to the rated speed of the motor when run
directly from a 50 Hz or 60 Hz line.
If the test values of Ixx77 are low enough that none of them magnetically saturate the rotor, the base
speeds in the test will be approximately inversely proportional to the value of Ixx77 (and the accelerations
to that speed will be approximately proportional to Ixx77). If you start increasing Ixx77 into the range
that causes magnetic saturation of the rotor, increases in Ixx77 will not cause further lowering of base
speed and further increase in rate of acceleration to that speed.
Many users will want a value of Ixx77 as high as possible without causing rotor saturation. These users
will want to find values of Ixx77 that do cause saturation, then reduce Ixx77 just enough to bring it out of
saturation. The Turbo Setup program finds this setting automatically.
Direct Microstepping of Motors (Open-Loop Commutation)
Turbo PMAC has the ability to do open-loop microstepping (direct microstepping) of standard stepper
motors, working off internally generated pseudo-feedback for both commutation and servo algorithms.
This technique is different from using Turbo PMAC with a pulse-and-direction output to command an
external microstepping drive; that technique does not utilize Turbo PMAC’s commutation algorithms at all.
When microstepping, Turbo PMAC provides two analog outputs that are used as current commands for
phases of the motor. Typically for a microstepping motor, the two phases are electrically independent and
90o out of phase with each other. In this case, the two outputs are simply bi-directional current
commands for the H-bridge amplifiers driving each phase. These amplifiers can be simple torque-mode
(current-mode) DC brush motor amplifiers.
Turbo PMAC’s microstepping algorithm provides 2048 microsteps per electrical cycle, which is 512
microsteps/step. On a typical 200-step/revolution motor, this amounts to 102,400 microsteps per
revolution. With the default phase update frequency of 9 kHz, Turbo PMAC can slew at over 4,600,000
microsteps/second (9000 full steps per second). With a small number of motors and/or fast versions of
the Turbo PMAC, higher phase-update frequencies can be used.
Sine-Wave Mode Command Output Addresses – MACRO ICs (Y-registers), Type 1 Protocol
IC# - Node# 0-0 0-1 0-4 0-5 0-8 0-9 0 - 12 0 - 13
Ixx02 $078420 $078424 $078428 $07842C $078430 $078434 $078438 $07843C
IC# - Node# 1-0 1-1 1-4 1-5 1-8 1-9 1 - 12 1 - 13
Ixx02 $079420 $079424 $079428 $07942C $079430 $079434 $079438 $07943C
IC# - Node# 2-0 2-1 2-4 2-5 2-8 2-9 2 - 12 2 - 13
Ixx02 $07A420 $07A424 $07A428 $07A42C $07A430 $07A434 $07A438 $07A43C
IC# - Node# 3-0 3-1 3-4 3-5 3-8 3-9 3 - 12 3 - 13
Ixx02 $07B420 $07B424 $07B428 $07B42C $07B430 $07B434 $07B438 $07B43C
What to Do Next
Once the appropriate steps in this section have been taken, the motor’s commutation and current loop
should be operating correctly. The motor should be turned in both directions with O-commands; positive
O-commands should cause the motor position to count in the positive direction, and negative O-
commands should cause the motor position to count in the negative direction.
Once this is done, the next step is to set up and tune the position/velocity loop servo, either the standard
PID loop, the Extended Servo Algorithm, or a user-written servo algorithm. This is done in the same
method as for Turbo PMAC motors without digital current loop and/or Turbo PMAC commutation. For
purposes of tuning, a system with PMAC commutation and/or current loop looks like a “torque mode”
drive to the position/velocity loop.
Remember to store the I-variable values that have been set here to the non-volatile flash memory with the
SAVE command.
The last line of the user-written phase must be RTS (ReTurn from Subroutine).
Available Registers
The following data registers may be used by the user-written phase:
• Internal DSP registers R0, N0, R1, N1, R5, and N5 may be used, and do not need to be restored when
done.
• Internal DSP registers M0, M1, M4, M5, R4, and N4 may be used, but must be restored to previous
values when done.
• Motor commutation registers X:$000xB2/32 through X:$000xBF/3F that are not I-variable registers
may be used to hold values from cycle to cycle. They are not used by any Turbo PMAC firmware as
long as the user-written phase is activated.
• Global registers X/Y:$0010F0 – $0010FF may be used. They are not used by any Turbo PMAC
firmware tasks, other than being set to 0 on power-up/reset.
• Registers in the user buffer established by the DEFINE UBUF command may be used. They are not
used by any Turbo PMAC firmware tasks.
• Other registers may be used as well, but it is possible for certain tasks of Turbo PMAC firmware to
overwrite these. For example, it is possible to use the registers for some P or Q-variables for the user-
written servo, but assigning a value to one of these variables will overwrite the register. It is also
possible to use the I-variables for Turbo PMAC’s standard servo algorithms as gains for the user-
written servo.
• The 2048-entry sine and cosine tables used by Turbo PMAC’s built-in phase routine are located at
addresses $003800 – $003FFF. The sine table is in Y-memory; the cosine table is in X-memory.
Turbo PMAC firmware automatically sets up these tables at power-up/reset; it does not write to these
registers afterwards.
Programming Restrictions
Any levels of the DSP’s stack may not be used, so no DO or JSR instructions are permitted.
Internal DSP address registers R2, R3, R6, and R7 may not be used; modifier registers M2, M3, M6, and
M7; offset registers N2, N3, N6 and N7.
Assembling the Algorithm
The assembly language algorithm must be assembled into DSP56300 machine code using Motorola’s
cross assembler for the computing platform. Follow the instructions from Motorola to do this.
Linking the Algorithm
Use the Delta Tau applet “CODET.EXE”, available on the Delta Tau website to convert the file that
results from the Motorola assembler into a format that can be directly downloaded to the Turbo PMAC.
This file should be archived on your computer or network.
Downloading the Algorithm
Use any version of the PMAC Executive program to download this resulting file into Turbo PMAC’s
program memory. Remember that it is downloaded into volatile RAM memory. To have the Turbo
PMAC retain this algorithm, issue a SAVE command before the controller is reset or power is removed
from it.
Executing the Algorithm
Set bit 1 of Motor xx variable Ixx59 to 1 (Ixx59 = 2 or 3) to select the user-written phase algorithm for
this motor. If bit 0 of Ixx01 is also set to 1, the user-written phase algorithm will execute for this motor
every phase cycle (every [I7+1] phase interrupts, every phase interrupt with the default I7 value of 0),
regardless of whether the motor is open-loop, closed-loop, enabled or disabled. Ixx00 for the motor does
not even have to be set to 1.
To Servo Address
Algorithms Encoder Conversion PMAC Hardware
Table Registers
Data
Conversion Instructions: Address Feedback
Process & Address Raw Data Signals
Feedback
Processed Data Data
Feedback Data
RAM Encoder Counters
& Timers, Latches, ADC's
2. Multi-Line Entry
Setup Structure
Each setup line is represented by an I-variable. The first setup line of the table is represented by I8000,
the second by I8001, and so on; the last setup line of the table is represented by I8191. Because
individual entries are 1, 2, or 3 lines long, each entry uses 1, 2, or 3 setup I-variables, consecutively
numbered.
These I-variables are 24-bit unsigned variables, usually represented as 6-digit hexadecimal values; they
are reported as hexadecimal values if I9 is set to the default of 2, or to 3. Detailed descriptions of the
values these I-variables can take are given in the Software Reference Manual description of I-variables
I8000 – I8191.
For example, the parallel extension (method digit $8) of an incremental encoder from a PMAC-style
(mode-switch bit 0) Servo IC 0 Channel 1 (source address $078000) in the first setup line of the
conversion table would be:
I8000=$878000
The same parallel extension (method digit $8, but from a PMAC2-style (mode-switch bit 1) Servo IC 0
Channel 1 (source address $078000) in the first setup line of the conversion table would be:
I8000=$8F8000
The structures of any subsequent lines for an entry are dependent on the method; each type is discussed
below.
The following table summarizes the operation specified by each method digit.
Method # of Process Defined Mode Switch 1st Additional Line 2nd Additional Line
Digit lines
$0 1 1/T Extension of None - -
Incremental Encoder
$1 1 Acc-28 style A/D 0 = signed data - -
converter (high 16 bits, 1 = unsigned data
no rollover)
$2 2 Parallel Y-word data, no 0 = normal shift Width/Offset Word -
filtering 1 = unshifted
$3 3 Parallel Y-word data, 0 = normal shift Width/Offset Word Max Change per Cycle
with filtering 1 = unshifted
$4 2 Time Base scaled digital None Time Base Scale Factor -
differentiation
$5 2 Integrated Acc-28 style 0 = signed data Input Bias -
A/D converter 1 = unsigned data
$6 2 Parallel Y/X-word data, 0 = normal shift Width/Offset Word -
no filtering 1 = unshifted
$7 3 Parallel Y/X-word data, 0 = normal shift Width/Offset Word Max Change per Cycle
with filtering 1 = unshifted
$8 1 Parallel Extension of 0 = PMAC IC - -
Incremental Encoder 1 = PMAC2 IC
$9 2 Triggered Time Base, 0 = PMAC IC Time Base Scale Factor -
frozen 1 = PMAC2 IC
Servo
Interrupts
T T T T
1 2 1 2
Velocity Estimation : V = K
n
T1
T2
Position Estimation : Pn = Counter +/-
T1
Note:
For PMAC2-style Servo ICs of Revision D or newer (introduced 2002), IC-
channel variable I7mn9 must be set to the default value of 0 so the two timers can
be read. (Backward compatibility is maintained.)
Examples:
I8000=$078000 ; Software 1/T extension of Servo IC 0 Channel 1
I8001=$078004 ; Software 1/T extension of Servo IC 0 Channel 2 (PMAC1)
Examples:
I8008=$C78200 ; No extension of Servo IC 2 Channel 1
I8009=$C78208 ; No extension of Servo IC 2 Channel 2 (PMAC2 IC)
High-resolution Interpolation (Method digit $F, extended method digit on second line $0)
This method calculates 10 bits of fractional count data (1024 states) per quadrature count – 4096 states
per line – by reading A/D converters on an Acc-51 board for the sine and cosine signals and computing
the arctangent. The whole count data comes from the digital quadrature counter. The mode-switch bit is
set to 0 if the data is read through a PMAC-style Servo IC (Acc-51P); it is set to 1 if the data is read
through a PMAC2-style Servo IC (Acc-51E, 51C).
A full list of source addresses is given in the Software Reference Manual. Common source addresses are:
Acc-51P as Servo IC 2, channels 1 – 4: $78200, $78204, $78208, $7820C
Acc-51E as Servo IC 4, channels 1 – 4: $79200, $79208, $79210, $79218
The second line contains the address of the first of the two ADCs read, with a $0 in the first hex digit.
For the Acc-51P, the ADC address is two higher than the channel base address used in the first line; for
the Acc-51E and 51C, it is five higher.
Common source addresses for the ADCs are:
Acc-51P as Servo IC 2, channels 1 – 4: $78202, $78206, $7820A, $7820E
Acc-51E as Servo IC 4, channels 1 – 4: $79205, $7920D, $79215, $7921D
The third line is a 24-bit bias term that is subtracted from both 24-bit words containing the ADC values
(even though the ADCs only occupy the top 14 bits) before the arctangent calculations are done.
The encoder counter used must be set up for times 4 decode by setting variable I7mn0 for the encoder
channel to 3 or 7. If this variable is changed, for example to change the direction sense of the counter, the
new value must be saved and the Turbo PMAC reset in order for this conversion to work properly (for the
direction sense of the fractional data to match the directional sense of the whole-count data).
Examples:
I8000=$F78200 ; Hi-res interpolation of Servo IC 2 Channel 1 (PMAC1 IC)
I8001=$078202 ; Read ADCs from Servo IC 2 Channel 1
I8002=$004000 ; Bias term of 4 LSBs of 12-bit ADCs
I8000=$FF8300 ; Hi-res interpolation of Servo IC 3 Channel 1 (PMAC2 IC)
I8001=$078305 ; Read ADCs from Servo IC 3 Channel 1
I8002=$000000 ; Zero bias term
Acc-28 Analog-to-Digital Converters
The conversion table can process the data from the 16-bit A/D converters of Acc-28 boards or their
equivalent. The source address is that of the A/D converter register in the IC that interfaces to the accessory.
Standard A/D conversion (Method digit $1)
This method takes the value in the A/D converter (without integrating it) and shifts it to leave the LSB in
bit 5 of the result – what Turbo PMAC software considers a count. If the A/D converter provides a
signed value (Acc-28A), the mode-switch bit should be set to 0; if the A/D converter provides an
unsigned value (Acc-28B, 28E), the mode-switch bit should be set to 1. This is a single-line entry.
Common source addresses are:
Acc-28A/B into PMAC channel 1 – 4: $78006, $78007, $7800E, $7800F
Acc-28B into PMAC2 channel 1A, 1B, 2A, 2B: $78005, $78006, $7800D, $7800E
Acc-28E as first I/O board, channel 1 – 4: $78C00, $78C01, $78C02, $78C03
Examples:
I8004=$178006 ; Conversion of Servo IC 0 ADC 1 (PMAC1 IC), signed
I8005=$1F8105 ; Conversion of Servo IC 1 ADC 1A (PMAC2 IC), unsigned
I8006=$1F8C00 ; Conversion of first Acc-28E Channel 1, unsigned
Integrated A/D conversion (Method digit $5)
This method takes the value in the A/D converter, shifts it so the LSB is in bit 5 and adds it to the
previous cycle’s result to yield a numeric integration. If the A/D converter provides a signed value (Acc-
28A), the mode-switch bit should be set to 0; if the A/D converter provides an unsigned value (Acc-28B,
28E), the mode-switch bit should be set to 1. This is a double-line entry. The second line holds a bias
term, expressed as a 24-bit number, that is subtracted from the source A/D data (whose LSB is in bit 8)
before the numerical integration.
Examples:
I8004=$578006 ; Integration of Servo IC 0 ADC 1 (PMAC1 IC), signed
I8005=$000300 ; Bias term (3 LSBs of 16-bit ADC)
Parallel Feedback
The conversion table can process parallel feedback data read from a register or set of registers. While this
is fundamentally a copying operation, it serves several important functions:
• It copies the data into an X-register, where the servo-loop I-variables can access it (most I/O
registers are in Y-memory).
• It can shift the data so the LSB of the source register ends in bit 5 of the result, which PMAC
firmware treats as a count.
• It can mask out unwanted bits from the source word, and properly handle rollover and software
extension.
• It can perform a filtering function, mitigating the effect of noise in significant data bits.
Parallel feedback data can be read from a continuous range of bits up to 24-bits wide from within a 48-bit
range, or from 2 or 3 byte-wide pieces in consecutive registers, as from many of the UMAC I/O boards.
Five method digits for the first setup line of the entry in the conversion table handle this case:
• $2: The 48 possible bits are from the Y-register at the specified address and the Y-register at the next
higher address. The conversion table performs no filtering.
• $3: The 48 possible bits are from the Y-register at the specified address and the Y-register at the next
higher address. The conversion table can perform filtering of the source data.
• $6: The 48 possible bits are from the Y-register at the specified address and the X-register at the
same address. The conversion table performs no filtering.
• $7: The 48 possible bits are from the Y-register at the specified address and the X-register at the
same address. The conversion table can perform filtering of the source data.
• $F: The data is in byte-wide pieces at the Y-register specified address and adjacent higher
address(es). In this case, the first hex digit of the entry’s second setup line must be either $2 (no
filtering) or $3 (with filtering).
In all of these cases, the bit-19 mode-switch bit in the first setup line of the entry is set to 0 to place the
LSB of the source data in bit 5 of the result, where Turbo PMAC firmware treats it as a count. If the
mode-switch bit is set to 1, the source LSB is placed in bit 0 of the result, where Turbo PMAC firmware
treats it as 1/32 of a count. This alternate setting can be used for very high-resolution feedback, where
numerical velocity saturation could be a problem.
Bits 0 – 18 of the first setup line of the entry specify the address of the source data. In the case of
methods $2 and $3, or $F/$2 and $F/$3, some of the source data could also come from the next higher
addresses.
The second setup line of the entry specifies which part of the source address data is used. This line is split
into four parts: the first hex digit, the second and third hex digits, the fourth hex digit, and finally the fifth
and sixth hex digits.
Second Setup Line for Parallel Data Entries
Hex Digits 1 2&3 4 5&6
Contents Aux Meth Bit Width Byte LSB Location
In the case of methods $2, $3, $6, and $7, the first digit is always 0. In the case of method $F, the first
digit is $2 if no filtering is to be done; it is $3 if filtering is to be done.
The second and third digits specify the bit width – how many bits are to be used.
In the case of methods $2, $3, $6, and $7, the fourth digit is always 0. In the case of method $F, the
fourth digit specifies which byte the data comes from: 0 for the low byte, 1 for the middle byte, and 2 for
the high byte.
The last two digits specify which bit of the source byte or word is to be used as the LSB. For byte-wide
data this is always in the range $00 to $07. For data from a 48-bit field, this value could be up to value of
48 minus the bit width.
If the source data is to be filtered, there is a third setup line in the entry, which specifies the maximum
change in the source data (in units of LSBs of the used source data) in a single servo cycle that is to be
regarded as real. If the source changes by more than this (maybe due to noise in a high bit), the result will
change by this amount only. This is an important protection against noise and other possible anomalies.
Examples:
These first three 3-line entries process 3 16-bit inputs on a 48-bit Acc-14D/V card
I8000=$378A00 ; Filtered parallel Y-data from first Acc-14D/V
I8001=$010000 ; Use 16 bits starting at bit 0
I8002=256 ; Max change of 256 LSBs per servo cycle
I8003=$378A00 ; Filtered parallel Y-data from first Acc-14D/V
I8004=$010010 ; LSB from bit 16, use 16 bits (high 8 bits from next address)
I8005=256 ; Max change of 256 LSBs per servo cycle
I8006=$378A01 ; Filtered parallel Y-data from first Acc-14D/V
I8007=$010008 ; LSB from bit 8, use 16 bits
I8008=256 ; Max change of 256 LSBs per servo cycle
These next several examples read MACRO registers unshifted
I8000=$2F8420 ; Unshifted unfiltered read of IC 0 Node 0 Reg 0 (address $078420)
I8001=$018000 ; Use 24 bits starting at bit 0
I8002=$2F8424 ; Unshifted unfiltered read of IC 0 Node 1 Reg 0 (address $078424)
I8003=$018000 ; Use 24 bits starting at bit 0
This next example reads data in byte-wide pieces from an Acc-14E
I8000=$F78C00 ; Read from $78C00
I8001=$314000 ; Filtered parallel Y-data 20 bits, low byte, start at bit 0
I8002=150 ; Max change of 150 LSBs per servo cycle
This example reads a timer register as parallel data for MLDT feedback
I8003=$378000 ; Filtered parallel read from Servo IC 0 Channel 1
I8004=$013000 ; Read 19 bits starting at bit 0
I8005=75 ; Max valid change of 75 LSBs per servo cycle
Exponential Filter
The conversion table can perform filtering functions on incoming data by executing the exponential-filter
entry. This entry implements a low-pass (single-pole IIR) filter on the source data. It is mainly useful for
master position data; its use for feedback data can be problematic because of the delays it introduces and
the resulting stability problems in the feedback loop.
This is a three-line entry. The first line uses a $D method digit, followed by the address. The source data
must be in the X-register of this address, and usually is the result of a previous entry in the conversion
table (addresses $3501 - $35C0).
The second line contains the maximum change in the source data that will be permitted in a single servo
cycle.
The third line contains the filter gain. Essentially, this is an inverse time constant; the gain term is set to
223/(Tf+1), where Tf is the filter time constant expressed in servo cycles.
Example:
I8004=$07820C ; 1/T interpolation of Servo IC 2 Encoder 4
I8005=$D03504 ; Exponential filter of I8004 result
I8006=4000 ; Max permitted change (LSBs/servo cycle)
I8007=524288 ; Filter gain for 15-servo-cycle time constant [223/(15+1)]
I1205=@I8007 ; Use filtered value as master position for Motor 12
Sum and Difference
A sum and difference entry in the conversion table can be used to do many useful tasks:
• Adding or subtracting two results in the table
• Changing the sign of a result in the table
• Integrating the value of a result in the table
• Integrating the sum or difference of two results in the table
This can be used, for example, to average the readings of two sensors on opposite sides of a rotary table to
take out the eccentricity, or to calculate the skew on a gantry by taking the difference of sensors on the
two sides.
This entry can use as source data only results in the conversion table. It is strongly encouraged to use
results from earlier in the table; using results from later in the table means results from the previous servo
cycle are used.
This is a one-line entry, split into four parts.
• The first part is the first hex digit, which is always “E” for this type of entry.
• The second part is the second hex digit (bits 16 – 19), which contains four mode-switch bits:
• Bit 19, if set to 1, integrates the final result, adding the sum or difference calculated each cycle to
the final result of the previous cycle.
• Bit 18, if set to 1, instructs Turbo PMAC to ignore the second source, permitting this entry to
simply negate and/or integrate a single value.
• Bit 17, if set to 1, negates the second entry before adding it into the result, creating an effective
subtraction.
• Bit 16, if set to 1, negates the first entry before adding it into the result.
• The third part uses the third and fourth hex digits as a number representing the offset from the
beginning of the table of the second source used. This can be calculated by subtracting 8000 from the
I-variable number that corresponds to this result.
• The fourth part uses the fifth and sixth hex digits as a number representing the offset from the
beginning of the table of the first source used. This can be calculated by subtracting 8000 from the I-
variable number that corresponds to this result.
Examples:
Using the following entries in the table as source data:
I8000=$078200 ; 1/T interpolation of Servo IC 2 Encoder 1
I8001=$078208 ; 1/T interpolation of Servo IC 2 Encoder 2
I8002=$078210 ; 1/T interpolation of Servo IC 2 Encoder 3
I8003=$078218 ; 1/T interpolation of Servo IC 2 Encoder 4
I8004=$F78C00 ; Byte-wide parallel read of Acc-14E data
I8005=$314000 ; Filtered, 20 bits, low byte, start at bit 0
I8006=256 ; Max change of 256 LSBs per servo cycle
The sum and difference entries can be used to do several processes:
I8012=$E00001 ; Sum of results from I8000 and I8001
I8013=$E10203 ; Subtract result of I8003 from result of I8002
I8014=$E40006 ; Negate result of I8006
I8015=$EC000D ; Integrate result of I8013
Time Base (Differentiation)
Time-base entries in the conversion table provide scaled digital differentiation of source data. Usually, the
source data is encoder count value, so the differentiation calculates a frequency value. This frequency value
can then be used as an external time base for a coordinate system in order to slave the motion of axes in the
coordinate system to the master encoder, creating an electronic cam. Refer to the Synchronizing Turbo
PMAC to External Events section for details in the use of this data for time base control.
Next, a PLC program will change the method digit to $B to arm the time base. Finally, the conversion
table will change the method digit to $A itself when it sees the capture trigger, as explained above.
Examples:
Untriggered time base
I8003=$079218 ; 1/T conversion of Servo IC 2 Channel 4 encoder
I8004=$403504 ; Untriggered time base from result of I8003
I8005=640 ; TBSF=131072/204.8 (RTIF=204.8 cts/msec)
I5193=@I8005 ; Use I8005’s result as time base for C.S. 1
Triggered time base
I8008=$AF9218 ; Triggered time base from PMAC2 Servo IC 2 Channel 4, running
I8009=256 ; TBSF=16384/64 (RTIF=64 cts/msec)
I5293=$350A ; Use I8009’s result address as time base for C.S. 2
Changing the servo update rate changes the percentage of processor time devoted to the servo tasks,
which can have important implications for lower-priority tasks, such as motion-program and PLC-
program calculations. Refer to the Computational Features section for details on how to evaluate these
changes.
If the servo update time is changed with the jumpers, change global parameter I10 to match the change so
that commanded trajectories are executed at the right speed. I10 does not have to be changed to match
changes in Ixx60 for individual motors.
Types of Amplifiers
Turbo PMAC can interface to a variety of amplifier types. The type of amplifier used for a particular
motor or hydraulic valve has important ramifications for the tuning of the servo loop. Each of the
common types is explained below.
Amplifiers for Which Servo Produces Velocity Command
Several types of amplifiers expect a velocity command out of the Turbo PMAC servo loop. The main
types of amplifiers in this class are:
• Analog-input velocity-mode servo amplifiers
• Pulse-and-direction-input amplifiers
• Hydraulic-valve amplifiers
If the command value from the Turbo PMAC servo loop, regardless of signal type, is a velocity
command, no velocity loop needs to be closed in the Turbo PMAC. With the standard PID loop, this
means that the derivative (D) term Ixx31 can be set to 0.
Analog-Input Velocity-Mode Amplifiers
Analog-input velocity-mode servo amplifiers close a velocity loop in the amplifier using the signal from
the Turbo PMAC as the commanded velocity and sensor feedback for the actual velocity. It is vital that
the amplifier’s velocity loop be tuned properly before attempting to tune the Turbo PMAC’s servo loop
around it.
The velocity loop of a velocity-mode drive must be well tuned with the load that it will drive before the
Turbo PMAC’s position loop is tuned. Because the velocity-loop tuning is load dependent, the amplifier
manufacturer cannot do the final tuning; the machine builder must tune the loop. The velocity step
response must not have any significant overshoot or ringing; if it does, it will not be possible to close a
good position loop around it with Turbo PMAC. The Turbo PMAC Executive Program’s tuning section
has a function called Open-Loop Tuning that can be used to give velocity command steps to the amplifier
and to observe the response plotted on the screen. This makes it easy to tune the amplifier, or to confirm
that it has been well tuned.
Pulse-and-Direction-Input Amplifiers
Pulse-and-direction-input amplifiers interpret each pulse as a commanded position increment. To
generate pulse-and-direction commands, the Turbo PMAC servo loop computes a pulse frequency value
that is sent to pulse-frequency modulation circuitry. This frequency value is effectively a velocity
command.
Amplifiers with this style of interface are of two types – Stepper Drive and Stepper Replacement
Amplifier.
Stepper Drive: There is no position feedback to this drive. Usually, there is no encoder at all for these
motors, so the Turbo PMAC must use the output pulse train as simulated feedback. This requires use of
an encoder channel on Turbo PMAC, even though no encoder is physically connected. If there is an
encoder on the stepper motor, it can be used in either of two ways:
1. It can be used as regular feedback to the Turbo PMAC, just as on a servo motor. In this method, the
key issue is the resolution and phasing of the encoder edges relative to the steps or microsteps
produced by the drive – some deadband may have to be created with Ixx64 and Ixx65 to prevent
hunting at rest.
2. The encoder can just be used for position confirmation at the end of moves. However, this technique
requires the use of two encoder channels on the Turbo PMAC: one for the simulated feedback of the
pulse train, and one for the confirmation encoder.
Stepper-Replacement Servo Amplifiers
These take position feedback from the servo motor and close all the loops inside the drive. Do not use the
encoder signal from the drive for feedback into Turbo PMAC’s servo loop, because the position loops in
the drive and the controller will conflict with each other. With these drives, use the commanded pulse
train from the Turbo PMAC as simulated feedback.
When using simulated feedback, it is possible to set up the Turbo PMAC servo gains solely with analytic
methods. See the Setting up Turbo PMAC2 for Pulse-and-Direction Control section for details. When
using real encoder feedback, tune the servo loop just as for an analog velocity-mode drive.
Hydraulic-Valve Amplifiers
Hydraulic-valve amplifiers, whether for servo valves or proportional valves, control a fluid-volume flow
proportional to their command input. Since fluid flow into or out of a hydraulic cylinder is proportional
to the velocity of the moving member of the cylinder, the command into the valve’s amplifier is
effectively a velocity command.
Amplifiers for Which Servo Produces Torque/Force Command
Several types of amplifiers require the Turbo PMAC servo loop to close the velocity loop as well, making
the output of this servo loop a torque or force command. If Turbo PMAC is not doing commutation for
this motor, the torque/force command is output to the amplifier; if Turbo PMAC is doing the
commutation, this command is an input to the commutation algorithm. The main types of amplifiers that
require the controller to close the velocity loop are:
• Analog-input torque-mode amplifiers
• Sinusoidal-input amplifiers
• Direct-PWM power-block amplifiers
If the command value from the Turbo PMAC servo loop, regardless of signal type, is a torque or force
command, the Turbo PMAC servo must close the velocity loop for the motor. With the standard PID loop,
this means that the derivative (D) term Ixx31 must be set to a non-zero value. This derivative action is
required to get the damping action needed for stability. Because motors produce a torque or force
proportional to motor current, the torque/force command out of the servo can also be considered a current
command.
There is no need to tune anything in the amplifier with the load attached to the motor, because no
velocity-loop closure is done in these types of amplifiers. Any tuning that may be required is dependent
only on motor properties, so potentially this can even be done by the amplifier manufacturer.
Analog-Input Torque-Mode Amplifiers
Analog-input “torque-mode” amplifiers accept an analog voltage that represents a torque/force, and hence
current, command. These amplifiers close a current loop inside, and if for brushless motors, perform the
motor phase commutation as well. Another name occasionally used for these types of amplifiers is the
transconductance amplifier, signifying that a voltage input results in a proportional current output.
Sinusoidal-Input Amplifiers
A sinusoidal-input amplifier accepts two phase-current commands that are sinusoidal functions of time in
the steady state. This type of amplifier expects the controller to calculate the commutation, using the
torque/force command from the position/velocity-loop servo as the current-magnitude command into the
commutation. The amplifier performs the current-loop closure in this style.
-1 -2
K (1-2z +z )
aff
+
Notch Filter
Reference
+ Big Step/ -1 -2
Position
Deadband
+ K
1+n1 z +n 2z
p -1 -2
Filter 1+d z +d z
- - 1 2
+
Notch Coefficients
n1 : Ix36
IM Ki n 2 : Ix37
K
d d 1 : Ix38
1-z -1
d 2 : Ix39
Secondary
Position
("Velocity")
K : Proportional Gain (Ix30) Feedback
p 1-z-1
K : Derivative Gain (Ix31)
d
K : Velocity Feedforward Gain (Ix32) (usually
vff the same)
K : Integral Gain (Ix33)
i
IM : Integration Mode (Ix34)
Primary
K : Acceleration Feedforward Gain (Ix35) Position
aff
Feedback
Ixx33*IE(n)/223]} -Ixx31*Ixx09*AV(n)/128]
where:
• CMDout(n) is the 16-bit output command (-32768 to +32767) in servo cycle n. It is converted to a -
10V to +10V output. DACout(n) is limited by Ixx69.
• Ixx08 is an internal position scaling term for Motor xx (usually set to 96)
• Ixx09 is an internal scaling term for the velocity loop for Motor xx (usually set to 96)
• FE(n) is the following error in counts in servo cycle n, which is the difference between the
commanded position and the actual position for the cycle [CP(n) - AP(n)]
• AV(n) is the actual velocity in servo cycle n, which is the difference between the last two actual
positions [AP(n) - AP(n-1)] in counts per servo cycle
• CV(n) is the commanded velocity in servo cycle n: the difference between the last two commanded
positions [CP(n) - CP(n-1)] in counts per servo cycle
• CA(n) is the commanded acceleration in servo cycle n, which is the difference between the last two
commanded velocities [CV(n) - CV(n-1)] in counts per servo cycle
• IE(n) is the integrated following error in servo cycle n, which is:
n−1
∑ [ FE( 1 )
j=0
(for all servo cycles for which the integration is active. Ixx34=1 turns off the input to, but not the
output from the integrator when CV does not equal zero.)
Notch Filter
Turbo PMAC’s standard servo loop includes a notch filter. This is a second-order bi-quad filter acting on
the output of the PID section of the servo loop, one of whose main purposes is to create a notch
(frequency of low response) in the servo reaction for the purposes of fighting a resonance.
This filter has several possible uses:
• Anti-resonance (notch) filter
• Low-pass filter
• Velocity-loop integrator
• Lead-lag filter
Each use will be treated in its own section below.
Filter Structure
For those familiar with control theory (not necessary to use the filter!), the form of Turbo PMAC’s notch
filter system is:
N ( z ) 1 + N 1 z −1 + N 2 z −2 1 + Ixx36 z −1 + Ixx37 z −2
= =
D( z ) 1 + D1 z −1 + D2 z −2 1 + Ixx38 z −1 + Ixx39 z −2
The I-variables Ixx36, Ixx37, Ixx38, and Ixx39 each have a range of -2.0 to +2.0; they are 24-bit values,
with one sign bit, one integer bit, and 22 fractional bits.
Use to Create a Notch
In feedback controls, a notch filter is an anti-resonance filter used to counteract a physical resonance.
While there are many different philosophies as to how to set up a notch filter, we recommend setting up a
lightly damped band-reject filter at about 90 percent of the resonant frequency, and a heavily damped
band-pass filter at a frequency somewhat greater than the resonant frequency (to reduce the high-
frequency gain of the filter itself). The band-reject filter is implemented in the numerator of the filter
[N(z)], creating zeros in control terms; the band-pass filter is implemented in the denominator of the filter
[D(z)], creating “poles” in control terms.
Automatic Notch Specification
The Turbo PMAC Executive program allows you to set up a notch filter very simply, without the need to
understand how a notch filter works. The easiest way is to enter the frequency of the mechanical
resonance that you wish to control. The Executive program will compute the desired characteristics of
the band-reject and band-pass filters, compute the coefficients, and download them to Turbo PMAC.
Alternatively, you can individually specify the desired characteristics of the band-reject and band-pass
filters. The two characteristics for each part of the filter are the natural frequency ωn and the damping
ratio ζ. The Executive program will compute the coefficients to achieve those characteristics, and
download them to Turbo PMAC.
Manual Notch Specification
To calculate the notch filter coefficients manually, consider the continuous transfer function for a notch
filter:
2
s 2 + 2ζ z ω nz + ω nz
G (s ) =
2
s 2 + 2ζ p ω np + ω np
Start with five parameters for the filter:
• ωnz: the natural frequency of the zeroes in radians/second (not in Hertz)
• ζz: the damping ratio of the zeroes
• ωnp: the natural frequency of the poles in radians/second (not in Hertz)
• ζp: the damping ratio of the poles
• Ts: the servo-loop sampling period in seconds (not in msec)
To compute radians/second from Hertz, multiply by 2π (6.283). To compute the sampling period in
seconds from the sampling rate in kHz, first multiply the rate by 1000 to get Hz, and then take the
reciprocal. Remember that the sampling period is equal to (Ixx60+1) times the servo-interrupt period.
First, compute the following intermediate values:
2 T2
α z = 1 + 2ζ z ω nz Ts + ω nz s
2 T2
α p = 1 + 2ζ p ω np Ts + ω np s
2
ω np αz 502.7 2 1.0748
Ixx30 new = Ixx30old = 500 ,000 = 979 ,169
2
ω nz α p 314.2 2 1.4049
Use to Create a Low-Pass Filter
It is also possible to use this filter component as a low-pass filter if reducing roughness of operation is
more important than high system bandwidth. Typically, the low-pass filter is used if a low-resolution
position sensor is used.
Automatic Specification
The Turbo PMAC Executive program allows the set up of a low-pass filter easily, without the need to
understand how it works. Enter the cutoff frequency of the filter (the frequency above which should not
pass much signal strength) and choose whether to create a first-order or second-order filter. The
Executive program will compute the desired characteristics of the band-reject and band-pass filters,
compute the coefficients, and download them to Turbo PMAC.
Manual Specification
To calculate a low-pass filter manually, specify the cutoff frequency in radians per second, and the servo-
update frequency in seconds.
First-Order Filter: To calculate a first-order low-pass filter, consider the continuous transfer function
for the filter:
1 ω
F (s ) = =
s/ω +1 s +ω
where ω is the cutoff frequency in radians per second (equal to 2πf, where f is the cutoff frequency in
Hertz). This value ω is equal to 1/τ, where τ is the time constant of the filter.
Next, convert this to a discrete-time transfer function using the approximation s=(1-z-1)/Ts, where Ts is the
servo update time in seconds.
ω ωTs ωTs 1
F (z ) = = = *
1 − z −1 1 − z −1 + ωTs 1 + ω Ts 1
+ω 1− z −1
Ts 1 + ωTs
In Turbo PMAC terms, the gain term is multiplied into the existing gain term Ixx30:
ωTs
Ixx30 new = Ixx30old *
1 + ωTs
The pole term uses the first-order notch filter pole parameter Ixx38. The other filter parameters Ixx36,
Ixx37 and Ixx39 are set to zero if the filter is used only as a low-pass filter.
1
Ixx38 = −
1 + ωTs
For example, to implement a first-order low-pass filter with a cutoff frequency of 50 Hz on a Turbo
PMAC with a servo update time of 442 µsec, we compute:
ωTs = 2* π * 50* 0.000442 = 0.139
0.139
Ixx30 new = Ixx30old * = 0.122 * Ixx30old
1 + 0.139
1
Ixx38 = − = −0.877
1 + 0.139
Ixx36 , Ixx 37 , Ixx39 = 0
Second-Order Filter: To calculate a second-order low-pass filter, we consider the continuous transfer
function for a generalized second-order filter:
ω n2
F (s ) =
s 2 + 2ζω n + ω n2
where ωn is the cutoff frequency of the filter in radians per second, and ς is the damping ratio – a value of
0.707 produces a Butterworth filter here.
First, compute the following intermediate value:
α = 1 + 2ζω n Ts + ω n2 Ts2
In Turbo PMAC terms, the gain term (Kpv+Kiv) is multiplied into the existing gain term Ixx30:
Ixx30new = Ixx30old * (K pv + K iv )
The zero and pole terms use the first-order notch filter parameters Ixx36 and Ixx38, respectively. The
second-order parameters Ixx37 and Ixx39 are set to zero if the filter is used only as an integrator.
K pv
Ixx36 = −
K pv + K iv
Ixx38 = −1
Use to Create a Lead-Lag Filter
This filter can be used simply as a lead-lag filter if the roots are real rather than imaginary. A lead-lag
filter is very similar in performance to a PID filter. It is useful when filter settings are determined
analytically rather than experimentally. When a basic lead-lag servo filter is desired, all servo gains
Ixx31 to Ixx35 should be set to zero; Ixx30 is still used as the generalized gain term.
The PMAC Executive program presently does not have any screens to assist in the automatic
specification of a lead-lag filter.
Manual Specification
The generalized analytical form of a digital lead-lag filter is:
L( z ) = K
(z + a ) (z + c )
(z + b ) (z + d )
where the (z+a)/(z+b) term is the lead filter, with a < b, the (z+c)/(z+d) term is the lag filter, with c > d, and
K is the DC gain term. In Turbo PMAC’s real-time implementation, the transfer function of the filter is:
1 + acz −1 + c 2 z −2
L( z ) = K
1 + bdz −1 + d 2 z −2
Turbo PMAC term Ixx30 is set to K; Ixx36 is set to ac; Ixx37 is set to c2; Ixx38 is set to bd; and Ixx39 is
set to d2.
Servo-Loop Modifiers
The PID filter has several modifying terms – non-linearities in control terminology – that can be
important to optimize the filter for performance and safety. Each is covered briefly below.
n=-16
23
KS (k 0 + ⋅ ⋅ ⋅ + k 3z -3 )
h 0 + h1 (1 - z -1)
1 + 4 (L1z −1 + ⋅ ⋅ ⋅ + L3z -3 )
r(z)
+ +
+ + TS (t 0 + ⋅ ⋅ ⋅ + t 3z -4 ) 1 + Ix69 + u(z)
32 ⋅ Ix08 s0 +
- - 1 + 8 (r1z −1 + ⋅ ⋅ ⋅ + r4 z - 4 ) +
1 + d1z −1d 2 z - 2 215
DAC
-1
s1 (1 - z )
+
f0 + GS (g 0 + g1 (1 - z -1 ))
- -
f1 (1 - z -1 )
The ESA for Motor xx is selected by setting the first supplemental motor I-variable Iyy00/50 (I3300 for
Motor 1, I3350 for Motor 2, etc. – see full table in the Software Reference Manual) to 1, and by setting bit
0 of Ixx59 to the default of 0 to disable the “user-written servo.” With this setting, the servo loop terms
are supplemental I-variables Iyy10/60 through Iyy39/89 (I3310 – I3339 for Motor 1, I3360 – I3389 for
Motor 2, etc.). The following table shows the variables used for each gain term:
I-Var. for I-Var. for Gain Range I-Var. for I-Var. for Gain Range
Odd- Even- Name Odd- Even- Name
Numbered Numbered Numbered Numbered
Motors Motors Motors Motors
Iyy10 Iyy60 s0 -1.0≤Var<+1.0 Iyy25 Iyy75 TS -223≤Var<223
Iyy11 Iyy61 s1 -1.0≤Var<+1.0 Iyy26 Iyy76 L1 -1.0≤Var<+1.0
Iyy12 Iyy62 f0 -1.0≤Var<+1.0 Iyy27 Iyy77 L2 -1.0≤Var<+1.0
Iyy13 Iyy63 f1 -1.0≤Var<+1.0 Iyy28 Iyy78 L3 -1.0≤Var<+1.0
Iyy14 Iyy64 h0 -1.0≤Var<+1.0 Iyy29 Iyy79 k0 -1.0≤Var<+1.0
Iyy15 Iyy65 h1 -1.0≤Var<+1.0 Iyy30 Iyy80 k1 -1.0≤Var<+1.0
Iyy16 Iyy66 r1 -1.0≤Var<+1.0 Iyy31 Iyy81 k2 -1.0≤Var<+1.0
Iyy17 Iyy67 r2 -1.0≤Var<+1.0 Iyy32 Iyy82 k3 -1.0≤Var<+1.0
Iyy18 Iyy68 r3 -1.0≤Var<+1.0 Iyy33 Iyy83 KS -223≤Var<223
Iyy19 Iyy69 r4 -1.0≤Var<+1.0 Iyy34 Iyy84 d1 -1.0≤Var<+1.0
Iyy20 Iyy70 t0 -1.0≤Var<+1.0 Iyy35 Iyy85 d2 -1.0≤Var<+1.0
Iyy21 Iyy71 t1 -1.0≤Var<+1.0 Iyy36 Iyy86 g0 -1.0≤Var<+1.0
Iyy22 Iyy72 t2 -1.0≤Var<+1.0 Iyy37 Iyy87 g1 -1.0≤Var<+1.0
Iyy23 Iyy73 t3 -1.0≤Var<+1.0 Iyy38 Iyy88 g2 -1.0≤Var<+1.0
Iyy24 Iyy74 t4 -1.0≤Var<+1.0 Iyy39 Iyy89 GS -223≤Var<223
The ESA consists of a series of blocks, most with multiple terms, each taking an input value, which could
be the output of another block, and computing an output value, which could be the input to another block.
Many of the blocks have polynomial transfer functions; an nth order polynomial implies the storage of n
cycles of history for the block.
Terms whose names consist of a letter and a number multiply a single control value that is i cycles old,
where i is the number in the name (e.g. t2 multiplies a value two cycles old). If the term is in the
numerator of the block, it multiplies an input value to that block; if it is in the denominator of the block, it
multiplies an output value from that block. These terms have a range of +/-1.0, with 24-bit resolution.
Terms whose names consist of two letters, with the second letter an S, multiply the results of an entire
block. These terms are treated as integers with a range of +/-8,388,608.
The PID terms Ixx30 – Ixx39, Ixx63 – Ixx65, and Ixx67 are not used. Ixx68 is used as the “friction
feedforward” term for the ESA, just as it is for the PID. Ixx69 is used for the ESA, but in a slightly
different manner from the PID. In the PID, Ixx69 is a truncation limit on the control effort output that
does not affect smaller command values; in the ESA it is an output scale factor that affects all output
command values.
Cascading Servo Loops
The open structure of Turbo PMAC’s servo loops and the ability to specify which registers are used for
its inputs and outputs provide the user with powerful capabilities such as the ability to “cascade” servo
loops. In this technique, the output of one servo loop (one Turbo PMAC “motor”) is used as an input to
another servo loop, bringing the capabilities of both loops to bear on a single actuator. The outer loop
does not drive an actuator directly; instead, it dynamically modifies the set point of the inner loop in an
effort to drive its own error to zero.
This technique has many possible uses. The most common is to be able to close an auxiliary loop around
a standard position loop. The auxiliary loop controls some quantity affected by the position loop’s
motion, such as torque or force applied, or distance from a surface. The coupling of the loops can be
turned on and off, permitting easy switching between control modes.
Common uses of this technique include:
• Web tensioning
• Torque-limited screwdriving
• Metal bending
• Controlled-force part insertion
• Height control over uneven surface (e.g. for auto-focus)
The inner loop in these applications is typically a standard position loop driving a real actuator with a
standard position feedback device such as an encoder or resolver. The first step in setting up such an
application is to get this loop working in standard positioning mode (running at continuous velocity if
appropriate).
The outer loop in these applications uses a feedback sensor measuring whatever quantity the outer loop is
to be controlled. Often these force or torque transducers such as strain gages or tensioning dancer arms,
or distance (gap) transducers employing capacitive or ultrasonic mechanisms.
By engaging and disengaging the outer loop, the user can switch between standard position control using
just the inner loop, as when not meeting the resistance of a surface, and control of the auxiliary function,
as when pushing with controlled force against a surface. The transition is simple to perform, and smooth
in operation.
A second use of this technique is to build a more complex filter than you can with the standard filter for a
single motor (e.g. incorporating a double notch filter). By using the output of the first filter as the input to
the second, you can chain them together and get the action of both filters between the command and the
output. While the general principle is the same, the details of the setup and the process for getting this
going will differ. The sections immediately following cover the process for setting up hybrid control. A
special section further down describes the differences in setting up using two loops to control a single
quantity.
Commanded
Auxiliary Ixx02 Ixx05
Σ∆t
Trajectory
or or
+
Ixx02 Ixx05
Servo
Filter Open
Register Ixx06
-
+
Servo Ixx02 Output
Actual +
Amp
Auxiliary Filter Device
Commanded
Value Position -
Trajectory
Auxiliary Motor M
Position Loop
Loop
ECT
Ixx03, Source
Actual
Ixx04 Address
Position ECT Position
E Sensor
Entry
ECT
Ixx03, Source
Ixx04 Address
ECT Auxiliary
S
Entry Sensor
Ixx06 for the inner loop’s motor also controls how the outer loop’s corrections interact with commanded
positions for the inner loop. When Ixx06 bit 1 (the following mode control bit) is set to 0, the inner
loop’s commanded positions are relative to a fixed origin, and these commanded moves effectively cancel
out whatever corrections have come in through the master position port. When Ixx06 bit 1 is set to 1
(offset mode), the corrections that come in through the master position port effectively offset the origin
for programmed commanded moves, permitting commanded moves and master corrections to be
superimposed. This distinction in mode is true even if following is disabled.
When the outer loop is engaged (Ixx06 bit 0 = 1), usually the following must be in offset mode (Ixx06 bit
1 =1), making the required value of Ixx06 be 3 for this operation. Even if there are no explicit commands
in the motion program for the axis assigned to the inner loop’s motor at this time, any motion command
for the coordinate system containing this motor implicitly commands that motor to its previous
commanded position. If the following is not in offset mode, this will take out the corrections that have
come in since the last programmed move or move segment.
When the following is disabled (Ixx06 bit 0 = 0), to command the inner loop’s motor to a definite
physical position, put the following in normal mode (Ixx06 bit 1 = 0), making the required value of Ixx06
be 0 for this operation.
Inner-Loop Master Scale Factor: Ixx07
The Ixx07 variable for the inner loop’s motor, the master scale factor, is a gain term for the outer loop in
this use. Set to 1 to keep the net outer-loop gain (inner-loop Ixx07 times outer-loop Ixx30) as low as
possible. It can be set to a negative value if necessary to invert the sense of the coupling between the two
loops.
Tuning the Outer Loop
In the cases of hybrid control, typically you will need only proportional gain (Ixx30) in the outer loop or
possibly integral gain as well (Ixx33). Most applications will require no derivative gain (Ixx31), and
because in most applications the outer loop is just trying to maintain a constant command value, usually
feedforward terms (Ixx32 and Ixx35) are not important.
If you are integrating the outer loop’s command value before using it in the inner loop, your Ixx30
proportional gain term probably will be extremely low (often around 10).
It is possible to use the Executive’s tuning tools to tune the outer loop gains as you would a standard loop.
Programming the Outer Loop Motor
With the outer loop engaged, commanding the position of the outer-loop motor will cause the outer loop’s
feedback loop to calculate offsets into the inner loop command in an attempt to drive the outer-loop’s
feedback device to the commanded value. This outer-loop command can be a motor jog command, or it
can be a programmed axis command. If a programmed axis command, the axis to which the outer-loop
motor is assigned can be in the same coordinate system as the inner-loop motor, or in a different
coordinate system.
Most commonly, the outer-loop motor will be assigned to an axis in the same coordinate system as the
inner-loop motor, and commanded in the same coordinate system. Axis-naming conventions and
standards (e.g. RS/EIA-267) consider these as secondary axes and suggest the name of U when matched
with an X axis, V when matched with Y, and W when matched with Z.
Setup Example
In this example, Motors 1, 2, and 3 are the X, Y, and Z-axes, respectively, in Coordinate System 1 of a
Cartesian stage. Each uses quadrature feedback with 0.1-micron resolution, and is programmed in
millimeters. Motor 4 is used to control the gap height of the vertical tool over the surface. It uses a capacitive
gap sensor through an Acc-28 16-bit A/D converter, with the LSB of the ADC measuring 0.25 microns. It is
assigned to the W-axis in the same coordinate system, also programmed in millimeters (of gap).
I8003=$1F8E00 ; ECT 4th entry: unsigned A/D from Y:$78E00
Gap virtual motor basic setup
I400=1 ; Activate Motor 4
I401=2 ; Output to an X register
I402=$10F0 ; Output to open register X:$10F0
I403=@I8003 ; Use result from ECT 4th entry for position
I404=@I8003 ; Use result from ECT 4th entry for velocity
Vertical positioning motor link to virtual motor
I305=$10F0 ; Use #4 output as master input
I307=1 ; Set lowest possible master scale factor
Coordinate system setup
&1
#1->10000X ; X-axis positioning in millimeters
#2->10000Y ; Y-axis positioning in millimeters
#3->10000Z ; Z-axis positioning in millimeters
#4->4000W ; Vertical gap in millimeters
Changing the Mode of Control
Whenever the following mode control bit is changed, re-align the relationship between the corresponding
motor and axis positions for the inner loop. While this is done automatically any time a program is
started with an R or S command, if this bit is changed in the middle of a motion program, command this
re-alignment explicitly by issuing a PMATCH command. This is an on-line command; from a motion
program, it must be issued with the CMD"PMATCH" syntax.
This command generally must be bracketed before and after with DWELL commands; the first to stop any
lookahead and blending (this can be a DWELL 0), and the second to give the on-line command time to
execute in background from the command queue before the next programmed move is calculated.
Mode Changing Example
The following code segment shows how the transition to engaging the outer loop can be accomplished.
This example continues the one above, in which the Z-axis has been assigned to the inner loop’s motor, so
it is a position axis, and the W-axis has been assigned to the outer loop’s virtual motor.
Z10 ; Pure position move on inner loop
DWELL0 ; Stop lookahead
I306=3 ; Engage following, put in offset mode
CMD"&1PMATCH" ; Re-align motor and axis position
DWELL10 ; Give PMATCH command time to execute
W5 ; Outer loop command
The following code segment shows how the transition to disengaging the outer loop can be accomplished.
W5 ; Outer loop command
DWELL0 ; Stop lookahead
I306=0 ; Disengage following, put in normal mode
CMD"&1PMATCH" ; Re-align motor and axis position
DWELL10 ; Give PMATCH command time to execute
Z0 ; Pure position move on inner loop
Commanded
Trajectory
+
Servo Ixx02 Ixx05
Filter
Ixx06
-
+
Actual Servo Ixx02 Output
+
Position Amp
(Always Zero) Filter Device
-
Ixx03,
Ixx04
(Always Zero)
ECT
Ixx03, Source
Ixx04 Address
ECT
E
Entry
Computational Features
The Open Servo provides powerful computational features to permit easy writing of sophisticated and
flexible algorithms.
Access to Turbo PMAC Variables
Open Servo algorithms can utilize all of Turbo PMAC’s I, P, Q, and M-variables, reading and writing to
them as appropriate. As in other user programs, it uses floating-point arithmetic to process these variable
values, even those that are stored as fixed-point values (see Floating-Point vs. Fixed-Point Mathematics,
below). Q-variables are accessed from Open Servo algorithms according to the Coordinate System 1
addressing scheme, no matter which coordinate system the motor executing the Open Servo algorithm is
assigned to.
Compiler-Assigned Pointer Variables
For direct and efficient access to Turbo PMAC registers, Open Servo algorithms support two types of
pointer variables for which the register assignment is made at compilation time, not at program execution
time.
L-variables are pointers to short (24-bit) registers, treated as integer (fixed-point) values. These work in
the same way as L-variables do in compiled PLC programs. They can access either X or Y short
registers, either as entire 24-bit registers (treated as signed integers only), or as portions of the registers 1,
4, 8, 12, 16, or 20 bits wide (treated as signed or unsigned integers, except for 1-bit variables, which are
unsigned only).
F-variables are pointers to long (48-bit) registers. If the F-variable definition is an L format (e.g. F1-
>L:$10F0), the register is accessed as a 48-bit floating-point register. If the F-variable definition is a D
format variable (e.g. F2->D:$88), the register is accessed as a 48-bit signed integer, but conversion to
or from Turbo PMAC’s 48-bit floating-point format is performed automatically, so it can be used in
floating-point mathematics.
Note:
Do not confuse L-variables, which are short-word compiler pointers, with L-format
F-variables and M-variables, which are long-word variables.
Turbo PMAC itself cannot recognize L-variables or F-variables; these variables have meaning only to the
compiler on the host computer.
By contrast, when using Turbo PMAC’s M-variable pointers, the register assignment is made when the
line is executed, each time it is executed. This assignment requires about 600 nanoseconds additional
computation time (on a 100 MHz CPU) each time the variable is accessed. However, this does permit the
M-variable definition to be changed during execution, enabling techniques such as indirect addressing.
It is possible to use L-variables for fast integer arithmetic while retaining the run-time flexibility of M-
variable definitions, but this adds the run-time definition-access computational penalty described above.
Instead of directly defining L-variables to registers for the compiler, you can reference a range of L-
variables to Turbo PMAC M-variable definitions with the LMOVERLAY {start},{end} compiler
directive. This directive must precede the actual Open Servo program. For example, LMOVERLAY
10,20 instructs the compiler that the definitions of L10 through L20 are to be assigned at run time using
the definitions of M10 through M20 respectively at the time each statement is executed, not at
compilation time.
Using the M-variable definition and accessing this definition at run time permits indirect addressing
techniques through real-time modification of this M-variable definition using another pointer variable.
Register Arrays: Register arrays work with the compiler’s short L-variables and long F-variables.
These arrays must be declared to the compiler before the start of the actual Open Servo algorithm. In use,
the number of the array index is placed inside square brackets, and specifies the address offset from the
declared beginning of the array. The expression that determines this number is a fixed-point expression,
so it can only use the compiler’s L-variables and constants that fit within the range of a 24-bit signed
integer.
L and F-variable register arrays must be declared to the compiler before the start of the actual Open Servo
algorithm. Examples of these definitions are:
L100->X:$010000[32]
F200->D:$030040[64]
F300->L:$030080[128]
The declared array size must be a power of 2 in the range 2 to 8192. L-variable register arrays always use
full 24-bit X or Y registers, treating the values as signed integers.
Operators
As with any Turbo PMAC user program, Open Servo can utilize the following mathematical and logical
operators:
• + (addition)
• - (subtraction
• x (multiplication)
• / (division)
• % (modulo, remainder)
• & (bit-by-bit AND)
• | (bit-by-bit OR)
• ^ (bit-by-bit XOR)
All of these operators can be used in either floating-point or integer statements. Integer division rounds
the result to the nearest integer; in the case where the fraction is exactly 0.5, it will round to the next more
positive integer (e.g. -7.5 to -7, and 7.5 to 8).
Comparators
As with any Turbo PMAC user program, Open Servo can utilize the following comparators in conditional
statements:
• = (equal to)
• > (greater than)
• < (less than)
• ~ (approximately equal to [within 0.5])
• != (not equal to)
• !> (not greater than, less than or equal to)
• !< (not less than, greater than or equal to)
• !~ (not approximately equal to [not within 0.5])
The ~ and !~ comparators can only be used in floating-point statements. Note that the <>, >=, and <=
comparators, which can be used in some programming languages, cannot be used in the Open Servo or
other Turbo PMAC programs.
Functions
As with any Turbo PMAC user program, Open Servo can utilize the following mathematical functions.
Note that these functions can only be used in floating-point statements within the Open Servo:
• SIN (trigonometric sine)
• COS (trigonometric cosine)
• TAN (trigonometric tangent)
COPYREG Command: The COPYREG command copies five key registers for the executing motor into
five consecutive P-variables, where they can easily be used for calculations. The user does not have to
know the addresses of these registers. In doing this copying, Turbo PMAC automatically converts the
data to 48-bit floating-point format.
The syntax of this command is COPYREG {P-variable name}, where {P-variable name}
specifies the number of the first variable into which data will be copied. The five registers to be copied
by this command are:
• Actual Velocity (1/[Ixx09*32] counts / [Ixx60+1] servo cycles)
• Desired Velocity (1/[Ixx08*32] counts / [Ixx60+1] servo cycles)
• Following Error (1/[Ixx08*32] counts)
• Actual Position (1/[Ixx08*32] counts)
• Desired Position (1/[Ixx08*32] counts)
The actual position value is derived from the register selected by Ixx03 for the motor (Position-Loop
Feedback Address), with the source value multiplied by the Ixx08 scale factor and extended into a 48-bit
long word. The actual velocity value is derived from the position value selected by Ixx04 for the motor
(Velocity-Loop Feedback Address), taking this cycle’s actual velocity-loop position value minus the
value at the previous loop closure and multiplying the difference by the Ixx09 scale factor. Note that this
scale factor is not necessarily the same as for the desired velocity.
For the desired position value, Turbo PMAC adds the trajectory commanded position and the master
position (from the position following, or electronic gearing function), then subtracts the compensation
position (from the position, or leadscrew compensation tables), creating a net desired position value. The
desired velocity value is simply this cycle’s desired position value minus the value at the previous loop
closure.
The following error value is the desired position the actual position. The subtraction is done using 48-bit
fixed-point values; then the difference is converted to floating-point format. There are several advantages
to using the following error value directly. First, it saves some computational time. Second, when the
commanded and actual positions get very large, it preserves fractional position data better.
If the command COPYREG P5 were used, the Actual-Velocity value would be copied into P5, Desired
Velocity into P6, Following Error into P7, Actual Position into P8, and Desired Position into P9. Note
the differing units between the actual and desired velocity registers. (The desired velocity value is not
typically used in actual servo loop closure. Turbo PMAC uses this register in the numerical integration
process to compute the desired position value each servo cycle.)
Offsets from Registers of Executing Motor: The compiler’s L-variables and F-variables can be
declared by address offset to specific registers of the executing motor. In this way, they automatically
index properly from motor to motor, permitting the same variables and code to be used for multiple
motors. These variables can be declared by offset to the motor’s R0 register, which is the motor’s
command output register ($BF for Motor 1), or by offset to the motor’s R1 register, which is the motor’s
status register ($B0 for Motor 1). L-variables can be declared to 24-bit X or Y registers this way; F-
variables can be declared to 48-bit fixed-point or floating-point registers this way. Some examples:
L220->X:(R1-$27) ; Ixx08 scale factor register
L270->Y:(R1+0) ; Motor status register
F392->D:(R1-$24) ; Motor master position register
F34->L:(R0+11) ; Ixx16 maximum commanded speed
The offset must be in the range –64 <= {offset} <= 63 (-$40 <= {offset} <= $3F).
Returned Value: The RETURN command takes the integer value inside the following parentheses and
places it in a 24-bit signed integer register where Turbo PMAC’s standard firmware will take it and use it as
the servo command. Typically, the commanded value will be computed as a floating-point value, so must
be converted to an integer with the ITOF function. Typical uses of the RETURN command could be:
RETURN(FTOI(P345))
L10=FTOI(P92/65536)
RETURN(L10)
The RETURN command will typically be the last line of an Open Servo algorithm. Putting it earlier in the
algorithm will not cause the command data to be used any sooner by the Turbo PMAC. If the Open
Servo program is used for a task other than servo-loop closure, there is no need to use the RETURN
command. In this case, when the Open Servo algorithm reaches the CLOSE statement that is required at
the end of the program, it will write a 0 to this holding register automatically.
Turbo PMAC will take the resulting value and add the contents of the torque compensation register
(usually from the motor’s TCOMP torque compensation table) to it. If Turbo PMAC is not performing
commutation for this motor (Ixx01 bit 0 = 0), it will take this sum and copy it to the register specified by
Ixx02. If you do not use the RETURN command in this case, Turbo PMAC will still copy the zero value
that it has placed in the holding register that would have been used by the RETURN command into the
register specified by Ixx02.
If Turbo PMAC is performing commutation for this motor (Ixx01 bit 0 = 1), it will use the resulting sum
as the “quadrature current” (torque) command input to the commutation algorithm. In this case, Ixx02
specifies the multiple output registers from the commutation algorithm.
The Ixx29 and Ixx79 offset terms are added automatically by Turbo PMAC, just as if the built-in servo
algorithms were used.
The returned value must be an integer value in the range –8,388,608 to +8,388,607. Most of the
command output ranges associated with Turbo PMAC’s automatic servo loops are expressed as 16-bit
values, with a range of –32,768 to +32,767. The values associated with RETURN are therefore 256 times
larger. The actual command output device will not necessarily have this full 24-bit resolution (and
probably will not). In general, however, an n-bit output device uses the high “n” bits of the 24-bit
returned value.
Variable Value Assignments
Mathematical operations in an Open Servo algorithm are performed with variable value assignment
statements, just as in other PMAC programs. The syntactical rules for these statements are the same as in
other PMAC interpreted and compiled programs. Any I, P, Q, M, L, or F-variable can be assigned a
value, whether referenced directly or as part of any array.
Logical Control
Logical branching and looping control in Open Servo algorithms is performed with IF / [ELSE] / ENDIF
branching constructs, and WHILE / ENDWHILE looping constructs, just as in other PMAC programs. The
syntactical rules for these statements are the same as in PMAC PLC programs; they do not support a few
features possible in motion programs (such as an action on the same line as a condition), and they do
support a few features not possible in motion programs (such as multiple-line conditions). Refer to the
Program Command section of the Software Reference manual for details (see IF, ELSE, ENDIF,
WHILE, ENDWHILE, AND, OR).
If WHILE / ENDWHILE loops are used in an Open Servo, it is the user’s responsibility to make sure that
the algorithm never gets stuck in a loop so long that other tasks are compromised. Turbo PMAC will not
release automatically from a loop in an Open Servo for any other task of equal or lower priority. Failure
to release from a loop in a timely fashion can result in servo error (failure to complete one cycle’s servo-
interrupt tasks by the next servo interrupt), run-time error (failure to compute commanded move
equations in time for that move to start, causing the motion program to abort), or watchdog timer error
(failure to cycle through all required tasks in a timely fashion, causing the Turbo PMAC to shut down
completely).
Processor Utilization
Servo algorithms are one of the most important tasks executed by the Turbo PMAC’s processor, but far
from the only one. While Turbo PMAC’s DSP processor is very efficient, it is still possible to overload
the processor, particularly with floating-point algorithms executing in compiled code from the Open
Servo. These do not run nearly as efficiently as the standard servo algorithms, which have been written in
assembly language and use fixed-point mathematics.
Generally, it is recommended that the portion of processor time devoted to phase and servo tasks not
exceed 50%, in order to allow sufficient time for lower-priority tasks, such as motion program and PLC
program calculations. To find out how much processor time an Open Servo algorithm occupies, refer to
the Evaluating the Turbo PMAC’s Computational Load section. This can be found in the Turbo PMAC
Computational Features section of this manual.
Memory Utilization
The DSP563xx CPU for the Turbo PMAC employs Harvard architecture, with separate areas of program,
or instruction, memory, and data memory. The actual instructions of the Open Servo are loaded into P
program memory; all of the data registers it uses are in X and Y data memory.
If an Option 5Cx 80 MHz CPU configuration is ordered, employing the DSP56303, only 3K words of
program memory are available for the Open Servo (P:$040000 through P:$040BFF). This may not be
enough for large algorithms, so it is recommended for the user to order a 100 MHz Option 5Dx or 160
MHz 5Ex CPU configuration, utilizing the DSP56309 and DSP56311 CPUs, respectively, for any
complex algorithms. With these processors, 19K words of program memory are available for Open Servo
code (P:$040000 through P:$044BFF). For reference, the Open Servo example below that mimics the
basic PID algorithm occupies 330 words of program memory.
The downloader will indicate how many words of program memory the program has just compiled
occupies. This can be found also by reading memory location P:$040014 (use an RHP:$040014 on-line
command), which contains the location of the end of the Open Servo algorithm in the Turbo PMAC
program memory; subtract the starting location $040000 (remember that these are hexadecimal values) to
get the program length.
For general data memory, most users will utilize some of Turbo PMAC’s 8192 P-variables to store
values. It is the user’s responsibility to keep track of which P-variables are used for Open Servo
algorithms and which are employed for other user tasks. Q-variables may also be used for Open Servo
algorithms; they are always accessed according to Coordinate System 1’s numbering. It is the user’s
responsibility to make sure that these P or Q-variables are not used for other tasks as well.
Many users will find it advantageous to utilize motor-specific registers that are not otherwise being used
because the Open Servo is executing for that motor. Registers listed as being gains or intermediate values
for either the PID or the ESA servo algorithms may safely be used by the Open Servo. The registers in
the range $000092 – $0000AC (for Motor 1; equivalent registers for other motors) with the exception of
$0000A5 (previous net desired position) may be used for this. Note that the integrated position error
register at $00009E and the previous net desired velocity register at $00009A are automatically zeroed
when the loop is opened. It is not necessary to use these registers in the same format as the automatic
servo algorithms would.
Note that any of these registers representing an I-variable for either the PID or ESA algorithms would be
overwritten by any command writing to that I-variable; that the values in such a register are copied into
flash memory on a SAVE command; that the last saved value from such a register is copied from flash
memory on a board reset. Some users may want to utilize these I-variable registers as gains for their own
servo algorithms – it is not necessary to use them for the same purpose, or with the same scaling, as the
built-in algorithms would.
For large amounts of extra data memory, it is recommended to use the User Buffer set up with the on-line
DEFINE UBUFFER command. The User Buffer occupies a number of registers at the high end of X/Y
data memory. With an Option 5x0 standard memory configuration, the end of data memory is at
X/Y:$0107FF; if DEFINE UBUFFER 2048 is declared, all data memory from $010000 through
$0107FF is reserved for the user’s own purposes. With an Option 5x3 extended memory configuration,
the end of data memory is at X/Y:$03FFFF; there is by default a User Buffer of 65,536 words, reserving
all memory registers from X/Y:$030000 to X/Y:$03FFFF for user use. It is the user’s responsibility to
make sure that registers in the UBUFFER utilized for Open Servo data storage are not used for other
purposes as well.
Writing the Open Servo Program
The Open Servo program should be written in a plain-text editor such as the editor in the new
PEWIN32PRO PMAC Executive program. While the program can be written in any plain-text editor, it
must be compiled by the PEWIN32PRO editor’s download function. In this program, released in October
2001, the download routine will recognize Open Servo routines automatically, compile them, and
download the resulting machine code. (Older versions of the PMAC Executive program are not capable
of doing this.)
In the file containing the Open Servo preceding the actual program must be all L-variable and F-variable
pointer definitions, and all #define macro substitutions, or #include references to accessible files
that contain these definitions and substitutions. Remember that the built-in compiler does not download
these definitions and substitutions to the Turbo PMAC; it uses them to do the compilation properly.
The OPEN SERVO command is a signal to the compiler that the statements following up to the (required)
CLOSE command are to be compiled into DSP machine code before downloading. The CLEAR
command that is used following the OPEN command on interpreted buffers is not required for Open Servo
algorithms, because downloading the newly compiled code automatically clears older code, but it may
still be used here.
Example 1: Proportional Control
The following algorithm shows one of the simplest possible Open Servo algorithms, implementing a
simple proportional control law using the motor’s Ixx30 parameter as the proportional gain.
OPEN SERVO ; Following lines to be compiled
CLEAR ; Not necessary, but acceptable
COPYREG P30 ; Copy following error into P32
P35=P32*I(ITOF(MTRNUM*100+30))/65536 ; Multiply by gain, scale
RETURN(FTOI(P35)) ; Make an integer and output
CLOSE
Example 2: Bi-Quad Filter
The next example shows an implementation of a bi-quad filter capable of running on multiple motors,
storing values from cycle to cycle for each motor. It uses #define substitution macros to keep the code
readable, and the MTRNUM function for variable and register arrays to separate stored values for each
motor. Variable arrays (which are easier for the user to access) are used for user-set “gains”, and register
arrays (which are quicker for the algorithm to access) are used for algorithm-calculated stored values.
This Open Servo program implements the following transfer function:
( z + a )( z + c )
U( z ) = K p E( z )
( z + b )( z + d )
It implements this as the following difference equation:
u k = K p [ek + (a + c )ek −1 + acek −2 ] − (b + d )u k −1 − bdu k −2
In order to start the algorithm correctly, it reads the servo cycle counter and compares it to the counter the
last time the last time this algorithm was executed. If the algorithm was not executed the previous cycle,
it zeros out the “history” values for the algorithm. It also does a saturation check on the commanded
output. This algorithm assumes a standard memory option (5x0) whose data memory ends at
X/Y:$0107FF and a UBUFFER defined of at least 2048 words.
Definitions and Substitutions
#define Kp P(ITOF(MTRNUM*100+30)) ; Gain term is Pxx30
#define A P(ITOF(MTRNUM*100+31)) ; A zero is Pxx31
#define B P(ITOF(MTRNUM*100+32)) ; B zero is Pxx32
#define C P(ITOF(MTRNUM*100+33)) ; C pole is Pxx33
#define D P(ITOF(MTRNUM*100+34)) ; D pole is Pxx34
#define E P42 ; Error term e(k) (not saved)
#define Temp1 P45 ; Temporary value
#define Temp2 P46 ; Temporary value
#define Temp3 P47 ; Temporary value
#define U P48 ; Output term u(k) (not saved)
#define LastE F1[MTRNUM-1] ; e(k-1) is F1[#-1]
F1->L:$010000[32] ; Float reg array in UBUFFER
#define PrevE F2[MTRNUM-1] ; e(k-2) is F2[#-1]
F2->L:$010020[32] ; Float reg array in UBUFFER
#define LastU F3[MTRNUM-1] ; u(k-1) is F3[#-1]
F3->L:$010040[32] ; Float reg array in UBUFFER
#define PrevU F4[MTRNUM-1] ; u(k-2) is F4[#-1]
F4->L:$010060[32] ; Float reg array in UBUFFER
#define ServoCycle L0
L0->X:$0,0,24,S ; Servo cycle counter
#define LastServoCycle L1[MTRNUM-1]
L1->X:$010080[32] ; Register array in UBUFFER
#define ServoExtension L2
L2->Y:(R1-$21) ; Ixx60 register as integer
#define OutputLimit 8388607
Start of Actual Algorithm
OPEN SERVO CLEAR
COPYREG P40 ; Following error into P42
; If loop was not closed last cycle, zero out stored values
IF (ServoCycle-LastServoCycle!=ServoExtension+1)
LastU=0
PrevU=0
LastE=0
PrevE=0
ENDIF
LastServoCycle=ServoCycle ; Store for next cycle
Temp1=Kp*(E+(A+C)*LastE+A*C*PrevE) ; Compute TF numerator
Temp2=(B+D)*LastU+B*D*PrevU ; Compute TF denominator
Temp3=Temp1-Temp2 ; Combine for net command
U=FLIMIT(Temp3,OutputLimit) ; Saturation check
PrevE=LastE ; Store values for next cycle
LastE=E
PrevU=LastU
LastU=U
RETURN(FTOI(U)) ; Return command value as integer
CLOSE
Available Registers
The following data registers may be used by the user-written servo:
• Internal DSP registers R4, N4, R5, and N5 may be used, and do not need to be restored when done.
• Internal DSP registers M0, M4, and M5 may be used, but must be restored to previous values when
done.
• Motor intermediate value registers X:$000x93/13 through X:$000x9A/1A may be used to hold values
from cycle to cycle. They are not used by any Turbo PMAC firmware as long as the user-written
servo is activated.
• Global registers X/Y:$0010F0 – $0010FF may be used. They are not used by any Turbo PMAC
firmware tasks, other than being set to 0 on power-up/reset.
• Registers in the user buffer established by the DEFINE UBUF command may be used. They are not
used by any Turbo PMAC firmware tasks.
• Other registers may be used as well, but it is possible for certain tasks of Turbo PMAC firmware to
overwrite these. For example, it is possible to use the registers for some P or Q-variables for the user-
written servo, but assigning a value to one of these variables will overwrite the register. It is also
possible to use the I-variables for Turbo PMAC’s standard servo algorithms as gains for the user-
written servo.
Programming Restrictions
Do not use any levels of the DSP’s stack, so no DO or JSR instructions are permitted.
Do not use internal DSP address registers R2, R3, R6, and R7; modifier registers M2, M3, M6, and M7;
offset registers N2, N3, N6 and N7.
Assembling the Algorithm
The assembly language algorithm must be assembled into DSP56300 machine code using Motorola’s
cross assembler for the computing platform. Follow the instructions from Motorola to do this.
Linking the Algorithm
Use the Delta Tau applet CODET.EXE, available on the Delta Tau website to convert the file that results
from the Motorola assembler into a format that can be directly downloaded to the Turbo PMAC. This file
should be archived on the computer or network.
Downloading the Algorithm
Use any version of the PMAC Executive program to download this resulting file into Turbo PMAC’s
program memory. Remember that it is downloaded into volatile RAM memory. To have the Turbo PMAC
retain this algorithm, issue a SAVE command before the controller is reset or power removed from it.
Executing the Algorithm
Set bit 0 of Motor xx variable Ixx59 to 1 (Ixx59 = 1 or 3) to select the user-written servo algorithm. As
with the PID or the ESA, the servo loop for the motor must be closed in order for this algorithm to
execute. It will not execute if the motor is either open-loop enabled or killed. If using the user-written
servo algorithm for non-servo tasks, be aware that certain commands (e.g. <CTRL-K>) or fault
conditions on other motors (fatal following error or amplifier fault if their Ixx24 specifies killing other
motors on their fault) can disable your algorithm.
∆x ∆x ∆x ∆x ∆x
E M
∆y ∆y ∆y ∆y ∆y ∆y
M
E
A second use for cross-axis compensation is what is often known as the electronic cam. In this case, the
entire movement of the target motor is caused by the entries in the compensation table, not just the
corrections. This method of implementing electronic cam operation has two significant advantages over
Turbo PMAC’s time-base following, the other method of creating electronic cams: the compensation
table is bidirectional – the master can turn in either direction – and it is absolute, so the phasing in is
simply a matter of homing the axes.
The time-base method, in which the motion program of the slave motors defines the motion, retains the
advantage of being able to change on the fly through math and logic in the program, and of second or
third order interpolation between points, rather than the compensation table’s 1st-order interpolation.
Refer to the Synchronizing Turbo PMAC to External Events section of this manual for details.
Dimension of the Table
Turbo PMAC presently supports one-dimensional (1D) and two-dimensional (2D) position compensation
tables. Three-dimensional (3D) tables may be supported in the future. 1D tables have a single source
motor; 2D tables have two source motors. Note that a table with a single source motor that is different
from the target motor (a cross-axis compensation table) is still a 1D table.
Note:
3D compensation may be achieved in Turbo PMAC through the use of the
kinematic subroutines, which can be used to compute the corrections
algorithmically. The correction equations would be fit to the observed
measurements, probably through a least-squares fit on polynomial equations.
Refer to the section on kinematics algorithms in the Setting up a Coordinate
System section of this manual for details. Note that both the correction equations
(the inverse kinematics) and their inverse (the forward kinematics) must be
entered.
Kinematic equations can also be used for 1D and 2D compensation if algorithm,
rather than table-based, compensation is desired. Corrections for all motors in the
coordinate system must be done in the same kinematic algorithm. By
parameterizing the algorithm coefficients, the corrections can be made dynamically
adjustable (as a function of temperature, for example).
Table Range
The compensation is defined directly for a range of source motor positions starting at zero counts (the
most recent home or power- up/reset position) and going in the positive direction. The size of this range
is declared as the last argument of the DEFINE COMP command. This argument has units of counts of
the source motor. The spacing between entries is the total range divided by the number of entries (which
is the first argument of the DEFINE COMP command). The first entry in the table defines the correction
at one spacing from the zero position of the source motor, the second entry at two spacings, and so on.
Rollover
Outside of this range, the uncorrected position is rolled over to within this range – essentially a modulo
(remainder) operation – before the compensation is done. For 2D tables, this rollover occurs in both
dimensions. The rollover permits compensation of rotary axes over several revolutions, and simple
compensation for encoder eccentricity. Of course, if the table is made big enough to cover the entire
source motor travel, the rollover feature will never be used.
If the motor has a travel range to the negative side of zero, and compensation is desired here, these entries
should be made as if they were past the positive end of the motor range. For instance, if the motor travel
were +/- 50,000 counts and a table entry was to be made every 500 counts (so 200 entries total), the table
would be set up with a DEFINE COMP 200,100000 command. The first 100 entries would cover the
500 to +50,000 count range, and the last 100 entries would cover the -50,000 to 0 count range. (Usually
the table is referenced so there is a zero correction at the source motor zero position, so the last entry in
the table should be 0.) Essentially, the -50,000 to 0 range would be mapped into the +50,000 to +100,000
range.
If global variable I30 (new in V1.939 firmware) is set to the default value of 0 when the table is
downloaded to Turbo PMAC, the correction value at 0 counts of the source motor is always 0. In this
case, the last entry of the table must be set to 0, or there will be a discontinuity in the correction (and
therefore a position jump) as the source motor passes either end of the table, rolling over the correction.
Most often, the correction is defined to be 0 at the zero position of the motor.
If I30 is set to 1 when the table is downloaded to Turbo PMAC, the correction value at 0 counts of the
source motor is set equal to the last entry of the table, guaranteeing smooth rollover of the table. If the
last entry for the table is 0, the result will be the same regardless of the setting of I30.
Determining Compensation Values
The values that will be entered into the compensation table are determined by comparing the raw
measurements of the sensor that will be used in the application against a reference sensor that is installed
only for the calibration process. Move the axis (or the axes) to the raw position at which you want to
make an entry. Read the reference sensor at this position. The entry in the table will be the raw position
minus the reference position, with both values scaled to 1/16 of a Turbo PMAC software count, both
measured from the motor home (zero) position.
For standard leadscrew compensation tables (1D tables with the same motor as both source and target),
Delta Tau provides a PC software package called Flycal that can perform these measurements on the fly
and automatically generate these tables quickly.
Entering Tables
Position compensation tables are entered into the Turbo PMAC with on-line commands. First there is the
DEFINE COMP command, which defines the size and span of the table, and which motors it uses as its
source and target motors. Following this is a series of numerical constants, separated by spaces and/or
carriage-return characters, which are entered sequentially into the table. (If there is no table to be filled, a
numerical constant sent to PMAC is assigned to variable P0.)
Position compensation tables must be defined in order from those assigned to higher-numbered motors to
those assigned to lower-numbered motors.
Entering 1D Tables
If the position compensation table to be entered has both the source and target motors equivalent to the
addressed (assigned) motor, and the table uses the actual position of this motor to calculate the
corrections, then there is no need to specify the motors in the DEFINE COMP command. The command
would look something like:
#2 DEFINE COMP 25, 500000
This command establishes a table using Motor 2 as both the source and target motor, using the actual
position to compute the corrections. The next 25 numerical constants sent to Turbo PMAC would be
entered into the table. The first value would be the correction at 500,000/25 = 20,000 counts. (20,000
here represents the uncorrected position.) The second value would be the correction at 40,000
uncorrected counts, and so on. The 25th entry would be the correction at 500,000 counts; if I30 were set
to 1 at the time of entry, this would be the correction at 0 counts as well. The units of the correction itself
are 1/16 count.
If you desire that either the source or target motors be different from the addressed motor, or you wish to
make the table a function of the source motor’s desired position, you must explicitly declare the motors in
the DEFINE COMP command. In this case, the command would look something like:
#1 DEFINE COMP 25, #2D, #2, 500000
This command establishes a table using Motor 2 both as the source, working from its net desired position,
and as the target to which the corrections are applied, even though the table is assigned to Motor 1. As in
the above case, the next 25 numerical constants would be entered into the table, with the first value being
the entry at 20,000 counts the second at 40,000 counts, and so on.
1D Table Example
Below is a simple example of the entry of a 1D table
#1
DEFINE COMP 8,4000 ; Table of 8 entries over 4000 cts belonging to
; motor 1 ; Uses motor 1 for source (actual pos)
; & target because no other motors specified
-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
96 ; Correction at 2000 counts is 6 counts
20 ; Correction at 2500 counts is 1.25 counts
-56 ; Correction at 3000 counts is -4.5 counts
-12 ; Correction at 3500 counts is -0.75 cts
0 ; Correction at 4000 (and 0) cts is zero
In this example, the correction at a raw position of 1300 counts would be linearly interpolated between
the corrections at 1000 counts and 1500 counts, as follows:
1300 − 1000
Correction = 5 + ( 7.5−5 )* = +6.5counts
500
Entering 2D Tables
If the position-compensation table has two source motors, establishing a 2D, or planar table, the entry is a
little more complex. Declare the length of the table (in number of entries) in both dimensions, and the
span of the table in both dimensions. Declare both source motors, and usually the target motor (although
the default is the addressed motor). The command that establishes the table will look something like:
#2 DEFINE COMP 15.20, #1D, #2D, #3, 20000, 15000
This command specifies that the table assigned to Motor 2 will have 15 rows and 20 columns. Therefore,
each row has 20 entries, and each column has 15 entries.
Motor 1 is the first source motor (the row motor), using its desired position; each row represents a row
span of counts of positions of Motor 1, and each column represents a constant raw position of Motor 1.
Motor 2 is the second source motor (the column motor), using its desired position; each column represents a
column span of counts of Motor 2, and each row represents a constant raw position of Motor 2.
Motor 3 is the target motor; the corrections are applied to Motor 3.
The span of each row is 20,000 counts, so there is a spacing of 20,000/20 = 1000 counts (of Motor 1)
between entries along the row dimension. The span of each column is 15,000 counts, so there is a spacing
of 15,000/15 = 1000 counts (of Motor 2) between entries along the column dimension.
The next (15+1)*(20+1)-1=335 numerical constants sent to Turbo PMAC are entered into this table.
Why this number of entries? Because there are entries in each row and column at both the zero position
and the maximum position (hence the n+1 terms), but there is no explicit entry at the origin of both source
motors (hence the final -1).
In this example, the first entry would be the correction at Motor 1 (raw) position 1000, Motor 2 (raw)
position 0 – i.e. at (1000, 0). The second entry would be at (2000, 0). The 20th entry would be at (20,000,
0). The 21st entry would be at (0, 1000), the 22nd at (1000, 1000), and so on. The 335th and last entry of
the table would be the correction at (20,000, 15,000). If I30 were set to 1, this value would also be the
correction at (0, 0). Typically the correction at the origin is made zero by definition, to serve as the
reference point for the other corrections.
If there is any possibility of motion going past the declared span of the table, whether for purposeful
rollover or not, the entries at both ends of each row should be the same; likewise for each column.
Otherwise, there will be a discontinuity in the correction at the edge of the table.
Note three things to be careful about in the entry of a 2D table. First, the number of rows and number of
columns is separated by a period, not a comma. Second, the number of rows (15 in the above example) is
entered first, before the number of columns, but the spacing (in counts) between rows is determined by
the span of a column (15,000 in the above example), which is entered after the span of a row. Finally, to
permit efficient computation in Turbo PMAC, both Row and Column 0 as well as Row and Column n
must be entered.
2D Table Example
The following example shows the entry of a simple 2D table, shown in a form that makes for easy reading
by a user. (Turbo PMAC does not require that the table be entered with each row on a separate line, but
this is recommended for readability.) Note that with an implied correction value of 0 for the zeroth entry,
Rows 0 and 4 are identical, as are Columns 0 and 5.
#3 DEFINE COMP 4.5, #1D, #2D, #3, 50000, 40000
38 45 –22 –35 0 ; Row 0, Columns 1-5
24 56 13 –34 –8 24 ; Row 1, Columns 0-5
18 43 –9 –65 32 18 ; Row 2, Columns 0-5
-6 28 22 –38 12 –6 ; Row 3, Columns 0-5
0 38 45 –22 –35 0 ; Row 4, Columns 0-5
In this example each row covers the span of Motor 1 (0 – 50,000 counts) at a constant position of Motor
2; each column covers the span of Motor 2 (0 – 40,000 counts) at a constant position Motor 1.
Enabling and Disabling Tables
All position compensation tables (as well as backlash and torque compensation tables) are enabled when
I51 is set to 1. All of these tables are disabled when I51 is set to 0.
The net correction for a target motor is stored each servo cycle in a specific register for the motor. For
Motor 1, this is the register at D:$000090. The suggested M-variable for this register for Motor xx is
Mxx69. The units of this register are 1/(Ixx08*32) counts, the same as other motor position registers. If
I51 is set to 1, this register is zeroed every servo cycle, and then the result of each table whose target
motor is this motor is added to this register. If I51 is set to 0, it is permissible to write values directly to
this register. Regardless of the setting of I51, the value in this register is added into the net desired
position value for the motor every servo cycle.
It is important to understand that the table corrections are calculated as a function of the uncorrected
motor position, whether using desired or actual position. For a table that uses the same motor as source
and target, the corrected position is by definition different from the uncorrected position. Since the
compensations vary with position, the compensation at a given corrected position will not be exactly the
same in general as the compensation at the uncorrected position of the same numerical value. The
differences are small, but may be noticeable if you are looking at the net compensation register. This is
important to understand if you are verifying the resulting correction of a table.
Reporting Table Information
The header information for a position compensation table – entered with the DEFINE COMP command –
can be queried with the LIST COMP DEF command. The contents of the table can be queried with the
LIST COMP command
Deleting Tables
The DELETE COMP command erases the position compensation table assigned to the presently addressed
motor (whether or not that motor is a source or target of the table). Position compensation tables must be
deleted in order from those assigned to lower-numbered motors to those assigned to higher-numbered
motors.
Backlash Compensation
Turbo PMAC can perform sophisticated backlash compensation for all motors. If the position feedback
utilizes a sensor on the motor and there is physical backlash in the coupling to the load (as in a typical
gear train), the physical position of the load for a given sensor-reported position will differ depending on
the direction of motion. Unless this is compensated for, significant position errors can result in the
application.
With Turbo PMAC’s backlash compensation, on reversal of the direction of the commanded velocity, a
pre-programmed backlash distance is added to or subtracted from the commanded position. This
backlash distance can be constant over the travel of the motor, or it can be a function of motor position.
The rate at which the backlash is introduced or removed is programmable, as is the magnitude of the
reversal required for backlash to be introduced or removed. The backlash amount is hidden from any
position reporting.
Constant Backlash Parameter
Variable Ixx86 for Motor xx is the constant backlash distance parameter. When the direction of the
motor’s commanded movement changes from positive to negative, this value is introduced into the active
backlash compensation register, which is subtracted from the nominal commanded position. When the
direction of the motor’s commanded movement changes from negative to positive, the value of the
backlash compensation register is reduced to zero.
Note that a positive value of Ixx86 adds extra distance to the travel of the motor on reversal, which is
what is desired to compensate for true physical backlash. (The only known practical use of a negative
backlash parameter is when the motor is electronically geared as a slave to an axis with physically greater
backlash.) The units of Ixx86 are 1/16 of a count, so the value should be 16 times the number of counts
of backlash compensation required (e.g. Ixx86=72 specifies 4.5 counts of backlash).
Backlash Take-Up Rate
Variable Ixx85 controls the rate at which backlash is introduced or removed upon reversal for Motor xx.
This permits the user to optimize for swift but smooth backlash compensation. When reversal is detected,
each background cycle (between each scan of each PLC) an amount equal to Ixx85 is added to or subtracted
from the active backlash compensation register, as appropriate, until a value Ixx86 or 0 in that register is
reached. In general, the highest value of Ixx85 that produces smooth transitions should be used.
Backlash Hysteresis
Variable Ixx87 controls for Motor xx the number of counts in the new direction of the net commanded
position that must be seen before PMAC determines that a reversal has occurred and the backlash must be
changed. As such, it acts as a “hysteresis” term. It is particularly important if a master encoder is used to
drive the motor, so slight dithering in the master encoder does not cause repeated introduction and
removal of backlash. Ixx87 has units of 1/16 count, so the default value of 64 provides a 4-count
hysteresis.
Backlash Compensation Tables
A backlash compensation table created with the DEFINE BLCOMP command can be used to create
backlash distances that vary with the position of the addressed motor. Most often this is used in
conjunction with a leadscrew compensation table to create the effect of a bi-directional leadscrew
compensation table. In this case, the backlash table (added to the constant backlash parameter) contains
the difference between the positive-going compensation and the negative-going compensation. Delta
Tau’s Flycal calibration program for the PC can generate these tables automatically.
then the correction applied to a 16-bit DAC at 600 counts would be:
600 − 500
Correction = −50 + (83 − [− 50 ]) = 3bits
750 − 500
How to Calculate Table Entry Values
Torque compensation tables are most commonly used to correct for torque ripple in motors due to
“cogging torque” effects. The simplest way of determining the entries in the table is to command a move
to each point you desire in the table and using integral gain to drive the error to zero, wait for the motor to
settle at this position. Then read the command output of the servo loop as a 24-bit value. This value is
best read in the motor’s quadrature/torque command value (X:$0000BF for Motor 1). Read as a 24-bit
value (e.g. use RX:$BF in the Executive program’s Watch window), this can be the entry into the table
for that position.
Reporting Table Information
The header information for a torque compensation table – entered with the DEFINE TCOMP command –
can be queried with the LIST TCOMP DEF command. The contents of the table can be queried with the
LIST TCOMP command
Enabling and Disabling Tables
All torque compensation tables (as well as position and backlash compensation tables) are enabled when
I51 is set to 1. All of these tables are disabled when I51 is set to 0.
Active Calculation of Corrections
The torque compensation is performed inside the servo loop (every servo cycle) to obtain the maximum
speed and accuracy. Turbo PMAC takes the position of the motor and finds the matching position in the
table. Typically this is between two entries in a table, so Turbo PMAC linearly interpolates (weighted
average) between these entries to obtain the correction for the current servo cycle. It then adds this
correction to the desired output from the position/velocity servo loop of the motor. Both the loop output
and the correction are 24-bit values at this point.
The torque correction for a motor is stored each servo cycle in a specific register for the motor. For
Motor 1, this is the register at Y:$0000BF, and the net output with correction is stored at X:$0000BF. If
I51 is set to 0, it is permissible to write values directly to the correction register. Regardless of the setting
of I51, the value in this register is added into the net desired output value for the motor every servo cycle.
Deleting Tables
The DELETE TCOMP command erases the torque compensation table for the presently addressed motor.
Torque compensation tables must be deleted in order from those assigned to the lower-numbered motors
to those assigned to higher numbered motors.
Suggested M-Variables
Note:
In a UMAC Turbo system, it is possible to have the DSPGATE2 IC driving the
JIO port at a base address other than the standard $078400. However, this is
unlikely, so the following discussion assumes the standard base address of
$078400 for this IC.
The 32 I/O lines are memory-mapped into PMAC’s address space in registers Y:$078400 and Y:$078401.
Typically these I/O lines are accessed individually with M-variables. A complete list of the suggested M-
variables is shown in the Software Reference; a few are shown here:
M0->Y:$078400,0 ; I/O00 Data Line; J3 Pin 1
M1->Y:$078400,1 ; I/O01 Data Line; J3 Pin 2
…
M23->Y:$078400,23 ; I/O23 Data Line; J3 Pin 24
M24->Y:$078401,0 ; I/O24 Data Line; J3 Pin 25
M25->Y:$078401,1 ; I/O25 Data Line; J3 Pin 26
…
M31->Y:$078401,7 ; I/O31 Data Line; J3 Pin 32
Direction Control
The direction control bit for each of these I/O bits is in the corresponding bit in the matching X register.
For example, the direction control bit for I/O03 is located at X:$078400,3; the direction control bit for
I/O30 is located at X:$078401,6. Because the buffer ICs can be switched only by byte, it is best to define
8-bit M-variables for the direction control. Suggested definitions are:
M32->X:$078400,0,8 ; Direction control for I/O00 to I/O07
M34->X:$078400,8,8 ; Direction control for I/O08 to I/O15
M36->X:$078400,16,8 ; Direction control for I/O16 to I/O23
M38->X:$078401,0,8 ; Direction control for I/O24 to I/O31
These M-variables should take values of 0 or 255 ($FF) only; 0 sets the byte to input, 255 sets the byte to
output.
In addition, the bi-directional buffer IC for each byte has a direction control line accessible as a software
control bit. These control lines and bits must match the ASIC direction bits. The buffer direction control
bits are at PMAC address Y:$070800, with bits 0 to 3 controlling the four bytes of the JIO port. A bit
value of 0 specifies input; 1 specifies output. Suggested M-variable definitions are:
M33->Y:$070800,0 ; Buffer direction control for I/O00 to I/O07
M35->Y:$070800,1 ; Buffer direction control for I/O08 to I/O15
M37->Y:$070800,2 ; Buffer direction control for I/O16 to I/O23
M39->Y:$070800,3 ; Buffer direction control for I/O24 to I/O31
In the default configuration automatically set at power-up/reset, I/O00 to I/O31 are set up as inputs (M32
through M39 = 0). This is done for maximum safety; no lines can be forced into an undesirable high or
low state. Any of these lines that are to be used as outputs must be changed to outputs by user programs
Usually this is done in PLC 1 acting as a reset PLC, scanning through once on power-up/reset, then
disabling itself.
Inversion Control
Each line on the JIO port is individually controllable as to whether it is an inverting I/O point (0=+5V;
1=0V) or a non-inverting I/O point (0=0V; 1=+5V). Registers X:$078404 and X:$078405 contain the
inversion control bits:
• X:$078404 bits 0 to 23 control I/O00 to I/O23, respectively
• X:$078405 bits 0 to 7 control I/O24 to I/O31, respectively
A value of 0 in the control bit sets the corresponding I/O point as non-inverting. A value of 1 in the
control bits sets the corresponding I/O point as inverting. At power-up/reset, PMAC automatically sets
all of the I/O points on the JIO port as non-inverting.
Alternate Uses
Each general-purpose I/O point on the JIO port has an alternate use as a supplemental fixed-use I/O point
on a supplemental machine interface channel (1* or 2*). The points are individually controllable as to
general-purpose use or fixed use by control registers Y:$078404 and Y:$078405. Refer to these registers
in the memory-I/O map to see the alternate uses of each point. At power-up/reset, Turbo PMAC
automatically sets up all of the I/O points on the port for general-purpose use.
Note:
The byte-wide direction control of the buffer ICs must be set properly for the
alternate uses of the I/O points, just as for the general-purpose I/O uses.
Hardware Characteristics
When configured as an output, each line on the multiplexer port has a 5V CMOS totem-pole driver. This
driver can sink or source up to 20 mA. There is a 10 kΩ pull-up resistor to 5V on each line for input
purposes, but the driver IC can hold the line high or low despite this resistor. When configured as an
input, the buffer IC presents a high-impedance input either sinking or sourcing; no significant current will
flow. The pull-up resistor on the line will bias the line high in the absence of anything actively pulling
the line low at significantly lower impedance.
Suggested M-Variables
The 16 I/O lines are memory-mapped into PMAC’s address space in register Y:$078402. Typically these
lines are used as a unit with specially designed multiplexing I/O accessories and appropriate multiplexing
M-variables (TWB, TWD, TWR, and TWS formats), in which case Turbo PMAC handles the direct control
of these I/O lines automatically. However, these lines can also be accessed individually with M-variables.
The complete list of M-variables is shown in the Software Reference Manual; a few are shown here:
M40->Y:$078402,8 ; SEL0 Line; J2 Pin 4
…
M47->Y:$078402,15 ; SEL7 Line; J2 Pin 18
M48->Y:$078402,8,8,U ; SEL0-7 Lines treated as a byte
M50->Y:$078402,0 ; DAT0 Line; J2 Pin 3
…
M57->Y:$078402,7 ; DAT7 Line; J2 Pin 17
M58->Y:$078402,0,8,U ; DAT0-7 Lines treated as a byte
Direction Control
In the default configuration automatically set at power-up/reset, DAT0 to DAT7 are set up as non-
inverting inputs; SEL0 to SEL7 are set up as non-inverting outputs with a zero (low voltage) value. If
any of the multiplexer port accessories are to be used, this configuration must not be changed.
The direction control bit for each of these I/O bits is in the corresponding bit in the matching X register.
For example, the direction control bit for DAT3 is located at X:$078402,3; the direction control bit for
SEL6 is located at X:$078402,14. Because the buffer ICs can be switched only by byte, it is best to
define 8-bit M-variables for the direction control. Suggested definitions are:
M60->X:$078402,0,8 ; Direction control for DAT0 to DAT7
M62->X:$078402,8,8 ; Direction control for SEL0 to SEL7
These M-variables should take values of 0 or 255 ($FF) only; 0 sets the byte to input, 255 sets the byte to
output.
In addition, the bi-directional buffer IC for each byte has a direction control line accessible as a software
control bit. These control lines and bits must match the ASIC direction bits. In the ISA and PCI-bus
versions of the Turbo PMAC, the buffer direction control bits are at Turbo PMAC address Y:$070800,
with bits 4 and 5 controlling the two bytes of the JTHW port. A bit value of 0 specifies input; 1 specifies
output. Suggested M-variable definitions are:
M61->Y:$070800,4 ; Buffer direction control for DAT0 to DAT7
M63->Y:$070800,5 ; Buffer direction control for SEL0 to SEL7
In the VME-bus versions of the Turbo PMAC, the buffer direction control bits are at Turbo PMAC
address Y:$070802, with bits 0 and 1 controlling the two bytes of the JTHW port. A bit value of 0
specifies input; 1 specifies output. Suggested M-variable definitions are:
M61->Y:$070802,0 ; Buffer direction control for DAT0 to DAT7
M63->Y:$070802,1 ; Buffer direction control for SEL0 to SEL7
If it is desired to change either of these I/O bytes, it must be done by user programs. Usually this is done
in PLC 1 acting as a reset PLC, scanning through once on power-up/reset, and then disabling itself.
Inversion Control
Each line on the JTHW port is individually controllable as to whether it is an inverting I/O point (0=+5V;
1=0V) or a non-inverting I/O point (0=0V; 1=+5V). Register X:$078406 contains the inversion control bits:
• X:$078406 bits 0 to 7 control DAT0 to DAT7, respectively
• X:$078406 bits 8 to 15 control SEL0 to SEL7, respectively
A value of 0 in the control bit sets the corresponding I/O point as non-inverting. A value of 1 in the
control bits sets the corresponding I/O point as inverting. At power-up/reset, PMAC automatically sets
all of the I/O points on the JTHW port as non-inverting. To use any of the multiplexed I/O accessory
boards on the JTHW port, all I/O points on the port must be left non-inverting.
Alternate Uses
Each general-purpose I/O point on the JTHW port has an alternate use as a supplemental fixed-use I/O
point on a supplemental machine interface channel (1* or 2*). The points are individually controllable as
to general-purpose use or fixed use by control register Y:$078406. Refer to this register in the memory-
I/O map to see the alternate uses of each point. At power-up/reset, Turbo PMAC automatically sets up all
of the I/O points on the port for general purpose use.
Note:
Because of the byte-wide direction-control buffer ICs, it is not possible to use all
of the I/O points on the JTHW in their alternate uses.
The analog-to-digital converters on Turbo PMAC require +5V and -12V supplies. These supplies are not
isolated from digital +5V circuitry on PMAC. If the Turbo PMAC2 is plugged into the bus (ISA, PCI, or
VME), these supplies are taken from the bus power supply. In a standalone application, these supplies
must be brought in on terminal block TB1.
The -12V and matching +12V supply voltages are available on the J1 connector to supply the analog
circuitry providing the signals. The +12V supply is not used by Turbo PMAC; it is merely passed
through to the J1 connector for convenience. If use of this supply is desired, it must come either from the
bus supply through Turbo PMAC’s bus connector, or from TB1.
Multiplexing Principle
Only one pair of analog-to-digital converter registers is available to the Turbo PMAC processor at any
given time. The data appears to the processor at address Y:$078800 on a Turbo PMAC2; it appears at
Y:$078808 on a Turbo PMAC PCI. The data from the selected analog input 0 to 7 (ANAI00-ANAI07)
appears in the low 12 bits; the data from the selected analog input 8 to 15 (ANAI08-ANAI15) appears in
the high 12 bits. This data is present only if Option 12A has been ordered.
The input is selected and the conversion is started by writing to this same word address Y:$078800. A
value of 0 to 7 written into the low 12 bits selects the analog input channel of that number (ANAI00-
ANAI07) to be converted in unipolar mode (0V to +5V). A value of 0 to 7 written into the high 12 bits
selects the analog input channel numbered 8 greater (ANAI08-ANAI15) in unipolar mode. If the value
written into either the low 12 bits or the high 12 bits is 8 higher (8 to 15), the same input channel is
selected, but the conversion is in bipolar mode (-2.5V to +2.5V).
De-multiplexing I-Variables
Turbo PMAC I-variables I5060 – I5096 permit the automatic de-multiplexing of these multiplexed A/D
converters (and of multiplexed A/D converters on external Acc-36 and Acc-59 boards as well).
I5060 controls the number of A/D converter pairs accessed in the de-multiplexing ring, up to 16 pairs.
Variables starting at I5061, and possibly up to I5076, specify the Turbo PMAC address of each ADC pair
to be read. The addresses of all eight pairs on the JANA port are located at $078800.
Variables starting at I5081, and possibly up to I5096, specify which pair of ADCs at the address specified
by the I-variable numbered 20 lower is read (e.g. I5081 for I5061), and how it is to be converted. I5081 –
I5096 are 24-bit values, represented by 6 hexadecimal digits. Legitimate values are of the format
$00m00n, where m and n can take any hex value from 0 through F.
For the on-board Option 12 and 12A ADCs on a Turbo PMAC2, the m value determines which of the
inputs ANAI08 to ANAI15 that come with Option 12A is to be read, and how it is to be converted,
according to the following formulas:
• m = ANAI # −8 ; 0 to +5V unipolar input
• m = ANAI # ; -2.5V to +2.5V bipolar input
For the on-board Option 12 and 12A ADCs on a Turbo PMAC2, the n value determines which of the
inputs ANAI00 to ANAI07 that come with Option 12A is to be read, and how it is to be converted,
according to the following formulas:
• n = ANAI # ; 0V to +5V unipolar input
• n = ANAI # +8 ; -2.5V to +2.5V bipolar input
The results of this A/D de-multiplexing are placed in registers at addresses Y:$003400 to Y:$00341F,
using bits 12 to 23 of these registers. The value of the A/D converter found in the low 12 bits of the
source register is placed in the register with the even-numbered address; the value of the A/D converter
found in the high 12 bits of the source register is placed in the register with the odd-numbered address.
Refer to the Turbo PMAC memory map or I5061 – I5076 description for details. Suggested M-variables
for the result registers are M5061 – M5076.
In operation, Turbo PMAC reads one ADC pair each phase cycle and copies it into the appropriate
memory registers. Therefore, it reads each ADC pair every I5060 phase cycles. If these values are used
as feedback for a servo loop, the loop should not be closed more often than the ADC is read.
UMAC Digital I/O Boards
The UMAC has an extensive family of digital I/O boards. The following table summarizes these boards
and their properties:
ACC # of Input Drivers for # of Output Output Notes
Inputs Range Inputs Outputs Range Drivers
9E 48 12V- Sink/Source by 0 – – Isolated I/O
24V wiring
10E 0 – – 48 5V – 24V Sink/Source by Isolated I/O
factory option
11E 24 12V- Sink/Source by 5V – 24V Sink/Source by Isolated I/O
24V wiring factory option
14E 0 - 48 5V TTL/Sinking 48 - 0 5V Sinking with TTL, each
pull-ups reversible
65E 24 12V- Sourcing only 24 5V – 24V Sourcing only Isolated,
24V protected I/O
66E 48 12V- Sourcing only 0 – – Isolated,
24V protected I/O
67E 0 – – 48 5V – 24V Sourcing only Isolated,
protected I/O
WARNING
Although this limit may be disabled by setting Ixx11 to zero, but this is strongly
discouraged in any application that has the potential to kill or injure people, or
even to cause property damage. Disabling the fatal limit removes an important
protection against serious fault conditions that can cause runaway situations,
bringing the system to full power output faster than anybody could react.
Good tuning of the motor’s servo loop is important for safety reasons as well as performance reasons.
The smaller the true following errors are made during proper operation, the tighter the Ixx11 limits can be
set without getting nuisance trips. Particularly important in this regard are the feedforward terms that can
dramatically reduce the errors at high speeds and accelerations.
Warning Following Error Limit
The second limit (Ixx12) is a warning limit – when exceeded, Turbo PMAC sets status bits for the motor
and the motor’s coordinate system, and can set output lines on the control panel connector, the machine
connectors, and through the programmable interrupt controller (for ISA and PCI bus Turbo PMACs).
This permits special action to be taken, either by Turbo PMAC itself through a PLC program, by the host,
which can find out through an interrupt or by polling the card, or by an operator notified with one of the
external signals.
The warning following error status bit for the motor can be used as the trigger condition for any of Turbo
PMAC’s automatic triggered moves (homing-search move, jog-until-trigger, programmed RAPID-mode
move-until-trigger) if bit 0 of Ixx97 is set to 1. This permits easy implementation of tasks such as homing
into a hard stop, torque-limited screwdriving, etc.
Variable Ixx25 for the motor must contain the address of the flag register for the channel into which these
limit switches are wired. Bit 17 of Ixx24 must be set to the default value of 0 to use these limit inputs. If
this bit is set to 1, Turbo PMAC will not monitor these limit inputs. This bit can be set permanently to 1
if the motor does not have limit switches; it can be set to 1 temporarily for operations such as homing into
a limit.
On hitting a limit, Turbo PMAC decelerates the offending motor at a user-programmed rate as defined by
the motor’s Ixx15. If the motor is in a coordinate system that is running a motion program at the time, all
motors in the coordinate system are decelerated to a stop at their own Ixx15 rate. The effect is equivalent
to issuing an A (abort) command. If the coordinate system has been executing a path move, this
deceleration will not necessarily be along that path.
Note:
Turbo PMAC brings the commanded trajectory for the motor to a stop at the Ixx15
rate as soon as it detects a limit condition. If there is significant following error at
the time, the actual position can try to catch up to the commanded position for a
long period of time. With a large enough following error, it is possible that the
commanded position would be well past the limit and into the hard stop. It is
important to set a reasonable fatal following error limit and to allow sufficient
room past the limit switch to absorb errors up to that following error limit.
The limit input pins are direction sensitive: the positive-end limit pin stops positive direction moves only
(those coming at it from the negative side), and the negative-end limit pin stops negative direction moves
only (those coming at it from the positive side). This makes it possible to command a move out of the
limit that you have run into. However, this also makes it essential to have your limit switches wired into
the proper inputs, or they will be useless.
Software Overtravel Limit Variables
Turbo PMAC also has positive and negative software limits for each motor to complement or replace the
hardware limits. These limits can use the motor’s desired as well as actual positions. Motor variables
Ixx13 and Ixx14 define the positive and negative actual position limits, respectively, in counts, for Motor
xx. These limits are referenced to the motor’s zero (home) position, and do not change if the
programming origin for the associated axis is offset.
Turbo PMAC continually compares the motor’s actual position to these limits. The behavior on
exceeding one of these limits is the same as hitting a hardware limit. A value of zero in one of these
parameters disables that software limit.
If bit 15 of Ixx24 for the motor is set to 1, Turbo PMAC will compare the motor’s desired position also,
calculated ahead of time for programmed moves, to the software limits. This permits the motor to come
to a full stop within the limits, not just begin to decelerate at the limits. This in turn can provide an extra
useful range of motion at the perimeter of a machine.
Note:
Turbo PMAC cannot pre-calculate the desired position for indefinite jog moves J+
and J-, and so will not begin to decelerate on these moves until the present desired
position exceeds a software limit. If it is desired that jog moves stop within the
limits, a J+ command should be replaced by a definite jog to the positive limit; a
J- command should be replaced by a definite jog to the negative limit.
For a LINEAR or CIRCLE-mode move executed with the special lookahead buffer active and exceeding
a desired position limit, the move will come to a stop along the programmed path exactly at the limit,
decelerating as controlled by the Ixx17 maximum-acceleration parameters for the motors in the
coordinate system. This is the equivalent of the \ quick-stop command. In this case, it is possible to
resume motion along the path after changing the offending limit parameter. (If bit 14 of Ixx24 is set to 1,
motion of these moves in lookahead mode will not stop on hitting a limit; instead, the commanded
position of the offending motor will saturate at the limit value.)
Motor variable Ixx41 defines the difference (in counts) between the motor’s actual and desired position
limits, permitting the desired position limits to be set inside the actual position limits. The positive
desired position limit is set at (Ixx13 - Ixx41); the negative desired position limit is set at (Ixx14 + Ixx41).
This can be important to ensure that the limit deceleration of path moves within lookahead stay on the
path, and to enable the program to be resumed if desired. Ixx41 should be set large enough to make sure
that the actual position during the deceleration from exceeding a desired position limit does not exceed
the actual position limit.
The software position limits are disabled automatically during homing search moves, until the homing
trigger is found. As soon as the trigger is found, the software limits are re-activated, using the new home
position as the reference. The software position limits are always referenced to the motor’s zero position,
whether established by a homing search move, an absolute position read, or just at power-up/reset. If the
programming origin of the axis assigned to the motor is offset, the software position limits are not
automatically offset with the programming origin.
Velocity Limits
Vector Velocity Limit
Turbo PMAC has a vector velocity limit parameter (Isx98), known as maximum feedrate for each
coordinate system. For programs run by this coordinate system, the value of any F (feedrate) command
in the program is compared to Isx98. If the value is greater than Isx98, the value of Isx98 is used instead
as the feedrate command. Isx98 is expressed in the same user velocity units (axis length units divided by
Isx90 milliseconds) as the feedrate command itself.
Motor Velocity Limit
Turbo PMAC has a programmable velocity limit parameter for each motor (Ixx16), in units of counts per
millisecond, which has several functions. First, it serves as the commanded velocity for the motor in
RAPID-mode moves if the motor’s rapid velocity-select parameter Ixx90 for the motor is set to the
default value of 1.
Second, for simple LINEAR-mode moves with move segmentation disabled (Isx13=0), Ixx16 serves as
the maximum velocity permitted. If the commanded velocity requested of a motor exceeds the limit for
the motor, the move is slowed so that the velocity limit is not exceeded. In a multi-axis programmed
move, all axes in the coordinate system are slowed proportionally so that no change in path occurs.
In addition, for LINEAR and CIRCLE-mode moves executed with segmentation enabled (Isx13>0) and
the special lookahead buffer active, it serves as the maximum velocity for each segment of the motion.
This can be particularly valuable for non-Cartesian systems programmed with Turbo PMAC’s kinematic
equations; very high motor velocities can inadvertently be commanded near “singularities.” The
lookahead algorithm can detect these problems beforehand, and slow the motion down along the path into
the problem point, observing the Ixx17 motor acceleration limits.
Velocities are compared to these limits assuming no feedrate override (% value of 100); if feedrate
override (a.k.a. time-base control) is used, the velocity limits scale with the override.
Acceleration Limits
Turbo PMAC has two programmable acceleration limits for each motor, one for jogging, homing, and
RAPID-mode moves (Ixx19), and one for LINEAR and CIRCLE-mode programmed moves (Ixx17).
Both parameters are in units of counts per (millisecond-squared). PVT and SPLINE-mode moves do not
observe either of these limits.
If the commanded acceleration requested of a motor by the change in velocity and the acceleration time
parameters exceeds the limit for the motor, the acceleration time is extended so that the acceleration limit
is not exceeded. In a multi-axis programmed move, all axes in the coordinate system are slowed
proportionally so that no change in path occurs. Accelerations are compared to these limits assuming no
feedrate override (% value of 100); if feedrate override (a.k.a. time-base control) is used, the acceleration
limits scale with the square of the override percentage.
Without the special lookahead buffer enabled, the Ixx17 acceleration limit works only on LINEAR-mode
moves with segmentation disabled (Isx13=0). In this mode of operation, the acceleration time can be
extended only equal to the move time of the incoming move. If this is not enough of an extension to
observe the acceleration limit, the limit will be violated.
The Ixx17 limit works on LINEAR and CIRCLE-mode moves executed with segmentation enabled
(Isx13>0) and the special lookahead buffer active. Ensuring that all these moves observe this acceleration
limit is the most important feature of the special lookahead buffer.
Command Output Limits
Turbo PMAC has a programmable output limit (on the command Turbo PMAC sends to the amplifier or
the internal commutation algorithm) for each axis (Ixx69) that acts as a torque/force limit for current-
mode, sine-wave, or direct-PWM amplifiers, or a speed limit for velocity-mode amplifiers. If this limit is
engaged to change what the servo loop commands, Turbo PMAC’s anti-windup protection activates to
prevent oscillation when coming out of the limiting condition. In addition, there is a limit on the size of
the error that the feedback filter is permitted to see (the Ixx67 “position error” limit), which has the effect
of slowing down too sudden a move in a controlled fashion.
2
Two I-variables control the functioning of the I T protection for each motor. Ixx57 is the continuous
current limit magnitude. It has the same units as the Ixx69 instantaneous output limit, bits of a 16-bit
DAC (even if some other output device is used). Both have a maximum magnitude of 32,767, which is
the size of Turbo PMAC’s maximum possible output. If Ixx57 is a positive value, I2T protection will be
used; if Ixx57 is a negative number, |I|T protection will be used. Generally Ixx57 will be 1/4 to 1/2 of the
magnitude of Ixx69.
Ixx58 is the integrated current limit parameter. If Ixx58 is set to 0, this function is disabled. If Ix58 is
greater than 0, Turbo PMAC will compare the integrated current value to Ixx58. When the integrated
current value exceeds this value, Turbo PMAC will fault this motor as if an amplifier fault had occurred.
The offending motor is killed; if it was in a coordinate system running a motion program, that motion
program aborted; other motors are killed according to the setting of bits 21 and 22 of Ixx24.
2
Turbo PMAC’s I T function works according to the following equation:
I 2 2 2
q Id Ixx57
Sum = Sum +
32768
+ − 32768 ∆t
32768
Turbo PMAC’s |I|T function works according to the following equation:
I q I
d Ixx57
Sum = Sum + + − ∆t
32768 32768 32768
where:
Iq (quadrature current) is the commanded torque-producing output of the PID filter in units of a 16-
bit DAC;
Id (direct current) is the magnetization current command as set by Ixx77. This is usually zero
except when Turbo PMAC is doing vector control of induction motors.
∆t is the time since the last sample in servo cycles
If Sum exceeds Ixx58, an integrated-current fault will occur. When commanded current levels are below
Ixx57, Sum will decrease, but it will never go below zero.
PMAC I2T Protection Feature
Normalized
I2 I2
32768 2 1.0 2
2 Saturation
Ix69
Ix692 Integrator
32768 Charge-Up
I2T Fault
~
2
~
Ix57
Ix57 2
32768
~
Integrator
~
Discharge
time
(servo cycles)
Example: With command output limit Ixx69=32767 (maximum), integrated current limit Ixx57=16384
(half of maximum), and magnetization current Ixx77=0, the motor hits an obstruction, and the command
output saturates at 32767. The integrated-current protection function will calculate during this time:
[ ]
Sum = Sum + 1 2 + 0 2 − 0.5 2 ∆t = Sum + 0.75 ∆t
Sum will increase at a rate of 0.75 per servo cycle. At the default servo cycle update rate of 2.25 kHz,
Sum will increase at a rate of 2250*0.75=1688 per second. If you want the motor to trip after 3 seconds
of this condition, you should set Ixx58 to 1688*3 = 5064.
When an integrated-current fault occurs on a motor, Turbo PMAC reacts just as for an amplifier fault
error. The offending motor is killed and possibly other motors as set by bits 21 and 22 of Ixx24. Turbo
PMAC sets the amplifier fault motor status bit. For an integrated-current fault, Turbo PMAC also sets a
separate integrated-current fault motor status bit. Both bits are cleared when the motor is re-enabled.
Note:
2
When Turbo PMAC is not commutating a motor with I T protection, make sure
magnetization current parameter Ixx77 is still set to 0. In this setup, Ixx77 will not
affect operation, but it will affect integrated-current calculations.
Encoder-Loss Detection
Most Turbo PMAC controllers have encoder-loss detection circuitry for each encoder input. Designed for
use with encoders with differential line-driver outputs, the circuitry monitors each input pair with an
exclusive-or (XOR) gate. If the encoder is working properly and connected to the Turbo PMAC, the two
inputs of the pair should be in opposite logical states – one high and one low – yielding a true output from
the XOR gate.
If the input circuits for the encoder have been configured so that both lines of the pair have pull-up
resistors (this is not the default – either an E-point jumper must be changed or a SIP resistor pack reversed
in its socket), then an encoder or cabling failure will cause both inputs into the same logical state, yielding
a false output from the XOR gate, and setting an error status bit. Note that in this setting, a single-ended
encoder cannot be used on the channel.
The following table shows the resistor pack for each channel for Turbo PMACs and accessories with this
feature. To enable the encoder-loss feature, pin 1 of the resistor pack (marked by a dot on the package)
should be placed at the opposite end of the socket from pin 1 of the socket (marked by a white-ink square
on the circuit board). For the 4-channel accessories (Acc-24E2x and 24C2x), the first four channels
shown are for accessories addressed as an even-numbered Servo IC (2, 4, 6, or 8); the second four
channels shown are for accessories addressed as an odd-numbered Servo IC (3, 5, 7, or 9).
Resistor Packs for Encoder Loss Circuitry
Device Ch. 1 Ch. 2 Ch. 3 Ch. 4 Ch. 5/1 Ch. 6/2 Ch. 7/3 Ch. 8/4
PMAC-PCI RP60 RP62 RP66 RP68 RP97 RP99 RP103 RP105
PMAC2-PCI RP43 RP48 RP44 RP49 RP104 RP109 RP105 RP110
QMAC RP55 RP57 RP66 RP68 - - - -
Acc-24P2 RP74 RP75 RP85 RP86 RP139 RP140 RP150 RP151
Acc-24E2 RP22 RP24 RP22* RP24* RP22 RP24 RP22* RP24*
Acc-24E2A RP22 RP24 RP22* RP24* RP22 RP24 RP22* RP24*
Acc-24E2S RP19 RP21 RP27 RP29 RP19 RP21 RP27 RP29
Acc-24C2A RP33 RP34 RP63 RP64 RP33 RP34 RP63 RP64
* On the daughter board for the accessory module
The following table shows the address of the encoder-loss status bit for each channel of each device. The
address is always for a Y-register. The x shown in some of the addresses represents the hex digit 8, 9, A,
or B, the same as the base address of the card itself. The bit value is 1 for a valid encoder signal; 0 to
signify encoder loss.
Device Ch. 1 Ch. 2 Ch. 3 Ch. 4 Ch. 5/1 Ch. 6/2 Ch. 7/3 Ch. 8/4
PMAC-PCI $70801,1 $70801,2 $70801,3 $70801,4 $70801,5 $70801,6 $70801,6 $70801,7
PMAC2-PCI $78403,8 $78403,9 $78403,10 $78403,11 $78403,8 $78403,9 $78403,10 $78403,11
QMAC $78403,8 $78403,9 $78403,10 $78403,11 - - - -
Acc-24P2 $7xF00,0 $7xF00,1 $7xF00,2 $7xF00,3 $7xF00,4 $7xF00,5 $7xF00,6 $7xF00,7
Acc-24E2 $7xF08,5 $7xF09,5 $7xF0A,5 $7xF0B,5 $7xF0C,5 $7xF0D,5 $7xF0E,5 $7xF0F,5
Acc-24E2A $7xF08,5 $7xF09,5 $7xF0A,5 $7xF0B,5 $7xF0C,5 $7xF0D,5 $7xF0E,5 $7xF0F,5
Acc-24E2S $7xF08,5 $7xF09,5 $7xF0A,5 $7xF0B,5 $7xF0C,5 $7xF0D,5 $7xF0E,5 $7xF0F,5
Acc-24C2A $7xF08,5 $7xF09,5 $7xF0A,5 $7xF0B,5 $7xF0C,5 $7xF0D,5 $7xF0E,5 $7xF0F,5
As of this writing, there is no automatic action taken on detection of encoder loss. Users who want to
take action on detecting encoder loss should write a PLC program to look for a change in the encoder loss
bit and take the appropriate action. Generally, the only appropriate response is to kill (open loop, zero
output, disabled) the motor with lost encoder feedback; other motors may be killed or aborted as well.
The following example shows how all motors can be killed on detection of the loss of signal for Encoder
1, used as feedback for Motor 1, on a Turbo PMAC.
#define Mtr1OpenLoop M138
#define Enc1LossIn M180
#define Mtr1EncLossStatus P180
#define Lost 0 ; Low-true fault
#define OK 1
Mtr1OpenLoop->Y:$0000B0,18,1 ; Standard definition
Enc1LossIn->Y:$078403,8,1 ; CTRL0 input
OPEN PLC 18 CLEAR
; Logic to disable and set fault status
IF (Mtr1OpenLoop=0 AND Enc1LossIn=Lost) ; Closed loop, no enc
CMD^K
Mtr1EncLossStatus=1
ENDIF
• 5V power-supply disturbances
• Loose connections
2. If there is an immediate watchdog timer trip in Step 1, power up with the re-initialization jumper ON.
If it does not trip now, there is a problem in the servo/phase task loading for the frequency, or an
immediate software problem on the board. Check for the following:
• Phase and servo clock frequencies vs. the number of motors used by Turbo PMAC. These
frequencies may need to be reduced.
• A PLC 0 or PLCC 0 program running immediately on power-up (I5 saved at 1 or 3) and taking
too much time.
• User-written servo or phase program not returning properly.
3. If there is an immediate watchdog timer trip in Step 2, check for hardware issues:
• Correct settings of clock-frequency jumpers (Turbo PMAC)
• Jumpers set for external servo and phase clock, but none provided
• Disconnect any accessories and repeat to see if they are causing the problem
• Check for adequate 5V power supply levels (check at the Turbo PMAC CPU, not at the supply)
• Inspect for hardware damage
4. If nothing is found in Step 3, power up with the firmware reload (bootstrap) jumper ON. If there is
no watchdog timer trip here and you can do basic communications (??? should cause a BOOTSTRAP
ROM reply), there is a problem with your operational firmware and it must be reloaded.
The following table summarizes the different commands that can be used to stop motion and their
attributes:
Command Scope Begin Stop on Stop at Decel Notes
Immed? Path? Prog Pt? Rate
J/ Motor Yes –- No Ixx19-
21
A C.S. Yes No No Ixx15 No easy restart
<CTRL-A> Global Yes No No Ixx15 No easy restart
Q C.S. No Yes Yes TA, TS Finishes calculated moves
<CTRL-Q> Global No Yes Yes TA, TS Finishes calculated moves
/ C.S. No Yes Yes TA, TS End of currently executing
move*, undoes blending
H C.S. Yes Yes No Isx95 Similar to %0
<CTRL-O> Global Yes Yes No Isx95 Similar to %0
\ C.S. Yes Yes No Ixx17/ Acts as H command if
Isx95 outside of lookahead
K Motor Yes No No — Must stop program first
<CTRL-K> Global Yes No No — Must stop program first
Program Checksums
Firmware Checksum
Turbo PMAC continually computes the checksum of its internal program (firmware) as a background
task. Each time it has computed the checksum, it compares this value to a reference register in memory
(obtainable with the CHECKSUM command) that has been manually entered with the correct value. Turbo
PMACs shipped from the factory are preloaded with the correct reference value for that firmware version
at the factory.
If Turbo PMAC detects a mismatch between its calculated checksum and the reference checksum, it sets
global status bits (bits 12 and 13 of X:$000006 – accessible with the ??? command) and stops
performing any checksum operations. This leaves the calculated value frozen in the running checksum
register X:$001080. Turbo PMAC does take any other action in the event of a firmware checksum error;
it is up to the host or a Turbo PMAC PLC program to decide what action to take.
When a Turbo PMAC is upgraded to new firmware by replacement of the PROM IC in standard CPU
sections or downloading of new firmware into the flash EEPROM IC in Option CPU sections, the
reference checksum value will be updated automatically for the new firmware.
User-Program Checksum
Turbo PMAC continually computes the checksum of the fixed user program buffers as a background task.
Each time it has computed the checksum, it compares this value to the checksum value that was computed
the last time one of these buffers was closed, stored in X:$001090.
If Turbo PMAC detects a mismatch between these two checksums, it sets a global status bit (bit 13 of
X:$000006 – accessible with ???) and stops performing any program or firmware checksum operations
(communications checksum is independent), freezing the running checksum value in X:$001080. It does
not shut down operation automatically. It is up to the host or a Turbo PMAC PLC program to decide
what action to take if there is a checksum error.
Jog Speed
Jogging speed is specified by Ixx22, which is a magnitude of the velocity, in counts per millisecond.
Direction is specified by the jog command itself.
V
Ix20 > 2 * Ix21
V
Ix20 < 2 * Ix21
Ix21
2*Ix21
Ix21 Ix21
2*Ix21
Ix21
T
V
Ix21=0
Ix20 Ix20
T
Vel
Move Timer Active = 1
Desired Velocity Zero = 0
In Position = 0
Ix22
Desired Velocity Zero = 1
Running a Program = 0
In Position = 1
(when FE in range)
Time
Ix21 Ix21 Ix21 Ix21
Jog Start
given (J+)
Ix20 Ix20
I12 I12
[Ixx90] [Ixx90]
Note: if the jog command is not of Note: Rate of acceleration
the indefinite length (not J+ or J-) then limited by Ix19 - can override
the “Running a Program” status bit will Ix20 and Ix21
be high for the entire jog move
Jog Commands
The commands to jog a motor are on-line (immediate) commands that are motor-specific; they act on the
currently addressed motor.
Note:
A jog command to a motor will be rejected if the motor is in a coordinate system
that is currently executing a motion program, even if the motion program is not
commanding that motor to move. PMAC will report ERR001 if I6 is set to 1 or 3.
Indefinite Jog Commands
J+ commands an indefinite positive jog for the addressed motor; J- commands an indefinite negative
jog; J/ commands an end to the jog, leaving the motor in position control after the deceleration. It is
possible for the J/ command to leave the commanded position at a fractional count, which can cause
dithering between the adjacent integer count values. If this is a problem, the J! command can be used to
force the commanded position to the nearest integer count value. (Alternatively, ½-count of deadband
created with Ixx64 and Ixx65 can prevent dithering at fractional count values.
Jogging to a Specified Position
Jog commands to a specified position, or of a specified distance, can be given. J= commands a jog to the
last pre-jog position; J={constant} commands a jog to the (unscaled) position specified in the
command; J=={constant} commands a jog to the (unscaled) position specified in the command and
makes that position the pre-jog position; J^{constant} commands a jog of the specified distance from
the actual position at the time of the command (J^0 can be useful to take up remaining following error);
J:{constant} commands a jog of the specified distance from the commanded position at the time of
the command.
Jog Moves Specified by a Variable
Jogging moves to a position or of a distance specified by a variable are possible. Each motor has a
specific register (L:$0000D7 for Motor 1, L:$000157 for Motor 2, etc., suggested M-variables Mxx72)
that holds the position or distance to move on the next variable jog command. This register contains a
floating-point value scaled in encoder counts. It should be accessed with an L-format (floating-point) M-
variable. The J=* command causes PMAC to use this value as a destination position. The J^*
command causes PMAC to use the value as a distance from the actual position at the time of the
command. The J:* command causes PMAC to use the value as a distance from the commanded position
at the time of the command.
Issuing Commands During Jog Moves
It is permissible to issue a jog command to a motor that is already jogging. On receipt of the new
command, Turbo PMAC will break into the already planned trajectory and create a smooth blend to the
trajectory of the new command as determined by the present acceleration and velocity commands. The
existing trajectory is extended out for Ixx92 milliseconds (default 10 msec) after receipt of the new
command; during this time the new trajectory is calculated. The calculations for the new move must be
able to complete within Ixx92 msec.
Parameters Used by Jog Commands
Each time one of these commands is given, the acceleration and velocity parameters at that time control
the response to the command. To change speed or acceleration parameters of an active jog move, change
the appropriate parameters, and then issue another jog command.
Homing Acceleration
The acceleration for homing search moves is controlled by the same parameters – Ixx19 (maximum
acceleration), Ixx20 (acceleration time), and Ixx21 (S-curve time) – as for jogging moves. These are
described in the above section on jogging moves.
Homing Speed
Ixx23 specifies the speed and direction of the homing-search move. If Ixx23 is greater than zero, the pre-
trigger homing-search move will be in positive direction. If it is less than zero, the pre-trigger move will
be in the negative direction. The magnitude of Ixx23 (expressed in counts/msec) controls the speed of
both the pre-trigger and post-trigger moves (should they be long enough to get to this speed).
Home Trigger Condition
The trigger condition for homing-search moves, as for other triggered moves, is specified by Ixx97,
Ixx24, and Ixx25, as described above in detail. If no trigger is found, the pre-trigger move will continue
indefinitely, or until stopped by an error condition such as hitting overtravel limits.
Post-Trigger Move
Variable Ixx26 specifies the (signed) distance from the trigger-captured position to the end of the post-
trigger move. The units of Ixx26 are 1/16 count. The endpoint of the commanded post-trigger move is
the new motor position zero (the motor’s “home” position). The change of the motor’s reported position
reference occurs at the beginning of the post-trigger move. As soon as this is done, reported positions are
referenced to this new zero position (plus or minus any axis offset in the axis definition statement – if the
axis definition is #1->10000X+3000, the home position will be reported as 3000 counts). Also at this
point, the motor’s “home search in progress” status bit is cleared, and the “home complete” status bit is
set.
If the post-trigger move fails with an error condition, it is not necessary to re-home the motor, as the
home position is already known. A command such as J=0 can move the motor to the home position once
the source of the problem has been cleared up.
If software overtravel limits are used (Ixx13, Ixx14 not equal to zero), they are re-enabled at this time
after having been automatically disabled during the search for the trigger. The trajectory to this new zero
position is then calculated, including deceleration and reversal if necessary. Note that if a software limit
is too close to zero, the motor may not be able to stop and reverse before it hits the limit. In normal
termination, the motor will stop under position control with its commanded position equal to the home
position. If there is a following error, the actual position will be different by the amount of the following
error.
Failure to Find Trigger
The pre-trigger move of a homing search will continue indefinitely if it fails to find the trigger condition it
is looking for. Typically, it will be stopped by an overtravel position limit switch or fatal following error
limit at the end of travel in this case. If you want a programmed limit to the length of the pre-trigger
move, you should use an incremental jog-until-trigger command or programmed move-until-trigger, with
the first value specifying the distance to move in the absence of a trigger, and the second the distance
from the trigger to the end of the post-trigger move (replacing Ixx26). Once the post-trigger move is
finished, a HOMEZ command (see below) can be used to set this position to be the motor zero position.
Time
Ix21 Ix21 Ix21
Ix20
Desired Velocity Zero=1
In Position=1
(when FE in range)
Home Command
The homing search move can be executed either through an on-line command (which can be given from a
PLC program using the COMMAND"" syntax) or a motion program statement.
On-Line Command
A homing search move can be initiated with the on-line motor-specific command HOME (short form HM),
for example #1HM. This is simply a command to start the homing search; Turbo PMAC provides no
automatic indication that the move is completed, unless set up to recognize the in-position (IPOS)
interrupt.
Monitoring for Finish: If monitoring the motor from the host or from a PLC program to see if it has
finished the homing move, it is best to look at the home complete and desired velocity zero motor status
bits, accessed either with the ? command or with M-variables. The home complete bit is set to zero on
power-up/reset; it is also set to zero at the beginning of a homing search move, even if a previous homing
search move was completed successfully. It is set to one as soon as the trigger is found in a homing
search move, before the motor has come to a stop.
Note:
The home search in progress bit is the inverse of the home complete bit during the
move: it is 1 until the trigger is found, then 0 immediately after. Therefore the
monitoring should also look for the desired velocity zero status bit to become 1,
which will indicate the end of the post-trigger move.
Monitoring for Errors: A robust monitoring algorithm will also look for the possibility that the homing
search move could end in an error condition. Often this is just part of the general error monitoring that is
done at all times, looking for overtravel limits, fatal following errors, and amplifier faults. If an error
does occur during the homing move, it is important to distinguish between one that occurs before the
trigger has been found, and one that occurs after. If the error occurs after, Turbo PMAC knows where the
home position is, and the homing search does not need to be repeated. Once the error cause has been
fixed, the motor can simply be moved to the home position with a command such as J=0.
Buffered Motion-Program Command
The homing search move also can be commanded from within a motion program with the HOMEn
command, where n is the motor number. Note that this command specifies a motor; unlike other motion
program commands that specify an axis move. In a motion program, Turbo PMAC’s automatic program
sequencing routines monitor for the end of the move. When the move is successfully completed, program
execution continues with the next command.
Multiple homing moves can be started together by specifying a list or range of motor numbers with the
command (e.g. HOME1,3 or HOME2..6). Further program execution will wait for all of these motors to
finish their homing moves. Separate homing commands, even on the same line (e.g. HOME1 HOME2)
will be executed in sequence, with the first finishing before the second starts. It is not possible to execute
partially overlapping homing moves from a single motion program.
Note:
Note carefully the difference in syntax between the on-line command and the
buffered command. The on-line command is simply HOME or HM, and it acts on
the currently addressed motor, so the motor number must be specified in front of
the command (e.g. #1HM). In the buffered command, the motor number is part of
the command, following immediately after HOME or HM letters (e.g. HM1).
Homing from a PLC Program
Turbo PMAC PLC programs can command homing search moves by giving on-line commands with the
COMMAND"" statement (e.g. COMMAND"#1HM"). These commands simply start the homing search
move; code must be written to monitor for finishing if that is desired. The motor number must be
specified in the specific command string, or with the ADDRESS#n statement; without this statement,
motor addressing is not modal within PLC programs.
Motion vs. PLC Program Homing
The following table summarizes the differences between homing using motion programs and PLC
programs.
Motion Programs PLC Programs
Program execution point stays on the line The PLC does not automatically monitor
containing the Home command until the for the start and end of the homing move.
homing move is finished.
Home command can be combined with Axis motion can only be performed
programmed axis moves. through Jog commands. .
The C.S. must be ready to run a motion The C.S. does not need to be ready to run
program. a motion program.
Can only home motors defined in the C.S. Can home any motor not defined in a C.S.
running the program. presently running a program.
Motors can be homed simultaneously, one Motors can be homed in any order. This
after another, or any combination of the includes starting one motor in the middle
two. All motors started together must of another motor's home move.
finish before next action can start.
The motion program must be started by an The PLC can be started by an on-line
on-line command, a PLC program, or command, a PLC program, another
another motion program. motion program, or automatically at
power-up or reset.
Zero-Move Homing
To declare the current position the home position without commanding any movement, use the HOMEZ
(on-line) or HOMEZn (motion program) command. These are like the HOME command, except that they
immediately take the current commanded position as the home position. The Ixx26 offset is not used
with the HOMEZ command. This no-move homing is useful both for early development, before the true
homing procedure is developed, and for specialized homing routines not supported by Turbo PMAC’s
automatic homing procedures.
Note:
If there is a following error when the HOMEZ command is given, the reported
actual position after the HOMEZ command will not be exactly zero; it will be equal
to the negative of the following error.
Homing Into a Limit Switch
It is possible to use a limit switch as a home switch. However, first disable the limit function of the limit
switch for the move to finish normally; if this is not done, the limit function will abort the homing search
move. Even so, the home position has been set; a J=0 command can then be used to move the motor to
the home position.
Note:
On PMAC-style servo channels, the polarity of the limit switches is the opposite of
what many people would expect. The -LIMn input should be connected to the
limit switch at the positive end of travel; the +LIMn input should be connected to
the limit switch at the negative end of travel.
To disable the limit function of the switch, set bit 17 of variable Ixx24 (bit value $20000) for the motor to
1. It is a good idea to use the home offset parameter Ixx26 to bring the home position out of the limit
switch, so the limits can be re-enabled immediately after the homing search move, without being in the
limit.
The following examples show two quick routines to do this type of homing. One uses a motion program
and the other a PLC program. The same function could also be done with on-line commands.
;*********** Motion Program Set-up Variables (to be saved) *************
CLOSE
I123=-10 ; Home speed 10 cts/msec negative
I124=$000000 ; PMAC-style flags, normal mode
I125=$78000 ; Use Servo IC 0 Channel 1 flags for Motor 1
I126=32000 ; Home offset of +2000 counts
; (enough to take you out of the limit)
I7102=3 ; Capture on rising flag and rising index
I7103=2 ; Use +LIM1 as flag (negative end switch)
;*********** Motion program to execute routine *********************
OPEN PROG 101 CLEAR
I124=$20000 ; Disable +/-LIM as limits
HOME1 ; Home #1 into limit and offset out of it
I124=$0 ; Re-enable +/-LIM as limits
CLOSE ; End of program
;*********** PLC Set-up Variables (to be saved) ************************
CLOSE
I123=-10 ; Home speed 10 cts/msec negative
I124=$000000 ; PMAC-style flags, normal mode
I125=$78000 ; Use Servo IC 0 Channel 1 flags for Motor 1
I126=32000 ; Home offset of +2000 counts
; (enough to take you out of the limit)
I902=3 ; Capture on rising flag and rising index
I903=2 ; Use +LIM1 as flag (negative end switch)
M133->X:$B0,13,1 ; Desired Velocity Zero bit
M145->Y:$C0,10,1 ; Home complete bit
ENDWHILE
I223=-10 ; Home speed 10 cts/msec negative direction
I224=$0 ; Re-enable hardware limits
I7222=11 ; Capture on flag low and index channel high
I7223=0 ; Use HOME2 (home flag) as trigger flag
CMD"#2HM" ; Do actual homing move
WHILE (M245=1) ; Waits for Home Search to start
ENDWHILE
WHILE (M233=0) ; Waits for Home motion to complete
ENDWHILE
DIS PLC11 ; Disables PLC once Home is found
CLOSE ; End of PLC
Already Into Home? A similar situation occurs when it is not known on power-up whether or not it is
already into the home trigger. Here, the easiest solution is to write a program that evaluates this
condition; if it is in the trigger, it moves out before doing the real homing.
;*************** Motion Program Set-up variables (to be saved) *********
CLOSE
M320->X:$078210,20,1 ; Variable for Servo IC 2 Ch. 3 home input
I325=$078210 ; Use Flags3 for Motor 3
;************** Motion program to execute routine *********************
OPEN PROG 103 CLEAR
IF (M320=1) ; Already in trigger?
I323=10 ; Home speed 10 cts/msec positive direction
I326=1600 ; Home offset +100 counts (to make sure clear)
I7232=11 ; Capture on falling flag and rising index
I7233=0 ; Use Home3 as flag
HOME3 ; "Home" out of switch
ENDIF
I323=-10 ; Home speed 10 cts/msec negative direction
I326=0 ; No home offset
I7232=3 ; Capture on rising flag and rising index
I7233=0 ; Use HMFL3 as flag
HOME3 ; Do actual homing move
CLOSE ; End of program
;***************PLC Set-up variables (to be saved) ********************
CLOSE
M320->X:$078210,20,1 ; Variable for Servo IC 2 Ch. 3 home input
I325=$078210 ; Use Flags3 for Motor 3
M333->X:$01B0,13,1 ; Desired Velocity Zero bit
M345->Y:$01C0,10,1 ; Home complete bit
;**************** PLC program to execute routine *********************
OPEN PLC 12 CLEAR
IF (M320=1) ; Already in trigger?
I323=10 ; Home speed 10 cts/msec positive direction
I326=1600 ; Home offset +100 counts (to make sure clear)
I7232=11 ; Capture on falling flag and rising index
I7233=0 ; Use Home3 as flag
CMD"#3HM" ; “Home” out of switch
WHILE (M345=1) ; Waits for home search to start
ENDWHILE
WHILE (M333=0) ;Waits for home motion to complete
ENDWHILE
ENDIF
I323=-10 ; Home speed 10 cts/msec negative direction
I326=0 ; No home offset
I7232=3 ; Capture on rising flag and rising index
I7233=0 ; Use Home3 as flag
CMD"#3HM" ; Do actual homing move
WHILE (M345=1) ; Waits for home search to start
ENDWHILE
WHILE (M333=0) ; Waits for home motion to complete
ENDWHILE
DIS PLC12 ; Disables PLC once home is found
CLOSE ; End of program
Storing the Home Position
Turbo PMAC automatically stores the encoder position that was captured during the latest homing search
move for the motor. This value is kept in the Motor Encoder Home Capture register [Y:$CE (Motor 1),
Y:$14E (Motor 2), etc., suggested M-variable Mxx73], which is set to zero on power-up/reset for motors
without absolute power-on position. If the position reference is obtained by reading an absolute sensor
(Ixx10>0) such as from a resolver, this register holds the negative of the absolute position read. In either
case, it contains the difference between the encoder-counter zero position (power-on position) and the
motor zero (home) position, scaled in counts.
There are two main uses for this register. First, it provides a reference for using the encoder position-
capture and position-compare registers. These registers are referenced to the encoder zero position, which
is the power-up position, not the home (motor zero) position. This register holds the difference between
the two positions. This value should be subtracted from encoder position (usually from position capture)
to get motor position, or added to motor position to get encoder position (usually for position compare).
Example: To move an axis until a trigger is found, then convert the captured encoder position to a motor
position, you can use the following M-variable definitions:
M103->X:$078003,24,S ; Servo IC 0 Channel 1 position-capture register
M117->X:$078000,17 ; Servo IC 0 Channel 1 position-capture flag
M125->Y:$0000CE,24,S ; Motor 1 encoder position offset register
Now you can use a motion program segment like the following:
INC ; Incremental moves
TM10 TA10 ; Move segment time 10 msec
WHILE (M117=0) ; While no trigger to capture position
X0.2 ; Command next move segment
ENDWHILE
P103=M103-M125 ; Read captured position; subtract offset to
; get motor position at trigger
The second use for this register is to determine whether the encoder counter has lost any counts. This can
be done by performing a second homing search move after an operation, and comparing the contents of
the register after the second homing search move to the contents after the first homing search move.
Jog-Until-Trigger Moves
The jog-until-trigger function permits a jog move to be interrupted by a trigger and terminated by a move
relative to the position at the time of the trigger. It is similar to a homing search move, except that the
motor zero position is not altered, and there is a specific destination in the absence of a trigger.
The “jog-until-trigger” function for a motor is specified by adding a ^{constant} specifier to the end
of a regular “definite” jog command for the motor, where this {constant} is the distance to be traveled
relative to the trigger position before stopping, in encoder counts. It cannot be used with the J+ and J-
indefinite jog commands.
This makes the jog command for a jog-until trigger something like J=10000^100 , J=*^-50 or
J:50000^0. The value before the ^ is the destination position or distance (depending on the type of jog
command) to be traveled in the absence of a trigger. If this first value is represented by a * symbol,
PMAC looks in a pre-defined motor register (suggested M-variable Mxx72) for the position or distance.
The second value is the distance to be traveled relative to the position at the time of the trigger. This
value is always expressed as a distance, regardless of the type of jog command. Both values are
expressed in encoder counts.
The trigger condition for the motor is set up just as for homing search moves, explained above.
Turbo PMAC will use the jog parameters Ixx19-Ixx22 in force at the time of the command for the pre-
trigger move, and the values of these parameters in force at the time of the trigger for the post-trigger
move.
The captured value of the sensor position at the trigger is stored in a dedicated register (Y:$D8 for Motor
1, Y:$158 for Motor 2, etc.) if later access is needed. The units are in counts; for incremental encoders,
they are relative to the power-up/reset position.
Turbo PMAC sets the motor home-search-in-progress status bit (bit 10 of the first motor status word
returned on a ? command) true (1) at the beginning of a jog-until-trigger move. The bit is set false (0)
either when the trigger is found, or at the end of the move.
Turbo PMAC also sets the motor trigger move status bit (bit 7 of the second motor status word returned
on a ? command) true at the beginning of a jog-until-trigger move, and keeps it true at least until the end
of the move. If a trigger is found during the move, this bit is set false at the end of the post-trigger move;
however, if the pre-trigger move finishes without finding a trigger, the bit is left true at the end of the
move. Therefore, this bit can be used at the end of the move to tell whether the trigger was found
successfully or not. The motor “desired-velocity-zero” status bit can be used to determine the end of the
move.
Motion Program Move-Until-Trigger
The move-until-trigger construct can be used from within a motion program. In this version it is a variant
of the RAPID move mode. These moves execute exactly like on-line jog-until-trigger moves, but they are
described a little differently.
A program move-until trigger is commanded with the {axis}{data}^{data} syntax. Basic
examples are X50^-2 and Y(P1)^(P2). The first value is the destination of the axis if no trigger is
found, expressed in the engineering units for the axis. This value can be a position or a distance,
depending on whether the axis is in absolute or incremental mode, respectively. The second value is the
distance from the trigger-captured position to the end of the post-trigger move, expressed in the
engineering units for the axis. The motion program must be in RAPID mode for the triggering to operate;
otherwise just the pre-trigger move will be executed to the specified endpoint.
The commanded acceleration for the move is specified by Ixx19, Ixx20, and Ixx21, as for other trigger
moves. The magnitude of the velocity for the move is specified by maximum velocity parameter Ixx16 if
Ixx90 is at the default value of 1, or by jog speed parameter Ixx22 if Ixx90 is 0. The trigger conditions
and capture methods are specified as for other triggered moves, as described above. Status bits are set as
for on-line jog-until-trigger moves.
For more information on these moves, look under RAPID-mode moves in the Writing and Executing
Motion Programs section and in the description of {axis}{data}^{data} motion-program
statements in the Software Reference manual.
Open-Loop Moves
Open-loop moves, as their name implies, do not do closed-loop position control. They open up the servo
loop and just put commands of the specified magnitude on the outputs. Typically, these are used for
diagnostic purposes, but they can also be used in the actual applications.
These moves are executed using the motor-specific O{constant} on-line command, where
{constant} represents the magnitude of the output as a percentage of Ixx69, the maximum output
parameter for the motor. This command may not be part of a motion program, and it may not be given to
a motor when that motor’s coordinate system is executing a motion program, even if it is not moving that
motor.
If Turbo PMAC does not commutate the motor, this command creates a constant signal on the single
output for the motor. If Turbo PMAC does commutate the motor, this command sets the magnitude of
the signal that is input into the sinusoidal commutation algorithm for the motor.
To do a variable O-command, define an M-variable to the filter result register (X:$AE for Motor 1, etc.),
command an O0 to the motor to put it in open-loop mode, then assign a variable value to the M-variable.
This technique will even work on PMAC-commutated motors.
The PMAC Executive Program tuning section uses the open-loop moves to allow you to diagnose and
tune amplifier response.
*
CT #1 #2 #3 #4 PLC 0 PLC 1...
Servo Background
Servo Background
*
CT #1 #2 #3 #4 PLC 0 Move Planning ...
Servo RTI
Servo Background
*
CT #1 #2 #3 #4 PLC 0 PLC 1 (cont) ...
Servo RTI
Servo Background
The internal format of 48-bit floating-point registers is shown in the following table:
X-word:
Bit: 23 22 21 20 19 18 17 16 15 14 13 12
Part: Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant
Val: -20 +2-1 +2-2 +2-3 +2-4 +2-5 +2-6 +2-7 +2-8 +2-9 +2-10 +2-11
Bit: 11 10 9 8 7 6 5 4 3 2 1 0
Part: Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant
Val: +2-12 +2-13 +2-14 +2-15 +2-16 +2-17 +2-18 +2-19 +2-20 +2-21 +2-22 +2-23
Y-word:
Bit: 23 22 21 20 19 18 17 16 15 14 13 12
Part: Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant Mant
Val: +2-24 +2-25 +2-26 +2-27 +2-28 +2-29 +2-30 +2-31 +2-32 +2-33 +2-34 +2-35
Bit: 11 10 9 8 7 6 5 4 3 2 1 0
Part: Exp Exp Exp Exp Exp Exp Exp Exp Exp Exp Exp Exp
Val: +211 +210 +29 +28 +271 +26 +25 +24 +23 +22 +21 +20
Reporting Values
Turbo PMAC reports numerical values to the host computer as part of response lines in decimal ASCII
text form (although address values can be reported in hexadecimal ASCII form if I9 = 2 or 3 – see below).
+47 +14
The value reporter is limited to passing values in the range of +2 , or +1.41 x 10 . Values outside of
this range are truncated to the maximum or minimum values of the range.
Addresses
Turbo PMAC uses a Motorola DSP563xx as its processor. The DSP563xx has dual 24-bit address spaces
(of which 19 bits are used by the Turbo PMAC) for memory and I/O. (Note that the I/O in Turbo PMAC
is memory-mapped; it does not have a separate I/O space as your PC does.) When specifying an address
in Turbo PMAC, you must state which half of memory (X or Y) – or both halves (L) for a long 48-bit
word – followed by an optional colon, followed by the numerical address itself. The numerical address is
a constant in the range of $000000 - $07FFFF. Usually, the address values are specified as a hexadecimal
value (with the $ prefix).
Do not confuse the memory and I/O addresses of Turbo PMAC itself with those of the host computer.
Examples of legal address specifications are:
Y:$078A02 (word containing machine I/O)
X:136 (Motor 1 commanded position – also X:$88)
X$078003 (captured encoder 1 position)
This form of address specification is used particularly in M- variable definitions and direct read (R) and
write (W) commands. There are I-variables that specify addresses, but usually these are pre-defined to the
X or Y space, so all that is needed is the numerical value. The data-gathering-address I- variables (I5001-
I5048) use an extra hex digit in front of the numerical value to specify the memory half (see I5001
description).
Variables
Turbo PMAC has several types of variables. In Turbo PMAC, a variable is specified by a single letter (I,
P, Q, or M) followed by a number from 0 to 8191. Each letter denotes a different type of variable, each
type with its own properties. The different types share the characteristics that when their name is cited in
an expression, the current value of the variable is used (reading from them); and values can be assigned to
them in an equation (writing to them).
Custom variable names on Turbo PMAC may not be specified; however the Editor in the PMAC
Executive Program has a substitution (macro) scheme that allows programs to be written using user-
defined variable names, but changes these names into Turbo PMAC-legal variable names during the
download process. This substitution scheme is strongly recommended for managing large applications.
I-Variables
I-Variables (initialization or setup variables) determine the personality of the card for a given application.
They are at fixed locations in memory and have pre-defined meanings. Most are integer values, and their
range varies depending on the particular variable. There are 1024 I-variables, from I0 to I8191, and they
are organized as follows:
I0 – I99 Global card setup
I100 – I199 Motor 1 setup
I200 – I299 Motor 2 setup
…
I3200 – I3299 Motor 32 setup
I3300 – I4799 Supplemental Motor setup
I4900 – I4999 Configuration status
I5000 – I5099 Data gathering/ADC demux setup
I5100 – I5199 Coordinate System 1 setup
I5200 – I5299 Coordinate System 2 setup
…
I6600 – I6699 Coordinate System 16 setup
I6800 – I6999 MACRO IC setup
I7000 – I7999 Servo IC setup
I8000 – I8191 Encoder conversion table setup
Value Assignment
Values assigned to an I-variable may be either a constant or an expression. The commands to do this are
on-line (immediate) if no buffer is open when sent, or buffered program commands if a buffer is open.
Examples:
I120=45
I120=I120+5
I(P1*100+20)=10
Limited Range
For I-variables with limited range, an attempt to assign an out-of-range value does not cause an error.
The value is automatically rolled over to within the range by modulo arithmetic (truncation). For
example, I3 has a range of 0 to 3 (4 possible values). The command I3=5 would assign a value of (5
modulo 4) = 1 to the variable.
Non-Volatile Storage
When a value is assigned to an I-variable, the value in an active memory register that is volatile (does not
retain its value when power is removed) is being removed. Copy all of these active values to non-volatile
flash memory with the SAVE command. On a power-up or reset, the last values saved into flash memory
are copied back into active memory automatically for use.
Default Values
Default values for all I-variables are contained in the manufacturer-supplied firmware. They can be used
individually with the I{constant}=* command, or in a range with the
I{constant}..{constant}=* command. Upon board re-initialization by the $$$*** command
or by a reset with the re-initialization jumper in the non-default setting, all default settings are copied
from the firmware into active memory. The last saved values are not lost; they are just not used.
See the I-variable description section for the functions of individual variables.
P-Variables
P-variables are general-purpose user variables. They are 48-bit floating-point variables at fixed locations
in Turbo PMAC’s memory, but with no pre-defined use. There are 8192 P-variables, from P0 to P8191.
A given P-variable means the same thing from any context within the card; all coordinate systems have
access to all P-variables (contrast Q-variables, which are coupled to a given coordinate system, below).
This allows for useful information passing between different coordinate systems. P-variables can be used
in programs for any purpose desired: positions, distances, velocities, times, modes, angles, intermediate
calculations, etc.
Type of Memory Used
P-variables can be located in either the main memory, or in the supplemental battery-backed parameter
memory (if Option 16 is ordered). If I46 is set to 0 (default) or 2, the P-variables are located in the main
memory, which has fast access (1 wait state) but whose values are not retained without a SAVE command
copying the values to flash memory. On power-up/reset, the last saved values are copied from flash
memory into the active variable registers in RAM.
If I46 is set to 1 or 3, the P-variables are located in the Option 16 battery-backed RAM, which has slow
access (9 wait states) but whose values are retained automatically by the battery when power is removed.
Special-Use P-Variables
Generally, Turbo PMAC firmware has no automatic use of P-variables. However, it can make special use
of variables P0 – P32 and P101 – P132, as described below.
If a command consisting simply of a constant value is sent to Turbo PMAC, Turbo PMAC assigns that
value to variable P0 (unless a special table buffer such as a compensation table or stimulus table has been
defined but not yet filled – in that case the constant value will be entered into the table. For example, if
the command 342<CR> is sent to Turbo PMAC, it will interpret it as P0=342<CR>.)
This capability is intended to facilitate simple operator terminal interfaces. It does mean, however, that it
is not a good idea to use P0 for other purposes, because it is easy to change this variable’s value
accidentally.
If your application uses kinematic subroutines to convert between tool-tip (axis) positions and joint
(motor) positions, variables P1 – P32 and P101 – P132 are used for the motor positions in these
subroutines (Pn is Motor n position; if PVT moves are converted, P10n is Motor n velocity). If you are
using the kinematic subroutines, make sure not to use the P-variables employed in the subroutines for any
other purpose.
Q-Variables
Q-variables, like P-variables, are general-purpose user variables – 48-bit floating-point variables at fixed
locations in memory, with no pre-defined use. However, the register using a given Q-variable (and hence
the value contained in it) is dependent on which coordinate system is utilizing it. This allows several
coordinate systems to use the same program (for instance, containing the line X(Q1+25) Y(Q2), but to
have different values in their own Q variables (which in this case, means different destination points).
Allotting Q-Variables
There is a total of 8192 Q-variables. If using only a single coordinate system (Coord.Sys. 1 – specified as
&1), use all of these: Q0 to Q8191. The Q-variables of Coordinate System 2 (&2) overlap these: Q0 of
&2 is the same thing as Q4096 of &1, and Q4095 of &2 is the same thing as Q8191 of &1. (The Q buffer
is actually rotary, so Q4096 of &2 is the same thing as Q0 of &1, and Q8191 of &2 is Q4095 of &1.)
Thus, both coordinate systems have 4096 unique Q-variables: Q0 to Q4095.
Note:
There is no protection against overwriting another coordinate system’s Q-
variables. It is your responsibility to keep Q-numbers within the proper range.
If using 3 or 4 coordinate systems, there are 2048 unique Q-variables for each coordinate system (Q0 –
Q2047). If using 5 to 8 coordinate systems, there are 1024 unique Q-variables for each coordinate system
(Q0 – Q1023). If using 9 to 16 coordinate systems, there are 512 unique Q-variables for each coordinate
system (Q0 – Q511).
The following table shows the addresses used to store Q0 for each coordinate system when the Q-
variables are stored in main memory. It shows how they potentially overlap.
CS # Q0 CS # Q0 CS # Q0 CS # Q0
Address Address Address Address
1 $8000 5 $8400 9 $8200 13 $9200
2 $9000 6 $8C00 10 $8600 14 $9600
3 $8800 7 $9400 11 $8A00 15 $9A00
4 $9800 8 $9C00 12 $8E00 16 $9E00
When accessing a Q-variable from a motion program statement (including kinematic subroutines), the Q-
variable belonging to the coordinate system running the program is being used. If a different coordinate
system runs the same motion program, it will use different Q-variables.
When accessing a Q-variable from a PLC program statement, the Q-variable for the coordinate system
that has been addressed by that PLC program with the ADDRESS command is being used. Each PLC
program can address a particular coordinate system independent of other PLC programs and independent
of the host addressing. If no ADDRESS command is used in the PLC program, the program uses the Q-
variables for C.S. 1.
Type of Memory Used
Q-variables can be located in either the main memory or in the supplemental battery-backed parameter
memory (if Option 16 is ordered). If I46 is set to 0 (default) or 1, the Q-variables are located in the main
memory, which has fast access (1 wait state) but whose values are not retained without a SAVE command
copying the values to flash memory. On power-up/reset, the last saved values are copied from flash
memory into the active variable registers in RAM.
If I46 is set to 2 or 3, the Q-variables are located in the Option 16 battery-backed RAM, which has slow
access (9 wait states) but whose values are retained by the battery automatically when power is removed.
Special-Use Q-Variables
Several Q-variables have special uses to watch for. The ATAN2 (two-argument arctangent) function
automatically uses Q0 as its second argument (the cosine argument). The READ command places the
values it reads following letters A through Z in Q101 to Q126, respectively, and a mask word denoting
which variables have been read in Q100. The S (spindle) statement in a motion program places the value
following it into Q127.
If the application uses kinematic subroutines to convert between tool-tip (axis) positions and joint (motor)
positions, variables Q1 – Q10 and possibly Q11 – Q19 for the coordinate system are used for the axis data
in these subroutines (Q1 – Q9 are for axis positions; Q10 tells whether PVT moves are being converted; if
PVT moves are converted, Q11 – Q19 are for axis velocities). If using the kinematic subroutines, make
sure not to use the Q-variables employed in the subroutines for any other purpose.
M-Variables
M-variables are provided to permit easy user access to Turbo PMAC’s memory and I/O space. Generally,
a definition only needs to be made once, with an on-line command. The SAVE command must be used to
retain the definition through a power-down or reset. Define an M-variable by assigning it to a location
and defining the size and format of the value in this location. An M-variable can be a bit, a nibble (4
bits), a byte (8 bits), 1-1/2 bytes (12 bits), a double-byte (16 bits), 2-1/2 bytes (20 bits), a 24-bit word, a
48-bit fixed-point double word, a 48-bit floating-point double word, or special formats for dual-ported
RAM and for the JTHW multiplexer port.
There are 8192 M-variables (M0 to M8191), and as with other variable types, the number of the M-
variable may be specified with either a constant or an expression: M576 or M(P1+20).
M-Variable Definitions
The definition of an M-variable is done using the defines-arrow (->) composed of the minus sign and
greater than symbol. Generally, a definition needs to be made only once, with in an on-line command,
because it is stored in battery-backed RAM or saved to flash memory. The M-variable thus defined may
be used repeatedly.
An M-variable may take one of the following types, as specified by the address prefix in the definition:
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
If an X or Y type of M-variable is defined, you must also define the starting bit to use, the number of bits,
and the format (decoding method).
Typical M-variable definition statements are:
M1->Y:$078C02,8,1
M102->Y:$78003,8,16,S
M103->X:$078003,0,24,S
M161->D:$8B
M5141->L:$2041
M50->DP:$060401
M51->F:$0607FF
M100->TWD:4,0.8.3,U
See the instructions for each type of M-variable definition in the On-Line Commands reference section of
the manual. This can be found in the Talking to Turbo PMAC section of this manual. Many suggested
M-variable definitions are given in the software reference manual as well.
It is a good idea to prepare a single file with all of your M-variable definitions and to put at the top of this
file the command M0..8191->*. This will remove all existing definitions, and help to prevent
mysterious problems caused by “stray” M-variable definitions.
The M-variable definitions are stored as 48-bit codes at Turbo PMAC memory addresses $004000 (for
M0) to $005FFF (for M8191). The Y-register contains the address of the register pointed to by the
definition; the X-register contains a code that determines what part of the register is used and how it is
interpreted.
If another M-variable points to the Y-register, it can be used to change the subject register. The main use
of this technique is to create arrays of registers, which can be used to walk through tables in memory.
Limited Range
Many M-variables have a more limited range than Turbo PMAC’s full computational range. If a value
outside of the range of an M-variable is placed to that M-variable, Turbo PMAC rolls over the value
automatically to within that range and does not report any errors.
For example, with a single bit M-variable, any odd number written to the variable ends up as 1, any even
number ends up as 0. If an attempt is made to place a non-integer value in an integer M-variable, Turbo
PMAC automatically rounds to the nearest integer.
Using M-Variables
Once defined, an M-variable may be used in programs just as any other variable – through expressions.
When the expression is evaluated, Turbo PMAC reads the defined memory location, calculates a value
based on the defined size and format, and utilizes it in the expression.
Care should be exercised in using M-variables in expressions. If an M-variable is something that can be
changed by a servo routine (such as instantaneous commanded position), which operates at a higher
priority than the background expression evaluation, there is no guarantee that the value will not change in
the middle of the evaluation. For instance, if in the expression
(M16-M17)*(M16+M17)
the M-variables are instantaneous servo variables, there is no guarantee that M16 or M17 will have the
same value in both places in the expression or that the values for M16 and M17 will come from the same
servo cycle. The first problem can be overcome by setting P1=M16 and P2=M17 right above this, but
there is no general solution to the second problem.
Use for Indirect Addressing
As pointers, M-variables can be used for a technique known as indirect addressing to access a range of
registers without having to define a separate variable for each register. This technique uses two M-
variables. The first is assigned to a register in the address area of interest, with a format of the desired
type; the second is assigned to the register that contains the address of the first definition.
M-variable address definitions are in fixed locations in Turbo PMAC memory, starting at $004000 (for
M0) and ending at $005FFF (for M8191). The X-register at each of these addresses holds the code that
determines the format of the M-variable; the Y-register holds the address of the register being pointed to.
By changing the contents of this Y-register, you can change the address of the register that this M-
variable points to.
This technique is best illustrated by an example. Suppose that a 2048-word UBUFFER had been created
in a Turbo PMAC with standard memory. This UBUFFER would occupy addresses $010000 to
$0107FF. In this buffer, we wanted to create a 2048-entry floating-point sine table. We would start off
with two M-variable definitions:
M64->L:$010000 ; Floating-point M-var def to start of UBUFFER
M65->Y:$004040,0,12 ; M64 definition address, low 12 bits
Now, by changing the value of M65, we change the address to which M64 points. Note that by assigning
M65 to only the low 12 bits (last 3 hex digits) of the M64 definition address, we can in this case just
assign values to M65 representing offsets from the beginning of the register set. To create the sine table,
use the following code:
M65=0 ; Point M64 to L:$010000
WHILE (M65<2048)
M64=SIN(360*M65/2048) ; Write sine value
M65=M65+1 ; Index M64 to next register
ENDHWILE
Operators
Turbo PMAC operators work like those in any computer language: they combine values to produce new
values. Detailed descriptions of the operators are given in the Software Reference manual; overviews are
given here.
Arithmetic Operators
Turbo PMAC uses the four standard arithmetic operators: +, -, *, and /. The standard algebraic
precedence rules are used: multiply and divide are executed before add and subtract, operations of equal
precedence are executed left to right, and operations inside parentheses are executed first.
Modulo Operator
Turbo PMAC also has the ‘%’ modulo operator, which produces the resulting remainder when the value
in front of the operator is divided by the value after the operator. Values may be integer or floating point.
This operator is particularly useful for dealing with counters and timers that roll over.
When the modulo operation is done by a positive value x, the results can range from 0 to x (not including
x itself). When the modulo operation is done by a negative value x, the results can range from -x to x (not
including x itself). This negative modulo operation is useful when a register can roll over in either
direction.
Logical Operators
Turbo PMAC has three logical operators that do bit-by-bit operations: & (bit-by-bit AND), | (bit-by-bit
OR), and ^ (bit-by- bit EXCLUSIVE OR). If floating-point numbers are used, the operation works on the
fractional as well as the integer bits. & has the same precedence as * and /; | and ^ have the same
precedence as + and -. Use of parentheses can override these default precedence levels.
Note:
These bit-by-bit logical operators are different from the simple Boolean operators
AND and OR used in compound conditions (q.v.).
Functions
As in any programming language, Turbo PMAC mathematical functions perform mathematical operations
on constants or expressions to yield new values. The general format is:
{function name} ({expression})
The available functions are:
SIN: Trigonometric sine
COS: Trigonometric cosine
TAN: Trigonometric tangent
ASIN: Trigonometric inverse sine (arcsine)
ACOS: Trigonometric inverse cosine (arccosine)
ATAN: Trigonometric inverse tangent (arctangent)
ATAN2: Special two-argument, four-quadrant trigonometric inverse tangent
LN: Natural logarithm (log base e)
EXP: Exponentiation (ex)
SQRT: Positive square root
ABS: Absolute value
INT: Truncation to integer (towards minus infinity)
Global I-variable I15 controls whether the trigonometric functions use degrees (I15 = 0) or radians (I15 = 1).
Detailed descriptions of each function, including domain and range, are given in the Software Reference
Manual.
Expressions
A Turbo PMAC expression is a mathematical construct consisting of constants, variables, and functions,
connected by operators. Expressions can be used to assign a value to a variable, to determine a motion
program parameter, or as part of a condition. A constant can be an expression, so if the syntax calls for
{expression}, a constant may be used as well as a more complicated expression. No extra
parentheses are required for non-constant expressions, unlike when {data} is specified (see below).
Examples of expressions are:
512
P1
P1-Q18
1000*COS(Q25*3.14159/180)
I100*ABS(M347)/ATAN(P(Q3+1)/6.28)+5
Note:
With synchronous assignment, the actual assignment is performed where the
blending to the new move begins, which is generally ahead of the programmed
point. In LINEAR and CIRCLE mode moves, this blending occurs V*TA/2
distance ahead of the specified intermediate point, where V is the commanded
velocity of the axis, and TA is the acceleration (blending) time.
Also, note that the assignment is synchronous with the commanded position, not necessarily the actual
position. It is the responsibility of the servo loop to make the commanded and actual positions match
closely.
In applications in which Turbo PMAC is executing segmented moves (Isx13 > 0), the synchronous M-
variables are executed at the start of the first Isx13 spline segment after the start of blending into the
programmed move.
Turbo PMAC checks to see whether it is time to pull synchronous assignments out of the queue and
execute them every real-time interrupt (every I8+1 servo cycles). The smaller I8 is, and the smaller the
servo cycle time is, the tighter the timing control of the synchronous outputs is.
Note:
Synchronous M-variables after the last move or DWELL in the program do not
execute when the program ends or temporarily stops. Use a DWELL as the last
statement of the program to execute these statements.
If synchronous assignments are left in the queue because the program ended or was stopped before it was
time for their execution, they can be removed from the queue with the on-line MFLUSH command.
Syntax. There are four forms of synchronous M-variable assignment statements:
M{constant}=={expression} ; Straight equals assignment
M{constant}&={expression} ; AND-equals assignment
M{constant}|={expression} ; OR-equals assignment
M{constant}^={expression} ; XOR-equals assignment
In all of these forms, the expression on the right side of the statement is evaluated when the line is
encountered in the program, ahead of the execution of the move. The value of the expression, the
variable number, and the operator are placed on a stack for execution at the proper time.
Execution
When actual execution of the appropriate move starts, these items are pulled off the stack, and the actual
action is performed. In the case of the == syntax, the value is simply assigned to the variable at this time.
In the case of the other forms (&=, |=, and ^=), the variable is read at this time, the bit-by-bit Boolean
operation (AND, OR, XOR, respectively) is performed between the variable value and the expression
value, and the result is written back to the variable.
Special Boolean Feature
These Boolean assignment operators are subtly different from what would seem to be equivalent ==
statements. Consider the two statements acting on an 8-bit M-variable, which attempt to make all of the
odd bits 1, while leaving the even bits where they are:
M50==M50 & $AA
M50&=$AA
The difference between the two statements is apparent when M50 is read for the operation. In the first
case, it is read when the statement is first evaluated in the program. In the second case, it is read when the
operation is pulled off the stack, immediately before the variable is written to. In this second technique
there is no chance that the value of the M-variable can be changed by some other task in the mean time.
Note:
<= and >= are not valid Turbo PMAC comparators. The comparators !> and !<,
respectively, should be used in their place.
Conditions
A condition can be used to control program flow in motion or PLC programs. It is evaluated as either
true or false. It can be used in an IF branching statement or WHILE looping statement. Turbo PMAC
supports both simple and compound conditions.
Note:
A condition in a command line – IF or WHILE – must be surrounded by
parentheses.
Simple Conditions
A simple condition consists of three parts:
{expression} {comparator} {expression}
If the relationship between the two expressions defined by the comparator is valid, then the condition is
true; otherwise, the condition is false. Examples of simple conditions in commands are:
WHILE (1<2) (always true)
IF (P1>5000)
WHILE (SIN(P2-P1)!>P300/1000)
Note that parentheses are required around the condition itself.
Note:
Unlike in some programming languages, a Turbo PMAC condition may not be
simply a value, evaluated for zero or non-zero (e.g. IF (P1) is not valid). It
must explicitly be a condition with two expressions and a comparator.
Compound Conditions
A compound condition is a series of simple conditions connected by the logical operators AND and OR.
The compound condition is evaluated from the values of the simple conditions by the rules of Boolean
algebra. In the Turbo PMAC, AND has execution precedence over OR (that is, ORs operate on blocks of
ANDed simple conditions). Turbo PMAC will stop evaluating compound AND conditions after one false
simple condition has been found. Examples of compound conditions in command lines are:
IF (P1>-20 AND P1<20)
WHILE (P80=0 OR I120>300 AND I120<400)
IF (Q16!<Q17 AND Q16!>Q18 OR M136<256 AND M137<256)
Note:
The simple conditions contained within a compound condition on a single line
must not be separated by parentheses. For example, IF((P1>-20) AND
(P1<20)) is an illegal condition and will be rejected for illegal syntax.
Single-Line Condition Actions
In Turbo PMAC motion programs (but not in PLC programs) the action(s) to be executed on a true
condition can be put on the same line as the condition itself. In this case, no ENDIF or ENDWHILE is
required to mark the end of the conditional action, and none may be used; the end of the line is
automatically the marker for the end of the conditional action. Examples of this form are:
IF (P1<0) P1=0
WHILE (M11=0) DWELL 10
In Turbo PMAC rotary program buffers single-line condition actions are the only types of conditional
statements permitted. Multiple-line conditions are not permitted because it cannot be guaranteed that the
line that must be jumped to will be in the rotary buffer at that time.
Multiple-Line Conditions
In Turbo PMAC PLC programs (but not in motion programs) compound conditions over several program
lines are allowed. The first line of the condition must start with IF or WHILE; following lines of the
condition must start with AND or OR. Simple and compound conditions within a program line are always
evaluated before the conditions on separate lines are combined. Between the conditions on multiple lines,
AND takes precedence over OR. Turbo PMAC will stop evaluating a multi-line AND condition after one
single-line condition has been found false.
An example is:
IF (M11=1 OR M12=1)
AND (M13=1 OR M14=1)
...
Timers
Each active coordinate system (those numbered from 1 to I68+1) has two timer variables running: Isx11 and
Isx12. These two 24-bit registers are general-purpose timers for user program use. Turbo PMAC decrements
them once per servo cycle. Usually a value equal to the time to wait is written scaled in servo cycles. Then the
program waits for the register to become less than 0. The registers will continue to count down until they
23
reach –2 (-8,388,608). They will not roll over back to positive values.
Since these timers have units of servo cycles, and most users will prefer to work in milliseconds, a
23
conversion must be done. To convert from milliseconds to servo cycles, multiply by 2 (8,388,608) and
divide by the value of I10.
The timer variables that belong to a coordinate system can be used by any task on Turbo PMAC,
including motion programs running in other coordinate systems.
Example:
In a PLC program, to turn on an output for a fixed number of milliseconds:
M1=1 ; Turn on Machine Output 1
I5111=125*8388608/I10 ; Set timer to 125 msec, in servo cycles
WHILE (I5111>0) ; Wait for counter to count down to zero
ENDWHILE
M1=0 ; Turn off Machine Output 1
Computational Considerations
When Turbo PMAC is doing calculations in a PLC program, motion program, or on-line, it uses its 48-bit
floating-point format for the intermediate form of the calculation. This gives Turbo PMAC the ability to
convert between its different numerical formats automatically, and enables it to do bit-wise operations on
its P and Q-variables even though they are floating-point values.
The process of converting a number to 48-bit format is very fast and will not be noticeable in most Turbo
PMAC applications. However, skipping the conversion step can help increase Turbo PMAC’s speed and
efficiency for computationally demanding applications. In such applications, using P, Q, and L- (long-)
format M-variables skip the conversion step (they are already in 48-bit floating-point format) and are
computed faster than other variable types.
12 X Y 12
16 S 1 1 1 16
G ... MANTISSA EXPONENT
N 2 4 8
20 20
36 12
24 24
48 48
I & M-Variables I & M-Variables
36 12 36 12
P & Q-Variables, Program Constants P & Q-Variables
However, when Turbo PMAC is doing calculations with L-variables in a compiled PLC program (PLCC)
it uses a 24-bit fixed-point format for the intermediate form of the calculation. This gives Turbo PMAC
the ability to perform the calculations extremely quickly. L-variable calculations are about 10 times faster
than equivalent calculations using intermediate floating-point data formats.
PMAC Program Mathematical Calculations
Fixed Point Compiled PLC
Program Lines Only
1 1
12 24 12
S
16 G
N
16
20 20
Program line may only contain L-Variables
S
G 24 and integer constants in range S
G 24
N N
All values - in,out, and intermediate -
L-Variables must stay in range - 8,388,608 to 8,388,607 L-Variables
Calculations are about 10 times faster than
equivalent calculations in floation point
Multiple-Motor Axes
More than one motor may be assigned to the same axis in a coordinate system. This is common in gantry
systems, where motors on opposite ends of the cross-piece are always trying to do the same movement.
By assigning multiple motors to the same axis, a single programmed axis move in a program causes
identical commanded moves in multiple motors. This is commonly done with two motors, but up to eight
motors have been used in this manner with Turbo PMAC. Remember that the motors still have
independent servo loops, and that the actual motor positions will not necessarily be exactly the same.
Coordinating parallel gantry motors in this fashion is in general superior to using a master/slave technique
(which can be done on Turbo PMAC with the position following feature described in the Synchronizing
Turbo PMAC to External Events section of this manual). In the master/slave technique, the actual
trajectory of the master as measured at the encoder, with all of the disturbances and quantization errors,
becomes the commanded trajectory for the slave, whose actual trajectory will have even more errors. The
roughness in the slave motor’s commanded trajectory makes it difficult or impossible to use feedforward
properly, which introduces a lag. True, if the master gets a disturbance, the slave will see it and attempt to
match it, but if the slave gets a disturbance, the master will not see it.
Care must be taken in the startup and homing of gantry motors that have a tight mechanical linkage. In
general, the motors will power up not quite in ideal alignment with each other. The usual procedure is to
do a homing search move on one motor with the second motor slaved to it, followed by an offset back out
far enough that the second motor knows which way it has to go to its home trigger. Next the second motor
is made the master and is told to do a homing search move with the first motor slaved to it. This will leave
the first motor slightly off from its home position; it can now be told to go there with just a J=0 command.
The slaving is then turned off, and the motors are commanded identically through joint axis commands.
Phantom Axes
An axis in a coordinate system can have no motors attached to it (a phantom axis), in which case
programmed moves for that axis cause no movement, although the fact that a move was programmed for
that axis can affect the moves of other axes and motors. For instance, if sinusoidal profiles are desired on a
single axis, the easiest way to do this is to have a second, phantom axis and program circularly interpolated
moves.
Axis Definition
A coordinate system is established by using axis definition statements. An axis is defined by matching a
motor (which is numbered) to one or more axes (which are specified by letter).
Matching Motor to Axis
The simplest axis definition statement is something like #1->X. This simply assigns motor #1 to the X-
axis of the currently addressed coordinate system. When an X-axis move is executed in this coordinate
system, motor #1 will make the move.
Scaling and Offset
The axis definition statement also defines the scaling of the axis’ user units. For instance,
#1->10000X also matches motor #1 to the X axis, but this statement sets 10,000 encoder counts to one
X-axis user unit (e.g. inches or centimeters). This scaling feature is used almost universally. Once the
scaling has been defined in this statement, you can program the axis in engineering units without ever
needing to deal with scaling again.
The statement #1->10000X+20000 also sets the axis zero at 20,000-count (2-user-unit) distance from
the motor zero (home position). This offset is rarely used. Further, an axis definition statement can match
a motor to a linear combination of Cartesian axes (see below), which allows for rotation of a coordinate
system, or orthogonality correction.
Axis Types
An axis can have several attributes, as specified below. Note that for most axis functions, it does not
matter what type of axis is used, or what letter is given it. However, for some features, only particular axis
names may be used.
Cartesian Axes
A Cartesian axis is one that may be put into a grouping of two or three axes so that movement along an
axis is a linear combination of motion on two or three motors. X, Y, and Z form one set of Cartesian axes;
U, V, and W form the other. In addition, there are several commands (NORMAL, circular move) that can
reference the X, Y, and Z-axes through the use of I, J, and K-vectors, respectively.
To make a Cartesian axis a linear combination of several motors, do so with an extended form of the axis
definition statement. For instance, a 30o rotation of the axes can be received from the motors with the
following axis definition statements:
#1->8660.25X-5000Y
#2->5000X+8660.25Y
In this case, a request for a Y-axis (or an X-axis) move would cause both motors #1 and #2 to move.
Only the X, Y, and Z Cartesian axes may be used for PMAC’s circular interpolation routines, cutter radius
compensation routines, and matrix axis transformation routines. If you want to do circular interpolation on
other axes, you can do it through blended short moves and trigonometry in subroutines.
4"
X (in)
2"
cts
Motor #1 (10,000 in )
2) Scaling and Rotation
cts #1 -> 7071.07X - 7071.07Y
Motor #2 (10,000 in ) #2 -> 7071.07X + 7071.07Y
45
cts
Motor #1 (10,000 )
in
3) Orthogonality Correction
Y (in) cts
Motor #2 (10,000 in )
X (in)
1 arc min
cts
(exaggerated) Motor #1 (10,000 in )
Rotary Axes
A rotary axis is one that permits rollover, but cannot be assigned to combinations of motors. A rotary axis
must be named A, B, or C. The rollover is technically a motor function, specified by Ixx27 for Motor xx,
but it can only operate when the motor is assigned to a rotary axis. Rollover permits the motor to take the
shortest path around the rotary range, or the specified direction to the destination, when an absolute axis
move is specified in a program.
Vector Feedrate Axes
A vector feedrate axis is an axis in a coordinate system that figures into the calculations of a feedrate-
specified move. The time for a feedrate-specified move is calculated as the vector distance for the feedrate
axes (calculated by Pythagorean theorem as the square root of the sum of the squares of the axis distances)
divided by the feedrate itself. If other axes are commanded to move in the same statement, they will be
linearly interpolated over this same computed time.
The default feedrate axes are the Cartesian axes X, Y, and Z. This setting can be changed with the FRAX
(feedrate axis) command. Any axis involved in the arc of a CIRCLE-mode move is automatically a vector
federate axis for that move, even if not explicitly declared as such.
Conversion from Axis to Motor Position
Technically, the conversion from axis (tool-tip) positions to motor (joint, or actuator) positions is known as
the inverse-kinematic conversion. Turbo PMAC automatically converts from the programmed axis
positions (in user engineering units) to motor positions (in counts) every programmed move, or in the case
of segmented moves, every segment of the move.
In the case of axes defined with axis-definition statements, Turbo PMAC simply plugs the axis values into
the equation of the definition statement, and computes the resulting motor position. (The axis-definition
statement is therefore an inverse-kinematic equation.) In the case of axes defined using kinematic
subroutines, Turbo PMAC executes the user-written inverse-kinematic subroutine to compute these (see
the Coordinate-System Kinematic Calculation section in this manual).
Conversion from Motor to Axis Positions
Technically, the conversion from motor (joint, or actuator) positions to axis (tool-tip) positions is known as
the forward-kinematic conversion. There is only one type of calculation in which Turbo PMAC
automatically performs these forward-kinematic calculations. This is in the PMATCH (position-match)
function, which converts from commanded motor positions to commanded axis positions. This is needed
in only a few cases.
First, when a motion program is started with an R (run) or S (step) command, Turbo PMAC automatically
executes a PMATCH command internally to compute the starting axis positions for the first move
calculations. Within a motion program, it normally assumes that the endpoint of the previous move is the
starting point for the subsequent move, and so does not do these calculations each move. However, when
a program is started, it does these calculations because there is a good chance that motors may have been
moved independently (e.g. jog moves, open-loop moves, stopping on an error condition); in other words,
the axes does not know where the motors have gone and motor and axis positions may not match properly.
Second, if the relationship between motor and axis positions is changed inside a motion program (e.g.
changing position-following offset mode, directly writing to the position-bias or axis scaling registers),
issue a PMATCH command before the next programmed move (using the CMD"PMATCH" structure).
Otherwise, the next move will not execute properly.
For axes defined with a simple definition statement, the PMATCH function inverts the equations contained
in the axis-definition statements for the coordinate system, using motor commanded positions, and solves
for axis commanded positions. If more than one motor is assigned to the same axis (e.g. #1->10000X,
#2->10000X), the commanded position of the lower-numbered motor is used in the PMATCH
calculations. For axes in a coordinate system with a user-written forward-kinematic subroutine (see
below), this subroutine is executed automatically for the PMATCH function.
The PMATCH function assumes that the position referencing – either a homing search move or an absolute
position-sensor read – has been done for each motor in the coordinate system. Each motor has a home
complete status bit that is set true if either has been done, and to check for this, do it at the application
level.
Some users will want to read instantaneous motor position registers (particularly motor actual position) –
Turbo PMAC does not compute instantaneous axes positions automatically – and convert them to axis
positions for position-reporting purposes. These forward-kinematic calculations must be done at the
application level, either in Turbo PMAC (usually in a PLC program) or in the host computer.
Coordinate-System Kinematic Calculations
Turbo PMAC provides structures that enable easy implementation and execution of complex kinematic
calculations. Kinematic calculations are required when there is a non-linear mathematical relationship
between the tool-tip coordinates and the matching positions of the actuators (joints) of the mechanism,
typical in non-Cartesian geometries. They are used most commonly in robotic applications, but can be
used with other types of actuators that are not considered robotic. For example, in 4-axis or 5-axis
machine tools with one or two rotary axes, it is desirable to program the cutter-tip path and let the
controller compute the necessary motor positions.
This capability permits the motion for the machine to be programmed in the natural coordinates of the
tool-tip – usually Cartesian coordinates, whatever the underlying geometry of the machine. The kinematic
routines are embedded in the controller by the integrator, and operate invisibly to the people programming
paths and the machine operators. These routines can be unchanging for the machines, but with
parameterization and/or logic, they can adapt to normal changes such as tool lengths and different end-
effectors.
In Turbo PMAC terminology, the tool-tip coordinates are for axes, which are specified by letter, and have
user-specified engineering units. The joint coordinates are for motors, which are specified by numbers,
and have the raw units of “counts”.
Note:
PMAC’s standard axis-definition statements handle linear mathematical
relationships between joint motors and tool-tip axes. This section pertains to the
more difficult case of the non-linear relationships.
The forward-kinematic calculations use the joint positions as input, and convert them to tool-tip
coordinates. These calculations are required at the beginning of a sequence of moves programmed in tool-
tip coordinates to establish the starting coordinates for the first programmed move. The same type of
calculations can also be used to report the actual position of the actuator in tool-tip coordinates, converting
from the sensor positions on the joints. (The Turbo PMAC forward-kinematic program buffer does not
support this position-reporting functionality, but functionally identical calculations can be used in a PLC
program for this purpose.)
The inverse-kinematic calculations use the tool-tip positions as input, and convert them to joint
coordinates. These calculations are required for the end-point of every move that is programmed in tool-
tip coordinates, and if the path to the end-point is important, they must be done at periodic intervals during
the move as well.
Note:
Formal robotic analysis makes a distinction between joint position, and the actuator
positions required for that joint position. Usually, while the two positions are the
same, there are cases, such as when two motors drive a joint differentially, where
there is an important difference. If your system has a distinction between joint and
actuator positions, your kinematic calculations must include this distinction, to go
all the way between actuator positions and tool-tip positions, with joint positions as
an intermediate step. This documentation will refer to only joint positions, although
this could technically refer to actuator positions in some applications.
Reserved Variables
If kinematic calculations are used in a system, the global variables P1 – P32 and the coordinate-system
variables Q1 – Q10 should not be used for any other purposes, because Turbo PMAC will write to these
variables automatically in executing the kinematic routines. (Q10 is used to distinguish between inverse-
kinematic calculations that involve velocity calculations and those that do not, as explained below.) If
inverse-kinematic calculations involving PVT-mode moves are used, additionally the global variables
P101-P132 and the coordinate-system variables Q11 – Q19 should not be used for any other purposes,
because Turbo PMAC will write to these variables automatically in executing the velocity portions of the
inverse-kinematic routines.
Example
Take the example of a 2-axis shoulder-elbow robot, with an upper-arm length (L1) of 400mm, and a lower-
arm length (L2) of 300mm. Both the shoulder joint (A) and the elbow joint (B) have resolutions of 1000
counts per degree. When both joints are at their zero-degree positions, the two links are both extended
along the X-axis. The forward-kinematic equations are:
X = L1 cos( A ) + L2 cos( A + B )
Y = L1 sin( A ) + L2 sin( A + B )
To implement these equations in a Turbo PMAC forward-kinematic program for Coordinate System 1 that
converts the shoulder angle in Motor 1 and the elbow angle in Motor 2 to the X and Y tip coordinates in
millimeters, the following setup and program could be used:
; Setup for program
I15=0 ; Trig calculations in degrees
&1 ; Address CS 1
M145->Y:$0000C0,10,1 ; Motor 1 home complete bit
M245->Y:$000140,10,1 ; Motor 2 home complete bit
M5182->Y:$00203F,22,1 ; CS 1 run-time error bit
Q91=400 ; L1
Q92=300 ; L2
Q93=1000 ; Counts per degree for A and B
; Forward-kinematic program buffer for repeated execution
&1 OPEN FORWARD ; Forward kinematics for CS 1
CLEAR ; Erase existing contents
IF (M145=1 AND M245=1) ; Properly position referenced?
Q7=Q91*COS(P1/Q93)+Q92*COS((P1+P2)/Q93) ; X position
Q8=Q91*SIN(P1/Q93)+Q92*SIN((P1+P2)/Q93) ; Y position
ELSE ; Not valid; halt operation
M5182=1 ; Set run-time error bit
CLOSE
The forward-kinematic program must calculate the axis positions for all of the axes in the coordinate
system, whether or not all of the motor positions are calculated in the inverse-kinematic program (see
below). For instance, if this arm had a vertical axis at the tip with a normal axis definition statement in
C.S. 1 of #3->100Z (100 counts per millimeter – a linear relationship between motor and axis), the above
program would still need to perform the forward-kinematic calculation for this motor/axis with a line such
as Q9=P3/100.
Note:
If the forward-kinematic algorithm is not correct, and does not yield a true
mathematical inverse of the inverse-kinematic algorithm, there will be a sudden and
potentially dangerous jump at the beginning of the first move executed after the
forward kinematic algorithm is executed. Make sure early in development that the
Ixx11 fatal following error limits are set as tight as possible to ensure that any large
errors will cause a trip and not result in violent motion.
Iterative Solutions
Some systems, particularly parallel-link mechanisms such as Stewart platforms (hexapods), do not have
reasonable closed-form solutions for the forward-kinematic equations, and require iterative numerical
solutions. Typically, these cases are handled by a looping WHILE … ENDWHILE construct in the
forward-kinematic program. Do not permit indefinite looping – if the solution does not converge in the
expected number of cycles, the program should be stopped (see the inverse-kinematic equations, below,
for examples of how to stop the program).
In this case, it is best to leave the I11 program-calculation delay variable at its default value of 0, so the
calculations can take as long as needed. If I11 is greater than 0, and the forward-kinematic calculations
plus the first move calculations do not finish within I11 msec, Turbo PMAC will stop the program with a
run-time error. In any case, if the forward-kinematic calculations take more than about 25 msec, it is
possible to trip the watchdog timer.
Position-Reporting Forward Kinematics
Another use of forward-kinematic calculations is for the position reporting function, reading actual joint
positions at any time, and converting them to tip positions for reporting. The forward-kinematic program
buffer on Turbo PMAC does not support this function. (Using the program for both initial-position
calculations and position reporting could lead to potential overlapping use and register conflicts.)
If the application requires the Turbo PMAC to do forward-kinematic calculations for position reporting as
well as for establishing initial tip position, the position-reporting calculations should be put into a PLC
program. The following PLC program could be used for the position-reporting function of the example
“shoulder-elbow” robot:
; M-variable definitions for actual position registers
M162->D:$8B ; Motor 1 actual position
M262->D:$10B ; Motor 2 actual position
; Forward-kinematic PLC program buffer for position reporting
OPEN PLC 10 ; Forward kinematics for CS 1
CLEAR ; Erase existing contents
P51=M162/(I108*32*Q93) ; Actual A position (deg)
P52=M262/(I208*32*Q93) ; Actual B position (deg)
Q27=Q91*COS(P51)+Q92*COS(P51+P52) ; Actual X position
Q28=Q91*SIN(P51)+Q92*SIN(P51+P52) ; Actual Y position
CLOSE
To implement these equations in a Turbo PMAC inverse-kinematic program for Coordinate System 1 that
converts the X and Y tip coordinates in millimeters to the shoulder angle in Motor 1 and the elbow angle in
Motor 2, the following program could be used. System constants Q91, Q92, and Q93 are the same as for
the above forward kinematic program.
; Setup for program
&1
#1->I ; Motor 1 assigned to inverse kinematic axis in CS 1
#2->I ; Motor 2 assigned to inverse kinematic axis in CS 1
M5182->Y:$00203F,22,1 ; CS 1 run-time error bit
; Pre-compute additional system constants
Q94=Q91*Q91+Q92*Q92 ; L1^2 + L2^2
Q95=2*Q91*Q92 ; 2*L1*L2
Q96=Q91*Q91-Q92*Q92 ; L1^2 – L2^2
; Inverse-kinematic algorithm to be executed repeatedly
&1 OPEN INVERSE ; Inverse kinematics for CS 1
CLEAR ; Erase existing contents
Q20=Q7*Q7+Q8*Q8 ; X^2+Y^2
Q21=(Q20-Q94)/Q95 ; cos(B)
IF (ABS(Q21)<0.9998) ; Valid solution w/ 1 deg margin?
Q22=ACOS(Q21) ; B (deg)
Q0=Q7 ; X into cos argument for ATAN2
Q23=ATAN2(Q8) ; A+C = ATAN2(Y,X)
Q24=ACOS((Q20+Q96)/(2*Q91*SQRT(Q20))) ; C (deg)
Q25=Q23-Q24 ; A (deg)
P1=Q25*Q93 ; Motor 1 = 1000A
P2=Q22*Q93 ; Motor 2 = 1000B
ELSE ; Not valid, halt operation
M5182=1 ; Set run-time error bit
ENDIF
CLOSE
Notes on the example:
• By choosing the positive arc-cosine solutions, we are automatically selecting the right-armed case. In
a more general solution, we would have to choose whether the positive or negative is used, based on
some criterion.
• Increased computational efficiency could be obtained by combining more operations into single
assignment statements. Calculations were split out here for clarity’s sake.
• This example does not use the substitution macros permitted by the Executive program to substitute
meaningful names for variables. Use of these substitution macros in complex applications is strongly
encouraged.
• This example stops the program for cases in which no inverse kinematic solution is possible. It does
this by setting the “run-time error” status bit for the coordinate system, which causes Turbo PMAC to
halt motion program execution and issue the Abort command. Other strategies may be used to cope
with this problem.
If this robot had a vertical axis at the tip, the relationship between motor and axis could be defined with a
normal linear axis-definition statement (e.g. #3->100Z for 100 counts per millimeter), and the motor
position would be calculated without the special inverse-kinematic program. Alternately, the motor could
be defined as an inverse-kinematic axis (#3->I) and the motor position could be calculated in the inverse-
kinematic program (e.g. Q3=Q49*100 to set Motor 3 position from the Z-axis with 100 counts per unit).
θ new = θ old + ∆θ
When the modulo operation is done in Turbo PMAC with a negative operand ‘-n’ (such as –180), the
result is always in the +n range.
For example, if the A-axis in the above example had the capability of rolling over, the line Q25=Q23-
Q24 could be replaced with:
Q25=P1/Q93+(Q23-Q24-P1/Q93)%-180 ; Handle rollover cases
The value (P1/Q93) is θold, from the previous cycle of the inverse kinematics or initially from the forward
kinematics; and value (Q23-Q24) is θnew-temp, both in degrees.
Velocity Calculation Flag
In every move mode other than PVT mode, Turbo PMAC sets the variable Q10 for the coordinate system
to 0 automatically as a flag to the inverse-kinematic program not to compute velocity values. If planning
to use both PVT mode and other modes, evaluate Q10 explicitly in the inverse-kinematic program (see
below).
Iterative Solutions
Some robot geometries do not have closed-form inverse-kinematic solutions, and require iterative
numerical solutions. Typically these cases are handled by a looping WHILE … ENDWHILE construct in
the inverse-kinematic program. Multiple executions of the WHILE loop inside the inverse-kinematic
program do not disable blending as they would inside the main motion program (due to the double jump-
back rule), but excessive iterations can cause the calculations not to be done within the required time.
This will cause a run-time error, aborting the program automatically.
Inverse-Kinematic Program for PVT Mode
The Turbo PMAC can also support the conversion of velocities from tip space to joint space in the inverse-
kinematic program to enable the use of PVT mode with kinematic calculations. With PVT-mode moves,
the position calculations are done just as for any other move mode. An additional set of velocity-
conversion calculations must also be done.
When executing PVT-mode moves with kinematics active (Isx50 = 1), Turbo PMAC will automatically
place the commanded axis velocity values from the PVT statements into variables Q11 – Q19 for the
coordinate system before each execution of the inverse-kinematic program. These are signed floating-
point values in the engineering velocity units defined by the engineering length/angle units and the
coordinate system’s Isx90 time units (e.g. mm/min or deg/sec). The following table shows the variable
used for each axis:
Axis-Velocity Axis Axis-Velocity Axis Axis-Velocity Q- Axis Letter
Q-Variable Letter Q-Variable Letter Variable
Q11 A Q14 U Q17 X
Q12 B Q15 V Q18 Y
Q13 C Q16 W Q19 Z
Turbo PMAC will also set Q10 to 1 in this mode as a flag to the inverse-kinematic program that it should
use these axis (tip) velocity values to compute motor (joint) velocity values.
In this mode, after any execution of the inverse-kinematic program, Turbo PMAC will read the values in
those variables P1xx (P101 – P132) for each Motor xx in the coordinate system defined as inverse-
kinematic axes (#xx->I). These are floating-point values, and Turbo PMAC expects to find them in
units of counts per Isx90 milliseconds. Turbo PMAC will use them as motor (joint) velocity values along
with the position values in Pxx to create a PVT move for the motor.
For PVT moves, then, the inverse-kinematic program not only must take the axis (tip) position values in
Q1 – Q9 and convert them to motor (joint) position values in P1 – P32; but also it must take the axis (tip)
velocity values in Q11 – Q19 and convert them to motor (joint) velocity values in P101 – P132.
Technically, the velocity conversion consists of the solution of the “inverse Jacobian matrix” for the
mechanism.
Example
Continuing with the “shoulder-elbow” robot of the above examples, the equations for joint velocities as a
function of tip velocities are:
L cos( A + B ) X&+ L2 sin( A + B )Y&
A&= 2
L1 L2 sin B
B&=
[ ] [ ]
− L1 cos A − L2 cos( A + B ) X&+ − L1 sin A − L2 sin( A + B ) Y& − XX&− YY&
=
L1 L 2 sin B L1 L2 sin B
The angles A and B have been computed in the position portion of the inverse-kinematic program. Note
that the velocities become infinite as the angle B approaches 0 degrees or 180 degrees. Since in our
example we are limiting ourselves to positive values for B, we will trap any solution with a value of B less
than 1o or greater than 179o (sin B < 0.0175) as an error.
&1
OPEN INVERSE
CLEAR
{Position calculations from above}
IF (Q10=1) ; PVT mode?
Q26=SIN(Q25) ; sin(B)
IF (Q26>0.0175) ; Not near singularity?
Q27=Q91*Q92*Q26 ; L1*L2*sinB
Q28=COS(Q25+Q22) ; cos(A+B)
Q29=SIN(Q25+Q22) ; sin(A+B)
Q30=(Q92*Q28*Q17+Q92*Q29*Q18)/Q27 ; dA/dt
Q31=(-Q7*Q17-Q8*Q18)/Q27 ; dB/dt
P101=Q30*Q93 ; #1 speed in cts/(Isx90 msec)
P102=Q31*Q93 ; #2 speed in cts/(Isx90 msec)
ELSE ; Near singularity
M5182=1 ; Set run-time error bit
ENDIF
ENDIF
CLOSE
Note that in this case the check to see if B is near 0o or 180o is redundant because we have already done
this check in the position portion of the inverse-kinematic algorithm. This check is shown here to illustrate
the principle of the method. In this example, a run-time error is created if too near a singularity; other
strategies are possible.
The inverse-kinematic program is executed automatically each time Turbo PMAC computes new axis
positions during the execution of a motion program. This occurs at the end-point of each programmed
move block for non-segmented moves, such as those in RAPID mode. It occurs at the end of each
intermediate segment – every Isx13 milliseconds – for segmented moves (LINEAR and CIRCLE-mode
moves with Isx13 > 0).
(With normal axis definition statements, Turbo PMAC executes this same function by using the equations
of the axis definition statements to derive motor positions from axis positions.)
When the inverse-kinematic program is executed only at programmed end-points, as in RAPID mode, all
interpolation occurs in joint space. In this case, the path of the tip from point to point is not well defined if
the programmed end-points are far apart, and in general it will not be a straight line.
When the inverse-kinematic program is executed at each intermediate segment boundary, the coarse
interpolation (segmentation) is done in tip space, so the path is well defined. After the conversion of the
segment coordinates to joint positions, the fine interpolation between segment boundaries is done in joint
space as a cubic spline, but with the segments close together (typically 5 to 20 msec each) any deviations
from the ideal tip path are negligible.
If the special lookahead buffer for the coordinate system is active (LINEAR or CIRCLE-mode moves with
the lookahead buffer defined for the coordinate system, Isx13 > 0, and Isx20 > 0), the internal spline
segments computed for the joints (motors) are entered into the lookahead buffer automatically. Here they
are continually checked against position, velocity, and acceleration limits for each motor. This permits
Turbo PMAC to check and correct automatically for the motion anomalies that occur near singularities, so
you do not need to do so.
Coordinate System Time-Base
Each coordinate system has its own time base that helps control the speed of interpolated moves in that
coordinate system. Turbo PMAC’s interpolation routines increment an “elapsed-time” register every servo
cycle. While the true time for the servo cycle is set in hardware for the entire system (by jumpers E98,
E29-E33, and E3-E6 on a Turbo PMAC1, by hardware-control variables I7m00, I7m01, and I7m02 for a
Turbo PMAC2 without MACRO, or by I6800, I6801, and I6802 for a Turbo PMAC2 with MACRO) and
does not change for a given application, the value of time added to the “elapsed-time” register for a
coordinate system each servo cycle is just a number in a memory register. It does not have to match the
true physical time for the cycle.
The units for the time base register are such that 223 (8,388,608) equals 1 millisecond. The default value
for the time-base register is equal to the value of I10. The factory default value for I10 of 3,713,707
represents the default physical servo cycle time of 442 microseconds.
If the value of the time base register is changed from I10, interpolated moves will move at a different
speed from that programmed. Many people call this capability feedrate override. Note that the physical
time does not change, so servo loop dynamics remain unchanged.
Each coordinate system has a variable Isx93 that contains the address of the register that the coordinate
system uses for its time base. With the default value of Isx93, the coordinate system gets its time base
information from a register that is set by % commands from the host computer. A %100 command puts a
value equal to I10 in this register; a %50 command puts a value equal to I10/2 in this register.
Note:
A motor that is not assigned to any coordinate system uses Coordinate System 1’s
time base value for executing its jogging and homing moves. To use another base
value, assign the motor to a different coordinate system, even if there is no need to
write a motion program to run this motor.
Regardless of the source of the time base information, a % query command cause PMAC to report back the
value of the present time base expressed as a percentage of I10.
Time base information can come from other sources. The most common alternative to command-sourced
time base is external frequency-sourced time base, in which the time base value is proportional to the
frequency of a master encoder. This provides a powerful position-synchronized slaving mechanism that is
commonly called electronic cam.
See instructions for using an external time base, in the Synchronizing Turbo PMAC to External Events
section of this manual.
G-Codes
To handle machine-tool-style G-codes, which provide direct access to part programs created by
CAD/CAM programs, Turbo PMAC treats a Gnn statement as CALL 1000.nn000. The following
values on the line (e.g. X1000) can be treated as parameters to be passed, as for a canned cycle, or the
subprogram can execute without arguments, return, and execute the rest of the line (as for a modal G-
code). The machine tool designer writes Program 1000 to implement the G-codes as he wishes, allowing
customization and enhancements. Delta Tau provides a sample file implementing all of the standard G-
codes. M, S, T, and D codes are similarly implemented.
Modal Commands
Many of the statements in Turbo PMAC motion programs are modal in nature. These include move
modes, which specify what type of trajectory a move command will generate; this category includes
LINEAR, RAPID, CIRCLE, PVT, and SPLINE. Moves can be specified either incrementally (distance)
or absolutely (location) – individually selectable by axis – with the INC and ABS commands. Move
times (TA, TS, and TM) and/or speeds (F), are implemented in modal commands. Modal commands can
precede the move commands they are to affect, or they can be on the same line as the first of these move
commands.
Move Commands
The move commands themselves consist of a one-letter axis-specifier followed by one or two values
(constant or expression). All axes specified on the same line will move simultaneously in a coordinated
fashion on execution of the line; consecutive lines execute sequentially (with or without stops in between,
as determined by the mode). Depending on the modes in effect, the specified values can mean,
destination, distance, and/or velocity (see Trajectory Features section).
Motion Program Trajectories
Among Turbo PMAC’s outstanding characteristics are the power and flexibility of its trajectory
generation algorithms. These algorithms allow a great variety of difficult maneuvers to be performed,
and permit you to make your own tradeoffs between ease of use and degree of control. It is important to
remember that these trajectories are a series of commanded positions only. It is up to the servo loops for
each axis to try to make the actual positions match the commanded positions. All the times, speeds,
distances, and profiles discussed in this section are commanded ones, unless otherwise noted.
Linear Blended Moves
The easiest class of moves to make is the linear blended move category. In this type of move, an axis
moves toward the target position at a designated speed, accelerating to and decelerating from this speed in
a controlled fashion. If more than one move is specified in succession with no pause in between, the first
move will blend into the second with the same type of controlled acceleration as is done to and from a
stop.
Linear blended move mode is the default mode for motion programs. If in another move mode, the
program can be put into this mode with the LINEAR statement. The program can be taken out of
LINEAR mode with another move mode statement (e.g. CIRCLE1, CIRCLE2, RAPID, PVT, SPLINE).
It is good programming practice to declare the LINEAR mode in each program, and not rely on the
default. The LINEAR statement is equivalent to the RS-274 G-Code G01.
Position or Distance Specification
The destination point of a linear-mode move is specified in the move command itself (e.g. X10Y20). The
commanded destination for each axis can be specified as a position relative to the programming origin (if
the axis is in ABS absolute mode) or with a distance from the last commanded position (if the axis is in
INC incremental mode). The program specifies one of these; Turbo PMAC automatically calculates the
other.
Feedrate or Move-Time Specification
You can specify either the target velocity (feedrate) for the move, with an F command, or the move time
with the TM command. If F is specified, the move time is calculated, and if TM is specified, the feedrate is
calculated. The relationship between the two values is reciprocal for a given move distance. Move-time
and feedrate values are modal; they affect all subsequent linear (and circle) mode moves until another F
or TM value is specified in the program.
The units of the TM time are milliseconds; the units of the F velocity are the user length (or angle) units of
the feedrate axes divided by the time units as defined by coordinate system variable Isx90 in milliseconds.
If Isx90 is at the default value of 1000, the F units are length units per second; if Isx90 is set to 60,000,
the F units are length units per minute.
If no F or TM value is specified after power-up/reset, the value of Isx89 is used for the moves as a feedrate
value. Any F value specified in a program is compared to maximum feedrate parameter Isx98; if greater
than this parameter, Isx98 is used instead.
Note:
Feedrate is a magnitude and should therefore always be a positive number. A
negative feedrate will cause the motion to be opposite of what is defined as
positive in the Coordinate System definition.
Vector Feedrate Axes
If a multi-axis move is specified by feedrate (and not time), theres is the further flexibility of specifying
which axes control the vector feedrate using the FRAX command (on-line or buffered) and velocity is
apportioned among these axes so that their vector combination (root of sum of squares) is the specified
velocity. Turbo PMAC calculates the move time as the vector distance of the feedrate axes divided by the
programmed feedrate. Therefore, each axis’ velocity does not have to be computed individually for each
different angle of movement. If a simultaneous move is requested of a non-feedrate axis, that move is
completed in the same time as that computed for the feedrate axes. The default feedrate axes for a
coordinate system are the X, Y, and Z-axes.
If there are other axes (non-feedrate axes) commanded on the same line, Turbo PMAC compares the
move time computed for the vector feedrate axes to the move time derived by taking the greatest distance
of a non-feedrate axis divided by the coordinate system’s alternate feedrate parameter Isx86. Whichever
of these move times is the longest is used for all axes.
Example Vector Feedrate Calculations (Isx86=40)
INC Vect Dist = SQRT(32 + 42) = 5
FRAX(X,Y) Move Time = 5/10 = 0.5
X3 Y4 F10 Vx = 3/0.5 = 6
Vy = 4/0.5 = 8
INC Vect Dist = SQRT(32 + 42) = 5
FRAX(X,Y) Vect Move Time = 5/10 = 0.5
X3 Y4 Z12 F10 Non-Vect Dist = 12
Non-Vect Move Time = 12/40 = 0.3
Vx = 3/0.5 = 6
Vy = 4/0.5 = 8
Vz = 12/0.5 = 24
INC Vect Dist = SQRT(32+42+122)=13
FRAX(X,Y,Z) Move Time = 13/10 = 1.3
X3 Y4 Z12 F10 Vx = 3/1.3 = 2.31
Vy = 4/1.3 = 3.08
Vz = 12/1.3 = 9.23
INC Vect Dist = 0, Non-Vect Dist = 10
FRAX(X,Y,Z) Move Time = 10/40 = 0.25
C10 F10 Vc = 40
Motor Velocity Limits
Turbo PMAC provides a velocity limit parameter Ixx16 for each Motor xx that can be used to
automatically limit the commanded velocity in linear-mode moves even if the motion program requests a
higher rate. The details of how this limiting function operates are dependent on the mode of operation.
This velocity limiting is active either if segmentation mode is not active (Isx13 = 0), in which case
circular interpolation and cutter-radius compensation are not permitted, or if segmentation mode is active
(Isx13 > 0) and the special lookahead buffer is active (Isx20 > 0, defined lookahead buffer).
If the velocity limits are active, Turbo PMAC compares the motor velocity magnitudes requested by the
motion program to the Ixx16 limit for each motor. If the request for any motor exceeds the limit, the
move time is extended so that motor will not exceed its limit; this automatically slows the other motors in
the coordinate system in proportion so that the relationship between motors (path in space) is maintained.
Acceleration Parameters
The acceleration to and from velocity can be constant, providing trapezoidal velocity profiles; it can be
linearly varying, yielding S-curve velocity profiles; or it can be a combination of the two. Specify the
time for the full acceleration (TA – default parameter is coordinate system I-variable Isx87) and the time
in each half of the S (TS – default parameter Isx88). If the specified TA time is less than twice the
specified TS time, the TA time used will be twice TS (users who want pure S-curve acceleration can just
set TA to 0). Turbo PMAC can use only integer values for TA and TS. If a non-integer value is
specified, PMAC will round it to the nearest integer before using it in trajectory calculations.
AUTOMATIC
"S" CURVE ACCELERATION
SPECIFY t AND t
ACCEL S
AND ACCELERATION LIMIT
ACCELERATION
Parabolic
Sinusoidal For Comparison 4
tL =0
t ACCEL = 2tS
3
2a
a
2 tL = tS 2
tS = 0
t ACCEL = 2tS 1
a
0 TIME
Parabolic (sinusoidal)
VELOCITY t L = t ACCEL - 2tS for comparison 4
t tL t
S S
MAX.
tL = 0
t ACCEL = 2t S 3
t L = tS 2
tS = 0
t ACCEL = t L
1
0 TIME
t
ACCEL
t ACCEL = 2tS +t L
Acceleration Limits
Turbo PMAC provides an acceleration limit parameter Ixx17 for each Motor xx that can be used to
automatically limit the commanded rate of acceleration in linear-mode moves even if the motion program
requests a higher rate. The details of how this limiting function operates are dependent on the mode of
operation.
• Segmentation mode not active (Isx13 = 0), special lookahead buffer not active (Isx20 = 0). This is the
simplest mode of operation. Circular interpolation is not permitted in this mode. Ixx17 acceleration
limits are active in this mode, but if the acceleration would have to be extended over more than a full
programmed move in order to observe the limit, the limit will be violated.
• Segmentation mode active (Isx13 > 0), special lookahead buffer not active (Isx20 = 0). This mode
permits circular interpolation and cutter-radius compensation, and to have circle-mode and linear-
mode moves to blend together, but the Ixx17 acceleration limits are not active in this mode.
• Segmentation mode active (Isx13 > 0), special lookahead buffer active (Isx20 > 0, defined lookahead
buffer). This is the most sophisticated mode of operation. This mode permits circular interpolation
and cutter-radius compensation, to have circle-mode and linear-mode moves blend together, to have
the Ixx17 acceleration limits active for both linear and circle-mode moves, and to be able to extend
the acceleration over multiple programmed moves if necessary.
This section covers the acceleration limiting algorithms of Mode 1 only. The acceleration limiting
function of the special lookahead buffer (Mode 3) is discussed in a manual section devoted to that
function, below.
If the acceleration calculated from the motion exceeds the maximum programmed acceleration (set by
2
Ixx17 in counts/msec ) for any motor involved in the move, the acceleration for all motors in the move is
decreased in proportion so that no motor exceeds this limit. The path through space is not changed, nor is
the shape of the velocity profile for any motor. If you want to specify acceleration rate directly, set TA
and TS to very small so as always to violate the limit, in which case the acceleration is controlled by the
motors’ I-variables Ixx17.
Note:
Unless the coordinate system is in segmentation mode (Isx13 > 0), do not set both
the TA and TS (Isx87 and Isx88) times to zero, even if you are planning to rely on
the acceleration. This would cause a divide-by-zero error, yielding possible erratic
performance.
When Too Effective
When blending linear moves together, the Ixx17 limit is enforced even for the intermediate decelerations
to a stop that are removed to blend into the next move. As Turbo PMAC calculates each move in the
blended sequence, it has to assume that it could be the last move in the sequence, and it will try to make
sure that the deceleration to a stop at the programmed position obeys this limit. This can result in a
deceleration time longer than the programmed move time (specified either directly with TM, or indirectly
by distance over F feedrate), which will cause the move to execute at lower than the programmed speed.
This can be especially limiting when moves are broken into very small pieces to be blended together. The
Ixx17 limit must be set higher than the top speed divided by the smallest segment time in order not to
limit the speed. This can make it too high for effective acceleration control.
When Not Effective Enough
Without the special lookahead buffer enabled, Turbo PMAC looks two moves ahead of actual move
execution to perform its acceleration limit, and can recalculate these two moves to keep the accelerations
under the Ixx17 limit. However, there are cases in which more than two moves, some much more than
two, would have to be recalculated in order to keep the accelerations under the limit. In these cases,
Turbo PMAC will limit the accelerations as much as it can, but because the earlier moves have already
been executed, they cannot be undone, and therefore the acceleration limit will be exceeded.
If you desire robust acceleration control in cases where the acceleration limiting may require modifying
the speed of several moves, the special lookahead buffer should be used. See the Turbo PMAC
Lookahead Function section in this manual for details.
Minimum Move Time
If a feedrate-specified move segment is so short in distance that it cannot reach its target velocity, it will
spend its entire time in acceleration (yielding a triangular rather than trapezoidal profile). The minimum
time for such a move is thus the specified acceleration time (the larger of TA or 2*TS). For a single move
remember to add on the extra acceleration time to decelerate to a stop.
In a time-specified move segment, if TM is less than the acceleration time, the segment will be done in
acceleration time, not TM time.
In other words, the acceleration time is the minimum time for an individual blended move or blended
move segment. This is in part a protection against move times getting so short that Turbo PMAC cannot
calculate them in real time. If you are working with very short move segments and your move sequence
is going more slowly than you want, this acceleration-time limit may well be causing the problem.
TM or ∆P/F time
TA TA
TA TA
TM or ∆P/F TM or ∆P/F TM or ∆P/F time
TA TA
TM or ∆ P/F time
V
TM or ∆P/F time
TA TA
CIRCULAR INTERPOLATION
+Z +Z
CW CW
+X +Y +X +Y
NORMAL K-1 NORMAL K1
+Z +Z
CW
CW
+X +Y +X +Y
NORMAL J-1 NORMAL J1
+Z +Z
CW
CW
+X +Y +X +Y
NORMAL I-1 NORMAL I1
NORMAL VECTORS FOR CIRCULAR MOVES:
THE PLANES AND CLOCK WISE ARCS THEY DEFINE
Center Vector
If the vector method of locating the arc center is used, the vector is specified by its I, J, and K-
components (I specifies the component parallel to the X axis, J to the Y axis, and K to the Z-axis). This
vector can be specified as a distance from the starting point (i.e. incrementally), or from the XYZ origin
(i.e. absolutely). The choice is made by specifying ‘R’ in an ABS or INC statement (e.g. ABS(R) or
INC(R)). This affects I, J, and K-specifiers together. (ABS and INC without arguments affect all axes,
but leave the vectors unchanged). The default is for incremental vector specification.
Note:
The standard machine-tool usage is for incremental vector specification even when
move endpoint specification is absolute.
A typical circular move command with a vector specification is:
X1000 Y2000 I500 J-500
Example:
Starting from the point X0 Y0, make a quarter circle clockwise in the XY plane to X20 Y20, then a linear
move to X40 Y20, then a three-quarters circle clockwise to X20 Y0. With the default modes of absolute
move and incremental vector specification, the program would be:
NORMAL K-1 ; XY plane
F10
CIRCLE1 ; Clockwise circle
PMAC
END
Y (25,30) Y
NORMAL K-1
DefaultsABS (X,Y)
INC (R) CIRCLE2
CIRCLE1 START
TM1000
F10 CENTER (25,20) X15Y10I-10
Y X25Y30I20J5 (15,20)
CENTER I
(30,10)
START
(10,5) J Y
END
(15,10)
I X X
X X
Y Y 1 CIRCLE2
CIRCLE1 TM2000
F25 X0Y10R10
X30Y10I-10J10 END
or (0,10) 2 CIRCLE2
CENTER I-10J10 TM2000
(20,20) 2 X0Y10R-10
J
I START,END
Y (30,10) 1
START (10,0)
X X
X
No Center Specification
If there is neither a vector specification nor a radius specification on a given move command line, the
move will be linearly interpolated between start and end points, even if the program is in circular move
mode. However, cutter compensation will not work properly if this is done. LINEAR move mode must
be explicitly declared if cutter compensation is on.
Vector Feedrate Axes
Any axes used in the circular interpolation are automatically feedrate axes for circular moves, even if they
were not so specified in an FRAX command. Other axes may or may not be feedrate axes. Any non-
feedrate axes commanded to move in the same move command will be linearly interpolated so as to finish
in the same time. This permits easy helical interpolation. See the Feedrate Axes section in this manual.
Circle-Radius Errors
If the endpoint is not the same distance from the center as the starting point, the change in radius is taken
up smoothly over the course of the move. Technically, Turbo PMAC generates an exponential spiral
curve with a constant vector feedrate and a constant change in radius with respect to time (constant
dR/dθ).
When using an IJK center vector, this spiral curve can be created over any angle between the start point,
the “center” and the end point. When using the R radius-magnitude specification, a spiral can be created
only if the distance between the start point and the end point is more than twice the radius magnitude. In
this case, the start point, the center, and the end point will all be collinear (like a semi-circle). For moves
specified this way, this technique is really used just to permit the execution of semi-circles with some
tolerance for round-off errors.
Each coordinate system has an I-variable (Isx96) that determines the limit in distance difference for which
this compensation will be done. Above this limit, a run-time error will be generated and the program will
stop. This limit allows distinguishing between round-off errors and major mistakes. Regardless of this
limit, if the distance from starting point to center or from ending point to center is zero, an error will be
generated and the program will stop. If the specified vector does not lie in the plane of interpolation, the
projection of that vector into the plane is used.
Move Segmentation Mode
Turbo PMAC computes circular trajectories through a rapid and continuous cubic spline technique called
“segmentation mode.” The spline segments are of a time specified by coordinate system variable Isx13
(in units of milliseconds). Typically a value of 5 to 10 milliseconds will be used, depending on the
number of axes being controlled by the card. When Isx13 is greater than zero, all blended moves – linear
and circular – are computed through this ongoing cubic spline technique. The exact move calculations
are performed every Isx13 milliseconds, and fine interpolation between these intermediate points is done
at the servo update rate using an efficient cubic B-spline interpolation (identical to Turbo PMAC’s
SPLINE1 mode).
If Isx13 is zero, linear moves are not computed using this spline technique and circular moves are not
permitted (if a circular move is requested, it will be done as a linear move). The difference in the actual
performance of linear-mode moves between Isx13=0 mode and Isx13>0 mode is virtually imperceptible,
unless the feature sizes of the moves are in the same range as the Isx13 time.
Segmentation mode (Isx13 > 0) also is required to use cutter-radius compensation (even if circle moves
are not explicitly programmed), kinematic calculations, and the special lookahead buffer.
Rapid-Mode Moves
Rapid-mode moves provide for minimum-time point-to-point moves, subject to pre-defined motor
constraints. These moves are essentially jog moves for each motor assigned to an axis specified in the
move. The acceleration for each motor is controlled by the Ixx20 and Ixx21 acceleration times; however,
if the rate of acceleration determined by the motor’s move speed and these variables exceeds the Ixx19
acceleration limit, the times will be extended so that the rate will not exceed Ixx19. Many users will set
Ixx20 and Ixx21 to very small values (e.g. 1 and 0; do not set both to 0) so that the Ixx19 rate controls all
of these acceleration profiles.
The speed of the move is controlled either by the maximum-speed parameter Ixx16 (default) or the jog-
speed parameter Ixx22, depending on the setting of motor variable Ixx90. A short move may not reach
the programmed speed, just accelerating and decelerating through the move.
A motion program is put into this mode using the RAPID statement. It is taken out of this mode by
another move mode command (e.g. LINEAR, CIRCLEn, PVT, SPLINEn). RAPID is equivalent to the
RS-274 G-Code G00.
Move Time
On a multi-axis rapid mode move, only the motor calculated to take the longest time at its specified Ixx16
or Ixx22 speed will actually be commanded to move at that speed. The commanded speeds for other
motors are lessened so that they have the same ratio of distance to speed, yielding the same move time for
all motors (before acceleration and deceleration are added). This makes the move path in a Cartesian
system approximately linear. However, if the acceleration times are not the same for all motors, as will
happen if the Ixx19 acceleration limits are hit, the commanded move path will not be perfectly linear.
Maximum Move Time Limit
The maximum move time for a RAPID-mode move is 8,388,607 msec, approximately 2 hours and 20
minutes. If the distance and speed for any motor request a move time greater than this time, Turbo
PMAC will use this maximum time instead, and the speed will be higher than what was programmed.
Minimum Move Time Limit
The minimum move time for a RAPID-mode move is the longest acceleration time (Ixx20 or 2*Ixx21,
whichever is greater) for any motor in the coordinate system, including motors not explicitly commanded
on the program line. Users who may command very short RAPID moves and want them to conclude very
quickly should set Ixx20 and Ixx21 very small for all motors, and use the Ixx19 acceleration limit to
control the acceleration profile.
Move Path
Because the move times (before accel/decel) for all motors are made the same, the move path in a
Cartesian system will be at least approximately linear. However, the acceleration times (not rates) for all
motors must be the same for a truly linear path in a Cartesian system. To obtain this fully linear path,
Ixx20 and Ixx21 must be the same for all motors in the coordinate system, and Ixx19 for all motors must
be set high enough not to be used for the move.
If kinematic subroutines are used to program a non-Cartesian system in Cartesian coordinates, RAPID-
mode moves will not in general have a linear path in the system. The kinematic calculations for RAPID-
mode moves are done only at the programmed end points for RAPID-mode moves, not at many points
along the way.
No Blending
A rapid-mode move is never blended with another move at the programmed end-point; all motors will be
commanded to at least a momentary stop before the next move is commanded to start. However, unlike
in other modes, rapid-mode moves may be broken into at arbitrary points along the trajectory to change to
a different destination. This can be implemented with the move-until-trigger and altered-destination
functions described below.
Motion Program Move-Until-Trigger
The move-until-trigger function permits a programmed rapid-mode move to be interrupted by a trigger
and terminated by a move relative to the position at the time of the trigger. It is similar to a homing
search move, except that the motor zero position is not altered, and there is a specific destination in the
absence of a trigger.
The move-until-trigger is a variant of the RAPID move mode on Turbo PMAC. Speeds and accelerations
are governed by the same variables as for regular rapid moves. The move-until-trigger function for an
axis, and therefore for any motors defined to that axis, is specified by adding a ^{data} specifier to the
move command for the axis, where {data} is the distance to be traveled relative to the trigger before
stopping.
This makes the axis command for a move-until trigger {axis}{data}^{data}, something like
X50^-5. The first value is the destination position or distance (depending on whether the axis is in
absolute or incremental mode) to be traveled in the absence of a trigger. The second value is the distance
to be traveled relative to the position at the time of the trigger. This value is always expressed as a
relative distance, regardless of whether the axis is in absolute or incremental mode. Both values are
expressed in the axis user units.
Other axes can be specified on the same line without a caret and second value. These axes will do a
simultaneous normal RAPID move. However, if an axis matrix transformation is active for the X, Y, and
Z-axes in this coordinate system (TSELECT has been used to select a matrix), if there is a move-until-
trigger on any of the X, Y, and Z-axes, the other axes in the XYZ triplet will also execute a move until
trigger. If no post-trigger move is specified for the axis, the post-trigger distance is assumed to be zero.
If no move at all is specified for the axis, a zero-distance pre-trigger move is assumed.
The trigger condition for each motor is set up just as for homing-search moves:
• Ixx97 bit 1 specifies whether input flags are used to create the trigger, or the warning-following-error
limit status bit is the trigger (the magnitude of the following error exceeds Ixx12): 0=flags, 1=error
status. Triggering on following error is often known as “torque-limited triggering.”
• If input flags are to create the trigger, Ixx25 specifies the flag register.
• If input flags are to create the trigger, Encoder/Flag I-variables I7mn2 and I7mn3 for this channel
specify which edges of which signals will cause the trigger.
• Ixx97 bit 0 specifies whether the hardware-captured counter value is used as the trigger position –
suitable for incremental encoder signals, real or simulated – or the software-read position is used
instead – suitable for other types of feedback (0=hardware, 1=software). The software-read position
must be used if the warning-following-error status is used for the trigger.
Note that each motor has an independent triggering function and move relative to the trigger, even if the
motors are assigned to the same axis. If a common trigger signal is desired for multiple motors, the same
trigger signal must be wired into the flag inputs for all of those motors.
Turbo PMAC will blend each motor smoothly from the pre-trigger move to the post-trigger move
according to the jog/home acceleration parameters Ixx19, Ixx20, and Ixx21.
All motors must come to a stop, either at the originally specified position, or at the post-trigger position,
before Turbo PMAC will calculate any further in the motion program. This means that there is no
blending of the post-trigger move into any subsequent moves.
The captured value of the sensor position at the trigger is stored in a dedicated register if later access is
needed. The units are in counts; for incremental encoders, they are relative to the power-up/reset
position.
Turbo PMAC sets the motor home-search-in-progress status bit (bit 10 of the first motor status word
returned on a ? command) true (1) at the beginning of a programmed move-until-trigger move. The bit is
set false (0) either when the trigger is found, or at the end of the move.
Turbo PMAC also sets the motor trigger move status bit (bit 7 of the second motor status word returned
on a ? command) true at the beginning of a programmed move-until-trigger move, and keeps it true at
least until the end of the move. If a trigger is found during the move, this bit is set false at the end of the
post-trigger move; however, if the pre-trigger move finishes without finding a trigger, the bit is left true at
the end of the move. Therefore, this bit can be used at the end of the move to tell whether the trigger was
found or not.
Altered-Destination Moves
Turbo PMAC gives you the capability for altering the destination of certain moves in the middle of the
execution of those moves by issuing an on-line command. This allows you to start a move with a
tentative destination and then change the destination during the move, with a smooth transition to the
altered destination. If no move is currently executing, this feature also gives the capability of
commanding a simple programmed move without using a program buffer.
This technique works with RAPID-mode moves only. The only motion mode whose destination can be
altered on the fly is RAPID mode, and the only motion mode that can be used to approach the new
destination is RAPID mode.
Altered-Destination Command
This feature is implemented by the on-line coordinate-system-specific command
!{axis}{constant}[{axis}{constant}…] or its variant
!{axis}Q{constant}[{axis}Q{constant}…] . The exclamation point identifies this
command as the on-line altered-destination command. The axis letters and their associated values specify
the new destination.
In the first case (e.g. !X3.0Y2.7), the constant value associated with each axis letter directly specifies
the new destination of the axis. Typically, this first case is used when the command is issued from a host
computer.
In the second case (e.g. !XQ21YQ22), the constant value associated with each axis letter after the ‘Q’
character specifies the number of the Q-variable for the coordinate system whose value represents the
new destination for the axis. For example, if Q21=3.0 and Q22=2.7, then !XQ21YQ22 is equivalent to
!X3.0Y2.7. Usually, this second case is used when the command is issued from a Turbo PMAC PLC
program.
The values specified in this command are always positions of the new destinations (relative to “program
zero”), not distances from previous commanded positions. That is, this command is always effectively in
absolute mode, regardless of whether the axes are in absolute or incremental mode. If the axes are in
incremental mode, they will stay in incremental mode for subsequent buffered program commands.
If there is no commanded move in progress when this command is issued, Turbo PMAC will execute a
RAPID-mode point-to-point move to the specified coordinates. This makes it equivalent to a jog-to-
position command in action, although the destination is specified in user units, not counts.
If a RAPID-mode move is in progress when the command is issued, Turbo PMAC will extend the current
trajectory of each motor for Ixx92 milliseconds. At that point, it will break into the trajectory of each
motor, compute a smooth blending for each motor to the RAPID-mode trajectory toward the new
destination, and execute the modified trajectory. Because the altered-destination move is itself a RAPID-
mode move, its destination can be modified with a subsequent altered-destination command.
If a move of some other mode is in progress when this command is issued, Turbo PMAC will reject the
command with an error.
Use of Altered Destination
The altered-destination command is most often used to modify the destination of a RAPID-mode move
executing from the coordinate system’s rotary motion-program buffer as the last move in that buffer. In
typical use, the RAPID move will be started with an approximate idea of the final destination, while some
sensor, such as a vision system, determines the exact location. The altered-destination command is then
sent to the coordinate system with the exact coordinates of the final destination.
If the altered-destination command is not received before the end of the move, there will be a momentary
pause before the move to the final end position is started, but all axes end up in the same location as if the
command were received before the end of the move. Note, however, that in this case, certain status bits
such as desired-velocity-zero, and in-position may get set at the end of the initial move, and so cannot be
counted on by themselves to show that the modified end-point has been reached.
The altered-destination command can also be used to modify a RAPID-mode move that is not at the end
of the rotary buffer, or one that is in a “fixed” motion-program buffer. In this case, there are a couple of
things to watch. First, if axes are in incremental mode, the subsequent moves in the program are modified
by the altered destination. Second, if the altered-destination command is received after the RAPID-mode
move is finished; it may be rejected with an error, depending on what the program is executing
subsequently.
Spline-Mode Moves
Turbo PMAC can perform two types of cubic splines (cubic in terms of the position-vs.-time equations)
to blend together a series of points on an axis. Its SPLINE1 mode is a uniform non-rational cubic B-
spline and its SPLINE2 mode is a non-uniform non-rational cubic B-spline. It can, of course, do either
spline for all of the axes simultaneously. Splining is particularly suited to odd (non-Cartesian)
geometries, such as radial tables and rotary-axis robots, where there are odd axis profile shapes even for
regular tip movements.
How They Work
In SPLINE1 mode, a long move is split into equal-time segments, each of TM or TA time (depending on
the setting of global variable I42). Each axis is given a destination position in the motion program for
each segment with a normal move command line like X1000Y2000. Looking at the move command
before this and the move command after this, Turbo PMAC creates a cubic position-vs-time curve for
each axis so that there is no sudden change of either velocity or acceleration at the segment boundaries.
The commanded position at the segment boundary may be “relaxed” slightly to meet the velocity and
acceleration constraints (see figures below).
The spline move time as used in the actual spline calculations is a 24-bit fixed-point value with 12 bits of
integer and twelve bits of fraction. This provides a range of up to 4096 milliseconds (just over 4 seconds)
with a resolution of about ¼-microsecond. If I42 is set to the default value of 0, this time is specified in a
TM command, which supports the fractional resolution. If I42 is set to 1, this time is specified in a TA
command, which does not support the fractional resolution. This mode is mainly for compatibility with
older non-Turbo PMAC applications.
Turbo PMAC computes intermediate “way-points” WPi for each axis for each point along the spline by
taking a weighted average of the specified point Pi and the specified points on either side. For the
uniform spline, this is done according to the equation:
P + 4 Pi + Pi +1
WPi = i −1
6
Turbo PMAC also computes the velocity Vi for each axis at each way-point along the spline. In the
uniform spline, it does this by taking the velocity halfway between the average velocities of the segments
on either side of the way point:
(Pi+1 − Pi ) + (Pi − Pi−1 ) P − Pi −1
Vi = = i +1
2T 2T
Similar calculations are done for the non-uniform spline.
Having computed exact positions and velocities at segment boundaries, Turbo PMAC calculates the
unique cubic position equation (parabolic velocity profile) that meets these constraints, and uses this
equation for interpolation.
Added Pieces
At the beginning and end of a series of splined moves, Turbo PMAC automatically adds a zero-distance
segment of the same segment time for each axis, and performs the spline between this segment and the
adjacent one. This results in S-curve acceleration to and from a stop.
Quantifying the Position Adjustment
The difference between the splined commanded position and the pre-splined (program-line) commanded
position for an axis at the end of segment i in the uniform spline can be calculated according to the simple
equation:
Dist i +1 − Dist i
Diff i =
6
where Disti is the programmed distance for segment i of the spline (whether in absolute or incremental
mode), and Disti+1 is the programmed distance for segment i+1.
5-Point Spline Correction
In contouring applications, it is often desired to pass through the series of points as closely as possible. In
these applications, the error introduced by the standard spline algorithm may be too large to tolerate.
However, in the uniform spline, a simple pre-compensation can reduce the splining errors dramatically.
For each point Pi in the spline, replace with a point P’i with the following formula before sending to
Turbo PMAC:
− Pi −1 + 8 Pi − Pi +1
P' i =
6
Non-Uniform Spline
Turbo PMAC’s SPLINE2 mode is similar to the SPLINE1 mode, except that the requirement that the
TA spline segment time remain constant is removed. The removal of this constraint makes the SPLINE2
mode a non-uniform non-rational cubic B-spline, whereas the SPLINE1 mode is a uniform non-rational
cubic B-spline. The “non-rational” specification indicates that there are no independent weightings
(ratios) of the different points in the spline.
The added segment at the beginning of a spline has the same time as the first programmed segment; the
added segment at the end of a spline has the same time as the last programmed segment.
The combined time of any three consecutive segments in a SPLINE2 continuous spline must be less than
8,388,608 msec, or about 2 hours and 20 minutes.
SPLINED MOVES
etc. Vc =
P
VEL
TA
No velocity or acceleration
discontinuities at segment
boundaries
etc.
INCREMENTAL
SPLINE
TA500
X10000
X9000
X10500
X12000
TA TA TA TA TA TA TIME
(added) (added)
VEL
dA
= constant (calculated)
dt
A0
P1 (specified)
(calculated)
P0 ,V 0 V1 (specified)
(from A 1 (calculated)
before)
PVT200
P P1 P0 ...
X9000:150
...
TA TIME
(specified)
PVT-Mode Moves
For the user who desires more direct control over the trajectory profile, Turbo PMAC offers Position-
Velocity-Time (PVT) mode moves. In these moves, you specify the axis states directly at the transitions
between moves (unlike in blended moves). This requires more calculation by the host, but allows tighter
control of the profile shape. For each piece of a move, you specify the end position or distance, the end
velocity, and the piece time.
Mode Statement
Turbo PMAC is put in this mode with the program statement PVT{data}, where {data} is a floating-
point constant, variable, or expression, representing the piece time in milliseconds. If I42 is set to the
default value of 0, Turbo PMAC converts this value to a 24-bit value with 12 bits of integer and 12 bits of
fraction. This provides a range of up to 4096 milliseconds (just over 4 seconds) with a resolution of about
¼-microsecond. If I42 is set to 1, Turbo PMAC converts this to a 12-bit integer value with no fractional
component (rounding to the nearest integer). This mode is mainly for compatibility with older non-Turbo
PMAC applications.
The move time may be changed between moves, either with another PVT{data} statement, or with a
TM{data} statement if I42 = 0, or a TA{data} statement if I42 = 1. The program is taken out of this
mode with another move mode statement (e.g. LINEAR, RAPID, CIRCLE, SPLINE).
Move Statements
A PVT mode move is specified for each axis to be moved with a statement of the form
{axis}{data}:{data}, where {axis} is a letter specifying the axis, the first {data} is a value
specifying the end position or the piece distance (depending on whether the axis is in absolute or
incremental mode), and the second {data} is a value representing the ending velocity.
The units for position or distance are the user length or angle units for the axis, as set in the Axis
Definition statement. The units for velocity are defined as length units divided by time units, where the
length units are the same as those for position or distance, and the time units are defined by variable Isx90
for the coordinate system (feedrate time units). The velocity specified for an axis is a signed quantity.
Turbo PMAC Calculations
From the specified parameters for the move piece, and the beginning position and velocity (from the end
of the previous piece), Turbo PMAC computes the only third-order position trajectory path to meet the
constraints. This results in linearly changing acceleration, a parabolic velocity profile, and a cubic
position profile for the piece.
Problems in Stepping
Since you can specify (directly or indirectly) a non-zero end velocity for the move, it is not a good idea to
step through a program of transition-point moves, and great care must be exercised in downloading these
moves in real time. With the use of the BLOCKSTART and BLOCKSTOP statements surrounding a series
of PVT moves, the last of which has a zero end velocity, it is possible to use a Step command to execute
only part of a program.
Use of PVT to Create Arbitrary Profiles
The PVT mode is the most useful for creating arbitrary trajectory profiles. It provides a "building block"
approach to putting together parabolic velocity segments to create whatever overall profile is desired.
The diagram PVT Segment Shapes, below, shows common velocity segment profiles. PVT mode can
create any profile that any other move mode can.
PVT
Vel Segme Vel
V nt V
Shapes
∆P=1/2 Vt
∆P=1/3 Vt
t Time t Time
Vel Vel
V V
∆P=2/3 Vt ∆P=Vt
t Time t Time
Vel Vel
V2 V
V
∆P =1/6 Vt
V/2 1
∆ P =5/6 Vt
∆P=1/2(V +V ) t 2
1 2
t Time t 2t Time
This same command also specifies the plane for circular interpolation. NORMAL K-1 is the default. The
compensation plane should not be changed while compensation is active.
Other common settings are NORMAL J-1, which specifies the ZX-plane for compensation, and NORMAL
I-1, which specifies the YZ-plane. These three settings of the normal vector correspond to RS-274 G-
codes G17, G18, and G19, respectively. If implementing G-codes in Turbo PMAC program 1000,
incorporate them in PROG 1000:
N17000 NORMAL K-1 RETURN
N18000 NORMAL J-1 RETURN
N19000 NORMAL I-1 RETURN
Defining the Magnitude of Compensation
The magnitude of the compensation – the cutter radius – must be set using the buffered motion program
command CCR{data} (Cutter Compensation Radius). This command can take either a constant
argument (e.g. CCR0.125) or an expression in parentheses (e.g. CCR(P10+0.0625)). The units of
the argument are the user units of the X, Y, and Z-axes. In RS-274 style programs, these commands are
often incorporated into “tool data” D-codes using Turbo PMAC motion program 1003.
Negative and zero values for cutter radius are possible. Note that the behavior in changing between a
positive and negative magnitude is different from changing the direction of compensation. See the
Changes in Compensation section of this manual. Also, the behavior in changing between a non-zero
magnitude and a zero magnitude is different from turning the compensation on and off. See the
appropriate sections below.
Turning On Compensation
The compensation is turned on by buffered motion program command CC1 (offset left) or CC2 (offset
right). These are equivalent to the RS-274 G-Codes G41 and G42, respectively. If implementing G-
Code subroutines in Turbo PMAC motion program 1000, incorporate them in PROG 1000:
N41000 CC1 RETURN
N42000 CC2 RETURN
Turning Off Compensation
The compensation is turned off by buffered motion program command CC0, which is equivalent to the
RS-274 G- Code G40. If implementing G-Code subroutines in Turbo PMAC motion program 1000,
incorporate them in PROG 1000:
N40000 CC0 RETURN
How Turbo PMAC Introduces Compensation
Turbo PMAC gradually introduces compensation over the next LINEAR or CIRCLE-mode move
following the CC1 or CC2 command that turns on compensation. This lead-in move ends at a point one
cutter radius away from the intersection of the lead-in move and the first fully compensated move with
the line from the programmed point to this compensated endpoint being perpendicular to the path of the
first fully compensated move at the intersection.
Note:
Few controllers can make their lead-in move a CIRCLE-mode move. This
capability permits establishing contact with the cutting surface very gently,
important for fine finishing cuts.
Inside Corner Introduction
If the lead-in move and the first fully compensated move form an inside corner, the lead-in move goes
directly to this point. When the lead-in move is a LINEAR-mode move, the compensated tool path will
be at a diagonal to the programmed move path. When the lead-in move is a CIRCLE-mode move, the
compensated tool path will be a spiral.
CC2 CC2
Line to Line Line to Arc
Line
Programmed
Path Programmed
r r Path
Arc Arc
Tool Center Arc
Path
Line
Arc
Spiral Spiral
Tool Center
Path
CC2 CC2
Arc to Line Arc to Arc
Outside Corner Introduction
If the lead-in move and the first fully compensated move form an outside corner, the lead-in move first
moves to a point one cutter radius away from the intersection of the lead-in move and the first fully
compensated move, with the line from the programmed point to this compensated endpoint being
perpendicular to the path of the lead-in move at the intersection. When the lead-in move is a LINEAR-
mode move, this compensated tool path will be at a diagonal to the programmed move path.
When the lead-in move is a CIRCLE-mode move, this compensated tool path will be a spiral. Then a
circular arc move with radius equal to the cutter radius is added, ending at a point one cutter radius away
from the intersection of the lead-in move and the first fully compensated move, with the line from the
programmed point to this compensated endpoint being perpendicular to the path of the first fully
compensated move at the intersection.
Introducing Compensation – Outside Corner
CC2 CC2
Line Line
Programmed
Path
Line Arc
Line Line Arc
Programmed
r Path r Tool Center
r r Path
Tool Center
Path
Arc
Line
Line to Line Line to Arc
CC2 CC2
Note that the behavior for lead-in moves is different from changing the compensation radius from zero to
a non-zero value while compensation is active. An arc move is always added at the corner, regardless of
the setting of Isx99. This ensures that the lead-in move never cuts into the first fully compensated move.
Treatment of Compensated Inside Corners
Inside corners are still subject to the blending due to the TA and TS times in force (default values set by
coordinate system I-variables Isx87 and Isx88, respectively). The longer the acceleration time the larger
the rounding of the corner. (The corner rounding starts and ends a distance F*TA/2 from the
compensated, but unblended corner.) The greater the portion of the blending is S-curve, the squarer the
corner will be.
When coming to a full stop (e.g. Step, Quit, or DWELL at the corner) at an inside corner, Turbo PMAC
will stop at the compensated, but unblended, corner point.
Line
Programmed
Path Programmed
r Path
Tool Center r
r Path Arc
Line r
Line Line
Arc
Line Line
Tool Center
Path
Line
Programmed Programmed
Path Path
r r
Tool Center Arc
r Path r
Arc Line Arc
Arc Arc Arc
Tool Center
Path
Line
Line Arc
Arc
r Line r Line
Programmed Programmed
Path Path
Arc r Arc r
Tool Center Tool Center
Path Path
Line Line
Line to Line Line to Arc
Line
Arc
Line
Arc
r r
Programmed Programmed
Path Path
Arc r Arc Arc r Arc
Arc Arc
Tool Center Tool Center
Path Path
Line
Line Programmed
Path
Line Arc
r
Programmed r
Path Line
r
r Arc
Line Tool Center
Path Tool Center
Line Path
Line to Line Line to Arc
Arc
Arc
Programmed
Line Path
Programmed Arc r Arc
Arc r Path r
r
Tool Center
Path Arc
Line Tool Center
Path
Arc to Line Arc to Arc
The added arc prevents the compensated corner from extending too far out on the outside of a sharp
corner. However, as an added move, it has the minimum time of the acceleration time, which can cause a
slowdown on a very shallow angle. While the default value for Isx99 of 0.9998 (cos1o) causes an arc to
be added on any change in angle greater than 1o, many users will set Isx99 to 0.707 (cos45o) or 0.0
(cos90o) so arcs are only added on sharp corners.
When coming to a full stop (e.g. Step, Quit, /, or DWELL) at an outside corner with an added arc, Turbo
PMAC will include the added arc move before stopping. When coming to a full stop at an outside corner
without an added arc, Turbo PMAC will stop at the compensated, but unblended, corner point.
Treatment of Full Reversal
If the change in directed angle at the boundary between two successive compensated moves is 180o + 1o
(the included angle is less than 1o), this is considered a “full reversal” and special rules apply. If both the
incoming and outgoing moves are lines, the corner is always considered an outside corner, and an arc
move of approximately 180o is added. If one or both of the moves is an arc, Turbo PMAC will check for
possible inside intersection of the compensated moves. If such an intersection is found, the corner will be
treated as an inside corner. Otherwise, it will be treated as an outside corner with an added 180o arc
move.
Reversal In Cutter Compensation
Line
r r
Programmed Programmed Path
Path Arc
Line Arc Line
<1o
Line r
Arc
Line
r
Line Arc
Tool Cen Tool Center Tool Center
Arc
ter Path Path Right Path Left
r r Programmed
Path
Arc Arc r r
Arc Arc
Arc Arc
Programmed Arc Arc
Tool Center
Path
Path
r
Programmed r 2 Short
Path Arc
r Executed
Compensated
3 Circle
“Skipped” Programmed
2 Full Circle
Arc
CC2 Line Line Programmed
Path
Programmed CC1
CC2 Line
Path
Tool Center Tool Center
Path Path
Line
Arc Programmed
CC1 CC2 Path
Arc
Arc Arc
Programmed
Path
Arc Arc
CC2 Line
Tool Center Tool Center
Path Path
Line CC1
Arc to Line Arc to Arc
However, if there is no intersection between the two compensated move paths, the change is introduced
linearly over the next move.
Outside Corner
If the last fully compensated move and the lead-out move form an outside corner, the last fully
compensated move ends at a point one cutter radius away from the intersection of the last fully
compensated move and the lead-out move, with the line from the programmed point to this compensated
point being perpendicular to the path of the fully compensated move at the intersection.
Turbo PMAC then adds a circular arc move with radius equal to the cutter radius, ending at a point one
cutter radius away from the same, with the line from the programmed point to this compensated endpoint
being perpendicular to the path of the lead-out move at the intersection.
Finally, Turbo PMAC gradually removes compensation over the lead-out move itself, ending at the
programmed endpoint of the lead-out move. When the lead-out move is a LINEAR-mode move, this
compensated tool path will be at a diagonal to the programmed move path. When the lead-in move is a
CIRCLE-mode move, this compensated tool path will be a spiral.
Removing Compensation – Outside Corner
Line Line
Programmed
Path
CC0 CC0
Line Arc
Line Arc Line
Programmed
Path r Tool Center r
r Path r
Tool Center
Path
Arc
Line
Line to Line Line to Arc
Arc Arc
Programmed
Path
CC0 CC0
Line Arc
Spiral Arc Spiral
Programmed
Path r Tool Center r
r Path r
Tool Center
Path
Arc Arc
Line
Arc to Line Arc to Arc
Note that this behavior is different from changing the magnitude of the compensation radius to zero while
leaving compensation active. An arc move is always added at the corner, regardless of the setting of
Isx99. This ensures that the lead-out move will never cut into the last fully compensated move.
Failures in Cutter Compensation
It is possible to give Turbo PMAC a program sequence in which the cutter compensation algorithm will
fail, not producing desired results. There are three types of reasons the compensation can fail:
1. Inability to calculate through corner
2. Inside corner smaller than radius
3. Inside arc radius smaller than cutter radius
Inability to Calculate through Corner
First, if Turbo PMAC cannot see ahead far enough in the program to find the next move with a
component in the plane of compensation before the present move is calculated, then it will not be able to
compute the intersection point between the two moves. This can happen for several reasons:
• There is a move with no component in the plane of compensation (i.e. perpendicular to the plane of
compensation, as in a Z-axis-only move during XY compensation) before the next move in the plane
of compensation, and no CCBUFFER compensation block buffer declared (see below).
• There are more moves with no component in the plane of compensation before the next move in the
plane of compensation than the CCBUFFER compensation block buffer can hold (see below).
• There are more than 10 DWELLs before the next move in the plane of compensation.
• Program logic causes a break in blending moves (e.g. looping twice through a WHILE loop).
Failures in Cutter Compensation
Overcut
Line
Programmed Tool Tool Center
Path Center Point Arc Path
Line at Failure
(No Overcut) r
r Programmed
r Tool r Path
Center Point Line Line
r at Failure Line
Line Tool Center
Path Line
Line
Overcut (Not
Executed)
With this buffer defined for the coordinate system, if Turbo PMAC encounters one or more moves
perpendicular to the plane of compensation while compensation is active, these moves will be stored in
the CCBUF temporarily while the next move in the plane is found, so the intersections can be computed
correctly. However, if there is not enough room in the buffer to store all of the perpendicular moves
found, Turbo PMAC will assume an outside-corner intersection; if the next move in the plane actually
forms an inside corner, overcut will have occurred.
When programmed moves are actually stored in the CCBUF, commands that change the current position
value – HOME, HOMEZ, and PSET – are not permitted. Turbo PMAC will report an ERR019 if I6 is set to
1 or 3.
The CCBUF, which stores motion program blocks for the purpose of computing proper cutter
compensation intersection points, should not be confused with the LOOKAHEAD buffer, which stores
small motion “segments” generated from these programmed blocks for the purpose of guaranteeing
observance of position, velocity, and acceleration limits. Both of these buffers may be defined and active
for a coordinate system at the same time.
The CCBUF is a temporary buffer. Its contents are never retained through a power-down or card reset;
the buffer itself is only retained through a power-down or reset if it was defined, and I14 was set to 1, at
the time of the last SAVE command.
Single-Stepping While in Compensation
It is possible to execute moves in “single-step” mode while cutter compensation is active, but the user
should be aware of several special considerations for this mode of operation. Because of the need for the
program to see ahead far enough to find the next move in the plane of compensation before the current
move can be executed, the execution of an S single-step command may not produce the intuitively
expected results. The single-step command on a move in compensation causes the preliminary
calculations for that move to be done, not for the move actually to be executed. This has the following
ramifications:
• A single-step command on the lead-in move for compensation will produce no motion, because the
next move has not yet been found.
• Single-step commands on compensated moves in the plane of compensation will cause the previous
move to execute.
• Single-step commands on compensated moves perpendicular to the plane of compensation will
produce no motion, as these will just be held in the CCBUFFER. A single-step command on the next
move in the plane of compensation will cause the previous move in the plane, plus all buffered moves
perpendicular to the plane to execute.
• A single-step command on the lead-out move will cause both the last fully compensated move and the
lead-out move to execute.
Unlike many controllers, Turbo PMAC can execute non-motion program blocks with single-step
commands with cutter compensation active. However, you should be aware that the execution of these
blocks may appear out of sequence, because the motion from the previous programmed move block will
not yet have been executed.
Synchronous M-variable assignments in this mode are still buffered and not executed until the actual start
of motion execution of the next programmed move.
TR TR TR
C
C
R
C
C
R
The second value is the tool radius itself, the radius of the shaft of the tool. This is set by the buffered
motion program command TR{data} (Tool Radius). This command can take either a constant
argument (e.g. TR7.50) or an expression in parentheses (e.g. TR(7.50-Q99)). The units of the
argument are the user units of the X, Y, and Z-axes. In operation, the compensation next offsets the path
by an amount equal to the tool radius minus the cutter’s end radius, perpendicular to the “tool-orientation”
vector (see below).
A flat-end cutter will have a cutter-end radius of zero. A ball-end cutter (hemispherical tip) will have a
cutter-end radius equal to the tool (shaft) radius. Other cutters will have a cutter-end radius in between
zero and the tool radius.
Turning on 3D Compensation
3D cutter compensation is turned on by the buffered motion program command CC3. Since the offset
vector is specified explicitly, there is no left or right compensation here. When 3D compensation is
turned on, the surface-normal vector is set to the null (zero-magnitude) vector automatically, and the tool-
orientation vector is also set to the null vector automatically.
Until a surface-normal vector is declared explicitly with 3D compensation active, no actual compensation
will occur. A tool-orientation vector must also be declared for compensation to work on anything other
than a ball-nose cutter.
Turning Off 3D Compensation
3D cutter compensation is turned off by the buffered motion program command CC0, just as for 2D
compensation. Compensation will be removed over the next LINEAR or CIRCLE mode move after
compensation has been turned off.
Declaring the Surface-Normal Vector
The direction of the surface-normal vector is determined by the NX{data}, NY{data}, and
NZ{data} components declared in a motion program line. The absolute magnitude of these components
does not matter, but the relative magnitudes define the direction. The direction must be from the surface
into the tool.
Generally, all three components should be declared together. If only one or two components are declared
on a program line, the remaining component(s) are left at their old value(s), which could lead to
unpredictable results. If it is desired that a component value be changed to zero, it should be declared
explicitly as zero.
Note that the coordinates of the surface-normal vector must be expressed in the machine coordinates. If
the part is on a rotating table, these coordinates will not in general be the same as the original part
coordinates from the part design – the vector must be rotated into machine coordinates before sending to
Turbo PMAC.
The surface-normal vector affects the compensation for the move on the same line of the motion program,
and all subsequent moves until another surface-normal vector is declared. In usual practice, a surface-
normal vector is declared for each move, affecting that move alone.
Declaring the Tool-Orientation Vector
If the orientation of the cutting tool can change during the compensation, as in five-axis machining, the
orientation for purposes of compensation is declared by means of a tool-orientation vector. (If the
orientation is constant, as in three-axis machining, the orientation is usually declared by the normal vector
to the plane of compensation, although the tool-orientation vector may be used.)
The direction of the tool-orientation vector is determined by the TX{data}, TY{data}, and
TZ{data} components declared in a motion program line. The absolute magnitude of these components
does not matter, but the relative magnitudes define the direction. The direction sense of the tool-
orientation vector is not important; it can be from base to tip, or from tip to base
Generally, all three components should be declared together. If only one or two components are declared
on a program line, the remaining components are left at their old values, which could lead to
unpredictable results. If it is desired that a component value be changed to zero, it should be declared
explicitly as zero.
Note that the coordinates of the surface-normal vector must be expressed in the machine coordinates. If
the part is on a rotating table, these coordinates in general will not be the same as the original part
coordinates from the part design.
The tool-orientation vector affects the compensation for the move on the same line of the motion
program, and all subsequent moves until another tool-orientation vector is declared. In usual practice, a
tool-orientation vector is declared for each move, affecting that move alone.
Note that the tool-orientation vector declared here does not command motion; it merely tells the
compensation algorithm the angular orientation that has been commanded of the tool. Typically the
motion for the tool angle has been commanded with A, B, and/or C-axis commands, often processed
through an inverse-kinematic subroutine on Turbo PMAC.
T
TR
N
CP
TR-C
CR
CC
R
PP
PP: Programmed Position
CP: Compensated Position
N: Surface-Normal Vector
T: Tool-Orientation Vector
CCR: Cutter’s End Radius
TR: Tool Shaft Radius
Because of the nature of the lookahead calculations – trajectory calculations are done well in advance of
the actual move execution, and moves are kept within machine limits by the automatic adjustment of
move speeds and times – they are not appropriate for some applications. Any application requiring quick
reaction to external conditions should not use lookahead. Also, also any application requiring precise
synchronization to external motion, such as those using PMAC’s external time base feature, should not
use lookahead.
When the lookahead function is enabled, Turbo PMAC will scan ahead in the programmed trajectories,
looking for potential violations of its position, velocity, and acceleration limits. If it sees a violation, it
will then work backward through the pre-computed buffered trajectories, slowing down the parts of these
trajectories necessary to keep the moves within limits. These calculations are completed before these
sections of the trajectory are actually executed.
Turbo PMAC can perform these lookahead calculations on LINEAR and CIRCLE mode moves. The
coordinate system must be put in segmentation mode (Isx13 > 0) to enable lookahead calculations, even if
only LINEAR mode moves are used. (The coordinate system must be in segmentation mode anyway to
execute CIRCLE mode moves or cutter radius compensation.) In segmentation mode, Turbo PMAC
automatically splits the moves into small segments, which are executed as a series of smooth splines to re-
create the programmed moves.
Turbo PMAC stores data on these segments in a specially defined lookahead buffer for the coordinate
system. Each segment takes Isx13 milliseconds when it is put into the buffer, but this time can be
extended if it or some other segment in the buffer violates a velocity or acceleration limit.
This technique permits Turbo PMAC to create deceleration slopes in the middle of programmed moves, at
the boundaries of programmed move, or over multiple programmed moves, whichever is required to
create the fastest possible move that does not violate constraints. All of this is done automatically and
invisibly inside the Turbo PMAC; the part programmer and operator do not need to understand the
workings of the algorithm.
The following diagram shows the principle of how the lookahead function can create acceleration and
deceleration profiles automatically over multiple programmed moves. In this case, the programmed
moves are too short to permit the full acceleration to and from programmed speed in a single programmed
move. Without any change to the motion program, the lookahead function will create a profile that does
not violate acceleration constraints.
Before Lookahead
F100
X1
X2
1 2 3 4 5 6 7 8 9 10 X3
X4
t X5
X6
X7
V X8
X9
X10
DWELL50
After Lookahead
ACCEL & DECEL ARE CONTROLLED BY
SPECIFIED ACCEL LIMIT (G’s)
1 2 3 4 5 6 7 8 9 10
t
The next diagram shows how the lookahead function can create a deceleration into a tight corner
automatically, permitting the corner to be taken slowly to keep it within acceleration constraints, and then
to accelerate back up to the programmed speed coming out of the corner. This permits the user to
command high speeds, and to have Turbo PMAC slow down the path only where needed. Note that the
post-lookahead profile in this diagram is not time-extended as it would really be; this was done to show
the correspondence of points on the profiles.
Lookahead & Small, Tight Corners
Y F50
X10 Y10 VX
5 X0 Y20
4 Time
3
1 2 3 4 5
2 VY
1
F50
Y X10 Y10 VX
7
X0 Y20 Time
6
5 ACCEL & DECEL
CONTROLLED BY
4 SPECIFIED G’s
1 2 3 4 5 6 7
AT CORNER
3
2
VY
1
Time
X Note how ‘Y” decelerates
After Lookahead to make the corner
If Turbo PMAC’s inverse kinematic calculations are used, the conversion from tip coordinates to joint
coordinates takes place before lookahead calculations, segment by segment for LINEAR and CIRCLE
mode moves. Therefore, Turbo PMAC can execute the lookahead calculations in joint space, motor by
motor, even if the system has been programmed in tip coordinates.
Once the lookahead function has been set up, the lookahead function operates transparently to the
programmer and the operator. No changes need to be made to a motion program to use the lookahead
function, although the programmer may choose to make some changes to take advantage of the increased
performance capabilities that lookahead provides.
Quick Instructions: Setting Up Lookahead
The following list quickly explains the steps required for setting up and using the lookahead function on
the Turbo PMAC. Greater detail and context are given in the subsequent section.
1. Assign all desired motors to the coordinate system with axis definition statements.
2. Set Ixx13 and Ixx14 positive and negative position limits, plus Ixx41 desired position-limit band, in
counts for each motor in coordinate system. Set bit 15 of Ixx24 to 1 to enable desired position limits.
3. Set Ixx16 maximum velocity in counts/msec for each motor in coordinate system.
4. Set Ixx17 maximum acceleration in counts/msec2 for each motor in coordinate system.
5. Set Isx13 segmentation time in msec for the coordinate system to minimum programmed move block
time or 10 msec, whichever is less.
6. Compute maximum stopping time for each motor as Ixx16/Ixx17.
7. Select motor with longest stopping time.
8. Compute number of segments needed to look ahead as this stopping time divided by (2 * Isx13).
9. Multiply the segments needed by 4/3 (round up if necessary) and set the Isx20 lookahead length
parameter to this value.
10. If the application involves high block rates, set the Isx87 default acceleration time to the minimum
block time in msec; the Isx88 default S-curve time to 0.
11. If the application does not involve high block rates, set the Isx87 default acceleration time and the
Isx88 default S-curve time parameters to values that give the desired blending corner size and shape
at the programmed speeds.
12. Store these parameters to non-volatile memory with the SAVE command if you want them to be an
automatic part of the machine state.
13. After each power-up/reset, send the card a DEFINE LOOKAHEAD {# of segments},{# of
outputs} command for the coordinate system, where {# of segments} is equal to Isx20 plus
any segments for which backup capability is desired, and {# of outputs} is at least equal to the
number of synchronous M-variable assignments that may need to be buffered over the lookahead
length.
14. Load your motion program into the Turbo PMAC. Nothing special needs to be done to the motion
program. The motion program defines the path to be followed; the lookahead algorithm may reduce
the speed along the path, but it will not change the path.
15. Run the motion program, and let the lookahead algorithm do its work.
Detailed Instructions: Setting up to use Lookahead
A few steps are required to calculate and set up the lookahead function. Typically, the calculations have
to be done only once in the initial configuration of the machine. Once configured, the lookahead function
operates automatically and invisibly.
Defining the Coordinate System
The lookahead function checks the programmed moves against all motors in the coordinate system.
Therefore, the first step is to define the coordinate system by assigning motors to axes in the coordinate
system with axis definition statements. This action is covered in the Setting up the Coordinate System
section of this manual.
Lookahead Constraints
Turbo PMAC’s lookahead algorithm forces the coordinate system to observe four constraints for each
motor. These constraints are defined in I-variables for each motor representing maximum position
extents, velocities, and accelerations. These I-variables must be set up properly in order for the lookahead
algorithm to work properly.
Position Limits
Variables Ixx13 and Ixx14 for each Motor xx define the maximum positive and negative position values,
respectively, that are permitted for the motor (software overtravel limits). These variables are defined in
counts, and are referenced to the motor zero, or home, position (often called machine zero). Even if the
origin of the axis for programming purposes has been offset (often called program zero), the physical
position of these position limits does not change; they maintain their reference to the machine zero point.
Turbo PMAC checks the actual position for each motor as the trajectory is being executed against these
limits; if a limit is exceeded, the program is aborted and the motors are decelerated at the rate set by
Ixx15.
Variable Ixx41 for each Motor xx defines the distance between the actual position limits explained above,
and the desired position limit that can be checked at move calculation time, even in lookahead. That is, if
the calculated desired move position is greater than (Ixx13 – Ixx41), or less than (Ixx14 + Ixx41), this
will constitute a desired position limit violation. Desired position limits are checked only if bit 15 of
Ixx24 is set to 1.
In this mode, if the lookahead algorithm, while scanning ahead in the programmed trajectory, determines
that any motor in the coordinate system would exceed one of its desired position limits, it will suspend the
program and force a stop right at that limit. It will then work backwards through the buffered trajectory
segments to bring the motors to a stop along the path at that point in the minimum time that does not
violate any motor’s Ixx17 acceleration constraint.
However, if bit 14 of Ixx24 is also set to 1, the program does not stop at the limit. Instead, it will
continue, with the offending motor saturating at the limit value.
When stopped on a desired position limit within lookahead, the program is only suspended, not aborted.
The action is equivalent to issuing a \ quick-stop command. It is possible to “retrace” the path coming
into the limit, or even to resume forward execution after changing the limit value. An “abort” command
must be issued before another program can be started.
Note, however, that if an actual position limit is also tripped during the deceleration to a stop at the
desired position limit, the program is aborted, so retracing and resuming are not possible. For this reason,
if the possibility of retracing and resuming is important, Ixx41 should be set to a large enough value so
that the actual position limit is never tripped during a desired position limit stop.
This technique permits these software position limits to be placed just within the hard stops of the
machine. Without the desired position limits, the software position limits cannot be detected until the
actual trajectory actually passes the limit. This requires that these limits be placed far enough within the
hard stops so that the motors have enough distance to stop after they pass the limits. (When a motor hits a
software position limit without lookahead, the deceleration of motors is controlled by Ixx15, not Ixx17,
and deceleration is not necessarily along the programmed path.)
Velocity Limits
Variable Ixx16 for each Motor xx defines the magnitude of the maximum velocity permitted for the
motor. These variables are defined in the raw PMAC units of counts per millisecond, so a quick
conversion must be calculated from the user units (e.g. millimeters per minute).
If the algorithm, while looking ahead in the programmed trajectory, determines that any motor in the
coordinate system is being asked to violate its velocity limit, it will slow down the trajectory at that point
just enough so that no limit is violated. It will then work backwards through the buffered trajectory
segments to create a controlled deceleration along the path to this limited speed in the minimum time that
does not violate any motor’s Ixx17 acceleration constraint.
Note:
During the initial move-block calculations, before move data is sent to the
lookahead function, a couple of factors can result in commanded velocities lower
than what is programmed. First, if the vector feedrate commanded in the motion
program with the F command exceeds the maximum feedrate parameter Isx98,
then Isx98 is used instead. Second, if the move-block time, either specified
directly with the TM command, or calculated as vector-distance divided by vector-
feedrate, is less than the programmed acceleration time (the larger of TA or 2 *
TS), the programmed acceleration time is used instead. This results in a speed less
than what was programmed. The lookahead function can further slow these
moves, but it cannot speed them up.
Acceleration Limits
Variable Ixx17 for each Motor xx defines the magnitude of the maximum acceleration permitted for the
motor. These variables are defined in the raw PMAC units of counts per (millisecond-squared), so a
quick conversion must be calculated from the user units (e.g. in/sec2, or g’s).
If the algorithm, while looking ahead in the programmed trajectory, determines that any motor in the
coordinate system is being asked to violate its acceleration limit, it will slow down the trajectory at that
point just enough so that no limit is violated. It will then work backwards through the buffered trajectory
segments to create a controlled deceleration along the path to this limited speed in the minimum time that
does not violate any motor’s Ixx17 acceleration constraint.
Calculating the Segmentation Time
Turbo PMAC’s lookahead function operates on intermediate motion segments calculated from the
programmed trajectory. An intermediate point for each motor is computed once per segment from the
programmed path, and then a fine interpolation using a cubic spline to join these segments is executed at
the servo update rate. Therefore, the user settable segmentation time is an important parameter for
optimization of the lookahead function.
Variable Isx13 for each Coordinate System x defines the time for each intermediate segment in the
programmed trajectory, in milliseconds, before it is possibly extended by the lookahead function. Isx13
is an integer value; if a non-integer value is sent, Turbo PMAC will round to the next integer. If Isx13 is
set to 0, the coordinate system is not in segmentation mode; no intermediate segments are calculated, and
the lookahead function cannot be enabled.
Several issues must be addressed in setting the Isx13 segmentation time. These include its relationship to
the maximum block rate, the small interpolation errors it introduces, and its effect on the calculation load
of the Turbo PMAC. Each of these is addressed in turn, below.
Block Rate Relationship
In most applications, the Isx13 segmentation time will be set so that it is less than or equal to the
minimum block (programmed move) time. Put another way, usually the segmentation rate defined by
Isx13 is set greater than or equal to the maximum block rate. For example, if a maximum block rate of
500 blocks per second is desired, the minimum block time is 2 milliseconds, and Isx13 is set to a value no
greater than 2.
This relationship holds because blocks of a smaller time than the segmentation time are skipped over as
Turbo PMAC looks for the next segment point. While this does not cause any errors, there is no real
point in putting these programmed points in the motion program if the controller is going to skip over
them. However, some people inherit old motion programs with points closer together than is actually
required; these users may have reason to set their segmentation time larger than their minimum block
time.
Note that the programmed acceleration time sets a limit on the maximum block rate. The move time for a
programmed block, even before lookahead, is not permitted to be less than the programmed acceleration
time. The programmed acceleration time is the larger of the TA time (TA = Isx87 by default) and twice
the TS time (TS = Isx88 by default). In high-block-rate lookahead applications, the TA time typically is
set equal to the minimum desired block time, and the TS time typically is set to (because it squares up
corners).
Interpolation Errors
The cubic-spline interpolation technique that Turbo PMAC uses to connect the intermediate segment
points is very accurate, but it does create small errors. These errors can be calculated as:
V 2T 2
Error =
6R
where V is the vector velocity along the path, T is the segmentation time (watch the units!), and R is the
local radius of curvature of the path. For example, if the speed is 100 mm/sec (~4 in/sec), the
segmentation time is 0.01 sec (Isx13 = 10 msec), and the minimum radius at this speed is 50 mm (~2 in),
then the worst-case interpolation error can be calculated as:
mm 2
100 2 * 0.01 2 sec 2
Error = sec 2 = 0.003mm = 3 µm
6 * 50 mm
If the programmed path itself introduces path error, such as the chordal error of linear interpolation, this
must be added to the error budget as well. In addition, if the servo-loop execution adds servo errors, these
must also be included.
Calculation Implications
While smaller Isx13 segmentation times permit higher real maximum block rates and permit more
accurate interpolation, they increase the Turbo PMAC computational requirements, particularly when
lookahead is active. The following table shows the result of benchmarking tests on the Turbo PMAC that
shows the minimum segmentation times that can be used for a given number of axes executing lookahead
calculations.
Number of Maximum Block Rate Minimum Segmentation
Axes (blocks/sec) Time (msec)
2 2000 1 @ 200%
3 1000 1
4 500 2
5 500 2
6 500 2
8 333 3
12 250 4
16 200 5
Notes:
1. Tests performed on 80 MHz Turbo PMAC
2. Tests performed at default 2.25 kHz servo update rate
3. Tests performed with no PMAC motor commutation or current-loop closure
4. Higher block rates can be done, but segmentation will smooth out features
Note that subject to these constraints, the length of the lookahead is subject only to memory limitations in
the Turbo PMAC.
In general, the Isx13 segmentation time is set to the largest value that meets user requirements in each of
the above three concerns. However, it is seldom set larger than 10 msec.
Calculating the Required Lookahead Length
In order for the coordinate system to reach maximum performance, it must be looking ahead for the time
and distance required for each motor to come to a full stop from maximum speed. Because the lookahead
buffer stores motion segments, this lookahead length must be expressed in segments.
To calculate this value, first compute the worst-case time required to stop for each motor in the coordinate
system. This value can be obtained by dividing the maximum motor velocity by the maximum motor
acceleration. In terms of Turbo PMAC parameters:
Ixx16
StopTime( m sec) =
Ixx17
Now take the motor with the longest stop time, and divide this time by 2 (because the segments will come
in at maximum speed, which takes half the time of ramping down to zero speed). Next, convert this value
to a number of segments by dividing by the coordinate system segmentation time:
StopTime( m sec) Ixx16
LookaheadLength( segs ) = =
2 * Isx13( m sec s / seg ) 2 * Ixx17 * Isx13
This is the number of segments in the lookahead buffer that always must be computed properly ahead of
time. Because the Turbo PMAC does not fully recalculate the lookahead buffer every segment, it must
actually look further ahead than this number of required segments
This size of the buffer for these assignments must be at least as great as the largest number of assignments
expected during the time for lookahead. There is no penalty for reserving more memory for these
synchronous M-variable assignments than is needed, other than the loss of this memory for other uses.
Note:
The buffer reserved in this manner for synchronous M-variables under lookahead
is distinct from the fixed-size buffer used for synchronous M-variables without
lookahead.
For example, the command &1 DEFINE LOOKAHEAD 500,50 creates a lookahead buffer for
Coordinate System 1 that can store 500 segments for each motor assigned to the coordinate system at that
time, plus 50 synchronous M-variable assignments.
Running a Program with Lookahead
The lookahead function is active when a motion program is run in a coordinate system, provided the
following conditions are true:
1. The coordinate system is in segmentation mode (Isx13 > 0).
2. The coordinate system is told to look ahead (Isx20 > 0).
3. A lookahead buffer has been defined for the coordinate system since the last board power-up/reset, or
if the lookahead buffer structure has been saved with I14 = 1.
4. The motion program is executing LINEAR or CIRCLE-mode moves.
The lookahead function is active under these conditions even when Turbo PMAC is performing inverse-
kinematic calculations every segment to convert tip positions to joint positions. This permits the user to
write a motion program in convenient tip coordinates, yet still observe all joint-motor limits automatically.
This is particularly important if the tip path passes near a singularity, requesting very high joint velocities
and accelerations.
Other move modes – RAPID, SPLINE, and PVT – can be executed with the lookahead buffer defined, but
the lookahead function is not active when these moves are being executed.
Note:
Absolutely no change is required to the motion program to utilize the lookahead
function.
It is important to realize the implications of the lookahead function on several aspects of the motion
program. Each of these areas is covered below.
Vector Feedrate
Without lookahead, the vector feedrate value (Fxxx) is a command for each programmed move block in
the motion program. That is, each move is calculated so that it is traversed at the programmed vector
feedrate (speed). With lookahead active, the feedrate value is only a constraint. The move will never be
executed at a higher speed, but it may be executed at slower speeds during some or all of the move as
necessary to meet the motor constraints.
If the move is programmed by move time instead of feedrate, the programmed move time becomes a
(minimum) constraint; the move will never be executed in less time, but it may be executed in greater
time.
Acceleration Time
The programmed acceleration times – Isx87 and Isx88 by default, or TA and TS in the motion program,
are the times before lookahead. The lookahead function will control the actual acceleration times that are
executed, but the programmed acceleration times are still important for two reasons.
First, the programmed acceleration time, which is the larger of TA or 2*TS, is the minimum move-block
time. If PMAC initially computes a smaller move time, typically as (vector-distance divided by vector-
feedrate), it will increase the time to be equal to the acceleration time, slowing the move. This check
occurs even before lookahead (which can only slow the move further), and it is an important protection
against computational overload. The acceleration time must be set low enough not to limit valid moves.
Note:
The acceleration time may be set to 0; in this case, Turbo PMAC sets a minimum
move time of 0.5 milliseconds.
Second, as longer moves are blended together, the programmed acceleration time and feedrate control the
corner size for the blending. The blended corner begins a distance of F*Ta/2 before the programmed
corner point, where F is the programmed feedrate, and Ta is either the specified acceleration time (TA) or
two times the specified S-curve time (2*TS), which ever is greater. The blended corner ends an equal
distance past the programmed corner point.
If the lookahead algorithm determines that the blended corner violates the acceleration limit on one or
more motors, it will slow the speed of the path in the corner. This will make the time for the blended
corner bigger than what was specified in the program. The lookahead will also create a controlled
deceleration ramp going into the blended corner, and a controlled acceleration ramp coming out of the
corner. In this manner, the size of the rounding at a corner can be kept small without violating
acceleration constraints, and without limiting speeds far away from the corners.
In general, the acceleration time should be set as large as it can be without either making the minimum
move time too large, or the corners too large. In high block-rate applications, the TA time is generally set
to the minimum block time, and the TS time is set to 0. In low block-rate applications, the TA and TS
times generally are set to achieve the desired corner size and shape.
Trajectory Filter
In high block-rate applications, rough motion can result from “quantization errors” in the programmed
path. This can produce machine vibration, audible noise, and high surface roughness on cut parts. These
errors can stem from the limited numerical resolution of the programmed points, from measuring errors if
the programmed points were scanned, or both.
This behavior can be compensated with a simple filtering of the interpolated motor trajectory, using
variable Ixx40 for each Motor xx. If Ixx40 is set to a value greater than zero, the desired trajectory is
passed through a simple first-order digital low-pass filter for smoothing purposes. (If Ixx40 is set to 0.0,
this filtering is disabled.) The higher the value of Ixx40, the greater the time constant of the filter.
The equation for the time constant Tf of the filter as a function of the servo update time Ts and Ixx40 is:
Ixx40 * Ts
Tf =
1 − Ixx40
Generally, time constants of a few milliseconds are selected when the filter is used. Note that only the
desired trajectory is filtered, so servo-loop stability is not affected. However, the filtering does introduce
a very slight path error (only noticeable for very large time constants) that can be quantified according to
the following equation:
V 2T 2
f
Error =
2R
where V is the velocity, Tf is the filter time constant, and R is the local radius of curvature of the path. For
example, with a velocity of 5000 mm/min (~200 in/min), a filter time constant of 2 msec, and a local
radius of 100 mm (~4 in), the path error would be:
mm 2 min 2
5000 2 * * 0.002 2 sec 2
Error = min 2 3600 sec 2 = 1.39 × 10 −6 mm = 1.39 nm
2 * 100 2 mm 2
Feedrate Override
All lookahead calculations are performed assuming a feedrate override value of 100%. If the feedrate
override value, from whatever source, changes from 100%, the velocity and acceleration calculations will
be incorrect. True velocity values vary linearly with the override value; true acceleration values vary with
the square of the override value.
For example, at 200% override, velocity values are twice the programmed values (and could exceed the
limit values by a factor of 2), and acceleration values are four times the programmed values (and could
exceed the limit values by a factor of 4).
Because the feedrate override can be changed at any time with immediate effects, the lookahead function
cannot anticipate what the override will be when the move will actually be executed. Therefore, it cannot
plan for any changes in the override, so it assumes operation at 100%.
The basic idea of lookahead is to remove the override function from the instantaneous judgment of the
operator, and instead use the mathematical calculations of the controller, which effectively act as an
override, to ensure proper and optimal execution of the path.
Computational Capabilities
The lookahead calculations can put significant real-time calculation loads on the Turbo PMAC processor.
If the processor fails to keep up with these real-time requirements, program execution will fail with a
“run-time” error, and motion will be aborted. There is also a slight possibility of a watchdog timer trip if
the processor is never released from the foreground lookahead calculations for background tasks.
It is important that the application be evaluated to ensure that the lookahead calculations can be
performed properly under the worst-case conditions. The period when the most intensive calculations are
being performed is at the beginning of a move sequence, when Turbo PMAC is filling the buffer
dynamically to get ahead the specified distance.
A good worst-case test is to run a motion program with programmed moves at the maximum move-block
rate right at the beginning of a blended sequence. Make sure that the Turbo PMAC can get through this
combination of high block-rate execution and dynamic filling of the lookahead buffer. To establish a
margin of safety, increase the override value above 100% to see what extra capability exists. A 20%
margin (proper execution at 120%) is strongly recommended.
Stopping While In Lookahead
If you wish to stop axis motion while in lookahead mode, he must carefully consider how the stopping is
to be done. It is important to realize what point in the chain of execution is being halted with the stopping
command. Different stopping commands have different effects, and different uses.
Quick Stop
The \ quick-stop command causes Turbo PMAC to immediately calculate and execute the quickest stop
within the lookahead buffer that does not exceed Ixx17 acceleration limits for motors in the coordinate
system. Motion continues along the programmed path to a controlled stop, which is not necessarily at a
programmed point (and probably will not be). This command is the effective equivalent of a feedhold
within lookahead (even though the internal mechanism is quite different), and it should be the command
issued when an operator presses a Hold button during lookahead. Outside of lookahead, this command
causes an actual feed hold, as if the H command had been given.
The \ command is the best command to use to stop interactively within lookahead operation with the
intention of resuming operation. Any synchronous M-variable assignments set to happen within the
deceleration will execute.
Motors may be jogged away from this stop point, if desired. Also, motion can be reversed along the path
with the < command (see Reversal, below).
Normal programmed motion can be resumed with the > resume-forward, R run, or S single-step
command, provided all motors are commanded to be at the same position at which they originally stopped
with the / command. If any motors have been jogged away from this point, they must first be returned
with the J= command. Acceleration limits are observed during the ramp up from a stop here. The >
resume command puts the coordinate system in either continuous run mode, or single-step mode,
whichever mode it was in before the quick-stop.
End-Block Stop
The / end block command will stop motion at the end point of the move currently being added to the
lookahead buffer, even if the next move has already been calculated. Motion segments up to the end of
this move are still added to the lookahead buffer, and all segments and synchronous M-variable
assignments in the lookahead buffer are completed.
Motion will come to a controlled stop at the end of the latest move block being added to the lookahead
buffer without violating constraints. However, there can be a significant delay – over (Isx20*Isx13) msec
if the lookahead buffer is full – from the time the / command is given and the time the axes stop.
Motors may be jogged away from this stop point, if desired. Motion can be resumed with the R or S
command, provided all motors are commanded to be at the same position at which they originally stopped
with the / command. If any motors have been jogged away from this stopped point, they must first be
returned with the J= command.
Quit/Step
The Q quit command simply tells the motion program not to calculate any further motion program blocks.
(The S single-step command will do the same thing if given while the program is running.) Motion
segments up to the end of the latest calculated motion program move block are still added to the
lookahead buffer, and all segments and synchronous M-variable assignments in the lookahead buffer are
completed.
Motion will come to a controlled stop at the end of the latest calculated move block without violating
constraints. However, there can be a significant delay – over (Isx20*Isx13) msec if the lookahead buffer
is full – from the time the Q or S command is given and the time the axes stop.
Motors may be jogged away from this stop point, if desired. Motion can be resumed with the R or S
command. Motors do not have to be at the same position at which they were originally stopped with the
Q or S command. However, if it is desired to return them to this position, the J= command should be
used.
Feed Hold
The H feed hold command brings the feedrate override value to zero, starting immediately, and ramping
down at a rate controlled by coordinate system variable Isx95. Motion continues along the programmed
path to a controlled stop, which is not necessarily at a programmed point (and probably will not be).
Acceleration limits are not necessarily observed during the ramp down to a stop. Any synchronous M-
variable assignments set to happen within the deceleration will execute.
Motors may be jogged away from this stop point, if desired. Programmed motion can be resumed with
the R or S command, provided all motors are commanded to be at the same position at which they
originally stopped with the H command. If any motors have been jogged away from this stopped point,
they must first be returned with the J= command. Acceleration limits are not necessarily observed during
the ramp up from a stop here.
Abort
The A abort command breaks into the executing trajectory immediately, and brings all motors in the
coordinate system to a controlled stop, each at its own deceleration rate as set by Ixx15 for the motor.
The stop is not necessarily at a programmed point (and probably will not be), and it is not necessarily
even along the programmed path (and probably will not be).
Segments and synchronous M-variable assignments already in the lookahead buffer are discarded; they
cannot be recovered. Although the program could be resumed with an R or S command, execution would
miss all of the discarded segments from the lookahead buffer. Special recovery algorithms would be
required to resume operation, so the abort command is not recommended except for stopping quickly
under error conditions.
Kill All
The <CTRL-K> kill-all command breaks into the executing trajectory immediately, and disables all
motors on the Turbo PMAC by opening the servo loops, forcing zero-value command outputs, and
disabling the amplifiers. Motors will coast to a stop in the absence of brakes or regeneration circuits.
Segments and synchronous M-variable assignments already in the lookahead buffer are discarded; they
cannot be recovered. Although the program could be resumed after re-enabling the servo loops with an R
or S command, execution would miss all of the discarded segments from the lookahead buffer. Special
recovery algorithms would be required to resume operation, so the “kill-all” command is not
recommended except for emergency conditions.
Note that the motor-specific K kill command is not permitted when the motor is in a coordinate system
that is executing a motion program. The program must first be halted, usually with an A abort command.
Reversal While in Lookahead
If the lookahead buffer has been sized larger than what is required simply for the actual lookahead, it will
contain historical data that can be used for reversal along the programmed path. This capability gives the
system a “retrace” capability, allowing it easily to go backwards along the already executed path. The
key command to be used in reversal is the < backup command, which causes the coordinate system to
start execution in the reverse direction through the segments in the lookahead buffer.
Back-up Command
If the < command is given while the coordinate system is in normal forward execution in the lookahead
buffer, Turbo PMAC will internally generate a \ “quick-stop” command to halt the forward execution,
then start reverse execution.
The < command can also be given after execution of the program has been halted with a \ quick-stop
command. It cannot be given after stopping with an / end-of-block, Q quit, S single-step, A abort or
<CTRL-K> kill-all command, or an automatic error termination.
Reverse Execution
Execution in the reverse direction will observe the position, velocity, and acceleration limits, just as in the
forward direction. Note, that if Isx20 is set to 1, limits are not observed in either the forward or reverse
direction. In this mode, the lookahead buffer is simply used to buffer points to enable reversal, without
the computational overhead of actual lookahead calculations. This mode is appropriate for EDM
applications, which require quick reversal, but not careful acceleration limiting.
If not stopped by another command, reverse execution will continue until it reaches the beginning (oldest
stored point) of the lookahead buffer. It will stop automatically at this point with a controlled
deceleration within the acceleration constraints. The oldest stored point in the lookahead buffer will
never be from before the first point in the current continuous blended motion sequence. This means that
you cannot reverse into, past, or through any of the following:
• A DWELL point
• A RAPID, SPLINE, or PVT-mode move
• A homing-search move
• A point where the program was stopped with a /, Q, or S command.
• A point where blending was stopped for any other reason (e.g. Isx92=1, double jump-back)
Remember that a DELAY command in a motion program does not disable blending, so it is possible to
reverse execution through a DELAY point. If a stop at a point is desired during execution of the program,
but the ability to reverse through the point is required, DELAY should be used instead of DWELL.
Stopping Reverse Execution
The reverse execution can be halted before this point with the \ quick-stop command. Reverse execution
can be resumed with another < back-up command; forward execution can be re-started with a > resume, R
run, or S single-step command. The > resume command puts the coordinate system in either continuous
run mode, or single-step mode, whichever mode it was in before the back up.
No synchronous M-variable assignments are executed either during a reversal or during the forward
execution over the reversed part of the path.
Forward execution over the reversed part of the path will blend seamlessly into previously unexecuted
parts of the path. At this point, standard execution of the lookahead buffer will resume, with new points
being added to the end of the lookahead buffer, and execution of buffered synchronous M-variable
assignments starting again.
Quick Reversal from within Turbo PMAC
If you wish to reverse very quickly from within PMAC, as for quick retracts in EDM applications, it is
best to bypass the command interpreter, which acts in background. This can be done by writing directly
to a lookahead-control I-variable from the PMAC program.
Variable Isx21 for each coordinate system contains the control bits for the state of lookahead execution.
By setting the value of this I-variable directly from a PLC program, the overhead and delay of the
command interpreter can be avoided and slightly faster reaction obtained. There are three values of use:
• Setting Isx21 to 4 is the equivalent of issuing the \ quick-stop command
• Setting Isx21 to 7 is the equivalent of issuing the < back-up command
• Setting Isx21 to 6 is the equivalent of resuming forward motion with the > resume-forward command.
If you are monitoring Isx21 at other times, you will see that the 4’s bit is cleared after the command has
been processed. Therefore, you will see the following values:
• Isx21 = 0 when stopped with a quick-stop command
• Isx21 = 3 when running reversed in lookahead
• Isx21 = 2 when running forward in lookahead
Axis Transformation Matrices
Turbo PMAC provides the capability to perform matrix transformation operations on the X, Y, and Z-
axes of a coordinate system. These operations have the same mathematical functionality as the matrix
forms of the axis definition statements, but these can be changed on the fly in the middle of programs; the
axis definition statements are meant to be fixed for a particular application.
The matrix transformations permit translation, rotation, scaling, mirroring, and skewing of the X, Y, and
Z-axes. They can be very useful for English/metric conversion, floating origins, making duplicate mirror
images, repeating operations with angle offsets, and more.
The basic mathematical operation that the matrix operation performs is as follows:
Note:
When using axis matrix transformation for scaling, do not use the R radius
specification for circular interpolation because the radius will not scale with the
axes. Use the IJK center vector specification instead.
Calculation Implications
Program move calculations involving the X, Y, and Z-axes take a small but possibly significant additional
amount of computational time (about ¼-millisecond for an 80 MHz CPU) if the matrix transformation
calculations have been activated with the TSELECTn command. This can decrease the maximum move-
block execution rate for the motion program slightly. To disable the matrix transformation calculations,
use TSELECT0, which deselects all matrices, and stops the matrix calculation overhead.
Examples
These concepts are probably best illustrated with some simple examples. In actual use, much more
sophisticated things may be done with the matrices, especially with the inclusion of math and logic.
Scaling Example
If axis definition statements scaled your axes in units of millimeters, but the program should at least
temporarily, scale in inches, set up the matrix as follows:
TSEL 1 ; Select Matrix 1
Q11=25.4 Q12=0 Q13=0 ; Variables for first row
Q14=0 Q15=25.4 Q16=0 ; Variables for second row
Q17=0 Q18=0 Q19=25.4 ; Variables for third row
AROT 11 ; Use Q11-Q19 for matrix
Note that pure scaling uses only the primary diagonal of the matrix. The scaling is done with respect to
the origin of the coordinate system. Of course, the Q-variable values do not need to be assigned as three
per command line, but this can be nice for program readability.
Rotation Example
To rotate the coordinate system 15 degrees about the origin in the XY plane. Set up the matrix as follows
TSEL 2 ; Select Matrix 2
Q40=COS(15) Q41=SIN(15) Q42=0 ; Variables for first row
Q43=-SIN(15) Q44=COS(15) Q45=0 ; Variables for second row
Q46=0 Q47=0 Q48=1 ; Variables for third row
AROT 40 ; Assign these values to the rotation portion
This transformation rotates the points 15 degrees counterclockwise in the XY plane relative to fixed XY
axes when viewed from the +Z axis in a right-handed coordinate system (i x j = k). Alternately stated, it
rotates the XY axes 15 degrees clockwise in the XY plane relative to fixed points when viewed from the
+Z axis in a right-handed coordinate system.
Displacement Example
To offset the Y and Z-axes by 5 units and 2.5 units, respectively, leaving the X axis unchanged. Set up
the matrix as follows:
TSEL 3 ; Select Matrix 3
Q191=0 ; First variable
Q192=5 ; Second variable
Q193=2.5 ; Third variable
ADIS 191 ; Assign these values to the displacement portion
A
CLOSE
DELETE GATHER
OPEN PROG n
CLEAR
{program statements}
CLOSE
After the program has been downloaded and the buffer CLOSEd, a coordinate system that is to execute
this program must be pointed to the program with the B command. For example, B6 would point the
addressed coordinate system’s program counter to the beginning of motion program 6. This can be
confirmed with the PC (program counter) query command, which should return P6:0 if it is pointing to
the top of program 6. If it returns a <BELL> character, it is not pointing to any valid program. Once the
coordinate system is pointing to the top of the program, execution can be started with the R command.
The B and the R commands can be combined into one command line, such as B6R.
Learning a Motion Program
It is possible to have Turbo PMAC learn lines of a motion program using the on-line LEARN command.
In this operation, the axes are moved to the desired position and the command is given to Turbo PMAC.
Turbo PMAC then adds a command line to the open motion program buffer that represents this position.
This process can be repeated to learn a series of points.
The motors can be open-loop or closed-loop as they are moved around. At the time of the LEARN
command, Turbo PMAC reads the motor commanded positions (in open-loop, commanded positions are
always equal to actual positions) and converts them to axis positions by effectively executing a PMATCH
command, inverting the axis definition equations.
If the LEARN command specifies which axes are to be learned (e.g. LEARN(A,B,C) ), only those axis
commands will be added to the program. If the LEARN command does not specify any axes, commands
for all 9 axis names are added to the motion program.
The LEARN function can add only axis move commands to the program. Any other parts of the motion
program, including math, logic, move modes, and move times, must be sent to the open motion program
buffer directly.
Motion Program Structure
Turbo PMAC motion programs typically are combinations of movement specification statements,
calculation statements, and logic statements. The movement specification statements are used to generate
commanded trajectories for the axes, according to the rules explained in the descriptions for each
trajectory mode earlier in this section. The calculation statements can be used to determine the
parameters for the movement specifications, and the logic statements can be used to determine which
movement statements get executed, and when.
Basic Move Specifications
The simplest motion programs contain only movement specifications. Take the example:
F5000
X10000
DWELL1000
X0
(Remember that in entering this program, these statements would be surrounded with the buffer control
commands explained above.)
The F (feedrate) statement specifies a speed, the X statements command actual moves for the X-axis, and
the DWELL statement commands a halt for the specified time. This program simply specifies a basic
move and return.
Defaults
A program this simple relies on quite a few default settings and modes. This one uses the following
defaults: LINEAR move mode, ABS (absolute) axis specification, with Isx87 and Isx88 specifying the TA
and TS acceleration times, respectively.
Controlling Parameters
What the values in the program mean can depend on external parameters as well. The X positions are in
user units, as defined in the axis definition statement for the X-axis. The F speed specification is in terms
of user position units divided by feedrate time units, as set by variable Isx90 for the coordinate system.
Simultaneous Moves on Multiple Axes
To perform simultaneous coordinate moves of several axes in a coordinate system, simply put their move
specifications on the same line. For instance, if the above program was changed to:
F5000
X10000 Y10000 Z10000
DWELL1000
X0 Y0 Z0
the X, Y, and Z-axes will command a simultaneous move to 10,000, stay there for one second, then
command a simultaneous move to 0.
If an axis in the coordinate system is not commanded in a given move line, a zero-distance move for that
axis is assumed (note that it is technically performing a move, so it cannot be in- position).
Sequential Moves
If the program is in LINEAR, CIRCLE, PVT, or SPLINE mode, and there is more than one move
command line in a program without a DWELL or DELAY in between (there can be other statements in
between), the moves will blend together without stopping. The exact form of the blending will depend on
the move mode in force (see Trajectory Features). However, if Isx92 for the coordinate system (Move
Blend Disable), this blending capability is disabled.
Adding Logic
A little logic can be added to make the language more powerful. Suppose we wanted to repeat the above
sequence 100 times. Rather than repeating the above statements 100 times, we can create a loop:
F5000
P1=0
WHILE (P1<100)
X10000
DWELL1000
X0
DWELL1000
P1=P1+1
ENDWHILE
Note that the F5000 statement is not inside the loop. By putting it before the loop, we save PMAC from
having to interpret and execute the statement every time through the loop. Since it is a modal statement,
its effect stays in force. This is not essential, but if loop time is very short, it can make a difference.
Line Labels
It is possible to put line labels in your motion program to mark particular sections of the program. The
syntax for a line label is N{constant or O{constant}, where {constant} is an integer from 1 to
262,143.
Note that these are line labels, not line numbers (even though they are specified by number). A line does
not require a label; and the labels do not need to be in numerical order. These line labels are used only to
specify the jumps in GOTO, GOSUB, and CALL commands (all discussed below).
GOTO Command
Turbo PMAC provides a GOTO{data} command in its motion program syntax, which causes a jump to
line label N{data} in the same motion program (without return). In general, the use of GOTO
commands is strongly discouraged, because of the tendency to build up programs that are very hard to
decipher.
However, when the {data} in a GOTO command is a variable or expression (e.g. GOTO(P20)), it can
be used to build the equivalent of a structured CASE statement, creating a multiple-pronged branching
point. See an example under the GOTO description in the Program Command Specification.
Adding Variables and Calculations
Motion programs can be made a lot more flexible with the use of variables and mathematical calculations.
The above example program will command the same moves with the same timing every time it is
executed. If any parameter for the program must be changed, the entire program must be re-entered (or a
different program used). However, if variables are used in place of the constants, only variable values
must be changed to change the action of the program:
F(P2)
P1=0
WHILE (P1<P3)
X(P4)
DWELL(P5)
X0
DWELL(P5)
P1=P1+1
ENDWHILE
The variables P2, P3, P4, and P5 could be set by the host with on-line commands (e.g. P2=2000), by a
PLC program as a result of inputs and/or calculations, or even by this or another motion program.
General mathematical expressions can be built in a PMAC motion program, using constants, variables,
functions and operators (see the Computational Features section of this manual). The calculations can be
done in separate program statements, assigning the calculated value to a variable, and then using the
variable in another statement. Alternately, use the expression directly in a motion specification statement,
in which case the value of the expression is not retained after the statement is executed.
Subroutines and Subprograms
It is possible to create subroutines and subprograms in PMAC motion programs to create well structured
modular programs with re-usable subroutines. The GOSUBx command in a motion program causes a
jump to line label Nx of the same motion program. Program execution will jump back to the command
immediately following the GOSUB when a RETURN command is encountered. This creates a subroutine.
The CALLx command in a motion program causes a jump to PROG x, with a jump back to the command
immediately following the CALL when a RETURN command is encountered. If x is an integer, the jump
is to the beginning of PROG x; if there is a fractional component to x, the jump is to line label
N(y*100,000), where y is the fractional part of x. This structure permits the creation of special
subprograms, either as a single subroutine, or as a collection of subroutines, that can be called from other
motion programs.
Once PMAC has encountered a PRELUDE1 command in the program, it will execute the specified
subprogram call each time it encounters a move command or other letter-number command in the motion
program (including G, M, T, and D codes, but excluding N and O line labels). The move command or
letter-number command must be at the beginning of a program line, or immediately following an N or O
line label at the beginning of a program line.
Once PMAC has jumped to the subprogram specified by PRELUDE1, it will treat any move command or
letter-number command in the subprogram as it normally would; these will not automatically cause
another subprogram call. Automatic PRELUDE subprogram calls therefore cannot be nested within each
other; however, a single PRELUDE subprogram call may be nested within explicit subroutine and
subprogram calls, and explicit subroutine and subprogram calls may be nested with a single automatic
PRELUDE subprogram call.
A new PRELUDE1 command supersedes the existing PRELUDE1 command. A PRELUDE0 command
(no arguments necessary) turns off the PRELUDE function.
Running a Motion Program
Once your motion program has been entered and the program buffer closed, you may execute the motion
program. Since Turbo PMAC can store multiple programs at once, the first thing you must do is tell the
Turbo PMAC coordinate system which program you wish to run (remember that it is a coordinate system
in Turbo PMAC that executes a motion program; different coordinate systems may be executing other
motion programs at the same time).
Pointing to the Program
This is done with the B{constant} command, where the {constant} represents the number of the
motion program buffer. Use the B command to change motion programs and after any motion program
buffer has been opened. It is not necessary if repeatedly running the same motion program without
modification; when PMAC finishes executing a motion program, the program counter for the coordinate
system is set automatically to point to the beginning of that program, ready to run it again.
Use the PC (program counter) command to see which program the coordinate system is pointing to at the
time. A response such as P5:0 will be received, which indicates that the coordinate system is pointing to
motion program 5, at the top (address offset of 0).
Running the Program
Once pointing to the motion program to be run, issue the command to start execution of the program. If
continuous execution of the program is desired, use the R command (<CTRL-R> for all coordinate
systems simultaneously). On a Turbo PMAC controller, take the START/ line on the JPAN connector
low with the coordinate system selected on the FPDn/ lines of the same connector. The program will
execute all the way through unless stopped by command or error condition.
Stepping the Program
To execute just one move, or a small section of the program, use the S command (<CTRL-S>for all
coordinate systems simultaneously), or take the STEP/ line on the JPAN connector low with the
coordinate system selected on the FPDn/ lines of the same connector. The program will execute to the
first move DWELL or DELAY, or if it first encounters a BLOCKSTART command, it will execute to the
BLOCKSTOP command.
What PMAC Checks For
When a run or step command is issued, Turbo PMAC checks the coordinate system to make sure it is in
proper working order. If it finds anything in the coordinate system is not set up properly, it will reject the
command, sending a <BELL> command back to the host. If I6 is set to 1 or 3, it will report an error
number as well telling the reason the command was rejected.
Turbo PMAC will reject a run or step command for any of the following reasons:
• A motor in the coordinate system has both overtravel limits tripped (ERR010)
• A motor in the coordinate system is currently executing a move (ERR011)
• A motor in the coordinate system is not in closed-loop control (ERR012)
• A motor in the coordinate system in not activated {Ix00=0} (ERR013)
• There are no motors assigned to the coordinate system (ERR014)
• A fixed (non-rotary) motion program buffer is open (ERR015)
• No motion program has been pointed to (ERR016)
• After a / or \ stop command, a motor in the coordinate system is not at the stop point (ERR017)
You may also want to set some variables in these routines to note what plane has been specified if you
want to use this information for other routines (such as G68 rotation). Turbo PMAC’s circular
interpolation and radius compensation routines do not need such a variable.
G40, G41, G42 – Cutter Radius Compensation
Cutter radius compensation can be turned on and off easily with the CC0, CC1, and CC2 PMAC commands,
corresponding to G40, G41, and G42, respectively. The subroutines to implement this would be:
N40000 CC0 RETURN ; Turn off cutter compensation
N41000 CC1 RETURN ; Turn on cutter compensation left
N42000 CC2 RETURN ; Turn on cutter compensation right
Spindle Programs
Controlling the spindle axis may be done in many different ways in Turbo PMAC, depending on what the
spindle needs to do. The simplest type of spindle operation, of course, is the one in which the spindle is
simply asked to move at constant speeds for substantial periods of time in one direction or another. In
this case, there is no need to write a spindle motion program; either Turbo PMAC just puts out a voltage
proportional to speed (so the spindle is open-loop as far as Turbo PMAC is concerned), or the spindle
motor is jogged (under Turbo PMAC closed-loop control).
Jogged Spindle
The jogged spindle motor does not need to be in any coordinate system (it must not be in the same
coordinate system as the other axes, or it cannot be jogged while a parts program is running), but it is a
good idea to put it in a different coordinate system, because motors that are not in any coordinate system
use Coordinate System 1’s time base control (feedrate override).
Spindle speed values are scaled and put into jog speed I-variables (Ix22), and the spindle on/off functions
command jog starts and stops (see M03, M04, and M05).
Open-Loop Spindle
If using the open loop spindle, write directly to an otherwise unused DAC output register by using a M-
variable. For instance, the definition M425->Y:$C00A,8,16,S matches the variable M425 to the
DAC4 output register. Any value given to this M-variable will cause a corresponding voltage on the
DAC4 output line. In this method, a spindle-on command (see M03, M04) could be M425=P10 or
M425=-P10, where P10 has been set previously by an S-code. The spindle-off command (see M05)
could be M425=0.
Switching Between Spindle and Positioning
There are cases in which the spindle motor is sometimes used as a regular axis, doing position moves
instead of steady velocity, and sometimes as a regular spindle. In this case, the spindle motor will be
made an axis in the main coordinate system so it can do coordinated moves. When real spindle operation
is desired, a pseudo-open-loop mode can be created by setting the motor’s proportional gain to zero and
writing to the output offset register (Ixx29). In this method Ixx29 would be treated just as M425 was in
the above paragraph. Of course, a velocity-loop (tachometer) amplifier would be required for this mode
of operation. See the example OPENCLOS.PMC for more details.
Constant-Surface-Speed Spindle
If you wish the spindle to be able to perform constant surface speed (CSS) mode, you must write a motion
program, because the speed must vary as a function of another axis position. The suggested method –
shown in the example SPINDLE.PMC – is to break the move into small time slices, with the commanded
distance for each slice dependent on the system conditions at the time – including commanded speed,
mode, and tool radial position.
If the spindle is to be controlled in open-loop fashion in CSS mode, it would be best to have a PLC
program modifying the output command (Mxx25 or Ixx29) as a function of tool radial position. The
structure of the PLC program would be much like that of the closed-loop motion program example
SPINDLE.PMC, except no actual move command would be needed; once the math was processed, the
value would be assigned to the appropriate variable.
Standard M-Codes
The sections below detail what is involved in implementing the standard M-codes. It is important to
realize the difference between an M-code in a program and an M-variable. To be interpreted as an M-
variable, it must be used in an equation or expression. For instance, M01=1 refers to M- variable number
1 (usually this sets Machine Output 1), whereas M01 by itself is the M-code number 1.
M-codes are treated as subprogram calls to the appropriate line label of motion program 1001.
M00 – Programmed Stop
The routine to execute this code simply needs to contain the STOP command. This code is looking for
the line label N0 of PROG 1001, and the beginning of any program is always implicitly N0, so this must
be at the very top of PROG 1001. The part of the file to implement this could be:
CLOSE
OPEN PROG 1001 ; Buffer control command
CLEAR ; To erase old when sending new
STOP ; First line of actual program
RETURN ; Will jump back when restarted
M01 – Optional Stop
Typically, this code is used to do a stop if the "Optional Stop" switch on the operator’s panel is set.
Assuming this switch is wired into PMAC’s Machine Input 1, and variable M11 has been assigned to this
input (this is the default), then the routine to execute this code could be:
N01000 IF (M11=1) STOP
RETURN
Preparing to Run
To prepare to run a rotary program in a coordinate system, use the B0 command (go to beginning of
program zero – the rotary program) when addressing that coordinate system. This must be done when no
buffers are open, or it will be interpreted as a B-axis command. Once prepared this way, the program is
started with the R command. This command can be given with the buffer either open or closed. If the R
command is given for an empty rotary buffer, the buffer will simply wait for a command to be given to it,
and then execute that command immediately.
Opening for Entry
The OPEN ROT command opens all of the rotary program buffers that have been defined. Program lines
following this are sent to the buffer for the host-addressed coordinate system (&n). Most users of rotary
program buffers will have only one coordinate system, so this will not be of concern to them, but it is
possible to switch coordinate systems on the fly and use several rotary buffers at once.
It is important to realize that after the OPEN ROT command, PMAC is treating as many commands as
possible as buffered commands, even if it is executing them immediately (some commands mean one
thing as an on-line command, and another thing as a buffered command). For instance, an I100
command is a request for a value of I-variable 100 when buffers are closed, but it is a command to do a
full circle with a 100-unit radius when a motion program buffer is open (the I-value is the X-axis
component of the radial vector; since no axis positions are given, they are all assumed to be the same as
the starting point)!
1
Execute "R"
I11 4 5 6 time
1 2 3
Calculate
1
Execute "R"
I11 3 4 5 time
1 2
Calculate
C. No moves ahead
Ix92=1, RAPID,
HOME, DWELL,"S"
"S" 1 2 2a 3
Execute "R"
The first 360 pieces will be blended (splined) together on the fly as Turbo PMAC cycles through the inner
loop. But when PMAC increments P2 to 360, it hits the first ENDWHILE and jumps back to the inner
WHILE condition, which is now false, so it jumps down, increments P1, hits the second ENDWHILE, and
jumps back to the outer WHILE condition, all without encountering a move command.
At this point, Turbo PMAC invokes the double-jump-back rule and lets the last programmed move come
to a stop. It does this to prevent the possibility that it might be caught in an indefinitely true set of loops
with no movement, which could mean that it would not have the next move equations ready in time. It
resumes calculations when this move has finished and will start up the next sequence of moves in the
inner loop.
To blend all of these moves together continuously, pull the last move of the inner loop outside of the
inner loop. This way, never will two ENDWHILE statements be encountered between move commands:
SPLINE1 TM20
P1=0
WHILE (P1<10)
P2=0
WHILE (P2<359) ; Note that loop stops earlier
X(P1*SIN(P2))
P2=P2+1
ENDWHILE
X(P1*SIN(P2)) ; Last move from inner loop
P1=P1+1
ENDWHILE
Looping to Wait:
There are several methods for holding program execution while waiting for a certain condition to occur.
Usually, this is done with a WHILE loop, but what is done inside the loop has an effect on responsiveness
and calculation load.
The fastest execution is the WHILE({condition}) WAIT loop. As soon as the WAIT command is
encountered, motion program calculations are suspended until the next real-time interrupt, at which time
they will re-evaluate the condition. The motion program effectively becomes like a one-line PLC
program. If the next RTI has already occurred, it will immediately re-enter the interrupt service routine
and re-evaluate the condition. If this occurs repeatedly, background routines will be starved for time,
slowing PLCs and communications, or in the worst case, tripping the watchdog timer. Usually this
happens only if multiple coordinate systems are in simultaneous WHILE...WAIT loops.
Of similar speed is an empty WHILE...ENDWHILE loop, or at least one with no motion commands
inside. Each RTI, this will execute twice, stopped by the double-jump-back rule. Calculations resume at
the next RTI, or if this has occurred already, they resume immediately, with the same possible
consequences for starving background calculations.
Using a WHILE({condition}) DWELL single-line loop helps to control the looping rate better,
giving time for background routines. The condition is evaluated only once after each DWELL.
Implications of Calculating Ahead
The need of the motion program to calculate ahead during a continuous sequence of moves means that
non-motion actions –particularly the setting of outputs – taken by the program happen before you might
think they would – by one or two moves. For variables that are only used within the program, this is no
problem, because everything happens sequentially within the program.
It is possible to move these non-motion actions to a point one or two moves later in the program to get the
actions to occur when they are desired. However this makes the program extremely difficult to read as far
as the proper sequence of operations.
The following ratio for each motor is set by Ixx07 and Ixx08, which can be analogized to the number of
gear teeth on master and slave, or the radii of the belted wheels, in a mechanical following application.
The following function is turned on and off with bit 0 of Ixx06. When it is on, the input stream from the
master acts just like a trajectory generator, creating a series of commanded positions to which the
following axis controls.
Motor
Master
Commanded follows
Position
Position
Ix07
∆ CPn = Ix08 ∆ MPn
∆ MPn ∆ CPn
Ix07 Ix08
Master Follower
Mechanical Analogy
Step 2: Interpolation
Once decoded and counted, the value from the signal is brought into the encoder conversion table once
per servo cycle, exactly as a position feedback signal would be. Using the 1/T conversion method here is
highly recommended; because this method gives a very good sub-count interpolation of the signal (using
timers associated with the counter) that significantly enhances the smoothness of the time base
information. Make sure that the conversion table is set up to process the counter from the input signal
this way. The factory-default configuration for the encoder conversion table is for 1/T conversion of the
present encoder counters. See the description of the encoder conversion table for more details.
Step 3: Time Base Calculation
A separate entry in the encoder conversion table takes the interpolated position information from the
above step, subtracts out the interpolated position information from the previous servo cycle, and
multiplies this difference by a scale factor to produce the time base value for the servo cycle. (This time
base value is then a multiplying factor in the position update calculations, so the amount of update is
proportional to the number of counts received from the time base signal in the last servo cycle.)
The two set-up items in this step are the source of information (the interpolated position register) and the
scale factor. Both of these are entries (I-variables) in the encoder conversion table. See the description of
the table for more details on how to enter these.
The equation for the time base conversion is:
% value = (100.0 * SCALE_FACTOR * INPUT_FREQ) / 2N
where the % value (also known as feedrate override value) is what controls the rate of position update –
when it equals 100.0, programs and moves operate in “real time” (i.e. at the times and speeds specified in
the program).
SCALE_FACTOR is the integer value that must be determined to set up time base following properly.
INPUT_FREQ is the count rate (as determined by the signal and I7mn0) in counts/millisecond. N is
equal to 17 for normal (untriggered) time base (217 is 131,072); N is 14 for triggered time base (214 is
16,384) – see below for details of triggered time base.
To set the scale factor, decide on a real-time input count frequency – the rate of input counts at which the
program and moves should execute at the specified rate. Since this is the rate at which the value will be
100.0, solve for the scale factor as:
SCALE_FACTOR = 2N / (REAL_TIME_INPUT_FREQ)
Since the scale factor must be an integer, and we are dividing into a power of 2, make the real time input
frequency a power of 2 in units of counts/msec. For instance, if there is a system where the typical full-
speed input count frequency is 60,000 counts/second, define the real-time input frequency to be 64
counts/msec. This would then make the scale factor for untriggered time base equal to 131,072 / 64 =
2,048.
So far, all we have is a value in a register proportional to the master frequency. Now we must make use
of this value to control our motion program.
Step 4: Using the Time-Base Calculation
Time base values work on a coordinate system. Each coordinate system has an I-variable that tells it
where to look for its time base information. This variable is Isx93 for Coordinate System x. The default
values for Isx93 are the addresses of registers that are under software control, not the control of an
external frequency. For a coordinate system that you wish to be under external time-base control, you
must put the address of the scaled time-base value determined above in the encoder conversion table.
For instance, if the table started with eight 1/T entries (using I8000 – I8007), and the time-base entry
followed using I8008 and I8009, the resulting time base value would be in the X-register accompanying
I8009 (address X:$350A). To use this value as the time base for Coordinate System 1, issue the
command I5193=$350A (specifying the address directly), or I5193=@I8009 (specifying the address
through the location of the I-variable). Both commands yield the same result.
Once this I-variable has been set up, all motors assigned to this coordinate system will be under the
control of the external frequency, in programmed and non-programmed moves.
I-variable Isx94 controls the maximum rate of change of the time-base value for Coordinate System x.
When commanding the time-base value from the host (with a %n command), this value should be fairly
low to produce a nice slewing to the new commanded value. However, to keep synchronized to an
external signal as time-base source, this value should be set as high as possible (maximum value is
8,388,607) so the time base can always slew as fast as the signal. Setting the value low can improve
following smoothness at the cost of some ‘slip’ in the following. If the Isx94 limit is ever used in external
time base, position synchronization to the master is lost.
Step 5: Writing the Program
When writing the program that is to be under external time-base control, simply write it as if the input
signal were always at the real-time frequency. When run, the program will execute at a rate proportional
to the input frequency. There is full floating-point resolution on the move times and feedrates that are
specify.
Remember that DWELL commands always execute in real time, regardless of the input frequency. To
have pauses in the program that are proportional to an input frequency, use the DELAY command, not
DWELL.
Time-Base Example
If there is a web of material moving at a nominal speed of 50 inches per second, there is a quadrature
encoder on the web that gives 500 lines per inch. There is a crosscutting axis under Turbo PMAC
control. When the web is moving at nominal speed, make a cutting move in 0.75 seconds and be ready to
start another move 2.50 seconds later. The web encoder is attached to Servo IC 2 Encoder 4 input lines.
Step 1: Signal Decoding
Since the web encoder is Servo IC 2 Encoder 4, I7240 controls the decoding. For maximum resolution,
set I7240 to 3 or 7 for x4 decode. Try 3 first. Looking in the list of suggested M-variables in the manual,
notice that the encoder position M-variable for this encoder is M401 for a UMAC or M1201 for other
types of Turbo PMAC. Make the definition for M401 or M1201 and query its value repeatedly (probably
using the Executive program Watch window) while turning the web encoder in the direction it will be
going in the application. If the value increases as the encoder is turned, I7240 is set properly. If it
decreases, change I7240 to 7. (If it does not change, check the connections.)
Step 2: Interpolation
Next, look at the current setup of the encoder conversion table. Make sure the encoder is processed with
a 1/T conversion. The easiest way to do this is through the Configuration menu of the PMAC Executive
program. If this is not available, look at the I8000+ variables directly. Issue a command such as
I8000..8009 and get back something like this:
$078200
$078208
$078210
$078218
$078300
$078308
$078310
$078318
$0
$0
Referring to the detailed description of the I8000 variables in the Software Reference Manual, notice that
this table processes all four encoder channels from Servo ICs 2 and 3 using 1/T extension, so the master
encoder is processed.
Step 3: Time-Base Calculation
Now set up an entry in the table to convert the interpolated position to time base format. Looking at the
values reported above, either in the raw form shown here, or more clearly in the Executive Program’s
configuration window, notice that there is no time-base entry, so one must be created.
The source encoder is processed in the fourth line of the table, with I8003. Looking up the address of this
entry, notice that this is at $3504. If using the Executive Program’s configuration menu, add an entry to
the end of the table, select the Time Base method, and enter the address – either selecting it from the pick
list or entering the address ($3504). Talking directly to the Turbo PMAC, send the I8008=$403504
command (the initial 4 specifies a time-base entry).
Now compute the scaling factor. Look at the nominal speed of 50 inches/sec, the resolution of 500
cycles/inch and the x4 decode, and calculate:
50 inches/sec * 500 cycles/inch * 4 counts/cycle
= 100,000 counts/sec
= 100 counts/msec
Since the math works out more easily if this number is a power of two, declare the real-ime” count rate to
be 128 counts/msec. Then calculate the scale factor as 131,072 / 128 = 1024. If using the Executive
Program’s configuration menu, enter this value into the proper field. If talking directly to the Turbo
PMAC, send the I8009=1024 command.
Step 4: Using the Time-Base Calculation
Since working in Coordinate System 1, assign I5193 to the address of the second line of this entry (either
with I5193=@I8009 or I5193=$350A) to point to this time base value. Set I5194 to the maximum
value of 8,388,607 so synchronicity will not be lost on rapid changes.
Step 5: Writing the Program
In writing the program, work at the real-time input frequency, which differs from the nominal speed
begun with – in this case, it is exactly 28% faster. Therefore, any programmed speeds would be 28%
higher; any programmed times would be 28% less. Take the nominal cut time of 750 msec (0.75 sec) and
multiply it by 100/128 to get exactly 585.9375 msec. The 2500 msec return is similarly scaled to
1953.125 msec. (If these numbers do not come out exactly in the program, put the math directly in the
program; Turbo PMAC calculates with 48-bit floating-point precision.) There would be a main program
loop such as:
WHILE (M11=1) ; Cut as long as input is true
TM 585.9375 ; Cut move time
X10000 ; Actual cut move
DELAY 500 ; Hold; part of 1953.125 msec return
TM 953.125 ; Return time; part of 1953.125 msec
X0 ; Actual return move
DELAY 500 ; Hold; part of 1953.125 msec return
ENDWHILE
These commands in the motion program are followed immediately by the calculations and commands for
the first moves that are to be started on the trigger. With the time-base frozen, Turbo PMAC will perform
all of the calculations, but not start actual execution of these moves. Variable I11 (calculation delay)
should be set to 0, so Turbo PMAC will be ready to start the move as soon as the time base starts.
Step 4: Arming the Trigger
The motion program that calculates the moves cannot arm the trigger itself without having a chance that
the trigger could occur before the calculations are done. If this were to happen, the program would be
behind the desired synchronization. Therefore, for reliable operation, the trigger should be armed by a
task that cannot execute until all of the move calculations are done, usually a PLC program. Arming the
trigger requires just one simple conditional branch in a PLC program; it just looks to see if the time base
is frozen, and if it is, the PLC program arms the trigger. Since the PLC program cannot interrupt the
motion program, this is guaranteed to happen after the motion program has finished the calculations for
the move.
Step 5: Starting on the Trigger
Once the trigger has been armed, Turbo PMAC waits for the position-capture trigger to occur on the
master encoder. Variables I7mn2 and I7mn33 determine which edges of which signals cause the trigger.
When Turbo PMAC sees that the trigger has occurred, it starts the time base, using the captured master
position as the starting point for the time base.
Triggered Time-Base Example
Motor #1 is the A-axis in Coordinate System 1. It is a rotary axis with a 2500 line-per-revolution encoder
on the motor, and its load is geared down from the motor at a 3-to-1 ratio. It is to be slaved to a master
encoder connected to Turbo PMAC on Servo IC 2 Encoder 4. The master encoder has 4096 lines per
revolution, and typically rotates at about 600 rpm. After being given the command to run, the X-axis
must wait for the index pulse of the master and for 45 degrees past it. For the next 36 degrees of the
master, it must accelerate up to speed, then run at speed for 144 degrees of the master, and finally
decelerate over 36 degrees of the master. This move must cover one full revolution of the A-axis.
We will use the triggered time-base, triggering from the master encoder’s index pulse. Choosing 600 rpm
as our “real-time” speed for the master, we compute our real-time input frequency (RTIF) in counts/msec:
600 rev/min * (min/60 sec) * (4096 lines/rev) * (4 counts/line) * (sec/1000 msec)
= 163.84 counts/msec
The time-base scale factor (SF) is:
SF= 131,072 / RTIF = 131,072 / 163.84 = 800 (decimal)
At the real-time speed of 600 rpm (10 rps), one revolution of the master takes 100 msec; so 45 degrees of
the master takes 12.5 msec, and so on.
Set-up and Definitions
I7240=3 ; x4 decode of IC 2 Enc 4, set to count up in direction of motion
I7242=1 ; ENC 4 capture trigger on rising edge of index pulse
I8008=$A78218 ; 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 Enc 4 registers
I8009=800 ; Scale factor is 800 decimal Result is at address $350A
M199->Y:$3509,20,4 ; Method digit of conversion table entry =$9 frozen, $B armed,
;$A running
&1 ; Address Coordinate System 1
#1->83.33333333A ; Motor 1 is A-axis in C.S. 1; 3 x 2500 x 4 cts/rev / (360 deg rev)
Motion program
The motion program freezes the time base and calculates the first move. But actual execution of this
move will not happen until the time base has been triggered.
CLOSE
OPEN PROG 12 CLEAR
I5193=$350A ; Time base source address is triggered time-base conversion in table
; (2nd line)
DWELL0 ; Stop lookahead in program
M199=$9 ; Freeze time-base
LINEAR ; Linear move mode
INC ; Incremental move specification
TA10 ; 36 degrees of master is 10 msec
TS0 ; No S-curve
DELAY12.5 ; 45 degrees of master is 12.5 msec
TM50 ; 36+144 deg of master is 50 msec
A360 ; One full revolution of slave axis
CLOSE
PLC Program
The PLC program simply looks to see if the time base has been frozen; if so, it arms the time base. In the
armed state, the triggered time-base conversion table entry looks for the trigger every servo cycle.
CLOSE
OPEN PLC 10 CLEAR
IF (M199=$9) ; Has time-base been frozen?
M199=$B ; Then arm for trigger
ENDIF
CLOSE
• Set I8 to 0, which forces a real time interrupt every servo cycle. If not running a PLC 0, leave this at
zero permanently.
• Begin your programs using R<CR> if @@ has been issued as in the simple case or use <CTRL-R>,
which is the global run command.
• To run a PLC 0, set I8 back to its original value, usually 2. Leaving I8 at 0 probably will cause PLC
0 to starve the background tasks for processor time, causing loss of communications or even a
watchdog timer failure.
• Enable the PLC programs required. Have the first line of each motion program enable the PLC
programs for its respective Turbo PMAC card.
Example:
OPEN PROG 1 CLEAR
ENA PLC 1..31
TM 1000
.
Hardware Position-Capture Functions
The hardware position-capture function latches the current encoder position at the time of an external
event into a special register. It is executed totally in hardware, without the need for software intervention
(although it is set up, and later serviced, in software). This means that the only delays in the capture are
the hardware gate delays (negligible in any mechanical system), so this provides an incredibly accurate
capture function. The accuracy is not limited by the servo update rate, as the position can be captured at
any time during the servo cycle.
Turbo PMAC has high-level move-until-trigger constructs that can utilize the hardware position-capture
function to end a commanded move automatically at a precise distance from the captured feedback trigger
position. The triggered time base slaving function uses the hardware-capture function on the master
position data to provide a precise starting reference point for the following. It is also possible to create
your own low-level algorithms to use the hardware capture functions for other purposes.
Requirements for Hardware Capture
The hardware position-capture function in a Turbo PMAC Servo IC latches the encoder counter value
upon a pre-defined change in a flag and/or index-channel input for that channel. Note that for position
data to have this hardware-capture capability, it must be processed through the encoder counter of a Servo
IC (although the sensor does not have to be an encoder – many resolver-to-digital converters produce
simulated quadrature whose count can be captured this way). Parallel-format and analog feedback do not
support this immediate hardware capture (the closest they can get is to the nearest servo cycle).
Both PMAC-style and PMAC2-style Servo ICs support the hardware position capture function. The
newest revisions (“D” rev and later) of the PMAC2-style Servo ICs optionally can support capture of
estimated sub-count position as well.
The position counter for a given encoder channel can be captured only by using input signals for that
channel. To capture multiple positions simultaneously, wire the triggering signal into inputs for each of
the channels whose position to capture.
Setting the Trigger Condition
For both automatic and manual uses, variables I7mn2 and I7mn3 determine what the trigger condition for
the capture is. This is true for both PMAC-style and PMAC2-style Servo ICs. I7mn2 specifies that the
encoder’s index channel is used to trigger, or an input flag for the channel is used, or both; and which
edges of these signals will cause the trigger. I7mn3 specifies which of the four main input flags for the
channel is used for triggering (if I7mn2 specifies that a flag is used).
By having software setup for a hardware capture, Turbo PMAC gets the best of both worlds: the
flexibility of software configuration, plus the immediacy and accuracy of hardware capture. It is possible
to have one setup for homing and another for probing or registration, for example, both with the high
accuracy of hardware capture, and the change requires no rewiring.
Automatic Move-Until-Trigger Functions
Turbo PMAC has three types of move-until-trigger functions that can use the hardware position-capture
feature to latch the triggered position:
1. Homing search moves (on-line or in a motion program)
2. On-line jog-until-trigger moves
3. Motion program RAPID-mode moves-until-trigger
All of these create basically the same type of motion. All of them end their post-trigger move at a pre-
defined distance from the triggered position. These moves are described in detail in the Executing
Individual Motor Moves section of this manual.
Manual Use of the Capture Feature
If the automatic move-until-trigger functions do not accomplish the action needed, create custom
functions by accessing the capture registers directly.
Position-Capture Registers and Flags
Each channel in a Turbo PMAC Servo IC has position-capture registers and a position-capture flag.
Position-Capture Flag
Each channel has a position-capture flag in the channel’s status word. In PMAC-style Servo ICs, this is
bit 17; in PMAC2-style Servo ICs, this is bit 11. This bit is set to 1 by the IC’s capture logic when the
trigger condition occurs and the position is latched into the capture register(s). It is set to 0 when the
(whole count) capture-position register is read by the processor. The act of reading this register
automatically resets and re-arms the capture logic.
Note:
The capture circuits in PMAC-style Servo ICs are edge-triggered. After the
capture logic is reset by reading the position-capture register, the triggering
input(s) must create another edge to the capturing state before the next capture will
occur. By contrast, the capture circuits in PMAC2-style Servo ICs are level-
triggered. If the triggering input(s) is (are) still in the capturing state when the
capture logic is reset, another capture will occur immediately.
For PMAC-style Servo ICs, the M-variable definitions for the position-capture flags are shown in the
following table. With the standard assignment of channels to motors, the suggested M-variable for the
flag for Motor xx is Mxx17.
Servo IC # Channel 1 Channel 2 Channel 3 Channel 4
0 X:$078000,17 X:$078004,17 X:$078008,17 X:$07800C,17
1 X:$078100,17 X:$078104,17 X:$078108,17 X:$07810C,17
2 X:$078200,17 X:$078204,17 X:$078208,17 X:$07820C,17
3 X:$078300,17 X:$078304,17 X:$078308,17 X:$07830C,17
4 X:$079000,17 X:$079004,17 X:$079008,17 X:$07900C,17
5 X:$079100,17 X:$079104,17 X:$079108,17 X:$07910C,17
6 X:$07A200,17 X:$07A204,17 X:$07A208,17 X:$07A20C,17
7 X:$07A300,17 X:$07A304,17 X:$07A308,17 X:$07A30C,17
8 X:$07B200,17 X:$07B204,17 X:$07B208,17 X:$07B20C,17
9 X:$07B300,17 X:$07B304,17 X:$07B308,17 X:$07B30C,17
For PMAC2-style Servo ICs, the M-variable definitions for the position-capture flags are shown in the
following table. With the standard assignment of channels to motors, the suggested M-variable for the
flag for Motor xx is Mxx17.
Servo IC # Channel 1 Channel 2 Channel 3 Channel 4
0 X:$078000,11 X:$078008,11 X:$078010,11 X:$078018,11
1 X:$078100,11 X:$078108,11 X:$078110,11 X:$078118,11
2 X:$078200,11 X:$078208,11 X:$078210,11 X:$078218,11
3 X:$078300,11 X:$078308,11 X:$078310,11 X:$078318,11
4 X:$079000,11 X:$079008,11 X:$079010,11 X:$079018,11
5 X:$079100,11 X:$079108,11 X:$079110,11 X:$079118,11
6 X:$07A200,11 X:$07A208,11 X:$07A210,11 X:$07A218,11
7 X:$07A300,11 X:$07A308,11 X:$07A310,11 X:$07A318,11
8 X:$07B200,11 X:$07B208,11 X:$07B210,11 X:$07B218,11
9 X:$07B300,11 X:$07B308,11 X:$07B310,11 X:$07B318,11
Bit 10 of the same status word on PMAC2-style Servo ICs also is set to 1 if the most recent position
capture used the encoder’s index (Bit 0 of I7mn2 = 1) gated to a single quadrature state wide (I7mn4 = 1).
This indicates that the captured position is suitable for use to see if the proper number of counts have
elapsed since the previous gated-index capture, a good safety check for encoder count loss.
Whole-Count Position-Capture Register
The position-capture register for an encoder channel contains the value of the encoder counter at the time
when the last trigger condition occurred. It is a 24-bit register, in units of counts, usually treated as a
signed quantity. The suggested M-variable for this register is Mxx03 for Motor xx (with encoders
assigned to motors in the standard order).
A count here is a hardware count that is, one increment of the hardware encoder counter. This is often,
but not necessarily, the same as a software count, what the motor software considers a count. In the case
of digital quadrature feedback where the motor gets feedback position with 5 bits of estimated or
measured fraction – 1/32 of a count – hardware and software counts will be the same.
However, in some cases, as with high-resolution interpolation of a sinusoidal encoder through an Acc-51,
where 10 bits of fraction are calculated per hardware count, the resolution of hardware counts and
software counts will be different. In the case of Acc-51 position, a hardware count will be equivalent to
32 software counts.
For PMAC-style Servo ICs, the M-variable definitions for the position-capture registers are shown in the
following table. Note that the capture register is read-only; a write operation to the same address is a
write to the position-compare register for the channel.
Servo IC # Channel 1 Channel 2 Channel 3 Channel 4
0 X:$078003,0,24,S X:$078007,0,24,S X:$07800B,0,24,S X:$07800F,0,24,S
1 X:$078103,0,24,S X:$078107,0,24,S X:$07810B,0,24,S X:$07810F,0,24,S
2 X:$078203,0,24,S X:$078207,0,24,S X:$07820B,0,24,S X:$07820F,0,24,S
3 X:$078303,0,24,S X:$078307,0,24,S X:$07830B,0,24,S X:$07830F,0,24,S
4 X:$079003,0,24,S X:$079007,0,24,S X:$07900B,0,24,S X:$07900F,0,24,S
5 X:$079103,0,24,S X:$079107,0,24,S X:$07910B,0,24,S X:$07910F,0,24,S
6 X:$07A203,0,24,S X:$07A207,0,24,S X:$07A20B,0,24,S X:$07A20F,0,24,S
7 X:$07A303,0,24,S X:$07A307,0,24,S X:$07A30B,0,24,S X:$07A30F,0,24,S
8 X:$07B203,0,24,S X:$07B207,0,24,S X:$07B20B,0,24,S X:$07B20F,0,24,S
9 X:$07B303,0,24,S X:$07B307,0,24,S X:$07B30B,0,24,S X:$07B30F,0,24,S
For PMAC2-style Servo ICs, the M-variable definitions for the position-capture registers are shown in the
following table:
Servo IC # Channel 1 Channel 2 Channel 3 Channel 4
0 X:$078003,0,24,S X:$07800B,0,24,S X:$078013,0,24,S X:$07801B,0,24,S
1 X:$078103,0,24,S X:$07810B,0,24,S X:$078113,0,24,S X:$07811B,0,24,S
2 X:$078203,0,24,S X:$07820B,0,24,S X:$078213,0,24,S X:$07821B,0,24,S
3 X:$078303,0,24,S X:$07830B,0,24,S X:$078313,0,24,S X:$07831B,0,24,S
4 X:$079003,0,24,S X:$07900B,0,24,S X:$079013,0,24,S X:$07901B,0,24,S
5 X:$079103,0,24,S X:$07910B,0,24,S X:$079113,0,24,S X:$07911B,0,24,S
6 X:$07A203,0,24,S X:$07A20B,0,24,S X:$07A213,0,24,S X:$07A21B,0,24,S
7 X:$07A303,0,24,S X:$07A30B,0,24,S X:$07A313,0,24,S X:$07A31B,0,24,S
8 X:$07B203,0,24,S X:$07B20B,0,24,S X:$07B213,0,24,S X:$07B21B,0,24,S
9 X:$07B303,0,24,S X:$07B30B,0,24,S X:$07B313,0,24,S X:$07B31B,0,24,S
The value in this register is referenced to the power-up/reset position of the sensor. That is, the counter is
set to zero at power-up/reset, and it counts from there. It does not get reset to zero if the motor using it
for feedback is homed. If the travel of the sensor from the power-up/reset position goes more than +/-
8,388,608 (+/-223) counts, the count value will roll over. In this case, you must keep track of the rollover.
Note that the act of reading the position-capture register resets the trigger logic, automatically re-arming it
for another trigger. It is a good idea to perform a dummy read of the capture register before starting a
capture sequence to make sure the trigger logic is armed (the standard move-until-trigger functions do this
automatically). If you are also reading the fractional-count capture register (see below), read that register
first to ensure that both it and the whole-count register represent the same triggered position.
Fractional-Count Position-Capture Register
In PMAC(2)-style Servo ICs of Revision D and newer (started shipments in 2002), it is possible to
capture timer-estimated sub-count position as well as the whole-count position described above. This is
most commonly used with the Acc-51 high-resolution sinusoidal-encoder interpolator, but can be used
with quadrature encoders as well.
If variable I7mn9 for Channel n of Servo IC m is set to 1, this function is enabled. (Note that if this is
enabled, the traditional “software 1/T” interpolation registers are disabled.) In this case, bits 12 – 23 of
the Y-register of the channel’s base address (Y:$078000 for Servo IC 0 Channel 1), contain the captured
fractional count value. Bit 23 has a value of ½-count, bit 22 has a value of ¼-count, and so on. A count
in this context is a “hardware count,” which is not necessarily the same as the motor’s “software count.”
The M-variable definitions for the fractional-count position-capture registers are shown in the following
table. The suggested M-variable for Motor xx, assuming the standard matching of channels to motors, is
Mxx83.
Servo IC # Channel 1 Channel 2 Channel 3 Channel 4
0 Y:$078000,12,12,U Y:$078008,12,12,U Y:$078010,12,12,U Y:$078018,12,12,U
1 Y:$078100,12,12,U Y:$078108,12,12,U Y:$078110,12,12,U Y:$078118,12,12,U
2 Y:$078200,12,12,U Y:$078208,12,12,U Y:$078210,12,12,U Y:$078218,12,12,U
3 Y:$078300,12,12,U Y:$078308,12,12,U Y:$078310,12,12,U Y:$078318,12,12,U
4 Y:$079000,12,12,U Y:$079008,12,12,U Y:$079010,12,12,U Y:$079018,12,12,U
5 Y:$079100,12,12,U Y:$079108,12,12,U Y:$079110,12,12,U Y:$079118,12,12,U
6 Y:$07A200,12,12,U Y:$07A208,12,12,U Y:$07A210,12,12,U Y:$07A218,12,12,U
7 Y:$07A300,12,12,U Y:$07A308,12,12,U Y:$07A310,12,12,U Y:$07A318,12,12,U
8 Y:$07B200,12,12,U Y:$07B208,12,12,U Y:$07B210,12,12,U Y:$07B218,12,12,U
9 Y:$07B300,12,12,U Y:$07B308,12,12,U Y:$07B310,12,12,U Y:$07B318,12,12,U
Scaled properly, this value can be added to the whole-count capture register value, regardless of the
direction of motion at the trigger. To combine these into units of hardware counts (which are the same as
software counts in many cases), the following equation can be used:
EncCaptureHWPos = FractionCount/4096 + WholeCount
If the capture is done on an Acc-51 interpolated sinusoidal encoder, the following equation can be used to
calculate the captured position in the motor’s software counts:
EncCaptureSWPos = FractionCount/32 + WholeCount*32
Note that the net position must be stored in a floating-point variable to keep the fractional value, and that
these equations use the fractional count first because reading the whole-count register resets the trigger
logic. In Turbo PMAC code, this could be something like:
P103=M183/32+M103*32
3. Compare output invert control bit: If this bit is set to 0, the off state is a low voltage out of the Servo
IC, and the on state is a high voltage. (Depending on the output driver circuitry, the actual output
from the card may be inverted from this.) If this bit is set to 1, the off state is a high voltage and the
on state is a low voltage. Note that this control bit can be used by itself to make the compare output a
general-purpose digital output, or in some cases, a software-driven interrupt to the host computer.
The single status bit is the position-compare flag, which shows the present state of the compare output
logic (and if the output is enabled, of the physical output). It is set to 1 if the compare output logic
state is on, and to a 0 if the output logic state is off.
There are no firmware functions for the automatic use of the position-compare circuitry. Your application
software must deal with the compare registers and control/status bits directly. Usually, these are accessed
with M-variables, and the file of suggested M-variables includes these definitions. For the first channel of
a Turbo PMAC (Servo IC 0 Channel 1), these definitions are:
M101->X:$078001,0,24,S ; 24-bit position counter register
M103->X:$078003,0,24,S ; 24-bit position compare register
M111->X:$078000,11,1 ; Compare flag latch control
M112->X:$078000,12,1 ; Compare output enable control
M113->X:$078000,13,1 ; Compare output invert control
M116->X:$078000,16,1 ; Compare logic status
To preload a compare position, simply write a value to the compare register (e.g. M103=1250).
Example: We have an array of 50 points in P1 through P50 that represent the distances from a starting
position at which we want compare outputs. Program code (running just a single time) that could start
this process is:
P100=1 ; Select first point of array
P101=M101 ; Read and store starting position
M103=P101+P(P100) ; Write first relative position to compare
M111=1 ; Set for latched output
M112=1 ; Enable compare output
Repeatedly executing program code (probably in a PLC 0 or PLCC 0) that could work through the array
is:
WHILE (P100<51) ; Loop until 50 points completed
IF (M116=1) ; Reached last compare position?
P100=P100+1 ; Select next point
M103=P101+P(P100) ; Write next relative position to compare
M111=0 ; Clear output by making transparent
M111=1 ; Set for latched output again
ENDIF
ENDWHILE
In addition, there is a memory-mapped status bit for the output that Turbo PMAC software can access
with M-variables for its own use.
If the Servo IC is on a Turbo PMAC, or directly connected to it, the registers and control/status bits are
accessed with user-defined M-variables. If the Servo IC is on a MACRO Station, these registers and bits
are accessed with pre-defined Station node-specific MI-variables for the MACRO node matched to this
interface channel.
Compare Registers
The position compare circuitry for each channel is based on three memory-mapped registers:
• Compare A (Turbo suggested M-variable Mxx08; MACRO Station MS{node},MI925)
• Compare B (Turbo suggested M-variable Mxx09; MACRO Station MS{node},MI926)
• Compare Auto-Increment (Turbo suggested M-variable Mxx10; MACRO Station
MS{node},MI922)
When the encoder counter value matches the value in either the channel’s Compare A Register or
Compare B Register, the compare output is toggled from the existing state; either from 0 to 1, or from 1
to 0. The toggling occurs on the transition from equal to not-equal in either direction. For instance, if the
compare register contains 100, the toggling of the output would occur on the transition from 100 to 101
counts in the positive direction, or on the transition from 100 to 99 counts in the negative direction.
In addition, when the output is toggled by one of the compare registers, the other register is incremented
immediately by the amount in the auto-increment register. If the output is toggled by moving in the
positive direction, the value in the auto-increment register is added to the other compare register. If the
output is toggled by moving in the negative direction, the value in the auto-increment register is
subtracted from the other compare register.
If the auto-increment register is non-zero, all of the compare edges should be at least two counts apart.
This means that the Compare A and Compare B registers should not be less than two counts apart, and the
minimum non-zero value for the auto-increment register should be 4.
Compare Control Bits
There are three control bits for each channel on a PMAC2-style Servo IC. They are:
1. Compare Channel Select Bit: (Turbo I-variable I7mn1; MACRO Station MS{node},MI911) This
control bit determines whether the compare circuitry for the channel acts on the encoder for that
channel, or the encoder for Channel 1 of this Servo IC. (Note that this bit does nothing for Channel
1.) This control bit has been assigned an I-variable – I7mn1 for Servo IC m Channel n. Note that
when multiple compare circuits have been assigned to Channel 1 of a Servo IC, the compare output
for the first channel is the logical OR of all of the compare logical outputs assigned to Channel 1.
2. Compare Direct-Write (Initial State) Value: (Turbo suggested M-variable Mxx12; MACRO Station
MS{node},MI929) This control bit allows you to set the state of the compare output for the channel
directly, either as an initial state for a compare sequence, or to use the output for general-purpose use,
or for a software-driven interrupt. A 1 here will force a high voltage on the output of the Servo IC; a 0
will force a low voltage. (Depending on the output driver used, this may be inverted on the output of
the controller itself.) It is the user’s responsibility to determine whether he is in his desired 0 region or
the “1” region when he uses the direct-write feature. Writing to this bit alone does not set the output;
this does not happen until the write is enabled, using the next control bit.
3. Compare Direct-Write Enable: (Turbo suggested M-variable Mxx11; MACRO Station
MS{node},MI928) Writing a 1 to this bit forces the value of the direct-write bit onto the compare
output line. As soon as the output state is set, this bit automatically sets itself back to 0.
The single status bit is the compare output status, which reflects the state of the output at any instant. A 1
here indicates a high voltage out of the Servo IC; a 0 indicates a low voltage. Depending on the output
driver used in a particular configuration, the voltage sense may be inverted out of the control card.
There are no firmware functions for the automatic use of the position-compare circuitry. The user’s
application software must deal with the compare registers and control/status bits directly. Usually, these
are accessed with M-variables (or MACRO Station setup MI-variables), and the file of suggested M-
variables includes these definitions. For the first channel of a Turbo PMAC2 (Servo IC 0 Channel 1),
these definitions are:
M101->Y:$078001,0,24,S ; Hardware position value (counts)
M108->Y:$078007,0,24,S ; Position compare A value (counts)
M109->X:$078007,0,24,S ; Position compare B value (counts)
M110->X:$078006,0,24,S ; Auto-increment value (counts)
M111->X:$078005,11 ; Position compare write enable
M112->X:$078005,12 ; Position compare direct-write (initial-state) value
M113->X:$078000,9 ; Position compare output status
Refer to the Suggested M-variable list in the Software Reference Manual for equivalent definitions for
other channels.
Setting Up for a Single Pulse Output
If just a single compare pulse is desired (not using the auto-increment feature), take the following steps:
• Write the encoder value at the front edge into the Compare A register
• Write the encoder value at the back edge into the Compare B register
• Set the Auto-Increment register to zero
• Set the initial state with the direct-write feature in a two-step process:
• Write a value to the initial state bit
• Write a 1 to the direct-write enable bit (this is self-clearing to 0)
• Start the move that will cause the compare function
Example: With the axis sitting still at about encoder position 100, and a 1 value of position compare
desired between encoder positions 1000 and 1010, the following code could be used:
M108=1000 ; Set front end compare in A
M109=1010 ; Set back end compare in B
M110=0 ; No auto-increment
M112=0 ; Prepare initial value of 0
M111=1 ; Enable direct write (resets immediately to 0)
{Command to start the move}
Setting Up for Multiple Pulse Outputs
By using the auto-increment feature, it is possible to create multiple compare pulses with a single
software setup operation. When the auto-increment register is a non-zero value, its value is automatically
added to or subtracted from one compare register’s value when the other compare value is matched.
PMAC keeps track of the direction of incrementing, so only positive values should be used in the auto-
increment register, even if the encoder will be counting in the negative direction.
The setup for multiple pulses is like the setup for a single pulse, except that a non-zero value must be
entered into the auto-increment register, and the value entered for the back edge must be that of the first
back edge minus the auto-increment if the move will be positive, or that of the first back edge plus the
auto-increment value if the move will be negative.
In other words, the starting values to the two compare registers must “bracket” the starting position.
When either compare value is matched by the encoder counter, the other compare value is incremented in
the direction of movement.
Starting Position
B0 A0 B1 A1
Auto-Increment
Example: Starting from the above example, desiring the compare output on between 1000 (A0) and 1010
(B1) counts, but adding an auto-increment value of 2000 counts, with a starting position of about 100
counts, program code to start the sequence could be:
M110=2000 ; Auto-increment of 2000 encoder counts
M108=1000 ; First front edge (A0) at 1000 counts
M109=1010-M110 ; First back edge (B1) at 1010 counts
M112=0 ; Prepare initial value of 0
M111=1 ; Enable direct write (resets immediately to 0)
{Command to start the move}
Fractional-Count Compare
Starting in the D revision of the DSPGATE1 PMAC2-style Servo IC (starting shipping in 2002), the
compare circuitry has the capability of triggering the output at a fractional count value, not just at the
nearest whole number of counts. This IC can create a fractional count value every encoder-sample clock
(SCLK) cycle using 1/T timer-based techniques and use this extended count value in the position-
compare (and capture) circuitry. This capability is not possible in PMAC-style Servo ICs.
This capability is particularly valuable when using a sinusoidal encoder through an interpolator circuit,
such as the Acc-51E. The interpolator greatly increases the resolution of the servo feedback, but does not
by itself increase the resolution of the compare function. Note, however, that use of a sinusoidal encoder
and interpolator is not required for the extended compare function; it works identically with digital
quadrature encoders.
This extended-count mode is enabled for Servo IC m Channel n by setting variable I7mn9 to 1. This
variable was implemented in V1.937 firmware, but not documented until the V1.939 software reference
manual (because the ICs that could use it did not start shipping until then). With I7mn9 set to the factory
default value of 0, the extended-count mode is disabled. This single-bit I-variable is bit 18 in the control
word for the channel in the IC.
When this mode is enabled, the meaning of the two 24-bit timer registers for the channel changes. (This
means that you cannot use the traditional software 1/T count extension in the conversion table for this
channel; if you are using digital quadrature encoders in this mode, you must use the new “hardware 1/T”
conversion method.) In extended-count mode these two registers contain four 12-bit values. The lower
half of each register contains the fractional count value for the position compare function. Suggested M-
variables for these values for Servo IC 0 Channel 1 are:
M188->Y:$078001,0,12,U ; Compare A fractional count
M189->Y:$078000,0,12,U ; Compare B fractional count
These registers must be used as unsigned values. Treated this way, these registers take a value of 0 to
4095, representing a (whole) count value 1/4096 as big. Higher values of fractional count are closer to
the more positive whole count, regardless of the direction of motion.
Note carefully what a count means here. Because we are dealing with the hardware counter in the Servo
IC, these are hardware counts – one unit of the hardware counter. With the times-4 decode that is almost
universally used (and must be used with the Acc-51 boards), there are 4 hardware counts per line (signal
cycle) of the encoder.
Turbo PMAC’s high-resolution interpolation of sinusoidal encoders produces 4096 states per line, or
1024 states per hardware count (10 bits of fraction). However, Turbo PMAC’s servo software assumes
there are only 5 bits of fractional count data in the positions it accesses. Therefore, a software count from
an Acc-51 interpolator is 1/32 the size of a hardware count, yielding 128 software counts per line of the
encoder.
The following table shows, for each Servo IC and channel, the I-variable that enables the sub-count
compare and the M-variable definitions for whole count and fractional count data.
IC Chan Mode Compare A Compare A Compare B Compare B
# # I-Var Whole Count Fractional Count Whole Count Fractional Count
(Mxx08) (Mxx88) (Mxx09) (Mxx89)
0 1 I7019 Y:$078007,0,24,S X:$078001,0,12,U X:$078007,0,24,S Y:$078000,0,12,U
0 2 I7029 Y:$07800F,0,24,S X:$078009,0,12,U X:$07800F,0,24,S Y:$078008,0,12,U
0 3 I7039 Y:$078017,0,24,S X:$078011,0,12,U X:$078017,0,24,S Y:$078010,0,12,U
0 4 I7049 Y:$07801F,0,24,S X:$078019,0,12,U X:$07801F,0,24,S Y:$078018,0,12,U
1 1 I7119 Y:$078107,0,24,S X:$078101,0,12,U X:$078107,0,24,S Y:$078100,0,12,U
1 2 I7129 Y:$07810F,0,24,S X:$078109,0,12,U X:$07810F,0,24,S Y:$078108,0,12,U
1 3 I7139 Y:$078117,0,24,S X:$078111,0,12,U X:$078117,0,24,S Y:$078110,0,12,U
1 4 I7149 Y:$07811F,0,24,S X:$078119,0,12,U X:$07811F,0,24,S Y:$078118,0,12,U
2 1 I7219 Y:$078207,0,24,S X:$078201,0,12,U X:$078207,0,24,S Y:$078200,0,12,U
2 2 I7229 Y:$07820F,0,24,S X:$078209,0,12,U X:$07820F,0,24,S Y:$078208,0,12,U
2 3 I7239 Y:$078217,0,24,S X:$078211,0,12,U X:$078217,0,24,S Y:$078210,0,12,U
2 4 I7249 Y:$07821F,0,24,S X:$078219,0,12,U X:$07821F,0,24,S Y:$078218,0,12,U
3 1 I7319 Y:$078307,0,24,S X:$078301,0,12,U X:$078307,0,24,S Y:$078300,0,12,U
3 2 I7329 Y:$07830F,0,24,S X:$078309,0,12,U X:$07830F,0,24,S Y:$078308,0,12,U
3 3 I7339 Y:$078317,0,24,S X:$078311,0,12,U X:$078317,0,24,S Y:$078310,0,12,U
3 4 I7349 Y:$07831F,0,24,S X:$078319,0,12,U X:$07831F,0,24,S Y:$078318,0,12,U
4 1 I7419 Y:$079207,0,24,S X:$079201,0,12,U X:$079207,0,24,S Y:$079200,0,12,U
4 2 I7429 Y:$07920F,0,24,S X:$079209,0,12,U X:$07920F,0,24,S Y:$079208,0,12,U
4 3 I7439 Y:$079217,0,24,S X:$079211,0,12,U X:$079217,0,24,S Y:$079210,0,12,U
4 4 I7449 Y:$07921F,0,24,S X:$079219,0,12,U X:$07921F,0,24,S Y:$079218,0,12,U
5 1 I7519 Y:$079307,0,24,S X:$079301,0,12,U X:$079307,0,24,S Y:$079300,0,12,U
5 2 I7529 Y:$07930F,0,24,S X:$079309,0,12,U X:$07930F,0,24,S Y:$079308,0,12,U
5 3 I7539 Y:$079317,0,24,S X:$079311,0,12,U X:$079317,0,24,S Y:$079310,0,12,U
5 4 I7549 Y:$07931F,0,24,S X:$079319,0,12,U X:$07931F,0,24,S Y:$079318,0,12,U
6 1 I7619 Y:$07A207,0,24,S X:$07A201,0,12,U X:$07A207,0,24,S Y:$07A200,0,12,U
6 2 I7629 Y:$07A20F,0,24,S X:$07A209,0,12,U X:$07A20F,0,24,S Y:$07A208,0,12,U
6 3 I7639 Y:$07A217,0,24,S X:$07A211,0,12,U X:$07A217,0,24,S Y:$07A210,0,12,U
6 4 I7649 Y:$07A21F,0,24,S X:$07A219,0,12,U X:$07A21F,0,24,S Y:$07A218,0,12,U
7 1 I7719 Y:$07A307,0,24,S X:$07A301,0,12,U X:$07A307,0,24,S Y:$07A300,0,12,U
7 2 I7729 Y:$07A30F,0,24,S X:$07A309,0,12,U X:$07A30F,0,24,S Y:$07A308,0,12,U
7 3 I7739 Y:$07A317,0,24,S X:$07A311,0,12,U X:$07A317,0,24,S Y:$07A310,0,12,U
7 4 I7749 Y:$07A31F,0,24,S X:$07A319,0,12,U X:$07A31F,0,24,S Y:$07A318,0,12,U
8 1 I7819 Y:$07B207,0,24,S X:$07B201,0,12,U X:$07B207,0,24,S Y:$07B200,0,12,U
8 2 I7829 Y:$07B20F,0,24,S X:$07B209,0,12,U X:$07B20F,0,24,S Y:$07B208,0,12,U
8 3 I7839 Y:$07B217,0,24,S X:$07B211,0,12,U X:$07B217,0,24,S Y:$07B210,0,12,U
8 4 I7849 Y:$07B21F,0,24,S X:$07B219,0,12,U X:$07B21F,0,24,S Y:$07B218,0,12,U
9 1 I7919 Y:$07B307,0,24,S X:$07B301,0,12,U X:$07B307,0,24,S Y:$07B300,0,12,U
9 2 I7929 Y:$07B30F,0,24,S X:$07B309,0,12,U X:$07B30F,0,24,S Y:$07B308,0,12,U
9 3 I7939 Y:$07B317,0,24,S X:$07B311,0,12,U X:$07B317,0,24,S Y:$07B310,0,12,U
9 4 I7949 Y:$07B31F,0,24,S X:$07B319,0,12,U X:$07B31F,0,24,S Y:$07B318,0,12,U
The auto-increment function is still available in extended-count mode, but the auto-increment value is
limited to integer numbers of counts.
In operation in this mode, you write to both the standard (integer) compare register and the fractional
compare register. In this mode, the integer value written to the compare register is offset by one count
from the count value at which the compare output will toggle. The direction of this offset is dependent on
the direction of motion. If a value of n counts is written to the integer compare register, the compare
output will toggle at n+1 counts when moving in the positive direction, or n-1 counts when moving in the
negative direction. To compensate for this, simply add or subtract 1 count depending on the direction of
motion. For instance, to get a compare edge at 743.25 counts when moving in the positive direction,
write 742 (=743-1) to the integer compare register, and write 1024 (=0.25*4096) to the fractional
compare register.
Example: P108 and P109 are floating-point variables representing the first count values at which the
compare output is to be turned on, then off. P110 is an integer value representing the auto-increment
length in counts. Motion is to be in the positive direction. Program code to start the sequence could be:
M110=P110 ; Auto-increment value
M108=INT(P108)-1 ; Compare A integer component
M188=(P108-(M108+1))*4096 ; Compare A fractional component
M109=INT(P109)-1-M110 ; Compare B integer component
M189=(P109-(M109+1+M110))*4096 ; Compare B fractional component
M112=0 ; Prepare initial value of 0
M111=1 ; Enable direct write
The conversion from axis position to motor position involves a scale factor and an offset, with the
following equation:
MotorPosition = ScaleFactor * AxisPosition + Offset
The scale factor is specified in the axis definition statement in counts per engineering unit. It should be
constant for an application. You can specify the scale factor directly in your equation, or you can access
the actual register that PMAC is using with suggested M-variables:
Mxx91 ; Axis scale factor for X, U, A, B, or C assigned to Motor xx
Mxx92 ; Axis scale factor for Y or V assigned to Motor xx
Mxx93 ; Axis scale factor for Z or W assigned to Motor xx
The offset is the position bias term, with suggested M-variable Mx64, and units of 1/(Ixx08*32) counts.
It is set equal to the axis definition offset (usually 0) on power-up/reset and homing. It can be changed
after this with on-line command {axis}= or motion program command PSET.
For example, with Motor 1 assigned to the X-axis, if you want to set the Compare 1A register to trigger at
+2.5 engineering units from the axis origin, you can compute motor position in counts as:
P1=M191*2.5+M164/(I108*32)
Then you can set the actual compare register with:
M108=P1+M173+I126/16
Note
If the expression on the right-hand side of this equation had produced a result
outside of the range of the compare register, the act of writing to the M-variable
assigned to this register would truncate the value properly to the 24-bit range so
that the compare function will work properly. 24-bit signed registers have a range
of -8,388,608 to +8,388,607. If you attempted to write a value of +9,388,608 –
one million counts past the rollover point – into this register, the resulting value
would be -7,388,608, which would be reached one million counts after the
rollover.
Example
A quick example of a PLC block entry is shown below:
OPEN PLC 2
CLEAR
IF (M11=1)
I130=10000
ELSE
I130=8000
ENDIF
CLOSE
ENABLE PLC 2
Notice that we had to make sure that P11 could follow M11 both up and down. We set P11 to 0 in a
level-triggered mode. We could have done this edge-triggered as well, but it does not matter as far as the
final outcome of the routine is concerned. It is about even in calculation time, and it saves program lines.
Any SEND, COMMAND, or DISPLAY action statement should be done only on an edge-triggered
condition, because the PLC can cycle faster than these operations can process their information, and the
communications channels can get overwhelmed if these statements are executed on consecutive scans
through the PLC.
IF (M11=1) ; input is ON
IF (P11=0) ; input was not ON last time
COMMAND"#1J+" ; JOG motor
P11=1 ; set latch
ENDIF
ELSE
P11=0 ; reset latch
ENDIF
WHILE Loops
Normally a PLC program executes all the way from beginning to end within a single scan. The exception
to this rule occurs if the program encounters a true WHILE condition. In this case, the program will
execute down to the ENDWHILE statement and exit this PLC. After cycling through all of the other
PLCs, it will re-enter this PLC at the WHILE condition statement, not at the beginning. This process will
repeat as long as the condition is true. When the WHILE condition goes false, the PLC program will skip
past the ENDWHILE statement and proceed to execute the rest of the PLC program.
If we want to increment our counter as long as the input is true, and prevent execution of the rest of the
PLC program, we could program:
WHILE (M11=1)
P1=P1+1
ENDWHILE
This structure makes it easier to hold up PLC operation in one section of the program, so other branches
in the same program do not need extra conditions to prevent their execution when this condition is true.
Contrast this to using an IF condition (see above).
Some COMMAND action statements should be followed by a WHILE condition to ensure they have taken
effect before proceeding with the rest of the PLC program. This is always true if a second COMMAND
action statement follows and requires the first COMMAND action statement to finish. (Remember,
COMMAND action statements are processed only during the communications section of the background
cycle.)
To have an input to stop any motion in a Coordinate System and start motion program 10 use the
following PLC:
IF (M11=1) ; input is ON
IF (P11=0) ; input was not ON last time
P11=1 ; set latch
COMMAND"&1A" ; ABORT all motion
WHILE(M5187=0) ; wait for motion to stop
ENDWHILE
COMMAND"&1B10R" ; start program 10
ENDIF
ELSE
P11=0 ; reset latch
ENDIF
Note:
M5187 is the Coordinate System In-Position bit as defined in the suggested M-
variable list.
Precise Timing
Since PLCs 1 to 31 are the lowest computation priority on Turbo PMAC, the cycle time cannot be
precisely determined. To hold up an action for a fairly precise amount of time, a WHILE loop can be
used, but instead of incrementing a variable, use an on-board timer.
Each coordinate system on Turbo PMAC has two user countdown timers: Isx11 and Isx12 (I5111 and
I5112 for Coordinate System 1). These timers are active for Coordinate Systems 1 through (I68+1).
They are 24-bit signed registers (range: -8,388,608 to +8,388,607) that count down once each servo cycle.
Typically, write a value to it representing the time to wait, expressed in servo cycles (multiply
milliseconds by 8,388,608/I10), then wait for it to reach zero. Example code is:
I5111=500*8388608/I10 ; Set timer to 500 msec
WHILE (I5111>0) ; Loop until counts to zero
ENDWHILE ; Exit PLC program here when true
If more timers are needed, use memory address X:$0. This 24-bit register counts up once per servo cycle.
Store a starting value for this, then each scan subtract the starting value from the current value and
compare the difference to the amount of time to wait. By subtracting into another 24-bit register, possible
rollover of X:$0 is handled gracefully.
Define the following M-variables with on-line commands:
M0->X:$0,24 ; Servo counter register
M85->X:$0010F0,24 ; Free 24-bit register
M86->X:$0010F1,24 ; Free 24-bit register
Then write as part of the PLC program:
M85=M0 ; Start of timer
M86=M0-M85 ; Time elapsed so far
WHILE (M86<P86) ; Less than specified time?
M86=M0-M85 ; Time elapsed so far
ENDWHILE ; Exit PLC program here when true
Compiled PLC Programs
It is possible to compile Turbo PMAC PLC programs for faster execution. The faster execution of the
compiled PLCs comes from two factors: first, from the elimination of interpretation time, and second,
from the capability of the compiled PLC programs to execute integer arithmetic. 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.
Turbo PMAC does not perform the compilation of the PLC programs itself. The compilation is done in a
PC; the resulting machine code is then downloaded to Turbo PMAC.
Turbo PMAC can store and execute up to 32 compiled PLC programs as well as 32 interpreted
(uncompiled) PLC programs for a total of 64 PLC programs. 15K (15,360) 24-bit words of Turbo PMAC
memory are reserved for compiled PLCs; or 14K (14,336) words if there is a user-written servo as well.
No other task may use this memory, and compiled PLCs may not use any other memory.
Note:
The size of the compiled code mentioned here refers to the space that the actual
compiled code will occupy in Turbo PMAC’s memory. It does not refer to the size
of the compiler’s output file on the PC’s disk drive.
A compiled PLC program is labeled PLCC n (PLC-Compiled #n) on Turbo PMAC. This distinguishes it
from an interpreted PLC, which is simply labeled PLC n. There is no special relationship between the
interpreted and compiled PLCs of the same number.
Execution of Compiled PLCs
Of the 32 compiled PLC programs (PLCC 0 to PLCC 31) only PLCC 0 operates in the foreground,
triggered by the real-time interrupt (RTI). PLCCs 1 to 31 operate as background tasks.
At each real-time interrupt, Turbo PMAC checks to see whether several user tasks need to be done. The
real-time interrupt occurs every (I8+1) servo cycles. Turbo PMAC checks the tasks in the following
order:
1. Motion program move planning: Turbo PMAC checks to see in each coordinate system whether it is
time to calculate the next move in the program.
2. Interpreted PLC 0: Turbo PMAC checks to see if I5=1 or 3 and if PLC 0 is enabled. If so, it executes
one scan of PLC 0.
3. Compiled PLC 0: Turbo PMAC checks to see if I5=1 or 3 and if PLCC 0 is enabled. If so, it executes
one scan of PLCC 0.
It is important that the scan execution time of PLCC 0 and PLC 0 be kept less than one real-time interrupt
period. Otherwise, their repeated execution will starve the background for time, and probably trip the
watchdog timer.
In background, Turbo PMAC executes one scan of a single background interpreted PLC program
uninterrupted by any other background task (although higher-priority tasks will interrupt). In between
each scan of each individual background interpreted PLC program, Turbo PMAC will execute one scan of
all active background compiled PLCs. This means that the background compiled PLCs execute at a
higher scan rate than the background interpreted PLCs. For example, if there are seven active background
interpreted PLCs, each background compiled PLC will execute seven scans for each scan of a background
interpreted PLC.
Writing Compiled PLC Programs
You can write compiled PLCs just as you write the standard interpreted PLCs, using a standard text editor
such as that in the PMAC Executive program. All statements that can be used in an interpreted PLC
program also can be used in a compiled PLC program, so it is possible to change an interpreted PLC to a
compiled PLC without any code changes.
However, compiled PLC programs support additional programming features that increase their efficiency
and flexibility. These features are described below. Remember that these features are not supported in
interpreted PLCs.
Compiler-Assigned Pointer Variables
For direct and efficient access to Turbo PMAC registers, compiled PLC programs support two types of
pointer variables for which the register assignment is made at compilation time, not at program execution
time.
L-Variables: Short Integer Pointers
L-variables are pointers to short (24-bit) registers, treated as integer (fixed-point) values. These work in
the same way as L-variables do in compiled PLC programs. They can access either X or Y short
registers, either as entire 24-bit registers (treated as signed integers only), or as portions of the registers 1,
4, 8, 12, 16, or 20 bits wide (treated as signed or unsigned integers, except for 1-bit variables, which are
unsigned only).
Legal L-variable names for the compiler contain the letter L followed by an integer in the range 0 to 8191,
for a total of 8192 possible L-variables (L0 to L8191).
For variables referencing fixed locations in Turbo PMAC’s memory and I/O space, the L-variables will
simply replace M-variables, and the L-variable definition will be made exactly like the M-variable
definitions. It is completely acceptable to retain the M-variable definition as well. You will probably
want to retain the M-variable definitions for debugging purposes, because Turbo PMAC will not accept a
query command for the value or definition of an L-variable. Often, you will use identical L-variable and
M-variable definitions.
For example, Machine Output 1 and Machine Input 1 on the JOPTO port typically are referenced by the
following definitions in uncompiled programs:
M1->Y:$078F02,8 ; Machine Output 1
M11->Y:$078F02,0 ; Machine Input 1
For the compiled PLC programs, you could create equivalent M-variable definitions:
L1->Y:$078F02,8 ; Machine Output 1
L11->Y:$078F02,0 ; Machine Input 1
A small routine in a compiled PLC to make Machine Output 1 follow Machine Input 1 would be:
IF (L11=1)
L1=1
ELSE
L1=0
ENDIF
You may access a register in one program statement with an L-variable, and then access the same register,
even the same part of the register, in another program statement with an integer M-variable or I-variable.
Mixing L-variable access and P- or Q-variable access to a P- or Q-variable register will yield nonsensical
results, because the P- and Q-variable access always treats the register as a floating-point number.
F-Variables: Long Floating-Point Pointers
F-variables are pointers to long (48-bit) registers. If the F-variable definition is an L format (e.g. F1-
>L:$10F0), the register is accessed as a 48-bit floating-point register. If the F-variable definition is a D
format variable (e.g. F2->D:$88), the register is accessed as a 48-bit signed integer, but conversion to
or from Turbo PMAC’s 48-bit floating-point format is automatically performed, so it can be used in
floating-point mathematics.
Note:
The use of F-variables requires the PRO series of PMAC Executive program
(PEWIN32PRO) and Turbo PMAC firmware revision 1.938 or newer.
Turbo PMAC itself cannot recognize L-variables or F-variables; these variables have meaning only to the
compiler on the host computer. Turbo PMAC will reject any uncompiled command containing an L-
variable that is sent to it.
Note:
Do not confuse L-variables, which are short-word compiler pointers, with L-format
F-variables and M-variables, which are long-word variables.
Comparison to Run-Time Linked Pointers
By contrast, when using Turbo PMAC’s M-variable pointers, the register assignment is made when the
line is executed, each time it is executed. This assignment requires about 600 nanoseconds additional
computation time (on a 100 MHz CPU) each time the variable is accessed. However, this does permit the
M-variable definition to be changed during execution, enabling techniques such as indirect addressing.
It is possible to use L-variables for fast integer arithmetic while retaining the run-time flexibility of M-
variable definitions. (This does add the run-time definition-access computational penalty described
above.) Instead of directly defining L-variables to registers for the compiler, reference a range of L-
variables to Turbo PMAC M-variable definitions with the LMOVERLAY {start},{end} compiler
directive. This directive must precede the actual compiled PLC program. For example, LMOVERLAY
10,20 instructs the compiler that the definitions of L10 through L20 are to be assigned at run time using
the definitions of M10 through M20 respectively at the time each statement is executed, not at
compilation time.
Using the M-variable definition for an L-variable and accessing this definition at run time permits indirect
addressing techniques through real-time modification of this M-variable definition using another pointer
variable.
Floating-Point vs. Fixed-Point Mathematics
Each statement in a compiled PLC that utilizes any mathematics can be executed either floating-point or
integer (fixed-point) mathematics. In a floating-point statement, all variables used are processed through
an intermediate working format that is 48-bit floating-point, regardless of the storage format of the
variable. Floating-point statements can utilize any of Turbo PMAC’s I, P, Q, or M-variables, and the
compiler’s long F-variable pointers. They cannot use the compiler’s short fixed-point L-variable pointers.
All constants used in these statements are stored as 48-bit floating-point values.
In an integer statement, all variables used are processed through an intermediate working format that is
24-bit signed integer, regardless of the storage format of the variable. Integer statements can only utilize
the compiler’s short fixed-point L-variable pointers. They cannot use the compiler’s long F-variable
pointers, or Turbo PMAC’s I, P, Q, or M-variables. All constants used in these statements are stored as
24-bit signed integers. All constants used and intermediate values computed must fit in the range of these
integers: -8,388,608 to +8,388,607. No mathematical functions (e.g. SIN, COS) may be used in an
integer statement.
Note that if a constant appears on a line before any variable (e.g. IF (0=P1) …), the line is assumed to
be floating-point. This means that the statement IF (0=L1) is illegal because it mixes floating-point
and fixed-point data types.
Short-word integer operations will execute more than 10 times faster than the same operations done as
long floating-point operations, but they do not have nearly the dynamic range of floating-point operations.
If direct conversion between integer and floating-point data types is required, compiled PLCs provide the
ITOF (integer-to-float) and FTOI (float-to-integer) functions. The ITOF function (with an integer
expression as its argument) can be used in a floating-point statement, such as:
P20=ITOF(L10+L11)*3.14159/P628
The FTOI function (with a floating-point expression as its argument) can be used in a fixed-point
statement, such as:
L10=L9+FTOI(P5*100)-5
The FTOI function will round the value of the floating-point expression to the nearest integer.
It is not permissible to nest FTOI and ITOF functions within an expression.
Note:
The use of FTOI and ITOF requires the “PRO” series of PMAC Executive
program (PEWIN32PRO) and Turbo PMAC firmware revision 1.938 or newer.
Arrays
Compiled PLC programs support two types of arrays: variable arrays and register arrays. Both provide
useful capabilities.
Variable Arrays
Variable arrays work with the Turbo PMAC’s standard PMAC I, P, Q, and M-variables. The number of
the array index is placed inside parentheses, and specifies the variable number for the specified type of
variable. The expression that determines this number is a floating-point expression, so it can use Turbo
PMAC I, P, Q, or M-variables, constants (which will be treated as floating-point values) and the
compiler’s F-variables, but it cannot use the compiler’s L-variables (unless the value has been converted
to floating-point with the ITOF function). The resulting value of this floating-point expression is
rounded automatically to the nearest integer to select the variable number to be used. Some examples of
statements using these variable arrays are:
P(P1)=P10*32
P30=I(ITOF(L10)*100+30)*P29
Register Arrays
Register arrays work with the compiler’s short L-variables and long F-variables. These arrays must be
declared to the compiler before the start of the actual Open Servo algorithm. In use, the number of the
array index is placed inside square brackets, and specifies the address offset from the declared beginning
of the array. The expression that determines this number is a fixed-point expression, so it can use only
the compiler’s L-variables and constants that fit within the range of a 24-bit signed integer.
L and F-variable register arrays must be declared to the compiler before the start of the actual Open Servo
algorithm. Examples of these definitions are:
L100->X:$010000[32]
F200->D:$030040[64]
F300->L:$030080[128]
The declared array size must be a power of 2 in the range 2 to 8192. L-variable register arrays always use
full 24-bit X or Y registers, treating the values as signed integers.
Note:
The use of register arrays requires the PRO series of PMAC Executive program
(PEWIN32PRO) and Turbo PMAC firmware revision 1.938 or newer.
Operators
As with any Turbo PMAC user program, compiled PLCs can utilize the following mathematical and
logical operators: + (addition), - (subtraction), * (multiplication), / (division), % (modulo, remainder), &
(bit-by-bit AND), | (bit-by-bit OR), and ^ (bit-by-bit XOR). All of these operators can be used in either
floating-point or integer statements. Integer division rounds the result to the nearest integer; in the case
where the fraction is exactly 0.5, it will round to the next more positive integer (e.g. -7.5 to -7,
and 7.5 to 8).
Comparators
As with any Turbo PMAC user program, compiled PLCs can utilize the following comparators in
conditional statements: = (equal to), > (greater than), < (less than), ~ (approximately equal to [within
0.5]), != (not equal to),!> (not greater than, less than or equal to), !< (not less than, greater than or equal
to), and !~ (not approximately equal to [not within 0.5]).
The ~ and !~ comparators can be used only in floating-point statements. Note that the <>, >=, and <=
comparators, which can be used in some programming languages, cannot be used in compiled PLCs or
other Turbo PMAC programs.
Functions
As with any Turbo PMAC user program, compiled PLCs can utilize the following mathematical
functions. Note that these functions can be used only in floating-point statements within a compiled PLC:
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), EXP
(exponentiation), LN (natural logarithm), and SQRT (square root).
The trigonometric functions use degrees if Turbo PMAC variable I15 is set to the default value of 0; they
use radians if I15 is set to 1. The present value of I15 is evaluated each time a trigonometric function is
executed.
Note:
The ATAN2 function uses Q0 as its second argument – the cosine argument. The
first argument – the sine argument – is inside the parentheses immediately
following ATAN2. The Q0 used is that of the coordinate system selected in the
PLCC by the ADDRESS statement, or Coordinate System 1’s Q0 if no ADDRESS
statement has been executed in that PLCC.
If an Option 5x0 standard memory configuration is ordered, 48K words of program memory are available
for the machine code of compiled PLCs (P:$050000 through P:$05BFFF). If an Option 5x3 extended
memory configuration is ordered, 432K words of program memory are available for the machine code of
compiled PLCs (P:$050000 through P:$0BBFFF). The Executive program’s downloader will tell you
how many words of program memory are occupied by the PLC programs you just compiled and
downloaded.
For general data memory, most users will utilize some of Turbo PMAC’s 8192 P-variables for floating-
point values. If just a few open registers are desired for use, the registers at X/Y:$0010F0 –
X/Y:$0010FF are unused by any firmware task, other than to be zeroed automatically at power-up/reset.
For large amounts of extra data memory, it is recommended to use the “User Buffer” setup with the on-
line DEFINE UBUFFER command. The User Buffer occupies a number of registers at the high end of
X/Y data memory. With an Option 5x0 standard memory configuration, the end of data memory is at
X/Y:$0107FF; if DEFINE UBUFFER 2048 is declared, all data memory from $010000 through
$0107FF is reserved for your own purposes. With an Option 5x3 extended memory configuration, the
end of data memory is at X/Y:$03FFFF; there is by default a User Buffer of 65,536 words, reserving all
memory registers from X/Y:$030000 to X/Y:$03FFFF for your use. It is your responsibility to make sure
that registers in the UBUFFER utilized for Open Servo data storage are not used for other purposes as
well.
Compiling the PLCs
The download function of the PMAC Executive program’s editor will compile these PLCs automatically
and transmit the resulting compiled machine code to the Turbo PMAC. The process of compilation is
basically invisible to the user, requiring no more work than downloading interpreted programs or on-line
commands.
The downloader observes the following rules in processing the editor file:
• The downloader automatically incorporates the contents of any file reference with a #include
directive. If the contents of the included file (e.g. macro substitutions) are referenced in the main file,
the #include directive must precede the use of the contents.
• The downloader automatically takes note of any macro substitution set with a #define directive.
Such a macro substitution directive must precede the use of the macro name in the file, whether made
directly in the file, or accessed through a #include directive.
• The downloader automatically recognizes L-variable and F-variable definitions, and uses them for
subsequent compiled code, but does transmit these statements to Turbo PMAC, as it would for M-
variable definition statements.
• The downloader recognizes three styles of comment delimiters. All characters from a semi-colon (;)
or a double-slash (//) to the end of the line are ignored; all characters from a “slash-star” (/*) to a star-
slash (*/) are ignored.
• The downloader will attempt to compile all statements between OPEN PLCC n and CLOSE, except
comments. The CLEAR command is not required after OPEN PLCC n, because the act of
downloading new compiled PLCs automatically erases the existing version. However, there is no
need to remove the CLEAR command for the compiler.
• The downloader automatically erases all of the compiled PLCs in the Turbo PMAC if it encounters
any compiled PLCs in the file(s) to be downloaded. Therefore, it is necessary to compile all of the
PLCC programs together every time. A change to a single PLCC program requires re-compilation of
all of the PLCC programs.
• All other commands are passed unchanged through the compiler to the output file.
The downloader places the compiled PLC code in Turbo PMAC’s active, but volatile SRAM memory.
To retain these programs through a power-cycle or reset, copy them to Turbo PMAC’s non-volatile flash
memory with the SAVE command.
Multi-Line Responses
A command to Turbo PMAC, such as LIST PROG 1 (report contents of motion program 1), that calls
for a multi-line text response, if valid will get multiple text-line responses each terminated by a <CR>,
followed by a single <ACK> character at the end. If it is invalid, Turbo PMAC will respond with a
<BELL> character instead.
Variations
Error Reporting
If Turbo PMAC variable I6 is set to 1 or 3, after Turbo PMAC responds to an invalid command with a
<BELL> character, it will send an error code, such as ERR004, as well to inform the host why the
command was rejected.
Checksums
If Turbo PMAC variable I4 is set to 1 or 3, Turbo PMAC will report the checksums it computes for both
commands from the host and response lines to the host. The checksum byte for the command is returned
immediately after the <ACK> character. The checksum byte for each response line is returned
immediately after the <CR> character that terminates that line. Note that Turbo PMAC does not compare
any checksums for validity; it is up to the host computer to evaluate the validity of checksums for both
commands and responses.
It is possible to evaluate the checksum of a text command sent to Turbo PMAC before that command is
executed. After the characters of the command have been sent, but before the <CR> character that causes
its execution is sent, the host computer can send the <CTRL-N> command. This causes Turbo PMAC to
compute the checksum of the pending command and to return the checksum byte to the host computer. If
the host evaluates the checksum as valid, it can then send the <CR> to cause execution of the command.
If it evaluates the checksum as invalid, it can then send the <CTRL-X> character to clear out the
command, and then re-transmit the command. If I4 is set to 1 or 3, Turbo PMAC will also report the
checksum of the command as part of the acknowledgement.
Checksums are mainly intended for serial communications; they are not supported for dual-ported RAM
communications.
Clearing the Port
Sending the <CTRL-X> character over a port to the Turbo PMAC causes Turbo PMAC to clear out both
the command and response queues for that port. A <CTRL-X> should be sent before a command any
time the communications software is not sure of the state of the port, as when starting the program, after a
communications error, or when sharing the port with another routine that is independently
communicating. If I63 is set to 1, Turbo PMAC will respond with a <CTRL-X> character when it is
finished clearing the ports. The clearing routine should also attempt to read a character from the port
register itself in case one has already been moved there from the response queue.
Unsolicited Messages
It is possible for Turbo PMAC to send text strings to the host computer without the host first sending a
command, using the SENDx or CMDx statements from within a motion or PLC program. (If these
statements are not used, Turbo PMAC will communicate to the host only in response to a host command.)
These unsolicited messages are a powerful feature, but have the potential to confuse communications
routines if not adequately prepared for, because it is possible for this message to come when the host is
expecting the response to a command.
If Turbo PMAC variable I64 is set to 1, any unsolicited message is preceded with a <CTRL-B> character.
This permits the host to distinguish the unsolicited message from a command response and to act
accordingly. If expecting unsolicited messages, it is a good idea not to use <CTRL-X> port clearing,
because that can easily erase an unsolicited message.
i = 0; /* Reset counter */
outportb(combase + 4, 2); /* Set port for input */
while (i++<timeout && (inportb(combase+5)==0); /* Loop until bit true */
if (i < timeout) inchar = inportb(combase); /* Get char. unless timed out */
disable(); /* Disable interrupts */
outportb(combase + 4, 0); /* Set port for output */
enable(); /* Re-enable interrupts */
To be able to read an entire line in a single routine, only turn around the port at the beginning and end of
the line.
ISA/PCI Host Port Communications
Host Port Structure
The host port interface of PMAC, used directly for communications over the ISA and PCI busses,
occupies 11 consecutive addresses of a 16-address region in the I/O space of the host computer (it is not
memory mapped). On the host side, these registers are accessed with byte-write and byte-read
commands, such as outportb, inportb, outp, and inp. On the PMAC side, the PMAC firmware takes care
of the direct access to these registers, in response to commands from the host.
For the ISA bus, the location of the first of these 11 registers in the host computer’s I/O space (the “base
address”) is selected by the settings of jumpers E91-E92, E66-E71 on Turbo PMAC boards and by the
settings of the S1 DIP switches on Turbo PMAC2 boards. Refer to the Talking to Turbo PMAC section
or the individual Hardware Reference manual for actual setting information. The addresses of these
registers range from base address to base address + 10.
For the PCI bus, the location of the base address of these registers is automatically determined by the host
computer’s operating system. Refer to the operating system documentation for instructions as to how to
determine where the operating system located these registers. If using Delta Tau’s PCOMM32PRO
library for Microsoft Windows operating systems, consult the documentation for PCOMM32PRO for
instructions for determining the host-port base address in this environment.
Register Functions
Each of these eleven registers has its own function for host communications, although only a few of them
are used commonly, and some are not used at all. The functions of the registers are:
Base + 0: Interrupt Control Register
Base + 1: Command Vector Register
Base + 2: Interrupt Status Register
Base + 3: Interrupt Vector Register
Base + 4: (Unused)
Base + 5: High-Byte Data Transmit and Receive
Base + 6: Middle-Byte Data Transmit and Receive
Base + 7: Low-Byte Data Transmit and Receive
Base + 8: Interrupt Controller Command Word 0
Base + 9: Interrupt Controller Command Word 1
Base + 10: Interrupt Acknowledge Word
{Base + 2} holds the handshaking status bits; even though this is called the Interrupt Status Register, it
can be used for polled communications with the host: The Write-Ready Bit (bit 1) is true when PMAC is
ready to have the PC write it a character; and the Read-Ready Bit (bit 0) is true when PMAC is ready to
have the PC read a character.
Setting up the Port
No real setup is required for the host port, although it is advisable to write zero values to the high-byte
and middle-byte registers to clear them. The following sample C code segment does this:
outportb (combase + 5, 0); /* Clear high-byte register */
outportb (combase + 6, 0); /* Clear mid-btye register */
It is a good idea in the initial set up to compute a timeout value, related to the host computer’s speed. As
the host polls PMAC to see if it is ready to communicate, a counter increments; if the counter exceeds the
timeout value, the host should give up on this attempt to talk to PMAC. Depending on the circumstances,
it should either just try again later (as when waiting for some asynchronous communications) or assume
there is an error condition.
Sending a Character
To send a character, the host waits for the Write-Ready Bit to go true, and then writes the character to the
output port, as this sample C code segment shows:
i = 0; /* Reset counter */
while (i++<timeout && !(inportb(combase+2) & 2)); /* Loop until bit true */
if (i < timeout) outportb(combase+7, outchar); /* Write character */
Reading a Character
To read a character, the host waits for the Read-Ready Bit to go true, and then reads the character from
the input port, as this sample C code segment shows:
i=0;
while (i++<timeout && !(inportb(combase+2) & 1)); /* Loop until bit true */
if (i < timeout) inchar = inportb(combase+7); /* Read character */
ISA/PCI Interrupts
The ISA-bus and PCI-bus versions of the Turbo PMAC have a built-in programmable interrupt controller
(PIC) that can be used to let Turbo PMAC interrupt the host computer over the bus. Each controller has
its own set of signals that can be used to interrupt the host computer, up to eight of which can be used at
any one time. The detailed description of the signals available for interrupt are shown in the hardware
reference manual for each controller; the signals for presently existing controllers are summarized below.
The Turbo PMAC-PC for the ISA bus uses a commercially available 8259 PIC chip. All other Turbo
PMAC designs integrate PCI logic that is similar, but not identical, to the 8259 into integrated bus logic
ICs. The differences are noted below.
Host Computer Interrupt Lines
ISA Bus
For ISA-bus Turbo PMAC boards, the interrupt line used on the ISA bus is selected by a jumper on the
Turbo PMAC. The following table lists the possibilities for each of these controllers. Only one of these
jumpers for a controller should be on at any given time.
ISA-bus Interrupt IRQ2 IRQ3 IRQ4 IRQ5 IRQ7 IRQ10 IRQ11 IRQ12 IRQ14 IRQ15
Turbo PMAC-PC E86 E81 E82 E83 E84 E80 E79 E78 E77 E76
Turbo PMAC2-PC x x x x x E7 E8 E9 E10 E15
Turbo PMAC2-PC x x x x x E7 E8 E9 x E10
Ultralite
PCI Bus
On the PCI bus, the operating system selects the interrupt line used by the controller automatically on the
power-up/reset of the PC. Consult the operating system documentation for details of how the operating
system determines which interrupt is selected. If using Delta Tau’s PCOMM32PRO library for Microsoft
Windows operating systems, consult the documentation for PCOMM32PRO for instructions for handling
interrupts in this environment.
Interrupt Source Signals
The following table shows which Turbo PMAC signals are available to produce interrupts on various ISA
and PCI Turbo PMAC boards. The signal that goes into line IRn of the PIC is used in bit n of the PIC
registers. Each signal has a brief explanation below.
PIC Input Line IR0 IR1 IR2 IR3 IR4 IR5 IR6 IR7
Turbo PMAC- IPOS BREQ EROR F1ER HREQ EQU1*/ EQU2/ EQU3/
PC, Turbo EQU5/ EQU6/ EQU7/
PMAC-PCI AXEXP1 AXEXP0/ EQU4/
MI1** MI2** EQU8**
Turbo PMAC- IPOS BREQ EROR F1ER HREQ EQU1*/ EQU2/ EQU3/
PCI Lite AXEXP1 AXEXP0/ EQU4**
MI1** MI2**
Turbo PMAC2- IPOS BREQ EROR F1ER HREQ EQU1* EQU5 WDO
PC, Turbo
PMAC2-PCI
Turbo PMAC2- IPOS BREQ EROR F1ER HREQ EQU1* EQU2 WDO
PCI Lite
Turbo PMAC2- IPOS BREQ EROR F1ER HREQ CTRL0* CTRL1 WDO
PC Ultralite,
Turbo PMAC2-
PCI Ultralite
* This signal can be used by the firmware for the DPRAM ASCII communications interrupt.
** One of these is chosen by jumper on the Turbo PMAC board.
IPOS (In-Position): The in-position signal goes true if Turbo PMAC determines that all motors in the
addressed coordinate system are in position. For a motor to be in-position, the following conditions must
be met: the servo loop must be closed, the desired velocity must be zero, and the move timer must be off
(it must be in some kind of indefinite wait, not in a move, dwell, or delay), and the following error
magnitude must be smaller than Ixx28. These conditions must be true for (I7+1) consecutive background
scans.
BREQ (Buffer-Request): The buffer-request signal goes true when an open motion program buffer,
particularly a rotary buffer, is ready to accept another line from the PC. For the fixed motion program
buffers (PROG), the ready state is controlled by I18; for the rotary program buffers (ROT), the ready state
is controlled by I16 and I17. Refer to Rotary Motion Program Buffers in the Writing and Executing
Motion Programs section for more details.
EROR (Fatal Following Error): The fatal following error signal goes true when any axis in the
addressed coordinate system exceeds its fatal following error limit as set by Ixx11.
F1ER (Warning Following Error): The warning following error signal goes true when any axis in the
addressed coordinate system exceeds its warning following error limit as set by Ixx12.
HREQ (Host Request): The host-request signal goes true when the Turbo PMAC is ready to read or
write another character over the ISA or PCI bus. Write to the base address of the Turbo PMAC to select,
whether the host request signal reflects write-ready only, read-ready only, or both. Writing a byte value
of 0 to the Turbo PMAC base address disables generation of the host-request signal; writing a 1 enables
the signal for host read-ready only; writing a 2 enables the signal for host write-ready only; writing a 3
enables the signal for both.
EQUn (Position Compare for Channel n): The EQUn line contains the state of the position-compare
output for Servo Channel n of the Turbo PMAC. This line can be toggled by the automatic action of the
encoder counter’s compare circuitry, or by writing directly to control bits for this circuitry, which permits
the use of this signal as a software-generated interrupt from Turbo PMAC programs.
In a Turbo PMAC, the EQUn line can be used for software-generated interrupts by writing to the EQU
out invert-enable bit for the channel (bit 13 of the channel’s control/status word, suggested M-variable
Mxx13). When the encoder counter and the compare register values do not match, setting this bit to 1
takes this signal high, which can generate an interrupt; setting it to 0 takes the signal low.
In a Turbo PMAC2, this line can be used for software-generated interrupts with the direct-write feature.
This is a two-step process. First, the value to be output is written to the direct-write value bit (bit 12 of
the channel’s control word, suggested M-variable Mxx12). Next, a 1 is written to the direct-write enable
bit (bit 11 of the channel’s control word, suggested M-variable Mxx11).
With the suggested M-variable definitions, the code to trigger a software-generated interrupt using EQU1
is:
M112=1 ; Prepare to set EQU1 high
M111=1 ; Enable writing of M112 value to EQU1 (M111 is self-clearing)
To clear EQU1 in advance of the next interrupt, the code is:
M112=0 ; Prepare to set EQU1 low
M111=1 ; Enable writing of M112 value to EQU1 (M111 is self-clearing)
If I56 and I58 are both set to 1 to enable DPRAM ASCII communications with interrupts, a (non-
Ultralite) Turbo PMAC will generate an interrupt on the EQU1 line each time it has loaded a response
line into the DPRAM ASCII response buffer. With this function active, no other use of the EQU1 line
should be made.
AXEXPn (Axis Expansion EQU Line): The AXEXP0 and AXEXP1 lines on a Turbo PMAC-PC board
are inputs that can be used to bring in selected EQUn lines for interrupt purposes from an Acc-24P Axis
Expansion board. Which EQU line is used from the Acc-24P board is determined by jumpers on the Acc-
24P board. The AXEXPn TTL-level lines can also be driven by other external signals.
MIn (Machine Input n): The MI1 and MI2 lines are general-purpose 5V-24V inputs on Turbo PMAC
controllers. With the appropriate jumpers selected, they can be used to interrupt the host computer.
CTRLn (Control Output n): The CTRL0 and CTRL1 signals are generally unused lines on Turbo
PMAC2 controllers. On Turbo PMAC2 Ultralite controllers, they can be used for software-generated
interrupts. They can be made outputs by setting bits 8 and 9, respectively, of X:$078403 to 1; then their
sense can be changed by writing to the inversion-control bits for these lines at bits 8 and 9 of X:$078407,
respectively.
If I56 and I58 both are set to 1 to enable DPRAM ASCII communications with interrupts, a Turbo
PMAC2 Ultralite will generate an interrupt on the CTRL0 line each time it has loaded a response line into
the DPRAM ASCII response buffer.
WDO (Watchdog Output): The watchdog signal goes true when the Turbo PMAC watchdog timer trips
and shuts down the card.
Integrated Interrupt Controller
The interrupt controller function on all Turbo PMAC2 boards and all PCI-bus Turbo PMAC boards (1
and 2) is integrated into the bus interface logic. It is modeled after the 8259, but is more simplified and
straightforward.
We will keep the same base address of Turbo PMAC from our previous example. The following tables
show the contents of the mailbox registers as we do this:
Address $7FA001 $7FA003 $7FA005 $7FA007 $7FA009 $7FA00B
Mailbox # 0 1 2 3 4 5
Character --- 1
We first write an ASCII 1 to location $7FA005, then a J to $7FA007, then a + to $7FA009, then a
carriage return (ASCII code 13) to $7FA010, and finally a # to $7FA001.
Example:
The above example works just fine for a command line of 15 characters or less (including the <CR>
added to terminate the line), but what if the command line contains more than 15 characters? Remember
there are only 15 mailbox registers that can be written to (do not forget that mailbox #1 cannot be used
when sending data to Turbo PMAC.).
Send the first 15 characters (do not send a <CR> yet!), followed by the remaining characters in succession
until all characters have been written. And after the last character, send the <CR>, which tells Turbo
PMAC to act upon the command. If downloading a motion program and one of the statements in the
program happens to be the following line:
IF(P1=1)DISPLAY"DELTA TAU"<CR>
There are 27 characters here to send, and thus 27 VME write commands must be performed. The
following tables again show the contents of the mailbox registers. After writing the first group of 14
characters (the characters F through Y in the above command line), the mailbox registers look something
like this:
Address $7FA001 $7FA003 $7FA005 ... $7FA01D $7FA01F
Mailbox # 0 1 2 ... 14 15
Character --- F . A Y
At this point, Turbo PMAC has taken these characters into its command queue, but has not done anything
with them yet since no <CR> has been encountered yet. It asserts the selected interrupt level (default is 2)
and provides the command a receipt interrupt vector (default is $A0), which must be acknowledged. Now
send the next 11 characters (D through " followed by a<CR>):
Address $7FA001 $7FA003 $7FA005 ... $7FA017 $7FA019
Mailbox # 0 1 2 ... 11 12
Character --- D . " <CR>
Finally, send the first character of this second (and last) group of characters, which is a ":
Address $7FA001 $7FA003 $7FA005 ... $7FA017 $7FA019
Mailbox # 0 1 2 ... 11 12
Character " --- D . " <CR>
Turbo PMAC again asserts interrupt level 2 and provides the command receipt interrupt vector. Since a
<CR> has been included, Turbo PMAC knows that the command line has finished. Turbo PMAC now
inserts this line into the program buffer that was previously opened (remember, in this example we were
downloading a motion program to Turbo PMAC).
Reading Data from Turbo PMAC-VME through the Mailbox Registers
Now that data has been sent to Turbo PMAC-VME using the mailbox registers, determine how to read
data from Turbo PMAC. Reading data will involve using the interrupts and interrupt vectors generated
by Turbo PMAC-VME over the VME bus. In the following examples, Turbo PMAC’s base address is at
$7FA000 and the I-variable I3 is set to 2 (the best setting of I3 for writing host communications routines).
The key to reading data from Turbo PMAC through the mailbox registers is that writing to mailbox
register #1 permits PMAC to place its data in the mailbox registers when it has something to say. This
can be done ahead of time, effectively pre-enabling Turbo PMAC’s response. This is the strategy we use
in all of the following examples.
If not pre-enabling, write to mailbox register #1 only when expecting an immediate response, which is
usually after acknowledging the $A0 interrupt (see examples). If this is not done, Turbo PMAC will not
interrupt with the $A1 vector. (The only real advantage in not pre-enabling is that the middle of a long
Turbo PMAC response can be broken to issue a command.) Note that if using the pre-enable strategy,
pre-enable once after power-up or reset. Refer to the flowchart below after reading the following
examples.
Example
This command line has just been sent to Turbo PMAC: #1J+<CR>. This command line is not a request
for any data, so Turbo PMAC will not respond with any data except an acknowledge <ACK>, signifying
an acknowledgment of receipt of a valid command line (if an invalid command was sent, a <BELL>
character would be sent instead of <ACK>). In this case, Turbo PMAC will generate an interrupt, sending
with it an interrupt vector $A0 (as we defined in I96). After seeing this interrupt and accompanying
interrupt vector, you (the VME master or host computer) must properly service or acknowledge this
interrupt so that Turbo PMAC will withdraw its interrupt assertion. (Generally, when you service any
VME interrupt, the interrupt vector will be available.)
Turbo PMAC will then interrupt again, this time with interrupt vector $A1 (the value of I96 plus 1),
signifying there is new data in the mailbox registers to be read. Now, read mailbox register #0 (at
$7FA001) to pick up the <ACK> character put there by Turbo PMAC, but this is necessary only to verify
that the command line just sent was received as a valid command by Turbo PMAC. Finally, write $00
into mailbox register #1 (location $7FA003), allowing Turbo PMAC to write new data into the mailbox
registers if necessary (also read the next example to better understand this). The next example shows how
to read data written in the mailbox registers by Turbo PMAC.
Example
Let us now assume the following command has been sent to ask for the position of motor 1: #1P<CR>.
Turbo PMAC, of course, will respond with data containing position information of motor 1. Let’s say
that motor 1 is currently at position 19.2. We now wish to read the mailbox registers to obtain this
information Turbo PMAC has waiting for us. The first thing we do is send the command line and service
the interrupt Turbo PMAC generates (using an interrupt vector of $A0) as an acknowledgment.
After Turbo PMAC has processed the command and put data into the mailbox registers, Turbo PMAC
interrupts us a second time with an interrupt vector $A1. Remember, we get this second interrupt because
PMAC has just now placed data in the mailbox registers, now ready to be read. We service this second
interrupt and note that the accompanying interrupt vector is $A1, telling us to read the data in the mailbox
registers.
Actually, these registers may be read in any order, but it is best to read these characters beginning with
the first mailbox register until we either:
1. Encounter a <CR> (signifying the end of that line) or
2. Encounter a <ACK> (valid command line received) or
3. Encounter a <BELL> (invalid command line received) or
4. Have read all 16 mailbox registers (from $7FA001 to $7FA01F).
These mailbox registers mya be read as many times as desired because Turbo PMAC will not write new
data into the mailbox registers (if Turbo PMAC has more data to send) until a value of $00 is written into
mailbox #1 (in this case, at $7FA003).
In this example, Turbo PMAC will have six characters waiting to be read: 19.2<CR><ACK>. (We are
assuming I-variable I3 is set to 2.) The data will be in the registers as follows:
Address $7FA001 $7FA003 $7FA005 $7FA007 $7FA009
Mailbox # 0 1 2 3 4
Character 1 9 . 2 <CR>
We start reading the characters at $7FA001, mailbox register 0. We see the <CR> in mailbox register 4,
so we stop reading, and write a $00 into mailbox register 1 to tell Turbo PMAC it is OK to send more.
Since Turbo PMAC still must send the final <ACK> it interrupts us again, and we find in the mail box
registers:
Address $7FA001 $7FA003 $7FA005 $7FA007 $7FA009
Mailbox # 0 1 2 3 4
Character <ACK> 9 . 2 <CR>
Now we start and stop at mailbox register 0, because it contains an <ACK>. Now, read in these characters
beginning with mailbox register #0 at $7FA001. Recall that we said never write into mailbox register #1
when sending data to Turbo PMAC-VME. This is because Turbo PMAC will be allowed to write new
data into the mailbox registers as soon as we write to mailbox #1. (Incidentally, it actually does not
matter what value we write into mailbox register #1, it’s the fact that we write to this register that counts.
However, it is recommended to write a value of $00 into mailbox register #1 for reasons given later.)
After writing a $00 into mailbox register #1, we may or may not get interrupted again by PMAC,
depending whether or not Turbo PMAC still has more data for us to read.
Example
Let us again assume that the following command has been sent to ask for the contents of memory locations
X:$1000 through X:$1002: RHX$1000,3<CR>. Let’s say that these three locations contain the values
$123456, $789012, and $345678. We again wish to go and read the mailbox registers, so we send the above
command line and service the interrupt PMAC generates (using an interrupt vector of $A0).
After Turbo PMAC has processed the command and put data into the mailbox registers, Turbo PMAC
interrupts us a second time with an interrupt vector $A1.
Remember, we get this second interrupt because Turbo PMAC has just now placed data in the mailbox
registers, which is now ready to be read. We service this second interrupt and note that the accompanying
interrupt vector is $A1, telling us to read the data in the mailbox registers. In this example, Turbo PMAC
will have 22 characters to be read: 123456 789012 345678<CR><ACK>, with the first 16 of them
in the mailbox registers. (We are assuming I-variable I3 is set to 2 again.) The data will be in the
registers as follows:
Address $7FA001 $7FA003 $7FA005 ... $7FA01D $7FA01F
Mailbox # 0 1 2 ... 14 15
Character 1 2 3 . 3 4
We read in the mailbox registers, beginning with the first one until we encounter a <CR>, <ACK>,
<BELL>, or have read all 16 registers. In this case, the first 16 characters PMAC has for us does not
contain a <CR>, <ACK>, or <BELL>. Therefore we read in all 16 mailbox registers to obtain the first 16
characters of Turbo PMAC’s response, and then write $00 to mailbox register #1 (in this case, at
$7FA003) to allow Turbo PMAC to put the next chunk of data in the mailbox registers. Turbo PMAC
interrupts us again with vector $A1, and the remainder of the characters in the mailbox registers are:
Address $7FA001 ... $7FA009 $7FA00B ... $7FA01D $7FA01F
Mailbox # 0 ... 4 5 ... 14 15
Character 5 . <CR> 2 . 3 4
Now we read again the mailbox registers, looking for <CR>, <ACK>, or <BELL>. The fifth character we
read in mailbox #4 ($7FA009) happens to contain a <CR>, so we stop reading and write $00 into mailbox
register #1. Because Turbo PMAC still has to send the final <ACK> character, it interrupts us again with
vector $A1 and we see in the mailbox registers:
Address $7FA001 ... $7FA009 $7FA00B ... $7FA01D $7FA01F
Mailbox # 0 ... 4 5 ... 14 15
Character <ACK> . <CR> 2 . 3 4
Now we stop at the first character, <ACK>, which serves as the end-of-transmission character, and we
again write $00 into mailbox register 1. Since Turbo PMAC does not having any more data to be read for
now, we will not get another interrupt (until we send another command or one of our executing PLC or
motion programs puts out data via the CMD or SEND command).
The diagram on the following page summarizes the communications process over the VME bus using the
mailbox registers.
Power up or
reset PMAC
Send NO
a line to
PMAC?
Has an NO
YES interrupt
ocurred?
Send command line to PMAC
(up to 16 characters)
YES
NO
I93 is an 8-bit value that specifies ISA bus address bits A23 – A16 for the DPRAM. Usually, it is
specified as a 2-digit hexadecimal value, and these two digits are the same as the first two digits of the
six-digit ISA hexadecimal address, $0D in the default case.
I94 is an 8-bit value that controls the addressing of the DPRAM over the ISA bus. If only a 16k x 8 block
is reserved for DPRAM, it also specifies ISA bus address bits A15 – A14. I94 usually is specified as a 2-
digit hexadecimal number.
If a 16k x 8 block of memory on the ISA bus is to be used for DPRAM, the first digit should be set to
equal the third digit of the six-digit base address. It can take a value of $0, $4, $8, or $C. For the default
base address of $0D4000, it should be set to 4. If a 64k x 8 block of memory is to be used, the first digit
should be set to 0.
The second digit represents the addressing mode. It should be set to 5 to use a 16k x 8 address space on
the ISA bus. It should be set to 4 to use a 64k x 8 address space.
For example, to use a 16k x 8 block of memory from $0EC000 to $0EFFFF on the ISA bus, I93 should be
set to $0E, and I94 should be set to $C5. To use a 64k x 8 block of memory from $0C0000 to $0CFFFF
on the ISA bus, I93 should be set to $0C, and I94 should be set to $04.
To implement these settings and to hold them for future use, these I-variable values must be stored to
non-volatile flash memory with the SAVE command, and the card must be reset ($$$ command).
Resetting the card copies the saved values of I93 and I94 back into the I-variable registers in RAM, and
then into the active control registers at X:$070009 and X:$07000A, respectively.
If a 16k x 8 block of memory has been used for the larger (32k x 16) DPRAM, the PC can view only one-
quarter of the DPRAM at a time. Following the instructions given above, this will be the first quarter
(lowest addresses on the PMAC side). To get at other parts of the DPRAM, a “bank select” process must
be used.
I94 can control the bank select with bits 1 and 3, but it is used only at power-on/reset, so it is not
appropriate for dynamic bank selection. Therefore, it is better to use the active control register at
X:$07000A directly. With the suggested M-variable definition of M94->X:$07000A,0,7, and I94 set as
suggested above to select Bank 0 at power-on/reset, the following equations can be used to select each of
the 4 banks (the vertical bar ‘|’ is the logical bit-by-bit OR operator):
M94=I94 | $00 ; Bank 0 (PMAC addresses $060000 - $060FFF)
M94=I94 | $02 ; Bank 1 (PMAC addresses $061000 - $061FFF)
M94=I94 | $08 ; Bank 2 (PMAC addresses $062000 - $062FFF)
M94=I94 | $0A ; Bank 3 (PMAC addresses $063000 - $063FFF)
I94 controls the VME address bus bits A15 – A08 for the mailbox registers. If bits A23 – A16 are the
same for both the mailbox registers and the DPRAM, it is essential that I94 be set up so that there is no
conflict between the 512 addresses required for the mailbox registers and the 16k registers required for
the DPRAM.
I95 controls which interrupt line is used when PMAC interrupts the host computer over the bus. Values
of $01 to $07 select IRQ1 to IRQ7, respectively. Turbo PMAC will use this interrupt line during
DPRAM ASCII communications if I56 is set to 1 and I58 is set to 1.
I96 controls the interrupt vectors that are provided when Turbo PMAC interrupts the host computer. If
the interrupt is asserted because PMAC has placed an ASCII response line in the DPRAM, the interrupt
vector provided is equal to (I96 + 1).
I97 controls the VME address bus bits A23 – A20 for the DPRAM. It is usually specified as a 2-digit
hexadecimal value. The first digit should always be set to 0. The second digit should be set to be equal to
the 1st of 6 hex digits of the address if 24-bit addressing is used, or to the 3rd of 8 hex digits of the address
if 32-bit addressing is used. For example, if the base address is $700000 in 24-bit addressing, I97 should
be set to $07. If the base address is $18C40000 in 32-bit addressing, I97 should be set to $0C.
I98 controls whether the DPRAM is enabled. It should be set to $E0 to enable DPRAM access.
I99 controls the VME bus address width. It should be set to $90 for 24-bit addressing with DPRAM, or
to $80 for 32-bit addressing with DPRAM.
To implement these settings and to hold them for future use, these I-variable values must be stored to
non-volatile flash memory with the SAVE command, and the card must be reset ($$$ command).
Resetting the card copies the saved values of I90 – I99 back into the I-variable registers in RAM, and then
into the active control registers at X:$070006 – X:$07000F.
One further step must be taken after every power-on/reset to select the VME address lines A19 – A14 for
the DPRAM. These address lines are selected using a dynamic page-select technique, which must be
used even if there is only a single “page” of DPRAM. One page consists of a 16k x 8 bank of memory
addresses – for the small (8k x 16) DPRAM, this page selects the entire DPRAM. For the large (32k x
16) DPRAM (when available), this page selects one-quarter of the DPRAM.
These address lines are selected by writing a byte over the VME bus to (the mailbox base address +
$121). The mailbox base address is defined by the settings of I92, I93, and I94 at the last power-on/reset.
If the mailbox base address is at the default value of $7FA000, this byte must be written to VME bus
address $7FA121.
Bits 0 to 5 of this byte must contain the values of A14 to A19, respectively, of the page of the DPRAM.
One way to calculate this value is to take the 2nd and 3rd hex digits of the DPRAM page base address in
24-bit addressing, or the 4th and 5th hex digits in 32-bit addressing, and divide this value by 4 (shift right
two bits). For example, if the base address is $780000 in 24-bit addressing, this byte should be set to $20
($80/4 = $20). If the base address is $18C40000 in 32-bit addressing, this byte should be set to $10.
Note:
It is common that this byte value will be $00, and some Turbo PMAC-VME
boards will power up with this byte already set at $00. However, this may not be
true on some boards, so the user should not count on this default setting. For
robust operation, this byte must be written after every power-on/reset.
PCI Bus
When using DPRAM communications over the PCI bus, the computer’s operating system automatically
establishes the base address of the DPRAM IC on the bus. Consult the documentation for the operating
system to understand how to find and use the base address established by the operating system.
USB/Ethernet
When USB or Ethernet communications is used with DPRAM, the host computer does not actually have
direct access to the DPRAM IC on the Turbo-PMAC end of the wire link. However, the USB and
Ethernet implementations support the creation of a virtual shared memory interface so higher level
routines can work as if there were direct access.
Mapping of Memory Addresses
The mapping of memory addresses between the host computer on one side, and Turbo PMAC on the
other side, is quite simple. Using this memory is a matter of matching the addresses on both sides. To
Turbo PMAC, the DPRAM appears as extra memory in the fixed address range $060000 to $060FFF
($063FFF for the large DPRAM). Since Turbo PMAC has two (X and Y) registers per numerical
address, the small DPRAM appears to the Turbo PMAC as a 4k x 32 block of memory; the large DPRAM
appears as a 16k x 32 block of memory. When the PMAC hexadecimal addresses of the DPRAM are
specified, the assembly-language convention of a ‘$’ prefix is used to denote the use of hex numbers.
Probably the host computer will use byte addressing. Therefore, the small DPRAM appears to the host
computer as a 16k x 8 block of memory. The large DPRAM appears as a 64k x 8 block of memory.
Since the address range of the DPRAM in the host computer will vary from application to application, we
can talk only of offsets from the base address when referring to individual registers. When the host
hexadecimal address offsets of the DPRAM are specified, the C-language convention of a ‘0x’ prefix is
used to denote the use of hex numbers.
Because the Turbo PMAC uses 32-bit addressing, and the host computer uses 8-bit addressing, the host
uses 4 numerical addresses for each 1 numerical address in PMAC. The following table shows how this
address incrementing works for key addresses in the DPRAM.
Turbo PMAC Host Address Example Host
Address Offset Address
Y:$060000 0x0000 0x0D0000
X:$060000 0x0002 0x0D0002
Y:$060001 0x0004 0x0D0004
X:$060001 0x0006 0x0D0006
… … …
Y:$060450 0x1140 0xD1140
… … …
Y:$060FFF 0x3FFC 0xD3FFC
X:$060FFF 0x3FFE 0xD3FFE
… … …
Y:$063FFF 0xFFFC 0xDFFFC
X:$063FFF 0xFFFE 0xDFFFE
The following two equations can be helpful for calculating matching DPRAM addresses:
PMAC_address = $060000 + 0.25*(Host_address – Host_base_address)
Host_address = Host_base_address + 4*(PMAC_address - $060000) + Offset
where:
Offset = 0 for accessing Y memory, or for X and Y together as 32 bits
Offset = 2 for accessing X memory alone
DPRAM
0 Byte 0
BYTE 1 Byte 1
NO. 2 S Byte 2
(RELATIVE) S S S S S S S S S = Sign bit
3
(SIGN EXTENSION)
48 BITS BIT # 23 16 15 8 7 0
PMAC Y: WORD S1 Byte 2 Byte 1 Byte 0
PMAC X: WORD S2 Byte 5 Byte 4 Byte 3
0 Byte 0
1 Byte 1
DPRAM 2 S1 Byte 2
BYTE 3 S1 S1 S 1 S1 S1 S 1 S1 S1
NO. 4(SIGN EXTENSION) Byte 3
(RELATIVE)
5 Byte 4
6 S2 Byte 5
S1 = First word sign bit
7 S2 S2 S2 S2S2 S2 S2 S2 S2 = Second word sign bit
(SIGN EXTENSION)
= Exponent for floating point
Addresses of Data: For details as to the exact registers used for each of these values for each motor,
consult the Turbo PMAC Memory Map in the Software Reference Manual.
Foreground Handshaking: If foreground transfer is used (I48 = 1), Turbo PMAC will set Bit 15 of
0x006E (X:$06001B) to 0 while it is copying motor data into the DPRAM, and it will set this bit to 1 as
soon as it is finished. The host computer should not try to read the data if this bit is 0. If I47 is set to 0
for on request transfers, the host computer should set this bit to 0 after reading the data to indicate to
Turbo PMAC that it is time to provide the next set of data.
If foreground transfer is used, Turbo PMAC also copies the 24-bit servo-cycle counter value into 0x006C
(Y:$06001B) and Bits 0 – 7 of 0x006E (X:$06001B) to “time-stamp” the data.
The host computer can set Bit 15 of 0x006A (X:$06001A) to 1 while it is reading the data. If Turbo
PMAC sees that this bit is 1 when it is ready to transfer more data into the DPRAM, it will skip this cycle.
The host must be sure to set this bit to 0 when it is done reading, to permit Turbo PMAC to transfer new
data.
Background Handshaking: If background transfer of motor data is used (I57 = 1 and I49 = 1), the
handshaking is the same as for the background coordinate system and global data buffers. Turbo PMAC
will set Bit 15 of 0x067A (X:$06019E) to 0 while it is copying coordinate-system and global data into the
DPRAM, and it will set this bit to 1 as soon as it is finished. The host computer should not try to read the
data if this bit is 0. If I50 is set to 0 for “on request” transfers, the host computer should set this bit to 0
after reading the data to indicate to Turbo PMAC that it is time to provide the next set of data.
If background transfer is used, Turbo PMAC also copies the 24-bit servo-cycle counter value into 0x0678
(Y:$06019E) and Bits 0 – 7 of 0x067A (X:$06019E) to time-stamp the data.
The host computer can set Bit 15 of 0x0676 (X:$06019D) to 1 while it is reading the data. If Turbo PMAC
sees that this bit is 1 when it is ready to transfer more data into the DPRAM, it will skip this cycle. The host
must be sure to set this bit to 0 when it is done reading, to permit Turbo PMAC to transfer new data.
DPRAM Background Data Reporting Buffer
Turbo PMAC can provide key global and coordinate-system data as a background function to the
DPRAM, where it can be accessed easily and quickly by the host computer. If this function is enabled,
Turbo PMAC will copy key global and coordinate-system registers into fixed registers in the DPRAM.
Enabling Copying: Setting I49 to 1 enables this copying of global and coordinate-system data into
DPRAM as a background function. I50 sets the update period. If I50 is greater than 0, each background
cycle, Turbo PMAC will check to see if more than I50 servo cycles have elapsed since it last copied this
data into DPRAM. If so, it will copy the present data. With I50 at 0, Turbo PMAC will check every
background cycle to see if the host computer has taken the previous data. If so, it will copy the present
data, for an “on request” transfer.
Coordinate System Specification: Bits 0 – 4 of 0x0676 (Y:$06019D) specify the number of highest-
numbered coordinate system in the Turbo PMAC whose data will be copied into DPRAM. The data for
C.S. 1 through this coordinate system will be copied each time. If this value is set to 0, the transfer of
coordinate-system data will be stopped.
Data Copied: For each coordinate system whose copying is enabled, the following data will be transferred:
• C.S. feedrate / move time
• C.S. time-base value (feedrate override)
• C.S. override source address
• C.S. status words
• C.S. axis target positions (ABCUVWXYZ)
• C.S. program status
• C.S. program lines remaining in rotary buffer
If Bit 15 is 0, there is no error, and there is a response string. Bits 8 and 9 tell what caused the
response. If they form a value of 0, a command from the host computer caused the response. If they
form a value of 1, an internal CMDR statement caused the response. If they form a value of 2, an
internal SENDR statement caused the response. Note the value in Bits 0 – 7. These will determine
whether this is the last line in the response or not (see Step 5, below).
3. Read the response string starting at 0x0F44 (Y:$0603D1). Two 8-bit characters are packed into each
16-bit word; the first character is placed into the low byte. Subsequent characters are placed into
consecutive higher addresses, two per 16-bit word. (In byte addressing, each character is read from
an address one higher than the preceding character.) Up to 255 characters can be sent in a single
response line. The string is terminated with the NULL character (byte value 0), convenient for C-style
string handling. For Pascal-style string handling, the register at 0x0F42 (X:$0603D0) contains the
number of characters in the string (plus one).
4. Clear the Host-Input Control Word at 0x0F40 (Y:$063D0) to 0. Turbo PMAC will not send another
response line until it sees this register set to 0.
5. If Bits 0 – 7 of the Host-Input Control Word had contained the value $0D (13 decimal, “CR”), this
was not the last line in the response, and steps 1 – 4 should be repeated. If they had contained the
value $06 (6 decimal, “ACK”), this was the last line in the response.
Note that the communications routines of the PCOMM32 library do all of these actions automatically. If
writing a custom low-level communications routine, this operation is fundamentally a string copy operation.
DPRAM Communications Interrupts
If I56 is set to 1, Turbo PMAC will interrupt the host computer whenever it has a response line ready for
the host to read. This interrupt has the potential to make the host communications more efficient, because
the computer does not need to poll the DPRAM to see when a response is ready.
VME Interrupt: On any of the VME-bus Turbo PMACs, this interrupt will appear on the VME-bus
interrupt line specified by I95. It will have an interrupt vector equal to (I96 + 1).
ISA Interrupt: On the ISA-bus Turbo PMACs, this interrupt will appear on the ISA-bus interrupt line
(IRQn) selected by an E-point jumper on the board. The interrupt controller IC on the board can pass
interrupts from eight different sources (IR0 – IR7) through this interrupt line.
On a Turbo PMAC-PC, source IR7 is used to generate the interrupt. Jumper E85 must be ON, and
jumpers E82 – E84 must be OFF for this feature to work. This brings the EQU4 line (position compare
for encoder 4) into the interrupt controller – the position-compare function for this encoder may not be
used for other purposes in this case.
On a Turbo PMAC2-PC, source IR5 is used to generate the interrupt from the EQU1 line (position
compare for Encoder 1). The position-compare function for this encoder may not be used for other
purposes in this case.
On a Turbo PMAC2-PC Ultralite, source IR5 is used to generate the interrupt from the CTRL0 line of the
DSPGATE2 IC, which does not have other functions.
Turbo PMAC will continue to assert this interrupt source until the host has cleared the Host-Interrupt
Control Word. Because of this, the host may see the source still active when it gets an interrupt from
another source.
DPRAM Background Variable Read Buffer
The Background Variable Data Read Buffer permits you to have up to 128 user-specified Turbo PMAC
registers copied into DPRAM during the background cycle. This function is controlled by I55. The
buffer has two modes of operation, single-user and multi-user. The default mode is single-user. It is
active when bit 8 of the control word 0x1044 (Y:$060411) is set to zero. Multi-user mode is active when
bit 8 of the control word is set to one.
General Description: The buffer has three parts. The first part is the header: 4 16-bit words (8 host
addresses) containing handshake information and defining the location and size of the rest of the table.
This is at a fixed location in DPRAM (see table below).
The second part contains the address specifications of the Turbo PMAC registers to be copied into
DPRAM. It occupies two 16-bit words (four host addresses) for each Turbo PMAC location to be copied,
starting at the location specified in the header.
The third part, starting immediately after the end of the second part, contains the copied information from
the Turbo PMAC registers. It contains 2 16-bit words (four host addresses) for each short (X or Y) Turbo
PMAC location copied, and four 16-bit words (eight host addresses) for each long Turbo PMAC location
copied. The data format is the same as for data gathering to dual-ported RAM.
Register Map
Background Variable Read Buffer Part 1
Definition and Basic Handshaking
Address Description
0x1044 PMAC to Host (Bit 0 = 1 for single user mode) Data Ready. PMAC
(Y:$060411) done updating buffer - Host must clear for more data.
0x1046 Servo Timer (Updated at Data Ready Time)
(X:$060411)
0x1048 Size of Data Buffer (measured in long integers of 32 bits each)
(Y:$060412)
0x104A Starting Turbo PMAC Offset of Data Buffer from beginning of
(X:$060412) variable-buffer space $060450 (e.g.. $0100 for starting PMAC
address $060550 – host address offset 0x1540)
When the host wants to read a register, it should check to see that Bit 15 of the data type specifier (the
Data Ready bit) has been set. If it has, the host can begin reading and processing the data from that
register. When it is done, it should clear the Data Ready bit to let Turbo PMAC know that it can update
that register the next cycle.
Data Format: Each 24-bit (X or Y) register is sign-extended to 32 bits. For a 48-bit (Long) register, each
24-bit half is sign-extended to 32 bits, for a total of 64 bits in the DPRAM. This data starts immediately
after the last address specification register.
Disabling: To disable this function, you can set the size register 0x1048 (Y:$060412) to 0, or simply
leave the individual Data Ready bit(s) set.
DPRAM Background Variable Data Write Buffer
The Background Variable Data Write Buffer is essentially the opposite of the Background Variable Data
Read Buffer described above. It lets you write to up to 32 user-specified registers or particular bits in
registers to Turbo PMAC without using a communications port (PCbus, serial, or DPRAM ASCII I/O).
This lets you set any Turbo PMAC variable without using an ASCII command such as M1=1 and without
worrying about an open Rotary Buffer. This function is controlled by I55.
General Description: The buffer has two parts. The first part is the header: 2 16-bit words (4 host
addresses) containing handshake information and defining the location and size of the rest of the table.
This is at a fixed location in DPRAM (Turbo PMAC address $060413 as shown in the table below).
The second part contains the address specifications of the Turbo PMAC registers to be copied into Turbo
PMAC. It occupies 6 x 16-bit words (12 host addresses) for each Turbo PMAC location to be written to,
starting at the location specified in the header.
Registers:
Background Variable Data Write Buffer Part 1
Definition and Basic Handshaking
Address Description
0x104C HOST to PMAC Data Transferred. PMAC is updated when cleared.
(Y:$060413) Host must set for another update.
0x07E8 Starting Turbo PMAC Offset of Data Buffer from beginning of
(X:$060413) variable-buffer space $060450 (e.g.. $0100 for starting PMAC
address $060550 – host address offset 0x1540)
Background Variable Write Buffer Part 2
Format for each Data Structure (6x16-bit)
Address X-Register Contents Y-Register Contents
Bits 11 – 15: Offset (= 0 – 23) – Starting bit
number of target register into which value will be
written
Bits 6 – 10: Width (= 0, 1, 4, 8, 12, 16, or 20 – 0
represent 24 bits) – number of bits of target
n register into which value will be written Bits 0 – 15 of target register
Bits 3 – 5: Type of target register address
=0: Y-register
= 1: Long (X/Y-register)
= 2: X-register
Bits 0 – 2: Upper 3 bits (bits 16 – 18) of target
register address
n+1 Upper 16 bits of data word 1 Lower 16 bits of data word 1
n+2 Upper 16 bits of data word 2 (only used for writing Lower 16 bits of data word 2
into long register) (only used for writing into long
register)
The binary rotary program transfer buffers in DPRAM are simply pass-through buffers to the internal
rotary program buffers. When Turbo PMAC receives a binary-format motion program command in the
DPRAM buffer from the host computer, it copies this data into the rotary buffer in internal memory. The
end result is the same as if an ASCII program command had been sent to Turbo PMAC through any of
the ports, but the transmission is quicker for several reasons:
1. There is no handshaking of individual characters.
2. There is no parsing of an ASCII command into internal binary storage format.
3. Multiple command lines can be processed in a single communications cycle.
If I45 is set to the default value of 0, Turbo PMAC checks the binary rotary buffers in DPRAM every
background cycle, transferring any new contents to the internal rotary program buffers. If I45 is set to 1,
it checks the binary buffers as a higher-priority foreground task, every real-time interrupt.
Routines in Delta Tau’s PCOMM32 communications library provide automatic support for the binary
rotary-program transfer buffer.
General Description: Each coordinate system’s binary rotary transfer buffer has two parts. The first part
is the header, at a fixed address in DPRAM. The header for each binary rotary transfer buffer occupies
six 16-bit words, and contains the key information on the size and status of the second part of the buffer.
The second part of the buffer is at a location in DPRAM specified by the user in the header. It contains
the actual binary-format motion-program commands. The size of this part is also specified by the user in
the header.
Registers: The following table shows the structure of the header. The addresses given are for the first
coordinate system. Headers for the other coordinate systems follow immediately after. Those addresses
can be found in the memory map in the Software Reference Manual.
Binary Rotary Transfer Buffer Control
Address for first Description
C.S. Rotary
Buffer
0x1050 PMAC to HOST Binary Rotary Buffer Status Word
(Y:$60414)
Bit 15 = 1:Error (Stops processing commands)
Bit 14 = 1 :Internal Rotary buffer full (Busy flag) PMAC Index stops updating.
Bits 7-0 = Code Error
------ ------------------------------------
1 Internal Rotary Buffer size = 0
or DPRAM Rotary Buffer Size = 0
These flags are set and reset by the PMAC. The Busy flag is
Set when the PMAC internal rotary buffer is full.
This however does not mean the DPRAM Binary
Rotary buffer is full. The Busy flag is
Reset when the PMAC internal rotary buffer is
Not full or the DPR binary rotary buffer is empty.
0x1052 Coordinate System Number and Enable Control
(X:$60414) Bits 0 – 4 represent C.S. #; buffer enabled if 0 < C.S.# < 17
0x1054 Host Binary Rotary Buffer Index – PMAC address offset from start address of
(Y:$60415) buffer as set in 0x105A
0x1056 PMAC Binary Rotary Buffer Index – PMAC address offset from start address
(X:$60415) of buffer as set in 0x105A
0x1058 Size of Binary Rotary Buffer – in PMAC addresses (= host computer addresses
(Y:$60416) / 4)
0x105A Starting Binary Rotary Buffer PMAC Address Offset – from start of DPRAM
(X:$60416) variable buffer space ($060450)
Using the Buffer: First, Turbo PMAC’s internal binary rotary program buffer must be established with
the &n DEFINE ROT command.
Next, the header information for the DPRAM transfer buffer must be set up. The starting address and size
of the transfer buffer must be declared. The buffer should not overlap any other use of DPRAM. The
size parameter must be an even number, with an absolute minimum of six PMAC addresses. The size
should be declared large enough to not limit throughput. Each basic PMAC command component (e.g.
X10) occupies two PMAC addresses in the transfer buffer. The transfer occurs each background cycle,
typically a few milliseconds.
Both indices should be set to zero to indicate that both sides are pointing to the start of the buffer. Next,
the &n OPEN BIN ROT command should be given, so that Turbo PMAC checks for new data in the
transfer buffer.
Now, binary format commands can be loaded into the transfer buffer, and the host index updated. As
Turbo PMAC reads the commands from the buffer, it updates the PMAC index.
Binary Command Structure: Typically, PCOMM32 routines generate the binary command format
automatically. Contact the factory if you require knowledge of this format.
DPRAM Data Gathering Buffer
Turbo PMAC’s data gathering function can create a rotary buffer in DPRAM, so that the host computer
can pick up the data as it is being gathered. This way, the size of the data gathering buffer is not limited
by Turbo PMAC’s own memory capacity. The data gathering buffer in DPRAM is selected if I5000 is set
to 2 or 3; if I5000 is set to 3, it is used in a rotary fashion, which is typically how the buffer is used.
The DPRAM data gathering buffer always starts at address 0x1140 (Y:$060450). Its size is determined
by the DEFINE GATHER {size} command, where {size} sets the number of PMAC addresses
from the start. This size value is stored at 0x113C (Y:$06044F).
Variables I5001 through I5048 determine the potential registers to be gathered. I5050 and I5051 are 24-
bit mask variables that determine which of the 48 possible sources will be gathered. I5049 determines the
gathering period, in servo cycles.
The actual gathering is started by the on-line GATHER command, and stopped by the on-line
ENDGATHER command. As Turbo PMAC gathers data into the DPRAM, it advances the pointer that
shows the address offset where the next item to be gathered will be placed. This pointer is stored at
0x113E (X:$06044F). The host computer must watch for changes to this pointer to indicate that more
data has been copied into DPRAM.
Turbo PMAC Ethernet Protocol
Communications through an Ethernet port are fully supported for Microsoft Windows 98, 2000, ME, and
XP operating systems through the PCOMM32PRO driver library. Users writing communications
programs under one of those operating systems should consult the manual for PCOMM32PRO. This
section explains how comparable Ethernet communications drivers can be written for other operating
systems.
This section is intended for application programmers who have a fundamental understanding of Berkeley
sockets used in the TCP/IP protocol suite. Before any attempt to read or understand the contents of this
manual review basic sockets and understand them before proceeding. The fundamental socket functions
that must be understood are recv, send, and socket.
The examples in this manual are for demonstration purposes only and are to there to convey the concepts
of how to communicate with the Turbo PMAC. Therefore, the examples do not include error checking
and timeouts. Delta Tau’s actual production code does, however, and application programmers are
strongly encouraged to include error checking and timeouts in their code to prevent hang-ups and
unresponsive behavior.
Turbo PMAC Ethernet communications ports talk using the UDP or TCP protocol of the TCP/IP suite of
protocols on port 1025. Therefore, the programmer should open either a datagram socket (UDP) or a
stream socket (TCP) on port 1025 the PMACPORT.
sock = socket(PF_INET,SOCK_DGRAM,0); // UDP Mode
or
sock = socket(PF_INET,SOCK_STREAM,0); // TCP Mode
// Embedded Ethernet's IP address
// The port that the embedded program is listening on.
sin.sin_port = htons(PMACPORT);
connect(*sock,(struct sockaddr*)&sin,sizeof(sin));
Every command that is sent to the Turbo PMAC through an Ethernet port begins using the
ETHERNETCMD packet structure and is initiated with a PC send command. Every command then must
issue a recv command to either receive an acknowledgement character back via the recv command or
receive meaningful data.
#define ETHERNETCMDSIZE 8
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE,0);
recv(sock,(char *)&EthCmd,1,0);
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_FLUSH;
EthCmd.wValue = htons(FLUSH_TIMEOUT);
EthCmd.wIndex = 0;
EthCmd.wLength = 0;
send(sock,
(char *)&EthCmd,
ETHERNETCMDSIZE ,
0);
recv(sock,
(char *)&EthCmd,
1,
0);
}
The above example and all of the examples in this document do not perform error checking and timeout
checking. It is the application developer’s responsibility to perform error checking and timeout checks to
insure that the application does not hang.
VR_PMAC_SENDLINE
This packet causes the NULL-terminated string in EthCmd.bData to be sent to the Turbo PMAC. The
string should not be terminated with a carriage return as this is done by the firmware. One byte will be
returned upon successful completion of the command.
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_SENDLINE;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons( (WORD)strlen(outstr));
strncpy((char *)&EthCmd.bData[0],
outstr
,(WORD)strlen(outstr));
Example
int CALLBACK PmacSockSendLine(char *outstr)
{
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_SENDLINE;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons( (WORD)strlen(outstr));
strncpy((char *)&EthCmd.bData[0],outstr,(WORD)strlen(outstr));
send(sock,
(char *)&EthCmd,
ETHERNETCMDSIZE + strlen(outstr),
0);
recv(sock,(char *)&EthCmd,1 ,0);
}
VR_PMAC_GETLINE
This packet causes the Ethernet connection to return any available string that may be residing in the
Turbo PMAC. All characters up to a <CR>, <ACK>, or <LF> are returned. The available string in
PMAC is returned and should be captured via an Ethernet recv command. It is recommended that this
function not be used. Use VR_PMAC_GETBUFFER instead, as this function will retrieve multiple lines
and will greatly enhance performance as opposed to using multiple calls of VR_PMAC_GETLINE.
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_GETLINE;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength Not used
Example
int CALLBACK PmacSockGetLine(char *instr)
{
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_GETLINE;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons( (WORD)strlen(outstr));
strncpy((char *)&EthCmd.bData[0],outstr,(WORD)strlen(outstr));
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE,0);
recv(sock,(char *)&instr,255 ,0);
}
VR_PMAC_GETBUFFER
This packet causes the Ethernet connection to return any available string that may be residing in the
Turbo PMAC. All characters up to an <ACK> or <LF> are returned. If a <BEL> or <STX> character is
detected, only the data up to the next <CR> is returned. The maximum amount of data that will ever be
returned is 1400 bytes. It is the caller’s responsibility to logically determine if there is more data to
follow and if VR_PMAC_GETBUFFER must be called again to retrieve all of the data available.
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_GETBUFFER;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons( (WORD)strlen(outstr));
EthCmd.bData - Not Used
Example
int CALLBACK PmacSockGetBuffer(char *instr)
{
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_GETBUFFER;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons( (WORD)strlen(outstr));
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE,0);
recv(sock,(char *)&instr,1400,0);
}
VR_ IPADDRESS
This packet permits either setting or retrieval of the current IP address in the Ethernet interface.
When setting the IP address to a new value it is required that the Turbo PMAC is powered down for the
new address to take effect.
EthCmd.RequestType = VR_UPLOAD to retrieve the IP address
or
EthCmd.RequestType = VR_DOWNLOAD to set the IP address
EthCmd.Request = VR_IPADDRESS;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons(4);
EthCmd.bData = contains 4 bytes of data indicating the IP
address set on the send command.
For the receive command four bytes of data are returned indicating the IP address.
VR_PMAC_SENDCTRLCHAR
This packet permits sending of a single character or control character to the Turbo PMAC Ethernet port.
The packet below is what is to be sent. The data received is irrelevant; its purpose is to insure the sender's
command was received.
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_SENDCTRLCHAR;
EthCmd.wValue = htons(outch); // the character to write
EthCmd.wIndex = 0;
EthCmd.bData - Not Used
VR_PMAC_PORT
This packet permits sending of a single byte or receiving of single byte through the Ethernet port to or
from the CPU’s host port.
To send data to the host port set the packet as follows. After sending the packet the programmer must
wait to receive 1 byte via the recv function before continuing. The data received is irrelevant; its purpose
is to insure the sender’s command was received.
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_PORT;
EthCmd.wValue = htons((WORD)offset);
EthCmd.wIndex = htons((WORD)outch);
EthCmd.wLength = 0;
To receive data from the host port set the packet as follows. After sending the packet the programmer will
receive 1 byte, which is the value the Ethernet port read from the Turbo PMAC’s CPU host port.
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_PORT;
EthCmd.wValue = htons(offset);
EthCmd.wIndex = 0;
EthCmd.wLength = 0;
VR_PMAC_READREADY
This packet permits determining if there is data on the Turbo PMAC CPU ready to be read.
Two bytes will be returned. The first byte, if non-zero, indicates there is data to be read; if zero, there is
no data to be read. The packet will be set up as follows:
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_READREADY;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons(2);
Example
ETHERNETCMD EthCmd;
char data[2];
int rc;
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_READREADY;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons(2);
rc = send(sock,((char *)&EthCmd),ETHERNETCMDSIZE,0);
rc = recv(*((SOCKET *)vh[dwDevice].hDriver),data,2,0);
return data[0];
VR_CTRL_REPONSE
This packet permits obtaining the response after sending a control character. The packet is set up as
follows. The received data is the response to the sent control character. Meaningful data is returned for
the following control characters <CTRL-B>, <CTRL-C>, <CTRL-F>, <CTRL-G>, <CTRL-P>, and
<CTRL-V>. All other data control characters do not return meaningful data.
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_CTRL_RESPONSE;
EthCmd.wValue = htons(outchar);//outchar=ctrl char to send out
EthCmd.wIndex = 0;
EthCmd.wLength = htons(len);
rc = send(sock,((char *)&EthCmd),ETHERNETCMDSIZE,0);
rc = recv(sock,outstr,len,0); // returned data appears
VR_PMAC_WRITEBUFFER
This packet permits writing multiple lines to the Turbo PMAC with just one packet. The packet is set up
as follows. The received data is the response to the sent control character. It is usually used for
downloading a file. Data should be of the form in which each line is separated by null byte.
For example, the following multi-line string could be sent in a single packet: OPEN PLC 1
CLEAR<00>P1=P1+1 <00> CLOSE<00>, where <00> indicates a null byte. The maximum data
length is 1024 bytes; anything bigger must be separated into multiple calls of
VR_PMAC_WRITEBUFFER.
Upon receiving this packet, the Turbo PMAC Ethernet interface sends back 4 bytes of data. Byte 3
indicates if there was an error downloading. If the value of this byte is 0x80, there was an error during
the download. If it is 0, there was no error during download. Byte 2 indicates the Turbo PMAC error
type if there was a download error. Consult the Turbo PMAC Software Reference summary or error list
under variable I6. Bytes 0 and Byte 1 together form a WORD that indicates the line number that caused
the error to occur. Byte 1 is the MSB and Byte 0 is the LSB of that word.
Example
char errcode[4];
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_WRITEBUFFER;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons(len) ;
memcpy(EthCmd.bData,data, len);
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE + len,0);
recv(sock,(char *)errcode,4 ,0);
VR_FWDOWNLOAD
This packet permits writing raw data to the Turbo PMAC host port for firmware download. The Ethernet
firmware takes the stream of data, then writes to the Turbo PMAC CPU host port at addresses {base + 5},
{base + 6}, and {base + 7}. The packet includes in the wValue parameter to command to start the
download at host port address {base + 5}. This packet permits writing multiple lines to the Turbo PMAC
with just 1 packet.
The packet is set up as follows. The received data is the response to the sent control character. It is
usually used for downloading a file. Data should be of the form each line separated by null byte. After
sending the packet the programmer must wait to receive 1 byte via the recv function before continuing.
The data received is irrelevant; its purpose is to insure the sender’s command was received.
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request= VR_FWDOWNLOAD;
EthCmd.wValue = htons((WORD)bRestart); //bRestart = 1 on start
EthCmd.wIndex = 0;
EthCmd.wLength = htons((WORD)len) ;
memcpy(EthCmd.bData,data, len);
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE + len,0);
recv(sock,(char *)&errcode,1 ,0);
VR_PMAC_GETRESPONSE
This packet causes the Ethernet connection to send a string to Turbo PMAC, then to return any available
strings that may be residing in the Turbo PMAC. All characters up to an <ACK> or <LF> are returned.
If a <BEL> or <STX> character is detected, only the data up to the next <CR> is returned. The
maximum amount of data that will ever be returned is 1400 Bytes. It is the caller's responsibility to
logically determine if there is more data to follow and if VR_PMAC_GETBUFFER needs to be called
again to retrieve all of the data available.
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_GETRESPONSE;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons( (WORD)strlen(outstr));
strncpy((char *)&EthCmd.bData[0],outstr,(WORD)strlen(outstr));
send(sock,(char*)&EthCmd,ETHERNETCMDSIZE + strlen(outstr),0);
recv(sock, szPmacData,1400,0);
VR_PMAC_GETMEM
This packet causes the Ethernet connection to read data from the DPRAM shared between the Turbo
PMAC CPU and the Ethernet microcontroller. Up to 1400 bytes may be received in a single packet. The
wValue field contains the byte offset to retrieve the data from, while the wLength parameter indicates how
many bytes to receive.
Example
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_GETMEM;
EthCmd.wValue = htons(offset); //
EthCmd.wIndex = 0;
EthCmd.wLength = htons(length);
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE ,0);
recv(sock,(char *)data,1400,0);
VR_PMAC_SETMEM
This packet causes the Ethernet connection to write data to the DPRAM shared between the Turbo PMAC
CPU and the Ethernet microcontroller. Up to 1400 bytes may be written in a single packet. The wValue
field contains the byte offset to write the data to while the wLength parameter indicates how many bytes
to write. After sending the packet the programmer must wait to receive 1 byte via the recv function before
continuing. The data received is irrelevant; its purpose is to insure the sender’s command was received.
Example
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_SETMEM;
EthCmd.wValue = htons(offset);
EthCmd.wIndex = 0;
EthCmd.wLength = htons(length);
VR_PMAC_SETBIT
This packet causes the Ethernet connection to perform a write to DPRAM shared between the Turbo
PMAC CPU and the Ethernet microcontroller that either sets bits in a 32-bit word or clears bits in a 32-bit
word. If the wIndex parameter is supplied with a 1, a logical OR is performed that sets bits. If it is 0, a
logical AND is performed, which clears bits. It is the programmer’s responsibility to use the appropriate
mask for setting or clearing bits. The wValue field contains the byte offset to retrieve the data from. After
sending the packet the programmer must wait to receive 1 byte via the recv function before continuing.
The data received is irrelevant; its purpose is to insure the sender’s command was received.
Example
DWORD mask = 0x00000001;
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_SETBIT;
EthCmd.wValue = htons((WORD)offset);
EthCmd.wIndex = htons((WORD)on);
EthCmd.wLength = htons(len);
// generate the mask
mask <<= bitno; // zero based
// If clearing a bit complement mask to prepare firmware for AND
if(!on)
mask = ~mask;
memcpy(EthCmd.bData,&mask,len);
// Send command request
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE+len,0);
recv(sock,(char *)&errcode,1,0);
VR_PMAC_SETBITS
This packet causes the Ethernet connection to perform a write to DPRAM shared between the Turbo
PMAC CPU and the Ethernet microcontroller that sets bits in a 32-bit word to a new value. The wValue
field contains the byte offset to retrieve the data from. The bData field of the Ethernet command packet
must be stuffed with a mask indicating which bits to set in four bytes followed by four bytes that indicate
the bits to clear in a 32-bit word. After sending the packet the programmer must wait to receive 1 byte via
the recv function before continuing. The data received is irrelevant; its purpose is to insure the sender’s
command was received.
Example
EthCmd.RequestType = VR_UPLOAD;
EthCmd.Request = VR_PMAC_SETBITS;
EthCmd.wValue = htons((WORD)offset);
EthCmd.wIndex = 0;
EthCmd.wLength = htons(2*sizeof(DWORD));
temp = 0xFF03FFFF ;
memcpy(EthCmd.bData,&temp,sizeof(DWORD));
temp = 0x00030000 ;
memcpy(EthCmd.bData + 4,&temp,sizeof(DWORD));
// Send command request
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE + 2*sizeof(DWORD),0);
recv(sock,(char *)&errcode,1,0);
Data Gathering
Turbo PMAC has a general-purpose data gathering function for repetitive on-the-fly storage of real-time
data. In this function, Turbo PMAC can store the contents of up to 48 memory locations at specified
intervals up to the servo interrupt frequency. This data is stored in a buffer in open Turbo PMAC
memory for later transmission to the host. This feature is useful for filter tuning and motion problem
solving.
Executive Program Data Gathering
Most users will utilize this feature in conjunction with the PMAC Executive Program on the PC, which
handles its details automatically. Refer to the manual of the Executive Program for details. It is possible
(although not trivial) to write a custom host program to utilize this feature.
Gathering I-Variables
Variable I5000 controls the location and mode of the data-gathering buffer. Bit 1 of I5000 controls
whether the gathered data is stored in Turbo PMAC’s main memory (bit 1 = 0), or whether it is stored in
optional dual-ported RAM (bit 1 = 1). The PMAC Executive program supports only the use of data
gathered to Turbo PMAC’s main memory.
Bit 0 of I5000 controls whether gathering will stop when the end of the buffer is reached, or whether it
will wrap around and continue gathering at the beginning of the buffer, overwriting previously gathered
data. Setting bit 0 to 0 causes gathering to stop at the end. This is the most common mode, used for
gathering during a known sequence of operation.
Setting bit 0 of I5000 to 1 enables the wrap-around. This mode is required for gathering to DPRAM and
real-time upload; it can be useful in gathering to main memory when trying to catch an intermittent
problem. When gathering in this mode, it is a good idea to gather the servo-cycle counter at X:$000000,
so it is possible for the host-computer software to unwrap the data properly. The PMAC Executive
program’s data gathering and plotting routines can upload and plot data from a buffer that has wrapped
around, but it cannot unwrap this data to plot it in the proper time order.
The user specifies up to 48 source addresses in I-variables I5001 to I5048. The low 19 bits of these
variables represent the word address itself. The top 2 bits control whether the X word, the Y word, or
both (in fixed or floating format) will be gathered. He sets a “mask” in 24-bit variables I5050 and I5051
to specify which of these 48 addresses will be collected, and defines the gathering period in servo
interrupt cycles with I5049.
Gathering Commands
The buffer in Turbo PMAC’s memory is set up with the on-line DEFINE GATHER [{constant}]
command. If no value is specified, the whole of Turbo PMAC’s open memory is reserved for this buffer.
(This means that no new motion or PLC programs can be added to Turbo PMAC as long as this space is
reserved). If a data-gathering buffer is present in Turbo PMAC’s memory, even if it does not occupy all
open memory no other buffer of the type created with a DEFINE {buffer} command (e.g. COMP,
LOOKAHEAD) may be added to memory until the data-gathering buffer is deleted.
The actual data gathering function is started with the GATHER command. When this has been done,
Turbo PMAC will store the specified data at the specified rate into the gather buffer until told to stop with
the ENDGATHER, or until space runs out. These are on-line commands; from within a motion program or
PLC program, the CMD"GATHER" and CMD"ENDGATHER" statements are used.
In a motion program, these statements are executed at the program calculation time, which can be well
ahead of the move execution time, so if you are not careful, it is easy to miss gathering the last one or two
commanded moves because the CMD"ENDGATHER" statement is issued before these moves actually
execute. Typically, it is a good idea to precede the CMD"ENDGATHER" statement with a DWELL
statement in the motion program. The DWELL statement stops any lookahead in the program, so the
CMD"ENDGATHER" statement will not be issued until the actual execution of the dwell is completed.
Even a DWELL 0 will ensure that the end of the last commanded move is gathered; a longer dwell can
catch the final settling.
The statements CMD"GATHER" and CMD"ENDGATHER" are executed as background tasks in Turbo
PMAC. Their function is simply to set and clear, respectively, the data gathering control bit at
X:$000006 bit 19. To do this without a background-cycle delay, you could assign an M-variable to this
bit (e.g. M89->X:$000006,19), then set and clear this bit directly in the program.
The stored data can be uploaded to the host with the LIST GATHER command. The data is sent to the
host in ASCII hexadecimal form, with 6 characters per item for the single (X or Y) words, and 12
characters per item for the double (L or D) words. The data is provided in 12-character groupings. If the
data gathered for a sample leaves the last grouping with only six characters, this last grouping is filled out
with the contents of the servo cycle counter register X:$000000.
It is the host program’s responsibility to decode and process this data, for plotting, storage, analysis, or
other use.
The space reserved for the data-gathering buffer can be freed with the DELETE GATHER command.
Data Format
Data is stored in the buffer in 32-bit sign-extended form. That is, each short (24-bit) word gathered from
Turbo PMAC is sign-extended and stored in 32-bits of DPRAM (LSByte first). The most significant byte
is all ones or all zeros, matching bit 23. Each long (48-bit) word is treated as 2 24-bit words, with each
short word sign-extended to 32 bits. The host computer must reassemble these words into a single value.
To reassemble a long fixed-point word in the host, take the less significant 32-bit word, and mask out the
sign extension (top eight bits). In C, this operation could be done with a bit-by- bit AND: (LSW &
16777215). Treat this result as an unsigned integer. Next, take the more significant word and multiply it
by 16,777,216. Finally, add the two intermediate results.
To reassemble a long floating-point value in the host, we must first split the 64-bit value into its pieces.
Bits 0 to 11 of the 32-bit word at the lower address form the exponent. Bits 12-23 of this word form the
low 12 bits of the 36-bit mantissa. Bits 0-23 of the 32-bit word form the high 24 bits of the mantissa; bits
24-31 are sign extension. The following code shows one way of creating these pieces (not the most
efficient):
exp = first_word & 0x00000FFFL; // Select low 12 bits for exponent
low_mantissa = (first_word >> 12) & 0x00FFFL;
// Select next 12 bits for mantissa
// shift right and mask
high_mantissa = second_word;
The floating point value can then be reconstructed with:
mantissa = high_mantissa * 4096.0 + low_mantissa;
value = mantissa * pow (2.0, exp - 2047 - 35);
2047 is subtracted from the exponent to convert it from an unsigned to a signed value; 35 is subtracted to
put the mantissa in the range of 0.5 to 1.0.
The following procedure in C performs the conversion efficiently and robustly:
double DPRFLoat (long first_word, long second word) {
// return mantissa/2^35 * 2^(exp-2047)
double mantissa;
long int exp;
m = (double)(second_word) * 4096.0 +
(double)((first_word>>12) & 0x00FFFL);
if (m == 0.0) return (0.0);
exp = (first_word & 0x00000FFFL) - 2082; // 2082=2047+35
return (mantissa * pow(2.0 * (double) exp));
}
To reassemble a long floating-point word in the host, treat the less significant word the same as for the
fixed-point case above. Take the bottom 12 bits of the more significant word (MSW & 4095), multiply
by 16,777,216 and add to the masked less significant word. This forms the mantissa of the floating-point
value. Now take the next 12 bits (MSW & 16773120) of the more significant word. This is the exponent
to the power of two, which can be combined with the mantissa to form the complete value.
DPRAM
0 Byte 0
BYTE 1 Byte 1
NO. 2 S Byte 2
(RELATIVE) S S S S S S S S S = Sign bit
3
(SIGN EXTENSION)
48 BITS BIT # 23 16 15 8 7 0
PMAC Y: WORD S1 Byte 2 Byte 1 Byte 0
PMAC X: WORD S2 Byte 5 Byte 4 Byte 3
0 Byte 0
1 Byte 1
DPRAM 2 S1 Byte 2
BYTE 3 S1 S1 S 1 S1 S1 S 1 S1 S1
NO. 4(SIGN EXTENSION) Byte 3
(RELATIVE)
5 Byte 4
6 S2 Byte 5
S1 = First word sign bit
7 S2 S2 S2 S2 S 2 S2 S2 S2 S2 = Second word sign bit
(SIGN EXTENSION)
= Exponent for floating point