hallo
wieder mal ein kleines update.
die kabelgebundene steuerung war nur eine notlösung!
hab mir heute überlegt wie ich das am einfachsten realisieren könnte via funk oder ir. hab mich für ir entschieden und die in Bascom implementierte rc5 abfrage verwendet.
zum glück hab ich eine all in one fernbedienung, denn von den standard drückern kann fast keiner rc5 bei mir jedenfalls.
zur abfrage hab ich ein programm auf meinen mega8 geladen um zu schauen welcher code bei welcher taste rüberkommt und dann die richtigen cods einfach in den schleifen abgefragt.
der einzige nachteil ist:
warten bis eine taste akzeptiert wird (dürft halt so sein bei rc5)
jedenfalls hie rmal mein programm
Code:
$regfile = "m8def.dat"
$crystal = 8000000
$lib "mcsbyte.lbx" 'Quarzfrequenz
$baud = 9600
$hwstack = 34
$framesize = 34
$swstack = 34
Config Pinb.1 = Output
Motor1_pwm Alias Portb.1
Config Pind.6 = Output
Motor1_in1 Alias Portd.6
Config Pind.7 = Output
Motor1_in2 Alias Portd.7
Config Pinb.2 = Output
Motor2_pwm Alias Portb.2
Config Pinb.0 = Output
Motor2_in1 Alias Portb.0
Config Pinb.5 = Output
Motor2_in2 Alias Portb.5
Config Pind.2 = Input
Config Rc5 = Pind.2
'RC5 initialisieren
Enable Interrupts
Dim Adress As Byte , Command As Byte
Do
Getrc5(adress , Command)
Waitms 5
If Command = 80 Then
Gosub Vor
End If
If Command = 209 Then
Gosub Zuruck
End If
If Command = 85 Then
Gosub Links
End If
If Command = 214 Then
Gosub Rechts
End If
If Command = 255 Then ''keine taste gedrückt 255 d.h für bremse/stop
Gosub Brems
End If
Loop
Vor:
Motor1_in1 = 0 'Drehrichtung Motor 1
Motor1_in2 = 1 'Drehrichtung Motor 1
Motor2_in1 = 1 'Drehrichtung Motor 2
Motor2_in2 = 0 'Drehrichtung Motor 2
Motor1_pwm = 1
Motor2_pwm = 1
If Command = 80 Then
Gosub Vor
Else
End If
Return
Zuruck:
Motor1_in1 = 1 'Drehrichtung Motor 1
Motor1_in2 = 0 'Drehrichtung Motor 1
Motor2_in1 = 0 'Drehrichtung Motor 2
Motor2_in2 = 1 'Drehrichtung Motor 2
Motor1_pwm = 1
Motor2_pwm = 1
If Command = 209 Then
Gosub Zuruck
End If
Return
Links:
Motor1_in1 = 1 'Drehrichtung Motor 1
Motor1_in2 = 0 'Drehrichtung Motor 1
Motor2_in1 = 1 'Drehrichtung Motor 2
Motor2_in2 = 0 'Drehrichtung Motor 2
Motor1_pwm = 1
Motor2_pwm = 1
If Command = 85 Then
Gosub Links
End If
Return
Rechts:
Motor1_in1 = 0 'Drehrichtung Motor 1
Motor1_in2 = 1 'Drehrichtung Motor 1
Motor2_in1 = 0 'Drehrichtung Motor 2
Motor2_in2 = 1 'Drehrichtung Motor 2
Motor1_pwm = 1
Motor2_pwm = 1
If Command = 214 Then
Gosub Rechts
End If
Return
Brems:
Motor1_pwm = 0
Motor2_pwm = 0
Return
End
eventuell bau ich dann eine eigene steuerung für meinen buboter, jedoch fürn anfang ist rc5 mehr als ausreichend!!!
so gehts weiter
die Sensoren werden demnächst im programm abgefragt
ein akku wir den buboter mit strom versorgen
die erste testplatine wird entwickelt
mfg
piri
Lesezeichen