Skip to main content

Kollmorgen Support Network

AKD Basic Position Move Using Modbus | 23 Oct 2015 | |

AKD Basic Position Move Using Modbus

Modbus TCP is made easy in the AKD Basic drive with the use of "User Defined" Modbus registers.  These are the 5000 series Modbus address numbers.  The registers are defined in the Basic program and mapped to variables.  You can then read/write the values of these variables over Modbus.

Here is a sample program using user defined Modbus registers to set the target position, speed, and start the move.

'-------------- Device Params -----------------------
Params
End Params

'-------------- Define (dim) Global Variables --------
Dim startbutton as integer
Dim targetposition as integer
Dim speed1 as integer
Dim accel as integer
Dim decel as integer

MBInfo 'map variables to user defined Modbus registers
$MBMap32(5000, targetposition) 'Modbus registers 5000 and 5001 for targetposition, 32bit
$MBMap16(5002, startbutton) 'Modbus register 5002 for start, 16bit
$MBMap32(5003, speed1) 'Modbus registers 5003 and 5004 for speed1, 32bit
End
'-------------- Main Program -------------------------
Main
DRV.SWENABLE = 0 'turn off software enable
startbutton = 0 'initial startbutton value=0

'Set default values
targetposition = 1000 'distance in user units
speed1 = 200 'speed of move to targetposition, in user units
accel = 1000 'acceleration of move to targetposition, in user units
decel = 1000 'deceleration of move to targetposition, in user units

Move.Acc = accel  ' Acceleration (drive units)
Move.Dec = decel  ' Deceleration (drive units)

DRV.SWENABLE = 1 'turn on software enable

While DRV.ACTIVE = 0 : Wend 'wait for hardware and software enable

While 1 = 1 'start continuous loop

While DRV.HWENABLE = 0  : Wend 'wait for hardware enable to be active
While startbutton = 0 : Wend 'wait for startbutton command over Modbus
Move.RunSpeed = speed1
Move.TargetPos = targetposition
Move.GoAbs
'Print "moving"
While MOVE.MOVING = 1 : Wend 'wait for move to complete
'Print "finished moving"
startbutton = 0 'reset start trigger

Wend 'loop back to While 1=1
End Main

'-------------- Subroutines and Functions ------------

'-------------- Interrupt Routines -------------------

About this Article

jcoleman02