Desk
Gebruiker
- Lid geworden
- 26 jan 2009
- Berichten
- 13
Een bestaand programma voor het aansturen van stappenmotoren via de USB poort dat met Forms werkt, heb ik omgebouwd tot een Console application.
Het programma geeft geen debug foutmeldingen, maar de motoren draaien niet.
Dat deden ze dus wel in het originele programma.
De meeste zaken zijn geregeld in een DDL.
Het programma geeft geen debug foutmeldingen, maar de motoren draaien niet.
Dat deden ze dus wel in het originele programma.
De meeste zaken zijn geregeld in een DDL.
Code:
Module Module1
Sub Main()
End Sub
'====================================================================================
' Polar Scan programma (C) 2009 Desk-nijverdal
'====================================================================================
'
Declare Function InitStp Lib "stp.dll" () As Integer
Declare Function RunMotor1 Lib "stp.dll" (ByVal steps As Integer, ByVal interval As Integer, ByVal direction As Integer, ByVal outputs As Integer) As Boolean
Declare Function RunMotor2 Lib "stp.dll" (ByVal steps As Integer, ByVal interval As Integer, ByVal direction As Integer, ByVal outputs As Integer) As Boolean
Declare Function StopMotor1 Lib "stp.dll" (ByVal outputs As Integer) As Boolean
Declare Function StopMotor2 Lib "stp.dll" (ByVal outputs As Integer) As Boolean
Declare Function SetStepMode Lib "stp.dll" (ByVal M1Mode As Integer, ByVal M2Mode As Integer) As Boolean
Declare Function GetCurrentStatus Lib "stp.dll" (ByRef M1Active As Integer, ByRef M2Active As Integer, ByRef M1Steps As Integer, ByRef M2Steps As Integer, ByRef Inputs As Integer) As Boolean
'Initialise StepperBee. This must be called before any of the other functions.
Private Sub Initialize(ByVal sender As System.Object, ByVal e As System.EventArgs)
InitStp()
End Sub
' specify the step mode to use for both motors
Private Sub Step_Mode(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim M1Mode, M2Mode As Integer
M1Mode = 1 ' full step mode selected
M2Mode = 1 ' full step mode selected
' set the step mode for both motors
SetStepMode(M1Mode, M2Mode)
End Sub
Private Sub Full_Cycle(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim steps As Integer
Dim interval As Integer
Dim direction As Integer
Dim outputs As Integer
Dim n As Integer
Dim as1 As Integer
Dim as2 As Integer
Dim i As Integer
Dim angle1 As Integer
Dim angle2 As Integer
Dim rowCount As Integer = 90
Dim columnCount As Integer = 90
Dim upperboundFirstDimension As Integer = rowCount - 1
Dim upperboundSecondDimension As Integer = columnCount - 1
Dim matrix(upperboundFirstDimension, _
upperboundSecondDimension) As Integer
i = 0
as1 = 0
as2 = 0
Do While i < 50
Console.Write(matrix(angle1, angle2) & " ")
Console.WriteLine()
Console.ReadLine()
i = i + 1
matrix(angle1, angle2) = i
For n = 1 To 50
as1 = 0
steps = 1
interval = 5
direction = 0
as1 = as1 + 1
angle1 = as1 * 1.8
RunMotor1(steps, interval, direction, outputs)
Next n
RunMotor2(steps, interval, direction, outputs)
as2 = as2 + 1
angle2 = as2 * 1.8
For n = 1 To 50
steps = 1
interval = 5
direction = 1
RunMotor1(steps, interval, direction, outputs)
Next n
Loop
End Sub
End Module