Functions to make timed position ramps and dwells. For example as might be used in a blow moulding controller.
' Function library to support timed ramps
'
'Declare a universal value to hold the table index
DIM tab_index AS INTEGER
' Set up a linear TABLE
FUNCTION set_tab(index AS INTEGER, local_units AS FLOAT)
DIM i, c AS INTEGER
c = 0
FOR i = index TO index + 10
TABLE(i, c * local_units / 10)
c = c + 1
NEXT i
tab_index = index
ENDFUNC
FUNCTION print_index()
PRINT #0, tab_index
ENDFUNC
FUNCTION move_time(target_dist, ramp_time AS FLOAT)
SPEED = 100 / ramp_time
ACC(SPEED * 1000)
CAM(tab_index, tab_index + 10, target_dist, 100)
ENDFUNC
FUNCTION dwell(d_time AS FLOAT)
WA(d_time * 1000000 / SERVO_PERIOD)
ENDFUNC
Example program:
' For blow moulding applications, a sequnce is needed that ramps up an axis over a period of time
' then applies a delay before doing another ramp at a different set rate.
' The sequence is as follows:
' move_time(target_position1, ramp_time1)
' dwell(dwell_time1)
' move_time(target_position2, ramp_time2)
' dwell(dwell_time2)
' move_time(target_position3, ramp_time3)
' dwell(dwell_time3)
' The TrioBASIC command that fits a change in position over a set time is CAM.
' With a linear ramp in the TABLE, it will represent a move over time.
' setup the axis
BASE(10)
UNITS = 50
SERVO = ON
WDOG = ON
DEFPOS(0)
set_tab(100, UNITS)
TRIGGER ' start the scope
move_time(100, 2.5)
WAIT IDLE
dwell(1)
move_time(50, 3.25)
WAIT IDLE
dwell(1.5)
move_time(50, 2.0)
WAIT IDLE
dwell(1.5)
move_time(-200, 5.0)
WAIT IDLE