Applied Motion RS-232 User Manual

Page 309

Advertising
background image

309

920-0002 Rev. I

2/2013

Host Command Reference

Communicating with a Q Program While It’s Running

You can use Type 2 commands to read and write registers while a Q program is running. The Q program

can send information to the host by changing a register that the host is polling. Registers 0 - 9 can be polled
using the Type 2 User Register Read command (opcode 9A).

The host can make changes to the Q program operation by writing to parameters that the program uses. For

example, you could change the motor speed sending a parameter write message that alters VE (Type 2 message,
opcode 83, operand 1D). The speed change will take effect on the next move.

Changes that affect a Q program immediately can be made using the Write Q Register command (message

type 2, opcode 9E). For example, if the motor is jogging after having been sent a CJ command, writing to register
J will result in an immediate speed change. Please note that Q register writes are not range checked, so be
careful before you write.

How to Know if a Q Program Has Stopped

Since a Q program can be launched and allowed to stop itself when it encounters a blank line, you may want

to know when it stops. You can do this by polling for the status word and observing bit 14. This bit is a one if the
program is executing. To fetch the status word, use the Type 2 Parameter Read command with operand 0x80 as
shown below.

Example: Checking Status While a Q Program is Running

opcode

0x84 parameter read, from Table 2

operand 0x80 status code, from Table 3

Type 2 Command Message Payload

Type 2 Response Message Payload

byte 0

0

reserved

byte 0

0

reserved

byte 1

2

message type

byte 1

2

message type

byte 2

84

opcode

byte 2

84

opcode

byte 3

80

operand

byte 3

80

operand

byte 4

0

not used

byte 4

?

status code MSB

byte 5

0

not used

byte 5

?

status code LSB

byte 6

0

not used

byte 6

0

not used

byte 7

0

not used

byte 7

0

not used

Typical return values:
0001

Motor enabled, Q program not running

4001

Motor enabled, Q program running

4801

Motor enabled, Q running, Wait Time command executing

4019

Motor enabled, motor moving, Q running

For more information about the status code, please read about the SC command in the main part of this

manual.

Advertising
This manual is related to the following products: