PDA

View Full Version : RC controller project



bennettdan
05-13-2006, 03:50 PM
Hello
··· I was wondering if I could read the Pulse Width of an 2 Channel·RC car controller reciver, It would take two pins reading pulsein but I understand that the BS2 can only read one pulsein at a time so if I was one to read the other·I need to measure for 2ms at a time to get an acurate reading?··

stamptrol
05-13-2006, 07:08 PM
You just program a loop that looks at all channels one after the other.

I've used a BS2 to read a 6-channel radio this way, plus executed a 600 line program to control the machine.

Cheers

bennettdan
05-13-2006, 11:37 PM
Did you pause between each read or just one right after the other?

stamptrol
05-14-2006, 01:57 AM
The general line of thought in most control loops is:

1. measure all the inputs

2. use the measured values to figure out what needs to be done

3. update the outputs based on what happened in step 2.

4. goto step #1.

So, to answer your question, I read all channels one right after the other. Here's a sample from a simpler, 4-channel system.


mainLOOP:

PULSIN 8,0,ch1 ' winch 1 control stick
PULSIN 9,0,ch2 ' winch 2 control stick
PULSIN 10,0,ch3 ' forward/reverse main motors;including trolling motor
PULSIN 11,0,ch4 ' left/right on fans; y-connection to steering servo

'DEBUG DEC3 ch1," ",DEC3 ch2," ",DEC3 ch3," ",DEC3 ch4," ",DEC1 IN12,HOME
GOSUB motspd
'PAUSE 250

GOTO mainLOOP


Cheers

bennettdan
05-14-2006, 09:09 AM
Thanks that is exactly how I planed to do it. I just wanted to make sure before I bought a controller. Thanks for your help!