$VERSION V1.0
$DRIVE UNIDRIVE
$define PITCH% #18.11
$define CIRCUMFERENCE% #18.12
$define CUT_DIST% #18.13
$define MOTOR_ENC_COUNTS% 16384
$define LINE_ENC_COUNTS% #18.14
$define LINE_CIRCUMFERENCE% #18.15
$define GEAR_RATIO% #18.16
$define RE_CALC% #18.31
INITIAL{
; Generate Mod_Sin Array (scaled)
;assign memory space for cam table arrays
DIM sin_array[100]
DIM line%[101]
DIM knife%[101]
;reset program variables
tmr1%=0
sum1=0
sum2=0
index%=0
ang=3.141592654/50
;Create an array with 100 points describing a modified sin
wave
DO
s=sin(ang*index%)
sum1=sum1+s
sin_array[index%]=s1
sum2=sum2+s1
index%=index%+1
LOOP WHILE index%<100
index%=0
;scale the mod_sin array so the total distance moved under
the curve is 1.
Do
sin_array[index%]=sin_array[index%]/s2
index%=index%+1
LOOP WHILE index%<100
;initialise the cam table
result%=CAMINIT(line%,knife%,101,0,0)
;control registers
_Q32%=0
;Reset Control Registers
_Q20%=0
;unidrive set-up parameters
#01.10=1
;Enable Bipolar speed ref.
#01.14=3
;Select Preset Speed reference.
#01.15=1
;Select Preset Speed #1.
#2.02=0
;Disable Speed Ramps
;position loop set-up parameters
_Q20%.1=1
;Enable Q4 as the PID loop reference
_Q20%.6=1
;Enable automatic writing of #91.02
#91.01=3
;Enable the use of #91.2 fast write to Preset
Speed #1.
#91.05=1500
;Set the maximum resolution speed in rpm of
#91.02
}
BACKGROUND{
top:
;calculate adjustments required for the rotary knife to cut in
the required place
line_scale%=LINE_ENC_COUNTS%/LINE_CIRCUMFERENCE
%
knife_scale%=MOTOR_ENC_COUNTS%*GEAR_RATIO%/CIR
CUMFERENCE%
catch_up_length%=(CIRCUMFERENCE%-PITCH%-
CUT_DIST%)*knife_scale%
pitch_increment_line%=(PITCH%-
CUT_DIST%)*line_scale%/100
pitch_increment_knife%=(PITCH%-
CUT_DIST%)*knife_scale%/100
;calculate the Cam table points to describe the required
motion
IF RE_CALC%=1 THEN
index%=0
Do
line%[index%]=pitch_increment_line%
knife%[index%]=INT(sin_array[index%]*catch_up_length%) +
pitch_increment_knife%
index%=index%+1
LOOP WHILE index%<100
line%[100]=CUT_DIST%
knife%[100]=CUT_DIST%
RE_CALC%=0
ENDIF
;Set the speed of the virtual axis for test purposes
v_master%=#18.20
goto top: // main background loop
}
SPEED{
;Increment the c/ required for the virtual master speed.
_Q1%=_Q1%+v_master%
}
options
Rotary Knife
(Example of DPL Code)
52