Professional Documents
Culture Documents
CHAPTER TWO
Communication
IN THIS CHAPTER
• Communication options (protocols, connections) ...........................................34
• Motion Planner™ communication features .....................................................34
• Communications Server...................................................................................35
• Serial Communication:
− Controlling multiple serial ports ................................................................41
− RS-232C daisy-chaining ............................................................................42
− RS-485 multi-drop .....................................................................................45
Communication Options
Note: When using VBScript, the syntax is identical to the example above except that the
variable declaration should omit the “As Object” keywords.
Once the proper object variable has been created and a connection is established, there is a
standard set of methods and properties which the client application(s) can access. Below are
descriptions of the methods and properties available via the RS-232 and Ethernet interfaces.
Chapter 2. Communication 35
Using the Communications Server with RS-232
NOTE
This section covers RS-232 methods, there are no RS-232 properties for the
Communications Server.
Connect ( port ) The Connect method, opens a connection to a 6K controller. The integer port argument
represents the PC COM port numbers (1 - 4). The method returns a TRUE value if the
connection is successfully opened, otherwise a FALSE value is returned.
Disconnect ( ) The Disconnect method closes a previously opened connection. There are no arguments for this
method and no return value.
GetFile ( filename ) The GetFile method is used to upload programs currently stored in the controller. The filename
argument represents the name of the file to store the uploaded program. If the filename is an
empty string then the user will be prompted for the filename. The method returns a zero if the
operation is successful or an error code otherwise.
LoadOS ( ) The LoadOS method, downloads the soft operating system to a 6K controller. There are no
arguments for this method. The user will be prompted for the operating system file. The
method returns a TRUE value if the operation is successful, otherwise a FALSE value is
returned.
Read ( ) The Read method, retrieves command responses from the controller. There are no arguments
for this method. The read method does not wait for incoming responses from the controller. It
returns immediately with a string containing the controller’s response at the time of the request.
If no response is available, this method will return NULL string.
SendFile ( filename ) The SendFile method is used to download program files to the controller. The filename
argument represents the name of the program file to be downloaded. If the filename is an
empty string, then the user will be prompted for the filename. The method returns a zero if the
operation is successful or an error code otherwise.
UploadOS ( ) The UploadOS method is used to retrieve the soft operating system from the controller. There
are no arguments for this method. You will be prompted to store the operating system to a file.
The method returns a TRUE value if the operation is successful, otherwise a FALSE value is
returned.
Write ( cmd ) The Write method is used to send commands to the controller. cmd is a string of commands to
be sent. Multiple commands can be sent, but each command should be separated with a valid
6K command delimiter (colon, carriage return, line feed). The command string should be
limited to 1024 characters or less. Excessively large command strings, may cause an overflow
in the 6K’s command buffer. It returns the number of bytes sent.
Ethernet Methods
Connect ( ipaddr ) The Connect method, opens a connection to a 6K controller. The ipaddr argument is a string
representing the target controller’s IP address. The method returns a TRUE value if the
connection is successfully opened, otherwise a FALSE value is returned.
Disconnect ( ) The Disconnect method, closes a previously opened connection. There are no arguments for
this method and no return value.
GetFile ( filename ) The GetFile method is used to upload programs current stored in he controller. The filename
argument represents the name of the file to store the uploaded program. If the filename is an
empty string then the user will be prompted for the filename. The method returns a zero if the
operation is successful or an error code otherwise.
Read ( ) The Read method, retrieves command responses from the controller. There are no arguments
for this method. The read method does not wait for incoming responses from the controller. It
returns immediately with a string containing the controller’s response at the time of the request.
If no response is available, this method will return NULL string.
SendFile ( filename ) The SendFile method is used to download program files to the controller. The filename
argument represents the name of the program file to be downloaded. If the filename is an
empty string then the user will be prompted for the filename. The method returns a zero if the
operation is successful or an error code otherwise.
Write ( cmd ) The Write method is used to send commands to the controller. cmd is a string of commands to
be sent. Multiple commands can be sent, but each command should be separated with a valid
6K command delimiter (colon, CR, LF). The command string should be limited to 1024
characters or less. Excessively large command strings, may cause an overflow in the 6K’s
command buffer.
Chapter 2. Communication 37
Ethernet Properties Bit Status Convention
When retrieving bit-oriented properties (e.g., AxisStatus, ErrorStatus, Limits, SystemStatus,
etc.) note that the convention in the 6K programming language differs from the convention
used for C and Assembly programming languages. Compumotor’s 6K convention is to refer
to the bits within a 32 bit long integer as bits 1 through 32 (left to right). The C and Assembler
Programmer's convention refers to these as bits 0 through 31 (right to left). When masking
these bits, you should be aware of this subtle difference when referring to 6K documentation.
AlarmStatus ( bit ) The AlarmStatus property returns the state of the controller’s alarm status. The integer bit
argument specifies the status bit of the alarm status to return. It can be a number between 0 and
32. Values between 1-32 represent the alarm bits as described in the table below (refer also to
the INTHW command). Specifying a bit value of 0 returns the entire 32 bit alarms status as a
long value; otherwise a value of 1 or 0 is returned to indicate the state of any single bit. When
any single bit status is retrieved using the AlarmStatus property, that bit status is automatically
cleared by the Communications Server. If a bit value of 0 is used then all alarm status bits are
cleared.
** Bits 1-12: software alarms are forced with the INTSW command.
AnalogInput ( channel ) The AnalogInput property returns the specified analog input value (in counts). The channel
argument specifies the analog input channel value to return (1 or 2).
AxisStatus ( axis ) The AxisStatus property returns a long value representing the current axis status for the
specified axis. The axis argument can be a number from 1 to 8.
CommandCount The CommandCount property, returns a long value representing the number of 6000 commands
which have been executed outside of defined programs, since the 6K controller was powered
up. This property is intended to allow users to track when commands being sent to the
controller via the communications ports have been executed. The value is reset to zero each
time power is cycled on the 6K.
Counter ( axis ) The Counter property returns an integer value representing the current Time Frame Counter
value. The Time Frame Counter is a free running timer in the controller.
ErrorStatus The ErrorStatus property returns a long value representing the current error status (TER) of
task 0.
FastStatus The FastStatus property returns a variant which represents the value of the entire FastStatus
data structure. This property allows for faster more efficient retrieval of the FastStatus
information if multiple FastStatus items need to be checked at once. The variant is essentially a
byte array which can be mapped into a FastStatus structure (see table below for FastStatus
structure).
FSEnabled The FSEnabled property is a read/write property that sets or returns the state of FastStatus
polling. If this property is set to TRUE, then FastStatus information is automatically retrieved
from the controller on a continual basis. If this property is set to FALSE then automatic
FastStatus polling is turned off and the FastStatus information is updated only once at the time
when the property is set. Enabling automatic FastStatus polling provides fresh data from the
controller on a continual basis, but this will impair the controller’s processing time. Disabling
FastStatus polling provides a means of getting fresh information at a specific point in time
without impairing the controller’s command processing or communications processing abilities.
NOTE: The FSEnabled property must be enabled to receive valid data from these properties:
AnalogInput, AxisStatus, CommandCount, Counter, EncoderPos, ErrorStatus, FastStatus,
Inputs, IPAddress, Limits, MotorPos, MotorVel, Outputs, SystemStatus, Timer, Triggers,
UserStatus, VarB and VarI.
FSUpdateRate The FSUpdateRate property is used to set the millisecond interval on which the controller
automatically updates its FastStatus information. This property should be set before, the
FSEnabled property is set to TRUE. Setting a larger value for this property means that
information will be update less frequently, thereby consuming less of the controller’s
processing resources. A small value will provide for more frequent updates, but consume more
processing time. Valid values for this property are from 10 to 65536.
Inputs ( brick ) The Inputs property returns a long value representing the current state of the inputs for the
specified brick. The brick argument can be a number from 0 to 3. Brick 0 represents the
onboard inputs. Brick 1-3 represent expanded I/O input bricks 1-3.
Chapter 2. Communication 39
IPAddress The IPAddress property returns long value representing controllers IP Address (NTADDR).
Limits The Limits property returns a long value representing the current limit status (TLIM).
MotorPos ( axis ) The MotorPos property returns a long value representing the current commanded position
(TPC) in counts for the specified axis. The axis argument can be a number from 1 to 8.
MotorVel ( axis ) The MotorVel property, returns a long value representing the current motor velocity (TVEL) in
counts/sec for the specified axis. The axis argument can be a number from 1 to 8.
Outputs ( brick ) The Outputs property, returns a long value representing the current state of the outputs for the
specified brick. The brick argument can be a number from 0 to 3. Brick 0 represents the
onboard outputs. Brick 1-3 represent expanded I/O input bricks 1-3.
Status The Status property indicates the status of the Ethernet connection:
0......... Closed
1......... Open
2......... Listening
3......... Connection Pending
4......... Resolving Host
5......... Host Resolved
6......... Connecting
7......... Connected
8......... Closing
9......... Error
While the Connect method and the Disconnect method are under program control, the
connection could be lost/broken (e.g., disconnected Ethernet cable or a network failure). If the
connection is lost/broken, the Status property will be change.
SystemStatus The SystemStatus property returns a long value representing the system status (SS) for task 0.
Timer The Timer property returns a long value representing the current limit Timer value (TTIM) for
task 0.
Triggers The Triggers property returns a long value representing the current state of the on board
triggers.
UserStatus The UserStatus property returns a long value representing the current state of the user status
(TUS).
VarB ( n ) The VarB property, returns a long value representing the value of the specified binary variable
(VARB). The integer argument, n, can be a number from 1 to 10
VarI ( n ) The VarI property, returns a long value representing the value of the specified integer variable
(VARI). The integer argument, n, can be a number from 1 to 10.
In this section:
• Controlling Multiple Serial Ports
• RS-232 Daisy Chaining
• RS-485 Multi-Drop
XON/XOFF
The XONOFF command was created to enable or disable XON/XOFF ASCII handshaking.
(XONOFF1 enables XON/XOFF, XONOFFØ disables XON/XOFF) Defaults: XONOFF1 for the
COM1 port, XONOFFØ for the COM2 port.
Controllers on a multi-drop do not support XON/XOFF; to ensure that XON/XOFF is
disabled for COM2, send the PORT2 command followed by the XONOFFØ command.
Configuring the To control the applicable port for setting up serial communication and transmitting ASCII text
COM Port strings, use the PORT command. PORT1 selects COM1 and PORT2 selects COM2.
• Serial communication setup commands (see list below) affect the COM port selected
with the last PORT command. For example, to configure the COM2 port for 6K
language commands only (e.g., to communicate to the 6K product over an RS-485
interface), execute the PORT2 command, then execute the DRPCHKØ command.
DRPCHK ........ RP240 Check
E.................... Enable Serial Communication
ECHO............. Enable Communication Echo
BOT ............... Beginning of Transmission Characters
BAUD............. Serial Communication Baud Rate
EOT ............... End of Transmission Characters
EOL ............... End of Line Terminating Characters
ERRBAD ........ Error Prompt
ERRDEF ........ Program Definition Prompt
ERRLVL ........ Error Detection Level
ERRORK ........ Good Prompt
XONOFF ........ Enable or disable XON/XOFF
• The PORT command also selects the COM port through which the WRITE and READ
commands transmit ASCII text strings. If an RP240 is connected, the DWRITE
command (and all other RP240 commands) will affect the RP240 regardless of the
PORT command setting. If no RP240 is detected, the commands are sent to the COM2
port. DWRITE text strings are always terminated with a carriage return.
Chapter 2. Communication 41
Setup for 6K To configure the COM ports for use with 6K language commands or an RP240, use the
Language or RP240 DRPCHK command. The DRPCHK command affects the COM port selected with the last PORT
command. The default for COM1 is DRPCHKØ; the default for COM2 is DRPCHK3. The
DRPCHK setting is automatically saved in non-volatile memory. NOTE: Only one COM port
may be set to DRPCHK2 or DRPCHK3 at any given time.
DRPCHKØ...... Use the COM port for 6K language commands only. This is the default
setting for COM1, and if using RS-485 half duplex on COM2. Power-up
messages appear on all ports set to DRPCHKØ.
DRPCHK1...... Check for the presence of an RP240 at power-up/reset. If an RP240 is
present, initialize the RP240. If an RP240 is not present, use the port only
for 6K language commands. NOTE: RP240 commands will be sent at
power-up and reset.
DRPCHK2...... Check for the presence of an RP240 every 5-6 seconds. If an RP240 is
plugged in, initialize the RP240.
DRPCHK3...... Check for the presence of an RP240 at power-up/reset. If an RP240 is
present, the initialize the RP240. If an RP240 is not present, use the COM
port for DWRITE commands only, and ignore received characters. This is
the default setting for COM2, unless you are using RS-485 multi-drop
communication (in which case the default changes to DRPCHKØ).
Selecting a To define the port (COM port) through which the 6K product sends its responses, you have 3
Destination Port for options:
Transmitting from
the Controller • Do nothing different. The response will be sent to the COM port through which the
request was made. If the command is in a stored program, the report will be sent to the
COM port selected by the most recent PORT command.
• Prefix the command with [. This causes the response to be sent to both COM ports.
(e.g., the [TFS command response will be sent through both COM ports)
• Prefix the command with ]. This causes the response to be sent to the alternative COM
port. For example, if a report back (e.g., ]TAS) is requested from COM1, the response
is sent through COM2. If the command is in a stored program, the report will be sent
out the alternate port from the one selected by the most recent PORT command.
RS-232C Daisy-Chaining
Up to ninety-nine stand-alone 6K Series products may be daisy-chained. There are two
methods of daisy-chaining: one uses a computer or terminal as the controller in the chain; the
other uses one 6K product as the master controller. Refer to you product’s Installation Guide
for daisy-chain connections.
Follow these steps to implement daisy-chaining:
Step 1 To enable and disable communications on a particular controller unit in the chain, you must use
the Daisy-Chain Address (ADDR) command to establish a unique device address for each the
unit. The ADDR command automatically configures unit addresses for daisy chaining. This
command allows up to 99 units on a daisy chain to be uniquely addressed.
Sending ADDRi to the first unit in the daisy chain sets its address to be (i). The first unit in turn
transmits ADDR(i + 1) to the next unit to set its address to (i + 1). This continues down the
daisy chain until the last unit of (n) daisy-chained units has its address set to (i + n).
Note that a controller with the default device address of zero (0) will send an initial power-up
Step 2 Connect the daisy-chain with a terminal as the master (see diagram in the product’s Installation
Guide).
It is necessary to have the error level set to 1 for all units on the daisy-chain (ERRLVL1).
When the error level is not set to 1, the controller sends ERROK or ERRBAD prompts after
each command, which makes daisy-chaining impossible. Send the ERRLVL1 command to
each unit in the chain. (NOTE: To send a the ERRLVL1 command to one specific unit on the
chain, prefix the command with the appropriate unit's device address and an underline.)
Commands:
1_ERRLVL1 ; Set error level to 1 for unit #1
2_ERRLVL1 ; Set error level to 1 for unit #2
3_ERRLVL1 ; Set error level to 1 for unit #3
After this has been accomplished, a carriage return sent from the terminal will not cause any
controller to send a prompt. Verify this. Instructions below (step 3) show how to set the error
level to 1 automatically on power-up by using the controller's power-up start program (highly
recommended).
After the error level for all units has been set to ERRLVL1, send a 6K series command to all
units on the daisy-chain by entering that command from the master terminal.
Commands:
OUT1111 ; Turn on onboard outputs 1-4 on all units
A50,50 ; Set accel to 50 (all units, axes 1 & 2)
To send a 6K series command to one particular unit on the chain, prefix the command with the
appropriate unit's device address and an underline:
Commands:
2_OUT0 ; Turn off onboard output 1 on unit #2
4_OUT0 ; Turn off onboard output 1 on unit #4
To receive data from a particular controller on the chain, you must prefix the command with
the appropriate unit's device address and an underline:
Commands:
1_A ; Request acceleration information from unit #1
*A50,50 ; Response from unit #1
Use the E command to enable/disable RS-232C communications for an individual unit. If all
6K controller units on the daisy chain are enabled, commands without a device address
identifier will be executed by all units. Because of the daisy-chain's serial nature, the
commands will be executed approximately 1 ms per character later on each successive unit in
the chain (assuming 9600 baud).
Units with the RS-232C disabled (EØ) will not respond to any commands, except E1;
however, characters are still echoed to the next device in the daisy chain.
Commands:
3_E0 ; Disable RS-232C on unit #3
VAR1=1 ; Set variable #1 to 1 on all other units
3_E1 ; Enable RS-232C on unit #3
3_VAR1=5 ; Set variable #1 to 5 on unit #3
Step 3 Now that communication is established, programming of the units can begin (alternatively,
units can be programmed individually by connecting the master terminal to one unit at a time).
To allow daisy-chaining between multiple controllers, the ERRLVL1 command must be used to
prevent units from sending error messages and command prompts. In every daisy-chained unit,
Chapter 2. Communication 43
the ERRLVL1 command should be placed in the program that is defined as the STARTP
program:
Program:
DEF chain ; Begin definition of program chain
ERRLVL1 ; Set error level to 1
GOTO main ; Go to program main
END ; End definition of program chain
STARTP chain ; Designates program chain as the power-up program
To define program main for unit #0:
Program:
0_DEF main ; Begin definition of program main on unit #0
0_GO ; Start motion
0_END ; End definition of program main on unit #0
Step 4 After all programming is completed, program execution may be controlled by either a master
terminal, or by a 6K Series controller used as a master.
Daisy-Chaining Controlling the daisy-chain from a master computer or terminal follows the examples above:
from a Computer or
Commands:
Terminal 0_RUN main ; Run program main on unit #0
1_RUN main ; Run program main on unit #1
2_GO1 ; Start motion on unit #2 axis #1
3_2A ; Get A command response from unit #3 axis #2
Daisy-Chaining Controlling the daisy-chain from a master 6K controller (the first unit on the daisy-chain)
from a Master 6K requires the programs stored in the master controller to control program and command
Controller execution on the slave controllers. The example below demonstrates the use of the WRITE
command to send commands to other units on the daisy chain.
NOTE
The last unit on the daisy-chain must have RS-232C echo disabled (ECHOØ command).
RS-485 Multi-Drop
Up to 99 6K Series products may be multi-dropped. Refer to your product's Installation
Guide for multi-drop connections.
To establish device addresses, using the ADDR command:
The ADDR command allows you to establish up to 99 unique addresses. To use the ADDR
command, you must address each unit individually before it is connected on the multi
drop. For example, given that each product is shipped configured with address zero, you
could set up a 4-unit multi-drop with the commands below, and then connect them in a
multi drop:
1. Connect the unit that is to be unit #1 and transmit the Ø_ADDR1 command to it.
2. Connect the unit that is to be unit #2 and transmit the Ø_ADDR2 command to it.
3. Connect the unit that is to be unit #3 and transmit the Ø_ADDR3 command to it.
4. Connect the unit that is to be unit #4 and transmit the Ø_ADDR4 command to it.
If you need to replace a unit in the multi drop, send the Ø_ADDRi command to it, where
"i" is the address you wish the new unit to have.
To send a 6K command from the master unit to a specific unit in the multi-drop, prefix the
command with the unit address and an underscore (e.g., 3_OUTØ turns off output #1 on unit
#3). The master unit (if it is not a 6K product) may receive data from a multi-drop unit.
The ECHO command was enhanced with options 2 and 3. The purpose is to accommodate an
RS-485 multi-drop configuration in which a host computer communicates to the “master” 6K
controller over RS-232 (COM1 port) and the master 6K controller communicates over RS-485
(COM2 port) to the rest of the units on the multi-drop. For this configuration, the echo setup
should be configured by sending to the master the following commands executed in the order
shown. In this example, it is assumed that the master's device address is set to 1. Hence, each
command is prefixed with “1_” to address only the master unit.
Chapter 2. Communication 45
1_PORT2............Subsequent command affects COM2, the RS-485 port
1_ECHO2............Echo characters back through the other port, COM1
1_PORT1............Subsequent command affects COM1, the RS-232 port
1_ECHO3............Echo characters back through both ports, COM1 and COM2
NOTE
Controllers on a multi-drop do not support XON/XOFF. To ensure that XON/XOFF is disabled
for COM2, send the PORT2 command followed by the XONOFFØ command.