PMAC Product Guide 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.
The ATAN2 (two-argument arctangent) function uses Q0 as its second argument (the "cosine" argument) automatically. 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 eight 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 working within a command depends on the type of command.
When accessing a Q-Variable from an on-line (immediate) command from the host, it is the Q-Variable for the currently host-addressed coordinate system (with the &n command). When accessing a Q-Variable from a motion program statement, it is 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 accessing a Q-Variable from a PLC program statement, it is 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 Coordinate System 1. 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.
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 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 • *: No address definition; uses part of the definition word as general-purpose variable Programming PMAC 47