Gast
#837890
Hallo,
wie schon im Betreff bin ich ein Anfänger und möchte mit einem atmega32
einen Servo ansteuern (und eine Ausgabe für einen zweiten Controller
geben).
Ich habe das ganze in Bascom Basic gemacht und es ging bis vor einigen
Tagen auch. Heute musste ich feststellen, dass das Programm nicht mehr
funktioniert!? Ich habe mehrere Stunden probiert und ich bin nicht
weitergekommen.
Das Programm empfängt über den UART eine dezimale Zahl (1, 2 oder 3).
Bei einer 1 oder 2 wird eine Ausgabe über mehrere Pins des Controllers
gegeben, bei einer 3 soll ein Servo angesteuert werden, der an Portb.1
hängt.
Ich poste hier einmal den gesamten Code. Ich hoffe sehr, jemand ist
bereit mir bei diesem Problem zu helfen (woran es auch immer liegt).
Marcel
$regfile = "m32def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 16000000
$baud = 9600
Config Portd.5 = Output
Config Portd.6 = Output
Config Portd.7 = Output
Config Pina.3 = Output
Smx Alias Porta.3
Config Pina.4 = Output
Smy Alias Porta.4
Config Pina.7 = Output
Minus Alias Porta.7
Config Pinb.1 = Output
Enable Interrupts
Config Servos = 1 , Servo1 = Portb.1 , Reload = 10
Dim I As Integer
Portd.5 = 0
Portd.6 = 0
Portd.7 = 0
Smx = 0
Smy = 0
Minus = 0
Do
If Ischarwaiting() <> 0 Then
I = Inkey()
If I = 1 Then
Print "SmX Aktiviert , Bitte Gebe Die Anzahl Der Einheiten An."
Do
If Ischarwaiting() <> 0 Then
Exit Do
End If
Loop
I = Inkey()
Print "SMX eingeschaltet"
Portd.5 = 1
If I < 99 Then
Do
Smx = 1
Waitms 30
Smx = 0
Waitms 30
I = I - 1
Loop Until I = 0
Else
Minus = 1
I = I - 100
Do
Smx = 1
Waitms 30
Smx = 0
Waitms 30
I = I - 1
Loop Until I = 0
Minus = 0
End If
Portd.5 = 0
Print "SMX ausgeschaltet"
Elseif I = 2 Then
Print "SmY Aktiviert , Bitte Gebe Die Anzahl Der Einheiten An."
Do
If Ischarwaiting() <> 0 Then
Exit Do
End If
Loop
I = Inkey()
Print "SMY eingeschaltet"
Portd.5 = 1
If I < 99 Then
Do
Smy = 1
Waitms 30
Smy = 0
Waitms 30
I = I - 1
Loop Until I = 0
Else
Minus = 1
I = I - 100
Do
Smy = 1
Waitms 30
Smy = 0
Waitms 30
I = I - 1
Loop Until I = 0
Minus = 0
End If
Portd.5 = 0
Print "SMY ausgeschaltet"
Elseif I = 3 Then
Dim Zahler As Byte
Zahler = 2
Print "SMh eingeschaltet"
Do
Servo(1) = 50
Wait 2
Servo(1) = 150
Wait 2
Zahler = Zahler - 1
Loop Until Zahler = 0
End If
End If
Loop
End