Example Program

Analog slew with stall detection

Description

This program will use the analog input reading to ram the velocity until the motor stalls. When the stall occurs, an error is generated.

A subroutine is triggered by the error to: Print the Error number and stalled sate of the motor,

The code shown on the right may be copied and pasted into the program editor window of the Motion Control Programmer application, or a zip file containing the program files may be downloaded below.

Topics

  • Closed Loop/Encoder
  • MCode OS

Applicable Product

  • Lexium MDrive
  • MDrive Linear Actuator
  • MDrive Plus

Resource Files

Ee=1 Sf=30 '[PROGRAMS] 'Main program will assign 'a register to do math on 'the value of the analog 'input and slew the register 'value. An on-error event 'calls a subroutine to register 'stall PG 1 LB Su OE X1 Er=0 R1=I5 R1=R1*50 SL R1 PR V H 250 BR Su E '[SUBROUTINES] 'on error routine LB X1 PR "Error! " Er LB Y1 BR Y2,Er <> 86 PR "Stall" LB Y2 Er=0 E PG ' End of Program S 'Keep this line to save program on load
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'LEXIUM MDRIVE DEMO PROGRAM
'Last modified 02/21/2013
'Sample test program for demontsration purposes only
'Not tested or verified for safety or any function
 
'[VARIABLES]
Ee=1
Sf=30
 
'[PROGRAMS]
'Main program will assign
'a register to do math on
'the value of the analog
'input and slew the register
'value. An on-error event
'calls a subroutine to register
'stall
PG 1
  LB Su
    OE X1
    Er=0
    R1=I5
    R1=R1*50
    SL R1
    PR V
    H 250
    BR Su
  E
 
'[SUBROUTINES]
'on error routine
LB X1
  PR "Error! " Er
  LB Y1
    BR Y2,Er <> 86
    PR "Stall"
  LB Y2
    Er=0
    E
  PG                    ' End of Program
S
'Keep this line to save program on load