AKD BASIC User Guide | 3 AKDBASICLanguage
call ActivateCam_2
CAMVM.GOVEL 'virtual master to run at
CAMVM.FREQ
While 1 : Wend
End Main
'-------------- Subroutines and Functions -----
-------
Sub CamCreate_2'This code creates a cam whose
profile is an exponentially damped sine wave.
dim m, s as float
dim i as integer
CAM.CREATE (2,501)
for i = 0 to NPOINTS-1
m = i * (MC / (NPOINTS-1))'master position
s = (1 / exp (1.5 * k * i)) * sin (2 * pi *
w * i)'computed slave position
CAM.ADDPOINT(m, 65536 * s)
Next i
End CAM.CREATE
End Sub
Sub ActivateCam_2
DRV.SWENABLE = 0 'Need to disable the drive
before changing positions
MOVE.POSCOMMAND = 0 'Zero out slave position
EXTENCODER.POSITION = 0 'Zero out real master
encoder position
CAMVM.POSITION = 0 'Zero out virtual master
encoder position
EXTENCODER.POSMODULO = MC 'Set master modulo
value
PL.MODPEN = 1 'Enable slave modulo
PL.MODP2 = 65536 'Set slave modulo value
DRV.SWENABLE = 1 'Enable drive
CAM.ACTIVATE = 2 'Start the cam
End Sub
3.11.6 Virtual encoder (virtual master)
The virtual encoder is an internal count generator that is used as the input to the cam. It is con-
trolled much like the profile generator used to control the motion of the motor. The Parameters
and statements associated with the virtual encoder are listed below:
CAMVM.DIR
CAMVM.FREQ
CAMVM.GOREL
CAMVM.GOUPDATE
CAMVM.GOVEL
CAMVM.MOVING
CAMVM.POSITION
Kollmorgenâ„¢ | March 30, 2012 46