Aussie noob loosing hair rapidly please help

k75

New Member
Well here it goes.
I thought of a simple project some nav lights for my RC Helicopter. So I got a 08m and l got all Led's blinking how I want them to. So then I thought (and here is where I should have Quit) wouldnt it be nice to actually turn them on with my Gears switch on my transmitter. Well shall we say no luck. I just need a way to read my rxsignals to turn the led on. I would appreciate a simple code with a simple explanation. I used input 3 (Infrain/In 3) for RX signals.
 

goom

Senior Member
Tap into the signal line from the receiver to the gear servo/switch, and feed into the Picaxe. Readthe pulse width with pulsin in a loop that encompasses the rest of your code. If the pulse width is, say, >150, then program so that the lights are commanded on, and off if <150.
 

k75

New Member
Sorry for the question but what do I have to do to read the pulse, I have seen this in the manual.
pulsin 3,1,w1
I just need an idiots guide to getting the pulse width.
 

Brietech

Senior Member
I actually did just this for a friend....here is my code:

Code:
symbol pwm_on = 150

main:
low 4		'turn off permanently_on leds
low 0

pulsin 3,1,w0

if w0 > pwm_on then light_up
goto main

light_up:	
	readadc 1, b0	'read in double-blink frequency
	w0=b0*8		
	readadc 2, b2	'read in inter-blink delay
	w1=b2*2		
	
	high 0 		'turn on permanently-on LEDs
	pause w0
	high 4
	pause w1
	low 4
	pause w1
	high 4
	pause w1
	low 4
	
	goto main
 

k75

New Member
Thank you for your help with my nav lights problem it frustrates me when I dont understand something. If I could bother you just on some explanations. Here is a simple
way of me learning this. All I want is that if signal is there Green led blinks and if no signal then Red Led blinks.If I can get this working I will be able to modify the code for my aplication.
picaxe-08M
Green led hooked upto input 1
Red led hooked upto input 2
Reciever hooked directly into input 3 (Not shoore about this one)

If possible could you help me understand what I am missing

symbol pwm_on = 150
pulsin 3,1,w0

if w0 > pwm_on then LedGreen

LedGreen:
high 1
pause 500
low 1
pause 500

LedRed:
high 2
pause 500
low 2
pause 500
 

moxhamj

New Member
You could put it all in a loop:

symbol pwm_on = 150
main:
pulsin 3,1,w0

if w0 > pwm_on then
gosub ledgreen
else
gosub ledred
endif

goto main

LedGreen:
high 1
pause 500
low 1
pause 500
return

LedRed:
high 2
pause 500
low 2
pause 500
return
 

goom

Senior Member
Your code needs a label at the start, and a goto this label after each flashing section.
A model aircraft is probably quite noisy (electrically), so you may get some spurious spikes in the signal line from the receiver to the Picaxe. You could add a bit of code to ignore them by looping straight back to the starting label. You may want to use the "select case" statemant which would be a little more elegant than multiple If statements, and probably take up less code memory.

Code:
start:
pulsin 3,1,w0
select case w0
 case 150 to 210
 high 1
 pause 500
 low 1
 pause 500
case 90 to 149
 high 2
 pause 500
 low 2
 pause 500
end select
goto start
Try this code in the simulator, and vary the "Generic" value (which will simulate the pulsin value). You will notice that for an invalid pulse (i.e. <90 or > 210), both LED's will be off.
I see that Dr Acula beat me too it. Just shows there are many ways to skin a cat.
 

k75

New Member
I am most grateful for all your help. I used the following code.
symbol pwm_on = 150
main:
pulsin 3,1,w0

if w0 > pwm_on then
gosub ledgreen
else
gosub ledred
endif

goto main

LedGreen:
high 1
pause 500
low 1
pause 500
return

LedRed:
high 2
pause 500
low 2
pause 500
return

The red led flashes fine but as soon as i Hook up a wire or eaven touch Infrain/in3 the green goes on. Mind you it is the first touch switch that I have made (but thats for another project LOL) I think that it must be to sensitive, can you tell me which setting would have to be changed. I believe
symbol pwm_on = 150 the 150 should be increased (am I on the right highway now?)
 

moxhamj

New Member
If you keep the picaxe chip connected to the computer while you test it you can put a debug command after the pulsin command. Then every second or so the screen on the computer will update with the new value of w0. This will help determine the actual value you need to put in the code to change between red and green.
 
Top