Delta Tau GEO BRICK LV User Manual

Page of 440
Turbo PMAC User Manual 
Writing a Host Communications Program
 
383
 
WRITING A HOST COMMUNICATIONS PROGRAM 
If communicating from a host computer to Turbo PMAC in the actual application, a host communications 
program must be written.  The PMAC Executive program used in development is not intended as a host 
program for an actual application; it was designed simply as a development tool. 
This section describes the actions to take if writing custom communications software, including low-level 
drivers.  If using Delta Tau’s PCOMM32 or PCOMM32PRO communications libraries for Microsoft 
Windows operating systems, this work has been done by the library routines, and it is not necessary to 
deal with the details presented in this section (although it is still a good idea to familiarize yourself with 
the basic issues presented in this section).  If using one of these communications libraries, refer to the 
manual for that library. 
At a fundamental level, the host communications routines that are written send and receive strings of 
ASCII-coded characters to and from PMAC.  Create some low-level routines to send and receive 
individual characters and text lines; these will be called repeatedly; specifying the different text strings to 
read or write.   
Note: 
The basic concepts of communications are covered in the Talking to Turbo PMAC 
section.  That section should be reviewed before studying this one. 
If dual-ported RAM option is present, it may be communicating by transfers of binary-coded numerical 
data through the shared registers of the DPRAM. 
Turbo PMAC Command/Response Format 
It is important to understand Turbo PMAC’s basic command/response format before attempting to write 
communications routines.  In general, both commands to Turbo PMAC and responses from it are ASCII 
text strings that are terminated with a carriage-return control character (although in dual-ported RAM they 
are null-character terminated).  It is also possible to send special control-character commands (such as 
<CTRL-A> to abort all motion), which do not require any text characters or a carriage return. 
The fundamental action in communicating with Turbo PMAC is to send a command, monitor the port 
until Turbo PMAC’s response is ready, pull in the response characters, and interpret them.   
Response Types 
Depending on the command given, there are three classes of responses: no-line, single-line, and multiple-
line.  With the proper setup on Turbo PMAC, and careful structuring of your communications routines, it 
is possible to write simple and efficient routines to handle all of these cases.  The most important factor 
for efficient and robust communications routines is setting I3=2.  This causes the overall response to all 
valid text commands to be terminated with an <ACK> character, making it a unique end-of-transmission 
character, and all invalid commands to be responded to with a <BELL> character.  The following 
descriptions assume a setting of I3=2. 
No-Line Responses 
A command to Turbo PMAC, such as J+(jog positive), that does not call for a text response will just get 
an <ACK> character in response if it is valid, or a <BELL> if it is not valid. 
Single-Line Responses 
A command to Turbo PMAC, such as P (report addressed motor position), that calls for a single-line text 
response, if valid will get the text-line response terminated by a <CR>, followed by an <ACK>.  If it is 
invalid, Turbo PMAC will respond with a <BELL> character instead.