Motorns lindningar som jag kallar A+B och C+D är inkopplade så här.
PIN0 A
PIN1 B
PIN2 C
PIN3 D
Problemet är att den hoppar fram och tillbaka.
Tar jag bort B och D så funkar det.
Kan inte riktigt komma på vad det som är fel.
Någon ide?
BASCOM Koden i sin helhet.
Kod: Markera allt
'// Port C bits 0,1,2,3 will be used for the motor.
$regfile = "m8515.dat"
$crystal = 16000000
Config Portc = Output
Portc = &B00000000
Dim Step_no As Integer
'// Only 4 step sequences for driving a stepper motor in full
'// step mode, so run around a loop incrementing each time, then
'// reset to 1 when all four steps have been completed.......
Do
Step_no = Step_no + 1
If Step_no = 5 Then
Step_no = 1
End If
Gosub Motor_full
'// This delay controls the actual step rate.....
Waitms 5
Loop
'//This will full step the motor, the actual step being determined
'//by the previous Do.....Loop
Motor_full:
Select Case Step_no
Case 1
'//step 1
Set Portc.0
Set Portc.2
Reset Portc.1
Reset Portc.3
Case 2
'//Step 2
Reset Portc.0
Set Portc.2
Set Portc.1
Reset Portc.3
Case 3
'// Step 3
Reset Portc.0
Reset Portc.2
Set Portc.1
Set Portc.3
Case 4
'//Step 4
Set Portc.0
Reset Portc.2
Reset Portc.1
Set Portc.3
End Select
Return
End