Hallo ihr da draußen,
ich habe mich mal wieder dran gemacht mein Hobby etwas voranzutreiben. Nun ist es so, ich habe mein Roboterchassie fertig und habe nun alle Elektronik aufgeschraubt. Ich steuer über ein mega128Funk Board, das klappt soweit hervoragend. Schon fast verwunderlich das alles ohne ein Problem.
Ich habe zum Test erstmal eine simple, manuelle Steuerung über die Nummerntasten programmiert. Das alles mit einer Casestruktur. Das sieht dann so aus:
Wenn ich nun die Steuerung durchführe muss ich die Tasten immer zweimal drücken damit beide Motoren abschalten oder laufen. Wenn ich nur einmal z.B. die 8 drücke, zum vorwerts fahren, fängt erst ein Motor an zu laufen, drücke ich nochmal die 8, dann dreht auch der Zweite. Ich habe nun schon einen Tag damit verbracht herrauszufinden warum, aber ich komm nicht drauf. Es ist auch total unlogisch da die Anweisung in einem Case steht. Ich kann mir nur vorstellen, dass das ein Timming Problem ist. Kennt wer diesen Effekt und kann mit weiterhelfen.Code:$regfile = "m128def.dat" ' Bei Mega 128 " $framesize = 64 $swstack = 64 $hwstack = 64 $crystal = 16000000 $baud = 19200 $baud1 = 9600 '----------------------Motortreiber Konfiguration-------------------------------- Config Ping.1 = Output Led_rot Alias Portg.1 Config Ping.0 = Output Led_gruen Alias Portg.0 Config Pinb.4 = Output Motorboard_richtung1 Alias Portb.4 Config Pinb.5 = Output Motorboard_richtung2 Alias Portb.5 Config Pina.1 = Output Motorboard_reset Alias Porta.1 Config Pine.3 = Output Motorboard_pwm1 Alias Porte.3 Config Pine.4 = Output Motorboard_pwm2 Alias Porte.4 '----------------------Funksender & Empfänger Konfiguration-------------------------------- Config Ping.0 = Output Lcdpower Alias Portg.0 Config Portc = Output Config Pine.2 = Output Rdy_hostempfangsbereit Alias Porte.2 'Auf Low setzen wenn Empfangsbereit für Daten vom Funkmodul Config Pine.5 = Input Bsy_funkmodulsendebereit Alias Porte.5 'Ist Low wenn Funkmodul frei zum senden Open "com2:" For Binary As #2 'Ausgabe über zweite serielle Schnittstelle (MAX) Sound Portg.2 , 400 , 450 'BEEP bei RN-Mega128Funk Sound Portg.2 , 400 , 250 'BEEP bei RN-Mega128Funk Sound Portg.2 , 400 , 450 'BEEP bei RN-Mega128Funk Config Serialin = Buffered , Size = 2 'Empfangsbuffer für Funkmodul anlegen Config Serialout1 = Buffered , Size = 100 'Ausgabebuffer für normalse RS232 Enable Interrupts Config Timer3 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 8 '--- Eigentliches Programm --- Dim P As Word Dim Empfang As Byte Motorboard_reset = 1 Rdy_hostempfangsbereit = 0 Do Empfang = Inkey() Select Case Empfang Case 56 Motorboard_reset = 1 Motorboard_richtung1 = 0 Motorboard_richtung2 = 1 Bsy_funkmodulsendebereit = 0 Print "Eingabe 8" Pwm3b = 750 Pwm3a = 750 Case 53 Motorboard_reset = 1 Bsy_funkmodulsendebereit = 0 Print "Eingabe 5" Pwm3b = 0 Pwm3a = 0 Case 50 Motorboard_reset = 1 Motorboard_richtung1 = 1 Motorboard_richtung2 = 0 Bsy_funkmodulsendebereit = 0 Print "Eingabe 2" Pwm3b = 750 Pwm3a = 750 Case 52 Motorboard_reset = 1 Motorboard_richtung1 = 0 Motorboard_richtung2 = 0 Bsy_funkmodulsendebereit = 0 Print "Eingabe 6" Pwm3b = 750 Pwm3a = 750 Case 54 Motorboard_reset = 1 Motorboard_richtung1 = 1 Motorboard_richtung2 = 1 Bsy_funkmodulsendebereit = 0 Print "Eingabe 4" Pwm3b = 750 Pwm3a = 750 Case 55 Motorboard_reset = 1 Motorboard_richtung1 = 1 Motorboard_richtung2 = 0 Bsy_funkmodulsendebereit = 0 Print "Eingabe 4" Pwm3b = 0 Pwm3a = 750 Case 57 Motorboard_reset = 1 Motorboard_richtung1 = 1 Motorboard_richtung2 = 0 Bsy_funkmodulsendebereit = 0 Print "Eingabe 4" Pwm3b = 750 Pwm3a = 0 End Select Waitms 150 Loop End
MfG Jolly







Zitieren

Lesezeichen