Using Encoder Motor to Detect Stalled Condition

The following MicroLYNX sample program shows how to detect a stalled condition by using an encoder motor.

VAR Num                'declare variables
Msel=256               'set 256 microsteps/full step
Munit=51200            'set 51200 microsteps per revolution
                           'MUNIT=256*200=51200
Eunit=800              'set encoder counts to 800
                           'encoder counts = 4*encoder line count
Ee=1                   'enable encoder mode
Stlde=1                'enable stall detection
Stlf=.01               'stall factor. Stepper motors stall when 
                           'they lag behind by more than 2 full steps
                           '(2/200)=.01 revolution. Thus Stlf=0.01

Ios 13=3,0,0,0,1,0     'Encoder Channel A input (low true)
Ios 14=4,0,1,0,1,0     'Encoder channel B input (high true)
                           'logic levels vary depending on the 
                           'encoder and the direction of count.
                           '+ moves need a + count.

Ios 21=0,1,0,0,0,0     'set IO 21 as a general purpose output

VAR stalled=21         'declare global variable called "stalled"

Pgm 1                  'enter program mode at address 1
LBL startup            'label designation that executes on power up
Io stalled=0           'set IO 21 to 0 or off
ONER stuck             'On Error transfer execution to a sub routine
                           'called stuck. ONER acts as a call not a branch.
MOVR 1                     'move relative 1 revolution in the + direction
HOLD 2                     'hold program execution until move is complete
DELAY 500              'delay 500 milliseconds
BR startup             'branch to label startup and repeat program
END                    'end of program
Pgm                    'exit program mode

Pgm 100                'enter program mode at address 100
LBL stuck              'label referred to in the "ONER" command
Error=0                'set ERROR to 0 and clear error
Io stalled=1           'set IO 21 to 1 or on.
END                    'end of program. Clears sub routine stack
Pgm                    'exit program mode 

IMS Logo Wide

370 N. Main St., P.O. Box 457
Marlborough, CT 06447 U.S.A.
Phone: 860 / 295-6102
Fax: 860 / 295-6107
Email: info@imshome.com

Contact

TECHNICAL SUPPORT (U.S.A.)
Phone: 860 / 295-6102
Fax: 860 / 295-6107
E-mail: etech@imshome.com

IMS ASIA PACIFIC OFFICE
30 Raffles Pl., 23-00 Chevron House
Singapore 048622
Phone: +65 / 6233 / 6846
Fax: +65 / 6233 / 5044
E-mail: wllee@imshome.com

IMS EUROPEAN SALES MGT.
4 Quai Des Etroits
69005 Lyon, France
Phone: +33 / 4 7256 5113
Fax: +33 / 4 7838 1537
E-mail: bmartinez@imshome.com

IMS UK Ltd
.
25 Barnes Wallis Road
Segensworth East
Fareham, Hampshire, UK  PO15 5TT
Phone: +44 / 0 1489-889825
Fax:: +44 / 0 1489-889857
E-mail: mcheckley@imshome.com

U.S.A. SALES OFFICES
Eastern Region 

Phone: 973 / 661-1270
Fax: 973 / 661-1275
E-mail: jroake@imshome.com

Central Region
Phone: 260 / 402-6016
Fax: 419 / 858-0375
E-mail: dwaksman@imshome.com

Western Region
Phone: 602 / 578-7201
E-mail: dweisenberger@imshome.com