Hi,
hab mir dein Programm auch mal angesehen.
Mir ist aufgefallen, dass die Endlosschleife (Do...Loop) über den ganzen Programmcode geht auch über die Unterfunktionen, die mit "gosub" angesprochen werden. Ich würde die Schleife nur über die "Aufrufe" der Unterfunktionen stellen, also in etwa so:
Code:
$regfile "m16def.dat"
$crystal = 16000000
$baud = 9600
$swstack = 16
$hwstack = 16
$framesize = 16
Dim A As Word
Dim B As Word
Dim C As Word
Dim X As Word
Dim Y As Word
Dim Z As Word
Config Portd.4 = Output
Config Portd.5 = Output
Config Porta.4 = Output
Config Porta.5 = Output
Config Porta.6 = Output
Config Portc.7 = Output
Config Portc.6 = Output
Config Portc.5 = Output
Config Portb.2 = Output
M1 Alias Porta.5
M2 Alias Porta.6
M3 Alias Portc.6
M4 Alias Portc.5
Config Servos = 1 , Servo1 = Portb.2 , Reload = 10
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1
Enable Interrupts
Servo(1) = 100
Wait 1
Do
Pwm1a = 64
Pwm1b = 64
A = Getadc(1)
B = Getadc(2)
C = Getadc(3)
If A > 250 Then
Gosub Brems
Waitms 500
Gosub Rueck
Waitms 200
Gosub Rueckr
Waitms 400
Else
Gosub Vor
End If
If B > 250 Then
Gosub Brems
Waitms 500
Gosub Way
Gosub Rueck
Waitms 200
Gosub Rueckl
Waitms 400
Else
Gosub Vor
End If
If C > 250 Then
Gosub Brems
Waitms 500
Gosub Rueck
Waitms 200
Gosub Rueckr
Waitms 400
Else
Gosub Vor
End If
Waitms 40
Loop
Vor:
M1 = 0
M2 = 1
M3 = 0
M4 = 1
Return
Rueck:
M1 = 1
M2 = 0
M3 = 1
M4 = 0
Return
Brems:
M1 = 1
M2 = 1
M3 = 1
M4 = 1
Return
Rueckr:
M1 = 1
M2 = 0
M3 = 0
M4 = 0
Return
Rueckl:
M1 = 0
M2 = 0
M3 = 1
M4 = 0
Return
Vorr:
M1 = 0
M2 = 1
M3 = 0
M4 = 0
Return
Vorl:
M1 = 0
M2 = 0
M3 = 0
M4 = 1
Return
Way:
Servo(1) = 100
Waitms 100
X = Getadc(2)
Waitms 100
Servo(1) = 150
Y = Getadc(2)
Waitms 100
Servo(1) = 50
Waitms 300
Z = Getadc(2)
Waitms 100
If Y > Z Then
Gosub Rueckr
Waitms 500
Gosub Brems
Waitms 300
Gosub Vor
End If
If Y < Z Then
Gosub Rueckl
Waitms 500
Gosub Brems
Waitms 300
Gosub Vor
End If
Return
Keine Ahnung, ob das zur Lösung des "Ausschlagproblems" beiträgt, mir ist es nur ins Auge gestochen 
Viele Grüße
Lesezeichen