okok, hier der Code:
Code:$regfile "m8def.dat" $crystal = 16000000 $framesize = 24 $swstack = 8 $hwstack = 32 Config Timer1 = Timer , Prescale = 8 'timer für Servos Enable Timer1 Timer1 = 62535 Config Portc = Output Portc.5 = 0 'hier hängt servo1 Portc.4 = 0 'hier hängt servo2 Portc.3 = 0 'hier hängt servo3 Portc.2 = 0 'hier hängt servo4 Config Portb.1 = Output Config Portb.2 = Output Portb.1 = 1 Portb.2 = 0 On Timer1 Servoirq 'servo Enable Interrupts Dim Kanal As Byte Dim Servo(4) As Word 'min: 61535, mitte 62535, max 63535 = 2000 schritte Waitms 100 Portb.2 = 1 Portb.1 = 0 Do Servo(1) = 63535 Servo(2) = 61535 'Mitte Servo(3) = 62535 'Mitte Servo(4) = 62535 'Mitte Loop Servoirq: If Kanal = 0 Then If Portc.5 = 0 Then 'wenn port low Timer1 = Servo(1) 'dann timer auf entsprechende verzögerung Portc.5 = 1 'und port anschalten Else 'das hier passiert erst bei dem darauf folgenden interrupt Portc.5 = 0 'dann port wieder ausschalten Incr Kanal 'und den nächsten kanal bearbeiten End If End If If Kanal = 1 Then If Portc.4 = 0 Then Timer1 = Servo(2) Portc.4 = 1 Else Portc.4 = 0 Incr Kanal End If End If If Kanal = 2 Then If Portc.3 = 0 Then Timer1 = Servo(3) Portc.3 = 1 Else Portc.3 = 0 Incr Kanal End If End If If Kanal = 3 Then If Portc.2 = 0 Then Timer1 = Servo(4) Portc.2 = 1 Else Portc.2 = 0 Incr Kanal End If End If If Kanal = 4 Then Timer1 = 40000 Kanal = 0 End If Return End







Zitieren

Lesezeichen