the pc gadgetmaster ii stepper motor control developed by frank shapleigh edited by jim tuff
Post on 05-Jan-2016
225 Views
Preview:
TRANSCRIPT
The PC GadgetMaster IIStepper Motor Control
Developed by Frank ShapleighEdited by Jim Tuff
Simple Variable“Contains” numbers, characters or strings of characters.
Contents of a variable change each time an assignment is made.
Eg.
X = 1
X = 2
X = 3
X = 4
X4
Stepper Control Variables Explained
Array Variable
Array “Elements” can also store numbers, characters or strings of characters.
Elements and their contents are referenced by an “index”.
Eg.
A(1) = 128
A(2) = 64
A(3) = 32
A(4) = 16
One Dimensional array
A( )
Stepper Control Array Variables Explained
1 128
2 64
3 32
4 16
Example:Private Sub Command1_Click()
A(1) = 128
A(2) = 64
A(3) = 32
A(4) = 16
S = 1
Text1 = A(S)
End Sub
Stepper Control Array Variables / Digital Output
Text1 Displays the value of A(1)
S = (1) = 128
Digital Output 1 (128) is 12 volts
Example:Private Sub Command1_Click()
A(1) = 128
A(2) = 64
A(3) = 32
A(4) = 16
S = 3
Text1 = A(S)
End Sub
Stepper Control Array Variables / Digital Output
Text1 Displays the value of A(3)
S = (3) = 32
Digital Output 3 (32) is 12 volts
Stepper Motor ControlClockwise Motion
Stepper Code:Private Sub Command1_Click()
If S < 4 Then
S = S + 1
Else
S = 1
End If
Out 888, A(S)
End Sub
Stepper Control
Clockwise Motion 00 1 2 3 4The Stepper Control Cycle begins with the Array Variable value of ‘S=0’
S = 0 + 1 = 1
A(S) = A(1) = 128
12 volts is sent to Digital Output 1
Stepper Code:Private Sub Command1_Click()
If S < 4 Then
S = S + 1
Else
S = 1
End If
Out 888, A(S)
End Sub
Stepper Control
Clockwise Motion 0 1 1 2 3 4The Stepper Control Cycle now has an Array Variable value of ‘S=1’
S = 1 + 1 = 2
A(S) = A(2) = 64
12 volts is sent to Digital Output 2
Stepper Code:Private Sub Command1_Click()
If S < 4 Then
S = S + 1
Else
S = 1
End If
Out 888, A(S)
End Sub
Stepper Control
Clockwise Motion 0 1 22 3 4The Stepper Control Cycle now has an Array Variable value of ‘S=2’
S = 2 + 1 = 3
A(S) = A(3) = 32
12 volts is sent to Digital Output 3
Stepper Code:Private Sub Command1_Click()
If S < 4 Then
S = S + 1
Else
S = 1
End If
Out 888, A(S)
End Sub
Stepper Control
Clockwise Motion 0 1 2 33 4The Stepper Control Cycle now has an Array Variable value of ‘S=3’
S = 3 + 1 = 4
A(S) = A(4) = 16
12 volts is sent to Digital Output 4
Stepper Code:Private Sub Command1_Click()
If S < 4 Then
S = S + 1
Else
S = 1
End If
Out 888, A(S)
End Sub
Stepper Control
Clockwise Motion 0 1 2 3 44The Stepper Control Cycle now has an Array Variable value of ‘S=4’
S is not less than 4!!
S = 1
A(S) = A(1) = 128
12 volts is sent to Digital Output 1 (cycle repeats)
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S < 4 Then
S = S + 1
Else
S = 1
End If
Out 888, A(S)
End Sub
5
4
3
2
1
PC GadgetMaster II Stepper Control
Clockwise Clockwise Motion Demo Motion Demo
((CWCW))
12 volts
5
4
3
2
1
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S < 4 Then ‘S is 0
S = S + 1
Else
S = 1 ‘S is 1
End If
Out 888, A(S) ‘A(1) is 128
End Sub
PC GadgetMaster II Stepper Control
Clockwise Clockwise Motion Demo Motion Demo
((CWCW))
5
4
3
2
1
12 volts
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S < 4 Then ‘S is 1
S = S + 1 ‘S is 2
Else
S = 1
End If
Out 888, A(S) ‘A(2) is 64
End Sub
PC GadgetMaster II Stepper Control
Clockwise Clockwise Motion Demo Motion Demo
((CWCW))
5
4
3
2
1
12 volts
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S < 4 Then ‘S is 2
S = S + 1 ‘S is 3
Else
S = 1
End If
Out 888, A(S) ‘A(3) is 32
End Sub
PC GadgetMaster II Stepper Control
Clockwise Clockwise Motion Demo Motion Demo
((CWCW))
12 volts
5
4
3
2
1
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S < 4 Then ‘S is 3
S = S + 1 ‘S is 4
Else
S = 1
End If
Out 888, A(S) ‘A(4) is 16
End Sub
PC GadgetMaster II Stepper Control
Clockwise Clockwise Motion Demo Motion Demo
((CWCW))
5
4
3
2
1 12 volts
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S < 4 Then ‘S is 4
S = S + 1
Else
S = 1 ‘S is 1
End If
Out 888, A(S) ‘A(1) is 128
End Sub
PC GadgetMaster II Stepper Control
Clockwise Clockwise Motion Demo Motion Demo
((CWCW))
Stepper Motor ControlCounter Clockwise Motion
Stepper Code:Private Sub Command1_Click()
If S > 1 Then
S = S - 1
Else
S = 4
End If
Out 888, A(S)
End Sub
Stepper Control Counter-Clockwise Motion 0 1 2 3 44
The Stepper Control Cycle begins with the Array Variable value of ‘S=0’
S is not greater than 1!!
S = 4
A(S) = A(4) = 16
12 volts is sent to Digital Output 4
Stepper Code:Private Sub Command1_Click()
If S > 1 Then
S = S - 1
Else
S = 4
End If
Out 888, A(S)
End Sub
Stepper Control Counter-Clockwise Motion 0 1 2 3 3 4
The Stepper Control Cycle now has an Array Variable value of ‘S=4’
S = 4 – 1 = 3
A(S) = A(3) = 32
12 volts is sent to Digital Output 3
Stepper Code:Private Sub Command1_Click()
If S > 1 Then
S = S - 1
Else
S = 4
End If
Out 888, A(S)
End Sub
Stepper Control Counter-Clockwise Motion 0 1 22 3 4
The Stepper Control Cycle now has an Array Variable value of ‘S=3’
S = 3 – 1 = 2
A(S) = A(2) = 64
12 volts is sent to Digital Output 2
Stepper Code:Private Sub Command1_Click()
If S > 1 Then
S = S - 1
Else
S = 4
End If
Out 888, A(S)
End Sub
Stepper Control Counter-Clockwise Motion 0 11 2 3 4
The Stepper Control Cycle now has an Array Variable value of ‘S=2’
S = 2 – 1 = 1
A(S) = A(1) = 128
12 volts is sent to Digital Output 1
Stepper Code:Private Sub Command1_Click()
If S > 1 Then
S = S - 1
Else
S = 4
End If
Out 888, A(S)
End Sub
Stepper Control Counter-Clockwise Motion 00 1 2 3 4
The Stepper Control Cycle now has an Array Variable value of ‘S=1’
S is not greater than 1!!
S = 4
A(S) = A(4) = 16
12 volts is sent to Digital Output 4 (cycle repeats)
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S > 1 Then
S = S - 1
Else
S = 4
End If
Out 888, A(S)
End Sub
5
4
3
2
1
PC GadgetMaster II Stepper Control
Counter Counter Clockwise Clockwise
Motion Demo Motion Demo ((CCWCCW))
12 volts
5
4
3
2
1
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S > 1 ‘S is 0
S = S - 1
Else
S = 4 ‘S is 4
End If
Out 888, A(S) ‘A(4) is 16
End Sub
PC GadgetMaster II Stepper Control
Counter Counter Clockwise Clockwise
Motion Demo Motion Demo ((CCWCCW))
5
4
3
2
1
12 volts
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S > 1 Then ‘S is 4
S = S - 1 ‘S is 3
Else
S = 4
End If
Out 888, A(S) ‘A(3) is 32
End Sub
PC GadgetMaster II Stepper Control
Counter Counter Clockwise Clockwise
Motion Demo Motion Demo ((CCWCCW))
5
4
3
2
1
12 volts
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S > 1 Then ‘S is 3
S = S - 1 ‘S is 2
Else
S = 4
End If
Out 888, A(S) ‘A(2) is 64
End Sub
PC GadgetMaster II Stepper Control
Counter Counter Clockwise Clockwise
Motion Demo Motion Demo ((CCWCCW))
12 volts
5
4
3
2
1
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S > 1 Then ‘S is 2
S = S - 1 ‘S is 1
Else
S = 4
End If
Out 888, A(S) ‘A(1) is 128
End Sub
PC GadgetMaster II Stepper Control
Counter Counter Clockwise Clockwise
Motion Demo Motion Demo ((CCWCCW))
12 volts
5
4
3
2
1
Private Sub Command1_Click()
Forward
End Sub
Public Sub Forward()
If S > 1 ‘S is 1
S = S - 1
Else
S = 4 ‘S is 4
End If
Out 888, A(S) ‘A(4) is 16
End Sub
PC GadgetMaster II Stepper Control
Counter Counter Clockwise Clockwise
Motion Demo Motion Demo ((CCWCCW))
The PC GadgetMaster IIStepper Motor Control
END
top related