Program Examples:Create Motion:CAM Table
Revision as of 11:39, 22 July 2015 by Nigeller (talk | contribs) (Created page with "The following example demonstrates how to create and use a CAM table.<br/> Refer to Axis Setup Procedure for an explanation and an example of how to s...")
The following example demonstrates how to create and use a CAM table.
Refer to Axis Setup Procedure for an explanation and an example of how to set up an axis.
'**********************************************************************************************************
' File: CAM_MOVE.PRG
' Purpose: Move two axes with CAM table and master-slave
' Version: 1.00
' Author: Nir Geller
' Description: This is an example of use of a CAM table. Initialize a CAM table with a sinus function character,
' and set master - slave relations between two axes. Move the master axis and see how the slave axis
' follows according to the cam table.
'
' Record or watch the PFB of AX_MASTER and AX_SLAVE.
'
'**********************************************************************************************************
'Declaring a cam-table type global variable:
common shared CamTable1 as cam
program
call SetCAM
attach AX_MASTER
attach AX_SLAVE
'call EC_SET_MOTION_OPMODE(AX_MASTER, POSITIONMODE)
AX_MASTER.en=1
sleep 1000
while 1
MOVE AX_MASTER 1000 vcruise=1000 starttype=immediate abs = 1
while AX_MASTER.IsMoving <> 0
sleep 1000
end while
MOVE AX_MASTER 0 vcruise=1000 starttype=immediate abs = 1
while AX_MASTER.IsMoving <> 0
sleep 1000
end while
end while
detach AX_MASTER
detach AX_SLAVE
end program
'****************************************************************************
' Subroutine Name: SetCAM
' Description: Initialize a CAM table with a sinus function character, and set
' master - slave relations between two axes.
' Called From: Program
' Author: Nir Geller
' Input Parameters: None
' Output Parameters: None
' Return Value: None
' Algorithm:
' Global Variables Used:
' Revisions:
'****************************************************************************
sub SetCAM
dim camsize as long = 10000
dim cam_amplitude as long = 100
dim i as long = 0
'Creating an empty cam table:
'This table is cyclic:
CamTable1.Cycle = -1
'Not linked to any other cam-tables:
CamTable1.Next = none
CamTable1.Prev = none
'Making it 10000 points
createcamdata camsize CamTable1
'Defining a 360 deg sine table:
for i = 1 to CamTable1.Size
CamTable1.MasterData [i] = 360*(i-1)/CamTable1.Size ' Master in degrees
CamTable1.SlaveData [i] = cam_amplitude *sin (CamTable1.MasterData [i] * pi/180)
next
'Store the newly created file onto flash disk:
storecamdata ct1.cam CamTable1
'Once the table is stored on the flash it can be reloaded as:
'loadcamdata ct1.cam CamTable1
print "CAM table set"
attach AX_MASTER
attach AX_SLAVE
AX_SLAVE.MasterSource = AX_MASTER.PCMD
AX_SLAVE.GearRatio = 1.0
AX_SLAVE.CamOffset = 0
AX_SLAVE.FirstCam = CamTable1
AX_SLAVE.slave = cam
detach AX_MASTER
detach AX_SLAVE
print "Master-Slave relation set"
end sub
The example corresponds to commit SHA-1: 6b843ca272c3e3d28d36d7116ba9812f4166d97f in GIT.