AKD Basic Analogue Velocity Control
Does anyone have a sample program or a snipet of code for the AKD Basic to control the velocity with the analogue input? Thanks for the help.
Comments & Answers
you can have an example code
I have take it run successfully in the pdmm, you can try it
Below two snippets out of a
I didn't copy the whole declarations and all the other stuff because it would be to complex.
The AKD BASIC operate in position mode and the move function is used.
I compared the current analog input value with a buffered old one.
If the value is bigger than a constant (dead zone, in order to avoid oscillating) I calculate a new velocity value and determine the direction in a subroutine.
Afterwards the move parameters will be updated with new velocity value and direction.
Of course the other move parameters needs to be initialized or updated each time as well.
'******************************************************************************
Case 30 'velocity mode
If (DIN1.STATE = 0) Then 'disable velocity mode
MOVE.ABORT
State = 39
'new velocity value
Elseif (ABS(AIN.VALUE-AINValueOld) > c_AINSTEP) Then
Call VelocityParameter
MOVE.RUNSPEED = ABS(AINSpeed)
MOVE.DIR = AINDir
MOVE.GOVEL
End If
'******************************************************************************
Sub VelocityParameter
If (ABS(AIN.VALUE) > c_AINSTEP) Then 'calculate speed depending on analog input value
AINSpeed = AIN.VALUE * c_VSCALE
Else 'Deadzone
AINSpeed = 0.0
End If
If (AINSpeed < 0) Then 'check for direction
AINDir = 1
Else
AINDir = 0
end if
AINValueOld = AIN.VALUE
End Sub
'******************************************************************************