Example Program

Position teach

Description

This program allows the user to “teach” the product a +/- move profile based on manually positioning the motor shaft. The shaft is manually moved to a position, then an input is toggled to store that position in encoder counts to a user variable. The shaft is moved to second position, the input is again toggled to store the second position in a second variable. The motor will then move between the two stored positions.

Note that the input settings are undefined in the program, as the default settings are used.

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

VA Q1 = 0 VA Q2 = 0 D1 = 255 D2 = 255 'encoder enabled Ee=1 '[PROGRAMS] 'Program stores a +/- move p 'profile based on encoder counts 'set by manually positioning 'the motor shaft. An input 'toggle stores the encoder 'counts to a user variable. PG 1 LB Su Er = 0 C2=0 Q1 = 0 O2 = 0 PR "Move motor to position 1" PR "Toggle switch 1 when ready" LB X1 BR X1, I1 = 0 Q1 = C2 PR Q1 LB X2 BR X2, I1 = 1 PR "Move motor to position 2" PR "Toggle switch 1 when ready" LB X3 BR X3, I1 = 0 Q2 = C2 PR Q2 LB X4 BR X4,I1=1 PR "Toggle Sw 2 to start cycle" LB X5 BR X5, I2 = 0 LB X6 MA Q1 H PR P H 250 MA Q2 H PR P H 250 BR X5 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'LEXIUM MDRIVE DEMO PROGRAM
'Last modified 02/21/2016
'Sample test program for demonstration purposes only
'Not tested or verified for safety or any function
CP  'preclear program space
 
'[VARIABLES]
VA Q1 = 0
VA Q2 = 0
D1 = 255
D2 = 255
 
'encoder enabled
Ee=1
 
'[PROGRAMS]
'Program stores a +/- move p
'profile based on encoder counts
'set by manually positioning
'the motor shaft. An input
'toggle stores the encoder
'counts to a user variable.
PG 1
  LB Su
    Er = 0
    C2=0
    Q1 = 0
    O2 = 0
    PR "Move motor to position 1"
    PR "Toggle switch 1 when ready"
  LB X1
    BR X1, I1 = 0
    Q1 = C2
    PR Q1
  LB X2
    BR X2, I1 = 1
    PR "Move motor to position 2"
    PR "Toggle switch 1 when ready"
  LB X3
    BR X3, I1 = 0
    Q2 = C2
    PR Q2
  LB X4
    BR X4,I1=1
    PR "Toggle Sw 2 to start cycle"
  LB X5
    BR X5, I2 = 0
  LB X6
    MA Q1
    H
    PR P
    H 250
    MA Q2
    H
    PR P
    H 250
    BR X5
  E
PG                    ' End of Program
S
'Keep this line to save program on load