Shop OBEX P1 Docs P2 Docs Learn Events
Control a few servos at the same time — Parallax Forums

Control a few servos at the same time

Henry ChanHenry Chan Posts: 5
edited 2006-10-27 08:03 in BASIC Stamp
Is this possible?
I want to make an model airplane Radio Control system using Stamp with RF module. Just like a usual radio control, I need to monitor at least 4 channels(Throttle, alieron, elevator and rudder) at the same time from 4 potentiometer. As there's no interrupt in Stamp, how can I do this? Hopefully I don't need to get an extra Stamp chip for every extra channel!

Thanks a lot

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2006-10-25 20:28
    Main:
    GOSUB ReadPorts
    GOTO MAIN

    ReadPorts:
    PULSIN 1, 1, Port1Val
    PULSIN 2, 1, Port2Val
    PULSIN 3, 1, Port3Val
    PULSIN 4, 1, Port4Val
    RETURN

    ' Note each "PULSIN" may take up to 20 mSec to complete,
    ' it depends on the order the 'reciever' channels are sent.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-10-25 22:08
    Henry -

    IF you're looking to INTERCEPT or MONITOR the R/C signals from an EXISTING R/C Transmitter/Receiver system, Allan has given you a fine example. Many folks have been quite surprised and pleased at·how much additional function or the various alterations they can achieve this way.

    IF you are looking to CONSTRUCT an R?C transmitter/Receiver system with a PBASIC Stamp, I'm afraid that's just not going to happen, for at least 1/2 a dozen different reasons.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 10/25/2006 10:19:24 PM GMT
  • Henry ChanHenry Chan Posts: 5
    edited 2006-10-26 05:46
    Thanks! I'm only a newbie on Stamp and I'm a VB programmer for a few years.

    Take it simple first. If I only make the Stamp as a dummy device, that is, I connect my existing 4 Channels R/C receiver to my BS2 port 1-4, and I connect my servos to port 5-8. So I read ports 1-4 using Allan's code and add another subroutine for ports 5-8 using PULSOUT command. Is this correct?

    Here's my actual scenario. I want to make a very simple UAV autopilot system like this http://www.micropilot.com/prod_mp2028g.htm. For my first version, I only need to INTERCEPT the R/C signals from my existing JR/Futaba remote control. And when I switch on the autopilot, the plane can fly itself from my preset GPS waypoints. When I switch off, I can control the plane again just like a usual R/C plane. Meanwhile the real-time flying data can be transmitted to my computer by the RF module. I found a transceiver(I only use it as transmitter), http://www.haccom.com/en.htm, that got 2km range which is good enough for my project.

    And for my second version, I don't want to waste half of transceiver(use to both transmit and receive this time) and I want to control my plane in real-time from my PC, this is my final goal!

    Sounds my first version is more realistic to complete than the second one.

    Thanks a lot!
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-10-26 06:25
    Henry -

    I'd prefer to think of the Stamp as an intercept device, rather than a "dummy device", but it sounds like you have your plan well in hand. Good luck with it, and let us know if we can be of further assistance.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-10-26 14:02
    Yup, read the ports with the above subroutine, and write the outputs with:

    WritePorts:
    PULSOUT 4, Port1Val
    PULSOUT 5, Port2Val
    PULSOUT 6, Port3Val
    PULSOUT 7, Port4Val
    RETURN

    Note the 'servo' output signal should be refreshed every 20 mSec. In this app, the delay of reading the INPUT signal will already give you that delay, so you don't need an additional "PAUSE 20" instruction in your code.

    If you DO want your BS2 to control the servo's "autonomously", then you'll need a PAUSE somewhere so you don't refresh the servo's too often.
  • jcfergusonjcferguson Posts: 86
    edited 2006-10-26 23:28
    Bruce, you say above that an RC system with stamps isn't going to happen? I asked this same question for several days a few weeks ago, and no one said it wasn't possible, so off I went. My system that reads three joysticks with one stamp and then sends the information over the Parallax 433 RF units to another that drives the servos seems to work (though it is two fixed-position devices, no range issues to deal with - and only three servos). The advantage is that I have very good control over servo range/speed/deadzone. The RC unit I had been using before switching to stamps was very glitchy, sensitive to any power supply variations, the stamps are rock solid.

    Why wouldn't it work (I am not asking sarcastically)? I want to know because I have a couple more projects planned and maybe I should switch methods.

    Thanks,

    Carlos
  • Henry ChanHenry Chan Posts: 5
    edited 2006-10-27 07:18
    Thanks guys. I now successfully connect my existing RC control to Stamp(intercept device) and it works fine! Except it should work together with an expensive PCM receiver. If I use a FM receiver, it's extremely glitchy that seems my servos will burnt out easily if I still using it.

    So my next step is to start my Maths lesson: work with the GPS, tell the plane how to fly.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-10-27 08:03
    Carlos -

    Have you ever used an ordinary multiple channel R/C transmitter and receiver? If not, just using one will show you part of the problem. With your setup, you can only move one servo at a time (concurrently). With an ordinary R/C transmitter you can operate multiple servos different amounts (nearly simultaneously).

    Next, unless I'm mistaken, using 433 MHz for "control purposes" is an illegal use under Part 15 of the FCC Regulations.

    Additional deficits can be found in individual channel trim, servo reversing, signal validity, transmitter range (Part 15 issue), minimal channel refresh time, and I suppose I could go on if you want me to.

    I'm glad your system worked out to meet your minimal needs.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
Sign In or Register to comment.