tmack

Member
I have been trying to use the picaxe to take the pwm signal that comes from a hobby radio reciever and use that to send output pins high and low to control relays. I believe the pwm signals a servo use are 75,125,225 for middle left and right positions. I would like to be able to set an input pins to recieve the pwm and when it gets 75 through 125 it turns the relay off and at 225 it turns the relay on. I dont really know how to use the pulsin or variables really. The last I tried is a modified version the code hippy showed me to make a camera sequencer.Im Kind of embarrassed to show what the code looked like because its probly not in the neiborhood of what it needs to be . But here it is:

pulsin 3,1w1

Do
Do : Loop While b1 = 0-125
Do : Loop While b1 = 225

LookUp b0

If b1 = 0-125
then low 1
if b1= 225
then high 1

Thanks for any help you guys can give me. I REALLY appreciate it.

hippy

Senior Member
Im Kind of embarrassed to show what the code looked like because its probly not in the neiborhood of what it needs to be . But here it is:
I wouldn't be too worried about it as we all had to start somewhere. At least with software it's often fixable, not so with cooking or explosives

PulsIn measures the pulse and sets the time in w0, in 10uS intervals. The easiest thing to do is convert the pulse time to microseconds so it makes the maths easier later -

Code:
``````PulsIn 3, 1, w1
w1 = w1 * 10``````
The PWM (servo) pulse time ranges from 750uS to 2250uS with mid-position being 1250uS, and you can determine which band the pulse is in by using a rather simple Case statement -

Code:
``````Select Case w1
Case <   750 : Goto Below_750
Case <= 1250 : Goto Between_750_And_1250
Case <= 2250 : Goto Between_1251_And_2250
Else         : Goto Above_2250
End Select``````
That should help get you on your way.

RBruceM

New Member
Nicely done, Hippy. I was very pleased to see "case" statements in the basic manual for the Picaxe chips. Not too basic, this Picaxe basic!

Bruce M

manuka

Senior Member

I'm either getting past it, or moving in the wrong circles as that "hobby radio" term initially confused. Is this just classic VHF radio control as used model aircraft etc => http://www.societyofrobots.com/member_tutorials/book/export/html/25 ?

Hippy - indeed a nice use of CASE, which I'd not realised was part of the command set !

Wrenow

Senior Member
Actually, you might find the signal to be anywhere between 75 and 225 depending on control position, end point adjustment, trim, and indifvidual radio characteristics.

A better approach for your application might be to determine where neutral is, say 150 (but I have seen some radios where it is 125 or 155), and set a band around it for the neutral, and if it goes outside this band, executes the trigger.

As in, assuming the center is, indeed, 150, something along the lines of.

Toggle one direction - w1<140 (say)
Toggle other direction- w1>160 (say)
Neutral - 140<=w1>=160

Cheers,

Wreno

PDO

New Member
I'm either getting past it, or moving in the wrong circles as that "hobby radio" term initially confused. Is this just classic VHF radio control as used model aircraft etc => http://www.societyofrobots.com/member_tutorials/book/export/html/25 ?

Hippy - indeed a nice use of CASE, which I'd not realised was part of the command set !