Also wie schon geschrieben habe ich mich mit Sonics Hilfe mal dran gesetzt und die Funktionen in Bascom geschrieben. Das gibts alles hier zum Downloaden mit einer Beschreibung aller Funktionen:
Zur Seite
Oder halt hier das ganze Script:
MFG MoritzCode:'************************************************************** '****** Der Versuch Asuro in Bascom zu übersetzen ;-) ****** '****** Von: RCO ****** '****** Mit Hilfe von Sonic und natürlich der Asuro.c ****** '************************************************************** '********* www.Roboternetz.de ********** '************************************************************** 'Integrierte Funktionen: 'Motordir(x,x) x: Fwd, Rwd, Break, Free 'Motorspeed(x,x) x: 0-255 'Backled(x,x) x: An, Aus 'Statusled(x) x: Aus, Green, Red, Yellow 'Frontled(x) x: An, Aus 'Odometrie() Ausgabe in Odoright;Odoleft(word) 'Linidata() Ausgabe in Lineright;lineleft(word) (da data reserviert) 'Pollswitch() :ist selbst die Variable(byte) $regfile = "m8def.dat" $crystal = 8000000 $baud = 2400 On Int1 Int1_int Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 8 Config Adc = Single , Prescaler = Auto , Reference = Avcc Enable Interrupts Start Adc Enable Adc Enable Int1 Config Int1 = Falling Declare Sub Motordir(byval Mldir As Byte , Byval Mrdir As Byte) Declare Sub Motorspeed(byval Mlspeed As Byte , Byval Mrspeed As Byte) Declare Sub Backled(byval Led1 As Byte , Byval Led2 As Byte) Declare Sub Frontled(byval Led1 As Byte) Declare Sub Statusled(byval Color As Byte) Declare Sub Odometrie() Declare Sub Linedata() Declare Function Pollswitch() As Byte '-----------Motoren------------------- Const Fwd = 1 Const Rwd = 2 Const Free = 3 Const Brake = 4 'Motor Rechts Config Pinb.1 = Output Config Pind.4 = Output Config Pind.5 = Output 'Motor Links Config Pinb.2 = Output Config Pinb.4 = Output Config Pinb.5 = Output '----------Led------------------------ Const Aus = 0 Const Red = 1 Const Green = 2 Const Yellow = 3 Const An = 1 'FrontLED (Odometrie) Config Pind.6 = Output ' ****** !!! ACHTUNG !!! *******BACKLEDs*********************************** Config Pinc.0 = Output 'Rechts Config Pinc.1 = Output 'Links ' Die BackLEDs können nicht genutzt werden wenn die Odometrie benutzt wird. ' --> BackLEDs pinc.0 und pinc.1 als Ausgang definieren ' --> Odometrie pinc.0 und pinc.1 als Eingang bzw. ADC definieren ' ****** !!! ACHTUNG !!! ************************************************** 'StatusLED Config Pind.2 = Output 'Rot? Config Pinb.0 = Output 'Grün? '----------Odometrie------------------- Dim Odoright As Word 'data geht nciht, da expression Dim Odoleft As Word Config Pinc.2 = Input Config Pinc.3 = Input '----------Line------------------- Dim Lineright As Word Dim Lineleft As Word 'Config Pinc.0 = Input 'Nur aktivieren wenn Backleds aus 'Config Pinc.1 = Input '-----------Pollswitch----------- Config Pind.3 = Input Portd.3 = 0 'für den Interrupt Config Pinc.4 = Input Portc.4 = 0 Dim Poll As Byte '########################################################################## '############################### Main ##################################### '########################################################################## Do Loop End '########################################################################## '############################### Ende ##################################### '########################################################################## '--------Subs------------------------- Sub Motorspeed(byval Mlspeed As Byte , Byval Mrspeed As Byte) Pwm1a = Mlspeed Pwm1b = Mrspeed End Sub Sub Frontled(byval Led1 As Byte) Portd.6 = Led1 End Sub Sub Motordir(byval Mldir As Byte , Byval Mrdir As Byte) If Mldir = 1 Then 'FWD Portd.4 = 0 Portd.5 = 1 Elseif Mldir = 2 Then 'RWD Portd.4 = 1 Portd.5 = 0 Elseif Mldir = 3 Then 'FREE Portd.4 = 0 Portd.5 = 0 Elseif Mldir = 4 Then 'BRAKE Portd.4 = 1 Portd.5 = 1 End If '----------------- If Mrdir = 1 Then 'FWD Portb.4 = 0 Portb.5 = 1 Elseif Mrdir = 2 Then 'RWD Portb.4 = 1 Portb.5 = 0 Elseif Mrdir = 3 Then 'FREE Portb.4 = 0 Portb.5 = 0 Elseif Mrdir = 4 Then 'BRAKE Portb.4 = 1 Portb.5 = 1 End If End Sub Sub Backled(byval Led1 As Byte , Byval Led2 As Byte) Portc.1 = Led1 Portc.0 = Led2 End Sub Sub Statusled(byval Color As Byte) If Color = 0 Then 'Aus Portd.2 = 0 Portb.0 = 0 Elseif Color = 1 Then 'ROT? Portd.2 = 1 Portb.0 = 0 Elseif Color = 2 Then 'Green ? Portd.2 = 0 Portb.0 = 1 Elseif Color = 3 Then 'Yellow Portd.2 = 1 Portb.0 = 1 End If End Sub Sub Linedata() Lineright = Getadc(2) Lineleft = Getadc(3) End Sub Sub Odometrie() Odoright = Getadc(0) Odoleft = Getadc(1) End Sub Function Pollswitch() As Byte Dim Erg2 As Long Dim Erg1 As Word Portd.3 = 1 Erg1 = Getadc(4) Erg2 = 10240000 / Erg1 Erg2 = Erg2 - 10000 Erg2 = Erg2 * 63 Erg2 = Erg2 + 5000 Erg2 = Erg2 / 10000 Pollswitch = Erg2 Portd.3 = 0 End Function Int1_int: 'Platz fpr Routine, z.B. Aufruf von Pollswitch() Return






Zitieren

Lesezeichen