#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Dim ts As TinyStepper
Dim t As Timer
Dim sequence As Byte = 0
Dim completed As Boolean = True
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
ts.Initialize
ts.connectToPins(8, 9, 10,11)
t.Initialize("t_tick", 200)
t.Enabled = True
End Sub
Sub t_tick
If sequence = 0 And completed = True Then
seq0
End If
If sequence = 1 And completed = True Then
seq1
End If
If sequence = 2 And completed = True Then
seq2
End If
If sequence = 3 And completed = True Then
seq3
End If
If sequence = 4 And completed = True Then
seq4
End If
If sequence = 5 And completed = True Then
seq5
End If
If sequence = 6 And completed = True Then
seq6
End If
If sequence = 7 And completed = True Then
seq7
End If
If sequence = 8 And completed = True Then
seq8
End If
If sequence = 9 And completed = True Then
seq9
End If
End Sub
Sub seq0
completed = False
ts.SpeedInStepsPerSecond = 4096
ts.AccelerationInStepsPerSecondPerSecond = 512
ts.CurrentPositionInSteps = 0
ts.moveToPositionInSteps(1024)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(2000)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq1
completed = False
ts.SpeedInStepsPerSecond = 256
ts.AccelerationInStepsPerSecondPerSecond = 512
ts.moveToPositionInSteps(0)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(1000)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq2
completed = False
ts.SpeedInStepsPerSecond = 200
ts.AccelerationInStepsPerSecondPerSecond = 1000
ts.moveRelativeInSteps(-4096)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(1000)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq3
completed = False
ts.SpeedInStepsPerSecond = 500
ts.AccelerationInStepsPerSecondPerSecond = 1000
ts.moveRelativeInSteps(4096)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(2000)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq4
completed = False
ts.SpeedInStepsPerSecond = 500
ts.AccelerationInStepsPerSecondPerSecond = 1000
ts.moveRelativeInSteps(-2048 * 2)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(2000)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq5
completed = False
ts.SpeedInStepsPerSecond = 500
ts.AccelerationInStepsPerSecondPerSecond = 1000
ts.moveRelativeInSteps(2048 * 2)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(2000)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq6
completed = False
ts.SpeedInStepsPerSecond = 100
ts.AccelerationInStepsPerSecondPerSecond = 1000
ts.moveRelativeInSteps(512)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(100)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq7
completed = False
ts.SpeedInStepsPerSecond = 200
ts.AccelerationInStepsPerSecondPerSecond = 1000
ts.moveRelativeInSteps(-512)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(100)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq8
completed = False
ts.SpeedInStepsPerSecond = 50
ts.AccelerationInStepsPerSecondPerSecond = 200
ts.moveRelativeInSteps(-248)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(100)
completed = ts.motionComplete
sequence = sequence + 1
End Sub
Sub seq9
completed = False
ts.SpeedInStepsPerSecond = 40
ts.AccelerationInStepsPerSecondPerSecond = 100
ts.moveRelativeInSteps(-248)
Log("current position = ", ts.WhatIsCurrentPositionInSteps)
Delay(100)
completed = ts.motionComplete
sequence = 0
End Sub