User`s manual

4.0 - Programming PMAC
Page - 31
P-variables are general-purpose user variables. They are 48-bit floating-point variables at fixed locations in PMAC's
memory, but with no pre-defined use. There are 1024 P-variables, from P0 to P1023. 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.
If a command consisting simply of a constant value is sent to PMAC, PMAC assigns that value to variable P0. For
example, if you send the command 342<CR> to 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 accidentally.
4.3.3 - 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 meaning of 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 do have different values in their own Q variables (which in this case,
means different destination points).
Several Q-variables have special uses that you need 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.
Based on that and since a total of 1024 Q-variables are shared between potentially 8 Coordinate Systems (128 variables
each), the practical range of the Q-variables to be safely used in motion programs is therefore Q1 to Q99.
The set of Q-variables you are working with in a command depends on the type of command. When you are accessing a Q-
variable from an on-line (immediate) command from the host, you are working with the Q-variable for the currently host-
addressed coordinate system (with the &n command). When you are accessing a Q-variable from a motion program
statement, you are working with the Q-variable belonging to the coordinate system running the program. If a different
coordinate system runs the same motion program, it will use different Q-variables.
When you are accessing a Q-variable from a PLC program statement, you are working with the Q-variable for the
coordinate system that has been addressed by that PLC program with the ADDRESS command. 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.
4.3.4 - M-Variables
To permit easy user access to PMAC's memory and I/O space, M-variables are provided. Generally, a definition only needs
to be made once, with an on-line command. On PMACs with battery backup, the definition is held automatically. On
PMACs with flash backup, the SAVE command must be used to retain the definition through a power-down or reset. The
user defines 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 thumbwheel multiplexer port.
There are 1024 M- variables (M0 to M1023), 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) when read from; the number must be specified by a
constant when written to.
The definition of an M-variable is done using the "defines-arrow" (->) composed of the minus-sign and greater-than
symbols. 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
L: 48 bits floating-point across both X- and Y-memory
DP: 32 bits fixed-point (low 16 bits of X and Y) (for use in dual-ported
RAM)