Geschwindigkeit für Schrittmotoren ändern
Hi Leute,
Ich habe ein kleines Problem. Ich möchte gerne zwei Schrittmotoren mit zwei Atmega 16 ansteuern. Befehle über Docklight nimmt er an (z.B. Motoridentifikationsnummer, Schrittzahl und Drehrichtung) doch mit der Geschwindigkeit habe ich noch Probleme.
Hier ist mein Programm für einen Motor:
$regfile = "m16def.dat"
$crystal = 7372800
$baud = 19200
Config Portb = Output
Const True = 1
Const False = 0
Dim M As Byte , M1 As Byte , D As Byte , S As Byte , S1 As Long , S2 As Long
Dim Hi As Byte , Lo As Byte , Phase As Bit
Config Timer0 = Timer , Prescale = 8
Step1 Alias Portb.1
D1 Alias Portb.0
Enable Timer0
Enable Interrupts
Phase = True
Motornummer:
S2 = 0
Inputbin M
If M = 001 Then Goto Befehl
Goto Motornummer
Befehl:
Print "Motor 1: Warte auf Befehl"
Inputbin D , S , Lo
If D = 000 Then D1 = 0
If D = 001 Then D1 = 1
Gobefehl:
Inputbin M1
If M1 = 001 Then Goto Ausfuehrung
Goto Gobefehl
Ausfuehrung:
S1 = S * 628
Hi = 255 - Lo
If Phase = True Then
Step1 = 1
Timer0 = Lo
Phase = False
Else
Step1 = 0
Timer0 = Hi
Phase = True
End If
S2 = S2 + 1
If S2 = S1 Then Goto Motornummer
Goto Ausfuehrung
Mir wurde geraten einen Timer zu benutzen, doch ich weiß nicht wie ich nun die Geschwindigkeit ändern kann. Ich hoffe dass ich eine schnelle Antwort bekomme.
Danke im voraus
MFG tohrr