pulse reader

geenius

New Member
Hi guys,

I would like to build my own lights switch for my RC car. I have a 4 channel transmitter and 4 channel receiver.

I have two questions:

Q1: I would like to have brake lights on my RC Car. Each of receiver channels has 3 pins. Pin1 = signal, Pin2 = +5V, Pin3 = GND. On the Pin1 are pulses between 0.75ms to 2.25ms where 1.5ms is neutral. I have done the brake light with the PULSIN command. (connected to channel 3). But when I quickly move the steering stick (channel 1) or quickly move the accelerate / brake stick (channel 2) the brake light quickly flashes. It looks like a noise is comming from the transmitter potentiometer or is generated on receiver. How can I remove the noise (or the jamming)? How could I change the program code? Or is it a HW problem? :confused:

Q2: I would also like to have front/tail lights, fog lights and hazard lights. I would like to control them via 4th channel. So when I move the 4th channels stick from neutral to left one time, the front/tail lights has to switch on, when from neutral to right one time, the hazard light has to switch on an whet from neutral to left two times, the fog lights has to switch on. If you want to switch off som of these light you have to repeat the step when switching it on. I have tried it with PULSIN and COUNT commands but I was unsuccessful. :confused::(

I am sorry about my english, I am not native.
Ask if you have question or you need to describe more in detail :)

Thanks
Geenius
 

Andrew Cowan

Senior Member
I've done this. I have headlights, fog lights, brake lights, reversing lights, left indicators and right indicators. And a failsafe.

Code:
Init:	Low 0	;Headlights
	Low 1	;reversing lights
	Low 2	;left indicator
	Low 3	;brake lights
	Low 4	;right indicator
	Low 5	;Rear red fog lights
	Low 6	;relay (failsafe)

Main:	
High 0
high 5
debug w1
	Pulsin 1,1,w1
	if w1>151 then gosub go_forward
	if w1<144 then gosub go_reverse
	if w1>145 and w1<150 then gosub neutral	;once the signal is back to neutral, turn everything off.  This is also the case if the signal just passes through (eg from full forward to reverse).
	goto main2

Main2:	Pulsin 0,1,w2
		Pulsin 1,1,w1
	if w1=0 then fail
	if w2>161 then left
	if w2<154 then right
	if w2<160 and w1>155 then nothing
	goto main

Go_forward:Pulsin 1,1,w3
	High 0
	Low 1
	Pause 20
	Pulsin 1,1,w4
	w4=w4+5
	If w4<w3 then goto brake	;if the throttle signal is getting less, then goto brake
	return

Go_reverse:High 1
	Return

Neutral:Low 1
	Low 3
	Return
	
Left:	High 2
	Pause 500
	Low 2
	Pause 500
	goto main2

Right:	High 4
	Pause 500
	Low 4
	Pause 500
	goto main2

Nothing:Low 2
	Low 4
	goto main

Brake:	High 3
	pause 1500
	low 3
	goto main
	
Fail:	let pins=0
high 2
high 4
	pause 200
	low 2
	low 4
pause 200
high 2
high 4
pause 200
low 2
low 4
pause 200
high 2
high 4
pause 200
low 2
low 4
pulsin 1,1,w1
pulsin 0,1,w2
if w1=147 and w2=155 then main
	goto fail
A
 

Attachments

Last edited:

geenius

New Member
yes this is very nice :). but the reason why I would like to have such a "complicated" method is because I have a tractor truck and tractors usually have a lots of functions that are real-time controled according needs. for example: coupling/decoupling, mini water pump, trailer support legs, lifting a trailer axle, dumping, and some other light effects.:) so you can control all of this functions with one or two channels.
for the lights that I have described in Q2 could be used the 08M (or maybe 08) chip :)

do you also have the "noise" that I have desciberd in Q1 ?:(
 

Andrew Cowan

Senior Member
To get rid of the noise, put capacitors accross the power supply.

To activate the switching, use a loop with a timeout. This code is not correct - it just shows you the idea.

Code:
main:
pulsin to b1
if b1>150 then parta
goto main

parta:
pulsin
if b1>150 then parta   'wait until it goes back to neutral
partb:
inc variable 'timout'
pulsin
if b1>150 then partc
if timeout>100ms then go routine 1
goto partb

etc.
A
 

geenius

New Member
I have resolved the issue in Q1 :D. the problem was in the program code. I used PULSIN 1,1,b1 instead of incorrect PULSIN 1,0,b1 . :D

I am working now on Q2 :)
 
Top