User's Manual

PMAC User Manual
250 Writing a Host Communications Program
where speed is 1 or 2 for a PC-XT, 3 or 4 for a 286-based computer, 5 to 6 for a 386-based computer, and
7 to 9 for a 486-based computer.
Sending a Character
To send a character, the host simply 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, 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 */
Using the PMAC PC/STD to Interrupt the Host Computer
The PMAC PC, PMAC Lite and PMAC STD motion control cards have the capability of interrupting the
host PC for any of a number of reasons. This capability can give additional speed, power, and flexibility
in the system, but using interrupts properly is one of the more demanding programming tasks on a PC. It
requires substantial programming experience and a lot of patience. Once done, the rewards can be
substantial in increasing the efficiency of the system.
These PMACs have an on-board Intel 8259 Programmable Interrupt Controller IC (PIC). This IC has
eight inputs that can cause it to send an interrupt signal to the PC. With a combination of hardware and
software, what signals, if any, can be selected that will cause an interrupt to the PC.
What Signals Can Be Used
The eight inputs to the PIC are labeled IR0 to IR7. IR0 has the highest priority; IR7 the lowest. The
PMAC design brings a variety of different signals into these inputs; on some of the inputs, what signal is
brought to the input is chosen with jumpers.
The following table shows which signals match to each input on the PMAC PC and PMAC Lite. Those
signals marked with an asterisk (*) are not available on the PMAC Lite:
IPOS is the coordinate system in-position signal. If the control panel is enabled (I2=0), it reflects the
panel-selected coordinate system (by FDPn/ lines). If the control panel is disabled (I2=1), it reflects the
host-addressed coordinate system (by &n command). For a coordinate system to be in-position, three
conditions must be met: the desired velocity must be zero on all axes; no move timers can be active (in
any move, DWELL, or DELAY); and all motors must have a following error smaller than the in-position
band (Ix28).
BREQ is the buffer request signal. It is high when a regular buffer still has room for more lines to be
entered (you can define how much memory left means enough room with I18). When a rotary buffer is
open, it is high when less than a prescribed number of lines ahead of the executing line (set by I16 and
I17) have been loaded. It is low when buffers are closed. When a program line is sent to an open buffer,
it is always set low, then set high again if the conditions as explained above warrant. This rising edge can
generate an interrupt to tell the host to send the next program line.