Example Program

Multiple Position Trips

Description

Example program to show how to use multiple position trips within a program.

This program will index the motor, while printing the position and velocity at each trip point, then repeat. It illustrates defining multiple position trips within a single program.

Topics

  • MCode OS
  • Motion
  • Programmable I/O
  • Trips Functions

Applicable Product

  • Lexium MDrive
  • MDrive Linear Actuator
  • MDrive Plus
  • MForce

Resource Files

VA Sp=33*51200/60 'Step 1 speed 33 RPM * 51200 Stp/rev /60 s/m VA Ds=50000 'Length of first step. '[PROGRAMS] PG 1 R1=0 P=0 'set position counter to 0 LB Aa PR "" PR "Starting Step 1 P=",P," V=",V Tp Ds,X1 Te=2 Vm=Sp 'Step 1 speed 33 RPM * 51200 Stp/rev /60 s/m MA Ds*9,0,1 LB G1 BR G1,R1=0 R1=0 BR Aa E '[SUBROUTINES] 'Each sub will move a dist at a velocity 'then redefine and re-enable the trip 'Step 2 speed 66 RPM * 51200 Stp/rev /60 s/m LB X1 PR " Starting Step 2 P=",P," V=",V Vm= Sp*2 MA Ds*9,0,1 Tp Ds*3,X2 Te=2 RT 'Step 3 speed 100 RPM * 51200 Stp/rev /60 s/m LB X2 PR " Starting Step 3 P=",P," V=",V Vm= Sp*3 MA Ds*9,0,1 Tp Ds*6,X3 Te=2 RT 'Step 4 speed 66 RPM * 51200 Stp/rev /60 s/m LB X3 PR " Starting Step 4 P=",P," V=",V Vm= Sp*2 MA Ds*9,0,1 Tp Ds*8,X4 Te=2 RT 'Step 5 speed 33 RPM * 51200 Stp/rev /60 s/m LB X4 PR " Starting Step 5 P=",P," V=",V Vm= Sp MA Ds*9 ',0,1 Tp Ds*9,X5 Te=2 RT 'Step 6 speed 33 RPM * 51200 Stp/rev /60 s/m LB X5 PR " Starting Step 6 P=",P," V=",V Vm= Sp MA 0,0,1 Tp Ds*8,X6 Te=2 RT 'Step 7 speed 66 RPM * 51200 Stp/rev /60 s/m LB X6 PR " Starting Step 7 P=",P," V=",V Vm= Sp*2 MA 0,0,1 Tp Ds*6,X7 Te=2 RT 'Step 8 speed 100 RPM * 51200 Stp/rev /60 s/m LB X7 PR " Starting Step 8 P=",P," V=",V Vm= Sp*3 MA 0,0,1 Tp Ds*3,X8 Te=2 RT 'Step 9 speed 66 RPM * 51200 Stp/rev /60 s/m LB X8 PR " Starting Step 9 P=",P," V=",V Vm= Sp*2 MA 0,0,1 Tp Ds,X9 Te=2 RT 'Step 10 speed 33 RPM * 51200 Stp/rev /60 s/m LB X9 PR " Starting Step 10 P=",P," V=",V Vm= Sp MA 0 H PR " Back at Start P=",P," V=",V R1=1 RT PG S 'Keep this line.
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
'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
 
'Distance traveled is V * 12 sec.
' 33 RPM * 0.2 min =  6.6 revs. X 51200 uSteps =  337920 uStp.
' 66 RPM * 0.2 min = 13.2 revs. X 51200 uSteps =  675840 uStp.
'100 RPM * 0.2 min = 19.8 revs. X 51200 uSteps = 1013760 uStp.
' Slew Rate is V/60 * 51200 uSteps/sec.
' 33 RPM /60 Sec.  X 51200 uSteps =  28160 uStp./Sec.
' 66 RPM /60 Sec.  X 51200 uSteps =  56320 uStp./Sec.
'100 RPM /60 Sec.  X 51200 uSteps =  85333 uStp./Sec.
 
'Step 1  V=33RPM
'Step 2  V=66RPM
'Step 3  V=100RPM
'Step 4  V=66RPM
'Step 5  V=33RPM
'Step 6  V=-33RPM
'Step 7  V=-66RPM
'Step 8  V=-100RPM
'Step 9  V=-66RPM
'Step 10 V=-33RPM
 
'STEPS
'   1   2    3    4   5    6    7   8    9    10
'           ____
'      ____|    |____
'  ___|              |___
'_|______________________|______________________________Ds
'                        |___                ____|
'                            |____      ____|
'                                 |____|
 
 
'[VARIABLES]
VA Sp=33*51200/60 'Step 1 speed 33 RPM * 51200 Stp/rev /60 s/m
VA Ds=50000  'Length of first step.
 
'[PROGRAMS]
PG 1
  R1=0
  P=0       'set position counter to 0
  LB Aa
    PR ""
    PR "Starting Step 1   P=",P,"    V=",V
    Tp Ds,X1
    Te=2  
    Vm=Sp       'Step 1 speed 33 RPM * 51200 Stp/rev /60 s/m
    MA Ds*9,0,1
    LB G1
      BR G1,R1=0
      R1=0
      BR Aa
    E
  
'[SUBROUTINES]
'Each sub will move a dist at a velocity
'then redefine and re-enable the trip
 
'Step 2 speed 66 RPM * 51200 Stp/rev /60 s/m
  LB X1
    PR " Starting Step 2   P=",P,"   V=",V
    Vm= Sp*2    
    MA Ds*9,0,1
    Tp Ds*3,X2  
    Te=2      
    RT
 
'Step 3 speed 100 RPM * 51200 Stp/rev /60 s/m
  LB X2
    PR "  Starting Step 3   P=",P,"  V=",V
    Vm= Sp*3    
    MA Ds*9,0,1
    Tp  Ds*6,X3
    Te=2      
    RT
 
'Step 4 speed 66 RPM * 51200 Stp/rev /60 s/m
  LB X3
    PR "   Starting Step 4   P=",P,"  V=",V
    Vm= Sp*2    
    MA Ds*9,0,1
    Tp Ds*8,X4  
    Te=2
    RT
  
'Step 5 speed 33 RPM * 51200 Stp/rev /60 s/m
  LB X4
    PR "    Starting Step 5   P=",P,"  V=",V
    Vm= Sp      
    MA Ds*9 ',0,1
    Tp Ds*9,X5
    Te=2
    RT
  
'Step 6 speed 33 RPM * 51200 Stp/rev /60 s/m
  LB X5
    PR "     Starting Step 6   P=",P,"  V=",V
    Vm= Sp      
    MA 0,0,1
    Tp Ds*8,X6
    Te=2
    RT
  
'Step 7 speed 66 RPM * 51200 Stp/rev /60 s/m
  LB X6
    PR "      Starting Step 7   P=",P,"  V=",V
    Vm= Sp*2    
    MA 0,0,1
    Tp Ds*6,X7
    Te=2
    RT
  
'Step 8 speed 100 RPM * 51200 Stp/rev /60 s/m
  LB X7
    PR "       Starting Step 8   P=",P,"  V=",V
    Vm= Sp*3    
    MA 0,0,1
    Tp Ds*3,X8
    Te=2
    RT
'Step 9 speed 66 RPM * 51200 Stp/rev /60 s/m
  LB X8
    PR "        Starting Step 9   P=",P,"  V=",V
    Vm= Sp*2    
    MA 0,0,1
    Tp Ds,X9
    Te=2
    RT
'Step 10 speed 33 RPM * 51200 Stp/rev /60 s/m
  LB X9
    PR "         Starting Step 10  P=",P,"   V=",V
    Vm= Sp      
    MA 0
    H
    PR "          Back at Start     P=",P,"   V=",V
    R1=1
    RT
  
  PG
S
'Keep this line.