Dann noch viel Spaß!!
PS:
machst du das nur so oder hasst du nich die Original Lib in Basic??
Liebes Forum,
einige Wissen ja bereits das ich mit der Entwicklungsumgebung der C-Control 128 Pro nicht viel am Hut haben wolte und habe deshalb den Pro-Bot nach ISP umgerüstet und habe nun vor eine Bascom-Lib zuschreiben
ich bin auch schon ziemlich voran gekommen Leds, Odometrie und den
Bruzzer ich werde auch hier die Lib dann zum download zur Verfügung
stellen und hoffe auch auf viel Kritik da ich noch nicht Lange in Bascom programmiere also weißt mich auch jeden Fehler und Platz verschwendung hin den die 4-KB-Marke schramme ich immer wieder.
Lade bald den ersten Teil hoch.
Dann noch viel Spaß!!
PS:
machst du das nur so oder hasst du nich die Original Lib in Basic??
Hier mal der erste Code:
@bitram nein mich nerft einfach die IDECode:$regfile = "m128def.dat" $framesize = 42 $swstack = 32 $hwstack = 32 $crystal = 14745600 Encoderled Alias Portb.0 Config Encoderled = Output Frontled Alias Portc.4 Config Frontled = Output Frontlled Alias Portc.3 Config Frontlled = Output Frontrled Alias Portc.2 Config Frontrled = Output Backlled Alias Portc.1 Config Backlled = Output Backrled Alias Portc.0 Config Backrled = Output Buzzer Alias Portb.4 Config Buzzer = Output Taster Alias Pine.4 Config Taster = Input Porte.4 = 1 Frontled = 1 Frontlled = 1 Frontrled = 1 Backlled = 1 Backrled = 1 Encoderled = 0 Declare Sub Lineled(byval Status As Byte) Declare Sub Flled(byval Status As Byte) Declare Sub Frled(byval Status As Byte) Declare Sub Blled(byval Status As Byte) Declare Sub Brled(byval Status As Byte) Declare Sub Encled(byval Status As Byte) Declare Sub Bruzzer(byval Ton As Byte , Byval Laenge As Byte) Declare Sub Intodometrie() Declare Function Getmicro() As Word Declare Function Getlsl() As Word Declare Function Getlsr() As Word Declare Function Getlinel() As Word Declare Function Getliner() As Word Declare Function Getakku() As Word Dim Encleft As Integer Dim Encright As Integer Do Call Bruzzer(0 , 120) Loop End Sub Lineled(byval Status As Byte) If Status = 1 Then Frontled = 0 Elseif Status = 0 Then Frontled = 1 End If End Sub Sub Flled(byval Status As Byte) If Status = 1 Then Frontlled = 0 Elseif Status = 0 Then Frontlled = 1 End If End Sub Sub Frled(byval Status As Byte) If Status = 1 Then Frontrled = 0 Elseif Status = 0 Then Frontrled = 1 End If End Sub Sub Blled(byval Status As Byte) If Status = 1 Then Backlled = 0 Elseif Status = 0 Then Backlled = 1 End If End Sub Sub Brled(byval Status As Byte) If Status = 1 Then Backrled = 0 Elseif Status = 0 Then Backrled = 1 End If End Sub Sub Encled(byval Status As Byte) If Status = 1 Then Encoderled = 1 Elseif Status = 0 Then Encoderled = 1 End If End Sub Sub Intodometrie() Encleft = 0 Encright = 0 Call Encled(1) On Int7 Encoleft On Int6 Encoright Config Int7 = Falling Config Int6 = Falling Enable Int7 Enable Int6 Enable Interrupts End Sub Sub Bruzzer(byval Ton As Byte , Laenge As Byte) Dim Count As Byte For Count = 1 To Laenge Config Timer0 = Timer , Prescale = 8 Timer0 = Ton On Ovf0 On_ovf0 Enable Ovf0 Enable Interrupts Waitms 5 Next Laenge End Sub Function Getmicro() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getmicro = Getadc(3) End Function Function Getlsl() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getlsl = Getadc(4) End Function Function Getlsr() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getlsr = Getadc(5) End Function Function Getlinel() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getlinel = Getadc(1) End Function Function Getliner() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getliner = Getadc(2) End Function Function Getakku() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getakku = Getadc(0) End Function Encoleft: Encleft = Encleft + 1 Return Encoright: Encright = Encright + 1 Return On_ovf0: Toggle Buzzer Return
Nich shclecht deine Arbeit bis jetz
Mfg
bnitram
@bitram ich würde dir und allen anderen Pro-Bot 128 besitzern raten die Unit
via ISP zuprogrammieren dafür muss man zwar ein bischen löten und man muss eine C-Control 128 Pro Unit opfern aber es lohnt sich den Bot in anderen Sprachen programmieren zu können! Im Notfall kann man sich ja ne neue Unit kaufen. Und mit Umbaukosten von ca. 27€ ist das auch leicht machbar (Programmer und 10-Poliger Wannenstecker).
Hallo
Ohne die C-Control zu opfern sollte es mit CCPro-Loader möglich sein, die mit Bascom erzeugten Hex-Dateien zu übertragen:
http://www.mikrocontroller.net/topic/134655
https://www.roboternetz.de/phpBB2/viewtopic.php?t=47484
Gruß
mic
Bild hier
Atmel’s products are not intended, authorized, or warranted for use
as components in applications intended to support or sustain life!
Hier mal eine etwas neuere Version mit ADC und Motoransteuerrung:
Nun möcht ich aber noch eine Funktion(Sub) schreiben die den Roboter mittels Odometrie gerade ausfahren lässt. Leider haben meine bisherigen Versuche nur Misserfolg kann mir jemand sagen wie man das in Bascom am besten umsetzt.(Der Pro-bot 128 benutzt Int7 Int6 um die 6 weißen und 6 schwarzen Segmente über Fotodioden einzulesen)Code:$regfile = "m128def.dat" $framesize = 42 $swstack = 32 $hwstack = 32 $crystal = 14745600 $baud = 19200 Encoderled Alias Portb.0 Config Encoderled = Output Frontled Alias Portc.4 Config Frontled = Output Frontlled Alias Portc.3 Config Frontlled = Output Frontrled Alias Portc.2 Config Frontrled = Output Backlled Alias Portc.1 Config Backlled = Output Backrled Alias Portc.0 Config Backrled = Output Buzzer Alias Portb.4 Config Buzzer = Output Taster Alias Pine.4 Config Taster = Input Porte.4 = 1 Frontled = 1 Frontlled = 1 Frontrled = 1 Backlled = 1 Backrled = 1 Encoderled = 0 Declare Sub Moveatspeed(byval Sleft As Byte , Byval Sright As Byte) Declare Sub Lineled(byval Status As Byte) Declare Sub Flled(byval Status As Byte) Declare Sub Frled(byval Status As Byte) Declare Sub Blled(byval Status As Byte) Declare Sub Brled(byval Status As Byte) Declare Sub Encled(byval Status As Byte) Declare Sub Bruzzer(byval Ton As Byte , Byval Laenge As Byte) Declare Sub Intodometrie() Declare Sub Motorstop() Declare Function Getmicro() As Word Declare Function Getlsl() As Word Declare Function Getlsr() As Word Declare Function Getlinel() As Word Declare Function Getliner() As Word Declare Function Getakku() As Word Dim Encleft As Integer Dim Encright As Integer Do Call Moveatspeed(220 , 220) Loop End Sub Lineled(byval Status As Byte) If Status = 1 Then Frontled = 0 Elseif Status = 0 Then Frontled = 1 End If End Sub Sub Flled(byval Status As Byte) If Status = 1 Then Frontlled = 0 Elseif Status = 0 Then Frontlled = 1 End If End Sub Sub Frled(byval Status As Byte) If Status = 1 Then Frontrled = 0 Elseif Status = 0 Then Frontrled = 1 End If End Sub Sub Blled(byval Status As Byte) If Status = 1 Then Backlled = 0 Elseif Status = 0 Then Backlled = 1 End If End Sub Sub Brled(byval Status As Byte) If Status = 1 Then Backrled = 0 Elseif Status = 0 Then Backrled = 1 End If End Sub Sub Encled(byval Status As Byte) If Status = 1 Then Encoderled = 1 Elseif Status = 0 Then Encoderled = 1 End If End Sub Sub Motorstop() Call Moveatspeed(220 , 220) End Sub Sub Intodometrie() Encleft = 0 Encright = 0 Call Encled(1) On Int7 Encoleft On Int6 Encoright Config Int7 = Falling Config Int6 = Falling Enable Int7 Enable Int6 Enable Interrupts End Sub Sub Bruzzer(byval Ton As Byte , Laenge As Byte) Dim Count As Byte For Count = 1 To Laenge Config Timer0 = Timer , Prescale = 8 Timer0 = Ton On Ovf0 On_ovf0 Enable Ovf0 Enable Interrupts Waitms 1 Next Laenge End Sub Sub Moveatspeed(byval Sleft As Byte , Byval Sright As Byte) Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1 Config Portb.7 = Output Portb.7 = 1 Compare1a = Sleft Compare1b = Sright End Sub Function Getmicro() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getmicro = Getadc(3) End Function Function Getlsl() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getlsl = Getadc(4) End Function Function Getlsr() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getlsr = Getadc(5) End Function Function Getlinel() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getlinel = Getadc(1) End Function Function Getliner() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getliner = Getadc(2) End Function Function Getakku() Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Getakku = Getadc(0) End Function Encoleft: Encleft = Encleft + 1 Return Encoright: Encright = Encright + 1 Return On_ovf0: Toggle Buzzer Return
Danke
Ein bischen Regeltechnic ist hier angewesen. Du kannst der Geschwindigkeit von beiden Motoren messen. Jeden 100 ms hat jeden Motor sofiel Pulsen weiter gelaufen. Jetzt muss du einfach das Unterschied zwischen beide Motoren aufaddieren. Das gibt dan ein Integral term. Diesen Term gibt ihr dan das Unterschied von Anfang an zwischen Linker und Rechter motor. Diesen Term kannst du wieder in die PWM Wert von jeden Antrieb verrrechnen. Sag mal Links 50 Pulsen hoher dan Rechts, dan geben wir die Linkse Antrieb 5%Weniger PWM, den Rechtse Antrieb 5% Mehr PWM. Jetzt hast du eine Verstarkungsfactor von 0.1 (50*0.1 = 5%). Die Kunst ist dan diese Factor so einzustellen das du eine Schnelle, aber stabile Regelung bekommst.
Das gleiche Spiel kann auch mit das reine Geschwindigkeitsunterschied, das ist dan das Proportional Anteil.
Stichwort : PID Regelung
Lesezeichen