Programming Tutorial for Camera Guided Laser Marking

Below is the sample program for the laser marking application using  a Class 5 SmartMotor.  For this application, FireTag used the two features in Class 5: interrupt and soft limit trigger without fault. Neither of these features are not available with Class 4.  We used the soft limit to tell the set the position mark as to where to fire the laser tag.  When the position is reached, the soft limit will set a status bit which caused the interrupt to output the trigger a laser fire, then update the next position mark for the next fire.  In the sample program, the label C10 is the routine that sets up the interrupt and C0 is the routine that does the output.

'sample program output I/O while in motion using soft limit interrupt trigger

ADDR=1          'set motor address
ECHO            'set echo on

EIGN(W,0,127)   'configure all I/Os as general input
ZS              'reset status bits

SLM(0)          'configure soft limit not to fault when triggered.


'list of variables used
a=0           'extract offset position
b=0           '# of encoder count increment
c=0           '# of index
i=0           'index counter
j=536870912   'value of the 30th bit to mask
k=16777215    'value of the first 24bits.

PAUSE         'pause program to wait for GOSUB() command to use interrupt


C10 'interrupt to start motion
a=al[i]&k         'extract value of offset and store into a
PT=a              'set this as final position if no firing is required
IF (al[i]&j)==j   'check if 30th bit is set for firing
i=i+1         'increment array to ready next value
b=al[i]       'increment position
i=i+1         'increment array to ready next value
c=al[i]       'number of fires
IF b<0        'check if increment is neg or pos to determine direction of motion
SLN=a           'set neg soft limit
SLP=1000000000  'set pos soft limit to be a big number
ITR(0,1,13,1,0) 'enable neg limit interrupt on neg direction
SLN=-500        'set neg soft to a smaller number
SLP=a           'set pos soft limit
ITR(0,1,12,1,0) 'enable pos limit interrupt on pos direction
SLE               'enable software limit
EITR(0)           'enable interrupt
ITRE              'enable global interrupt
PT=a+b*c          'calculate final target position base on initial first position and number of fires
G           'start motion
TWAIT       'wait for motion to end
i=i+1       'increment array
DITR(0)     'disable interrupt
SLD         'disable software limit
ZS          'reset status bits


C0 'interrupt
IF SLP<PT   'check if this the last point
OR(4)     'output I/O A to low
ELSE        'if last point
WAIT=500  'have delay
OR(4)     'then output
SLP=SLP+b   'increment to next interrupt
ZS          'reset status bits
WAIT=200    'wait for 0.5 sec
OS(4)     'set output I/O A to high
RETURNI 'return

Newsletter Sign-up