BASIC commands
PROGRAMMING MANUAL
48
R
e
vi
si
o
n
1
.0
fig. 6
/i
LASER
MOTOR
OP(15)
TRIGGER
Example
A masked wheel is used to create a stencil for a laser to shine through for use
in a printing system for the ten numerical digits. The required digits are trans-
mitted through port 1 serial port to the controller as ASCII text.
The encoder used has 4000 edges per revolution and so must move 400
between each position. The cam table goes from 0 to 1, which means that the
CAM
multiplier needs to be a multiple of 400 to move between the positions.
The wheel is required to move to the pre-set positions every 0.25 seconds.
The speed is set to 10000 edges/second, and we want the profile to be com-
plete in 0.25 seconds. So multiplying the axis speed by the required comple-
tion time (10000 x 0.25) gives the distance parameter equals 2500.
GOSUB profile_gen
WHILE IN(2)=ON
WAIT UNTIL KEY#1 'Waits for character on port 1
GET#1,k
IF k>47 AND k<58 THEN 'check for valid ASCII character
position=(k-48)*400 'convert to absolute position
multiplier=position-offset 'calculate relative movement
'check if it is shorter to move in reverse direction
IF multiplier>2000 THEN
multiplier=multiplier-4000
ELSEIF multiplier<-2000 THEN
multiplier=mul4000
ENDIF
CAM(0,200,multiplier,2500) 'set the CAM movment
WAIT IDLE
OP(15,ON) 'trigger the laser flash
WA(20)
OP(15,OFF)
offset=(k-48)*400 'calculates current absolute position
ENDIF
WEND
profile_gen:
num_p=201
scale=1.0
FOR p=0 TO num_p-1
TABLE(p,((-SIN(PI*2*p/num_p)/(PI*2))+p/num_p)*scale)
NEXT p
RETURN