Back to top

AKD Basic Sample Program with Modbus Interrupt

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

'-------------- Define (dim) Global Variables --------
Dim slowtrigger as integer
Dim fasttrigger as integer
Dim originaltrigger as integer
Dim endprogramtrigger as integer
MBInfo
$MBMap32(5000, slowtrigger)
$MBMap32(5002, fasttrigger)
$MBMap32(5004, originaltrigger)
$MBMap32(5006, endprogramtrigger)
End
'-------------- Main Program -------------------------
Main 
    INTR.MODBUS = 1
    endprogramtrigger = 0
    MOVE.ACC = 10000
    MOVE.DEC = 10000
    MOVE.RUNSPEED = 10
    MOVE.GOVEL 
    While endprogramtrigger = 0
    Wend
    DRV.STOP
End Main

Interrupt MODBUS 
    If slowtrigger = 1 Then
        MOVE.RUNSPEED = 100
        MOVE.GOVEL 
        slowtrigger = 0
    End If
    If fasttrigger = 1 Then
        MOVE.RUNSPEED = 500
        MOVE.GOVEL
        fasttrigger = 0
    End If
    If originaltrigger = 1 Then
        MOVE.RUNSPEED = 10
        MOVE.GOVEL
        originaltrigger = 0
    End If
    INTR.MODBUS = 1
End Interrupt