Jetzt habe ich 2 Probleme:
1. Der Wertebereich zur Servoansteuerung (bei mir 8 bis 19) ist zu klein. Eigtl. soll das eine Tricopter-Steuerung werden, da brauch ich auch PID-Regler usw.. Ich denke, dass damit zu ungenau geregelt wird?!
2. Der neue Wert, der per UART reinkommt, wird erst nach einer geschätzten Minute auf die Servo-Ausgänge gegeben.
Hier mal die Codes:
ATMEGA8:
ATTINY45:Code:$regfile = "m8def.dat" $crystal = 16000000 $framesize = 100 $hwstack = 100 $swstack = 100 Open "COMD.4:38400,8,N,1" For Output As #1 Dim _bl(4) As Byte Dim Channel As Byte Dim Kanal(4) As Byte Dim I As Byte For I = 1 To 4 _bl(4) = 80 Next I Config Timer2 = Timer , Prescale = 256 On Timer2 Detectrxpause Enable Timer2 Config Int1 = Rising On Int1 Getreceiver Enable Int1 Config Pind.3 = Input Portd.3 = 0 Enable Interrupts Do For I = 1 To 4 _bl(i) = 8 Next I Printbin #1 , _bl(1) , _bl(2) , _bl(3) , _bl(4) Wait 3 For I = 1 To 4 _bl(i) = 10 Next I Printbin #1 , _bl(1) , _bl(2) , _bl(3) , _bl(4) Wait 3 Loop End Getreceiver: If Channel > 0 And Channel < 5 Then Kanal(channel) = Timer2 End If Timer2 = 6 Incr Channel Return Detectrxpause: Channel = 0 Return
Wo liegt mein Fehler?Code:$regfile = "attiny45.dat" $crystal = 8000000 $framesize = 40 $hwstack = 40 $swstack = 40 Open "COMB.0:38400,8,N,1" For Input As #1 Config Pinb.0 = Input Config Servos = 4 , Servo1 = Portb.3 , Servo2 = Portb.2 , Servo3 = Portb.4 , Servo4 = Portb.1 , Reload = 100 , Interval = 100 Config Portb.1 = Output Config Portb.2 = Output Config Portb.3 = Output Config Portb.4 = Output Dim _bl(4) As Byte Dim _blold(4) As Byte Dim I As Byte Const Min_servo = 8 '900µs Const Max_servo = 19 '2000µs For I = 1 To 4 _bl(i) = Min_servo _blold(i) = _bl(i) Servo(i) = _bl(i) Next I Enable Interrupts Wait 2 Do Inputbin #1 , _bl(1) , 4 For I = 1 To 4 If _bl(i) <> 0 And _bl(i) <> 255 Then If _bl(i) >= Min_servo And _bl(i) <= Max_servo Then Servo(i) = _bl(i) End If End If Next I Loop End
Gruß
Chris







Zitieren

Lesezeichen