4.3 Examples of command control from a PC
See the Command Reference for more examples.
On this Page
- Start and stop of jog move
- Position Move
- Obtain and clear counter value
- Homing Operation
- Linear interpolation operation
- Circular Interpolation Operation
- On-the-fly speed change
- Synchronization Function
- Control of general purpose input/output
Start and stop of jog move
Summary of operation
Set the speed of the X-axis movement and turn on excitation. After that, start the movement of the X axis in the negative direction. After a while, decelerate and stop the axis.
Program code
cmdStr = "LSPDX=500"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Starting speed of X-axis set to 500 pps
cmdStr = "HSPDX=5000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Moving speed of X-axis set to 5,000 pps
cmdStr = "ACCX=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Accel time of X-axis set to 200 ms
cmdStr = "DECX=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Decel time of X-axis set to 200 ms
cmdStr = "EO1=1"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Enable X-axis
cmdStr = "JX−"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Start moving in the (−) direction
cmdStr = "STOPX"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Decelerate and stop
Position Move
Summary of operation
Set the global moving speed and turn on the excitation of X and Y axes. Set positioning coordinates to absolute mode. Move the X axis to position −20,000 and Y axis to position 15,000.
Program code
cmdStr = "LSPD=500"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Starting speed set to 500 pps (Global)
cmdStr = "HSPD=5000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Moving speed set to 5,000 pps (Global)
cmdStr = "ACC=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Accel time set to 200 ms (Global)
cmdStr = "DEC=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Deceleration time set to 200 ms (Global)
cmdStr = "EO=3"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Enable X and Y-axis
cmdStr = "ABS"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Set position coordinate mode to Absolute
cmdStr = "X−20000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Start moving the X-axis to the position of −20,000
cmdStr = "Y15000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Start moving the Y-axis to the position of 15,000.
Obtain and clear counter value
Summary of operation
Read and display the command pulse and feedback pulse counter on the X-axis. The counter value can be cleared only when the axis is normally stopped (stopped without error). Read the counter value in a timer event.
Program code
cmdStr = "PX"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Obtain the command pulse counter value on X-axis
OutplsX.Text = replyStr ’Display the command pulse counter value
cmdStr = "EX"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Obtain the feedback pulse counter value on X-axis
FeedbackX.Text = replyStr ‘Display the feedback counter value
cmdStr = "MSTX"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Obtain the status value of X-axis
mStatusX.Text = replyStr ‘Display the status value for X-axis
Execute the above process repeatedly in the timer event
If mStatusX.Text = "0" Then ‘Does X-axis stop normally?
cmdStr = "PX=0"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’X-axis command pulse counter clear
cmdStr = "EX=0"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’X-axis feedback pulse counter clear
Homing Operation
Summary of operation
Set the Y-axis moving speed and enable axis. Then, start the Y-axis homing operation in the negative direction using homing mode 1.
Program Code
cmdStr = "LSPDY=500"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Starting speed of Y-axis set to 500 pps
cmdStr = "HSPDY=5000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Moving speed of Y-axis set to 5,000 pps
cmdStr = "ACCY=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Accel time of Y-axis set to 200 ms
cmdStr = "DECY=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Decel time of Y-axis set to 200 ms
cmdStr = "EO2=1"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Enable Y-axis
cmdStr = "HY−1"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Start the homing operation of Y-axis
Linear interpolation operation
Summary of operation
Set global moving speed and enable the X- and Y-axes. Set the positioning coordinate mode to absolute. Execute the linear interpolation operation, moving the X-axis to position −20,000 and the Y-axis to position 15,000.
Program code
cmdStr = "LSPD=500"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Starting speed set to 500 pps (Global)
cmdStr = "HSPD=5000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Moving speed set to 5,000 pps (Global)
cmdStr = "ACC=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Accel time set to 200 ms (Global)
cmdStr = "DEC=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Decel time set to 200 ms (Global)
cmdStr = "EO=3"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Enable X and Y-axes
cmdStr = "ABS"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Set position coordinate mode to absolute
cmdStr = "EINT=1"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Interpolation operation enabled
cmdStr = "X−20000Y15000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’ Start interpolation operation of X and Y axes
Circular Interpolation Operation
Summary of operation
Set global moving speed and enable the X and Y axes. Set positioning coordinate mode to absolute. Execute a circular interpolation move. The center coordinates of circle are (1000, 0) and the rotation direction clockwise.
Program code
cmdStr = "LSPD=500"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Starting speed set to 500 pps (Global)
cmdStr = "HSPD=5000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Moving speed set to 5,000 pps (Global)
cmdStr = "ACC=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Accel time set to 200 ms (Global)
cmdStr = "DEC=200"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Decel time set to 200 ms (Global)
cmdStr = "EO=3"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Enable X and Y axes
cmdStr = "ABS"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Set position coordinate mode to absolute
cmdStr = "EINT=1"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Interpolation operation enabled
cmdStr = "CIRXYP1000:0"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Start interpolation operation of X and Y axes
On-the-fly speed change
Summary of operation
Change the X-axis speed at 50,000 pps to 70,000 pps during motion.
Program code
cmdStr = "LSPDX=500"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Starting speed of X axis set to 500 pps
cmdStr = "HSPDX=50000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Moving speed of X axis set to 50,000 pps
---omitted steps---
cmdStr = "JX−"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Start moving in the − direction
cmdStr = "SSPDM=2"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Double the speed range
cmdStr = "SSPD=70000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Update speed to 70,000 pps
Synchronization Function
Summary of operation
When the X axis moves to position 5,000, turn on synchronization signal DO1/SYNCx.
Program code
cmdStr = "LSPDX=100"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Starting speed of X axis set to 100 pps
cmdStr = "HSPDX=1000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Moving speed of X axis set to 1,000 pps
---omitted steps---
cmdStr = "SYNCX=1"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Set X-axis sync condition
cmdStr = "SYNPX=5000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Set X-axis comparison data value to 5,000
cmdStr = "SYNO"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Sync output configuration enabled
cmdStr = "X5000"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ‘Move X axis to position 5,000
‘DO1/SYNCx will be on when movement is completed
Control of general purpose input/output
Summary of operation
Turn ON/OFF general-purpose output 19 in synchronization with general-purpose input 1.
Program code
cmdStr = "IOCFG=262144" ’Configure general-purpose IO19 to output all other IO to input
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr)
---omitted steps---
cmdStr = "IO1"
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr) ’Read status of general-purpose input 1
If replyStr = "1" Then
cmdStr = "IO19=1" ’It is ON
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr)
Else
cmdStr = "IO19=0” ’It is not ON
result = SendReceiveCommanderHID(devHandle, cmdStr, replyStr)
End If
Note: The state of the general-purpose input must be read repeatedly