User's Manual

PMAC User Manual
272 Writing a Host Communications Program
Example
With I3=3 and I4=1, and assuming P100=35, Q10=0, Q11=1, and Q12=2:
Host sends: J+<CR>
PMAC sends: <ACK><117dec> (117=74[J] + 43[+])
Host sends: P100<CR>
PMAC sends: <LF>35<CR><127dec> (127=10+51+53+13)
<ACK><225dec>
(225=80+49+48+48)
Host sends: Q10..12
PMAC sends: <LF>0<CR><71dec>
(71=10+48+13)
<LF>1<CR><72dec> (72=10+49+13)
<LF>2<CR><73dec> (73=10+50+13)
<ACK><369or113dec> (369=81+49+48+46+46+49+50)
(113=369 modulo 256)
Data Gathering
PMAC has a general purpose data gathering function for repetitive on-the-fly storage of real-time data. In
this function, PMAC can store the contents of up to 24 memory locations at specified intervals up to the
servo interrupt frequency. This data is stored in a buffer in open PMAC memory for later transmission to
the host. This feature is useful for filter tuning and motion problem solving.
Executive Program Data Gathering
Usually, this feature is used in conjunction with the PMAC Executive Program on the PC, which handles
the details of this function automatically. Refer to the Executive Program manual for details. It is
possible (although not trivial) to write a custom host program to utilize this feature.
Gathering I-Variables
Specify up to 24 source addresses in I-variables I21 to I44. The low 16 bits of these variables represent
the word address itself. The top two bits control whether the X word, the Y word, or both (in fixed or
floating format) will be gathered. A mask is set in I20 to specify which of these addresses will be
collected, and the gathering period is defined in servo interrupt cycles with I19.
Gathering Commands
The buffer in the PMAC memory is set up with the on-line DEFINE GATHER [{constant}]
command. If no value is specified, the whole of the PMAC open memory is reserved for this buffer.
(This means that no new motion or PLC programs can be added to PMAC as long as this space is
reserved). The actual data gathering function is started with the GATHER command. When this has been
done, PMAC will store the specified data at the specified rate into the gather buffer until told to stop with
the ENDG, or until space runs out.
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 six 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 twelve-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.
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.
On-line Data Gathering
The <CONTROL-E> command is a sort of single-shot data gathering. On receipt of this command,
PMAC reports the contents of the registers specified by I20-I44 to the host. Here, the contents are sent in
binary, not ASCII form, and without any handshaking characters. There are three bytes per short word,
and six bytes per long word. This command is useful for quick status and position querying.