Shop OBEX P1 Docs P2 Docs Learn Events
R/C Radio Control over a Propeller using SPIN — Parallax Forums

R/C Radio Control over a Propeller using SPIN

Paul_HPaul_H Posts: 85
edited 2007-02-28 01:17 in Propeller 1
Hi All,

As a new propeller owner and relatively new hobbyist, I posting to ask if there is existing SPIN code to read in pulses from an R/C controller (receiver).

My project is for a basic autopilot for my RC plans and I want to switch from manual-to-Propeller control by reading a servo control channel. (I'll be passing servo control thru for the other channels). I have read several examples under BS2, but nothing specifically for SPIN, and I have searched the forums and have not come across this type of scenario.

I'll be happy to post my results as I make headway.

Thanks for your examples and pointers!

Paul

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-23 21:13
    You should be able to use the BS2 compatibility library (PULSIN or RCTIME) from the Propeller Object Exchange to measure the width of the incoming servo pulses, then you can do whatever you want with them. You can also use the routines as examples and modify them or incorporate them into you own code.
  • statemachinestatemachine Posts: 24
    edited 2007-02-24 12:29
    Sounds interesting,Paul,how about a general overview of how the autopilot goes about it's business?

    ···· Bry.
  • Paul_HPaul_H Posts: 85
    edited 2007-02-26 23:04
    Mike,
    Good Idea - I had though about that but was concerned that the BS2 library would take more resources than native code. Is this concern founded or Is there a performance hit using PULSIN or RCTIME? And Yes I know I have 8 cogs to pick up any slack smile.gif !

    Paul
  • Paul_HPaul_H Posts: 85
    edited 2007-02-26 23:22
    Bry,

    I have two goals for the project
    1. Be at a safe altitude
    2. Come Home

    I fly my plane from a first person view with a video downlink. I want the the propeller act as a safety in the event that I loose the video downlink, or the R/C control uplink. If I can get the plane to come closer to me after a failure, the theory goes that the control and video should return. Here's the highlevel overview for a system to return the plane to it's takeoff location. It's nowhere near code yet, but its the flowchart:

    1. Record the starting location (Lon/Lat/Alt) to a variable, maybe write to a flash card.
    2. Plane has onboard GPS which provides HDG (compass heading), ALT(altitude), Log/Lat.
    3. By subtracting the two Lat/Lon coordinates the using the Float32Full ATAN2 function on the difference, I can compute the bearing the plane needs to go.
    4. Subtract again the current heading from the needed bearing and make the turn decision: 1-180 means turn right, 180-360 (or 0- minus180) turns left - I might have that backwards...
    5. Tell the rudder servo to make a gentle turn.
    6. When the plane is close to "home", start circling at a a predefined radius, or just let the routine above keep turning the place around.

    My plane is very stable, so if I make these "flat turns" I can slowly bring it to the right direction. There are a few special cases for the math, as well as real-world concerns (like going to a preset altitude above the ground first, keeping level, etc) but I think I have a handle on them.

    I'll keep posting as I make progress. Be warned - It'll take me a few months at least! You can check out my 2 video pilotage videos on my website at www.hubner.net. There is one early take and one funny, err, "landing". I'll post more as I make them.

    Thanks!
    Paul

    Post Edited (Paul H) : 2/27/2007 2:21:28 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-27 00:00
    Paul,
    There's an insignificant performance hit in using the BS2 routines. The main issue is that the portions of the BS2 library that you don't use are still occupying memory. If you have plenty of memory, who cares? If memory is tight, you can cut and paste the routines you need into your own program and discard the rest. There are a couple of global variables (uS, ms, s) and a global constant (cntMin) that you'd have to include, but that's easy.
  • statemachinestatemachine Posts: 24
    edited 2007-02-27 00:06
    It would be interesting to get a look inside these units.I believe a lot of work is in store.Bry.
    · http://www.micropilot.com/autopilots.htm
  • Paul_HPaul_H Posts: 85
    edited 2007-02-27 14:29
    Whatcha talkin about Bry? It'll be a piece of cake AND I'll undersell the market and it'll only take a week..... lol!

    The micropilot gear is probably (literally) bulletproof and does a heck of a lot more than mine, but I really am not too worried.
    And now that I've written that, I'll have something to eat if I'm wrong smile.gif


    Mike - thanks for the info - This will make my first trys that much easier.
    Paul
  • statemachinestatemachine Posts: 24
    edited 2007-02-28 01:17
    Looking forward with interest Paul.



    ·Bry.
Sign In or Register to comment.