Shop OBEX P1 Docs P2 Docs Learn Events
RC controller project — Parallax Forums

RC controller project

bennettdanbennettdan Posts: 614
edited 2006-05-14 02:09 in BASIC Stamp
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?··

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2006-05-13 12:08
    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
  • bennettdanbennettdan Posts: 614
    edited 2006-05-13 16:37
    Did you pause between each read or just one right after the other?
  • stamptrolstamptrol Posts: 1,731
    edited 2006-05-13 18:57
    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
  • bennettdanbennettdan Posts: 614
    edited 2006-05-14 02:09
    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!
Sign In or Register to comment.