Hi, I'm currently finishing off my AS DT project which is a remote controlled car thing. I've been learning how to use Picaxe chips as I've been building it and I realise in hindsight some things I've done had much easier solutions so I do apologise if I've made any glaringly obvious mistakes.
On the whole, the circuit and Programs I've got are working perfectly 90% of the time although sometimes I get some problems such as the 8 bytes from the transmitter chip being received in the wrong variables so the car will just endlessly accelerate or something. I think I need to use the serin qualifier thing but I can't get my head around how it works. would I set the b0 to say 87 and then make the qualifier 87 so it always starts in the same place?
I'm having another problem where if the joystick is say being pushed forward and you keep it completely still, the program stops accelerating even though the joystick is still being pushed forward and it hasn't reached the value of the acceleration. This isn't too much of a problem because I just move the joystick very slightly the left and right whilst its accelerating and it works fine then.
I think this is a problem with my wiring but the car sometimes behaves strangely if I turn the indicators on and off. Like there are 1-4 second delays when the car doesn't receive anything from the controller. Or sometimes if I turn on the indicator switch on the remote the car doesn't turn them on at all.
Any help would be massively appreciated or if there are any other suggestions for the programs I won't be able to thank you enough!
Sorry if there are any details I haven't included that I need to, I'm still quite new to all of this.
Thanks,
Theo
40X2 Car
08M2 Steering chip
08M2 Lights Chip
20M2 Controller
On the whole, the circuit and Programs I've got are working perfectly 90% of the time although sometimes I get some problems such as the 8 bytes from the transmitter chip being received in the wrong variables so the car will just endlessly accelerate or something. I think I need to use the serin qualifier thing but I can't get my head around how it works. would I set the b0 to say 87 and then make the qualifier 87 so it always starts in the same place?
I'm having another problem where if the joystick is say being pushed forward and you keep it completely still, the program stops accelerating even though the joystick is still being pushed forward and it hasn't reached the value of the acceleration. This isn't too much of a problem because I just move the joystick very slightly the left and right whilst its accelerating and it works fine then.
I think this is a problem with my wiring but the car sometimes behaves strangely if I turn the indicators on and off. Like there are 1-4 second delays when the car doesn't receive anything from the controller. Or sometimes if I turn on the indicator switch on the remote the car doesn't turn them on at all.
Any help would be massively appreciated or if there are any other suggestions for the programs I won't be able to thank you enough!
Sorry if there are any details I haven't included that I need to, I'm still quite new to all of this.
Thanks,
Theo
40X2 Car
Code:
symbol steering = b1
symbol acceleration = b4
symbol light = b6
symbol duty = b29
initialise:
pause 1000
output B.4
output A.3
low b.4
low A.3
setfreq em32
let duty = 128
HPWM PWMDIV4, 0, 0, %0100, 32, 0
pause 4000
goto main
main:
do
high C.4
serin [6000,disconnected], C.7, n2400, b0,b1,b2,b3,b4,b5,b6,b7
low C.4
let b8 = light
let b8 = light & 4
if b8 > 0 then 'headlights on
'high B.7 '
else
'low B.7 'Headlights off
endif
let b8 = light & 2
if b8 > 0 then ' left indicator on
high C.3
else
low C.3
endif
let b8 = light & 1
if b8 > 0 then ' right indicator on
high D.0
else
low D.0
endif
if b3 = 1 then
goto disconnected
endif
if steering < 75 then
high A.3
else
low a.3
endif
if steering > 180 then
high B.4
else
low b.4
endif
let acceleration = b4
if acceleration > 140 then 'if joystick forward
if acceleration > duty then
duty = duty + 4 MAX acceleration
endif
elseif acceleration < 115 then
if acceleration < duty then
duty = duty - 4 MIN acceleration
endif
endif
if duty > 127 then 'moving forward
low D.5
high D.4 'Motor Forward
let acceleration = duty - 128
else 'reversing
low D.4
high D.5 'Reverse Motor
let acceleration = 128 - duty
endif
hpwmduty acceleration 'Speed of motor
loop
disconnected:
hpwmduty 0
low B.4, A.3
low D.0, C.3
pause 2000
do until b7 = 1
high D.0, C.3
pause 400
low D.0, C.3
loop
do until b7 = 0
low high D.0, C.3
loop
goto initialise
Code:
initialise:
input C.4 'Left
input C.3 'Right
let b1 = 130
symbol duty = b1
start:
do
if PinC.4 = 1 then
duty = duty + 2 MAX 220
endif
if PinC.3 = 1 then
duty = duty - 2 MIN 60
endif
pause 10
servo C.2, duty
loop
Code:
initialise:
setfreq m32
input C.3
Input C.2
main:
do
low C.1, C.4
pause 3500
if pinC.2 = 1 then
high C.1
endif
if pinC.3 = 1 then
high C.4
endif
pause 3500
loop
Code:
symbol light = b6
initialise:
setfreq m32
main:
let b7 = 0
let b3 = 0
let light = 0
if Pinc.5 = 1 then
let light = light + 1 'left indicator
Endif
if Pinc.6 = 1 then
let light = light + 2 'right indicator
Endif
if Pinc.7 = 1 then
let light = light + 4 'headlights
Endif
if PinC.3 = 1 then
let b3 = b3 + 1
Endif
if PinC.4 = 1 then
let b7 = b7 + 1
Endif
readadc C.1, b1 'acceleration
readadc C.2, b4 'acceleration
rfout c.0, (b0,b1,b2,b3,b4,b5,b6,b7)
goto main
'b1 steering
'b3 stop
'b4 acceleration
'b6 lights
'b7 reset