Shop OBEX P1 Docs P2 Docs Learn Events
Autonomous Helicopter With Basic Stamp — Parallax Forums

Autonomous Helicopter With Basic Stamp

codysprakercodyspraker Posts: 46
edited 2012-04-13 21:26 in Robotics
Currently I am part way through designing a helicopter that can perform basic tasks such as maintaining level flight without a user. To do this, I took apart the controller that was used to pilot the helicopter and did some tinkering with the potentiometers to see if I would be able to send voltage signals from my basic stamp to the potentiometer pins as if I were piloting it. I plan on using PWM to do this. For now I am just using different resistors and sometimes putting the original potentiometer in line with the 5v HIGH from the pin 0 on the basic stamp. I have successful had my code send pulses to the rc controller where the potentiometer used to be and have the helicopter respond to the commands. However, like the original potentiometers purpose was supposed to do, my basic stamp changing voltage is not causing the helicopter to change speed. The original voltage that when through the potentiometer was 5 volts. The potentiometer would then act as a variable resistor to the that 5v causing a change that could be interpreted by the controller and sent to the helicopter in the form of motor speed instructions. To mimic this I bypassed the potentiometer and tried to send my own signal between 0 and 5 volts hoping that any value I send to the signal pin between these two values would result in a corrosponding power signal to be sent to the helicopter's motor. However the helicopter always spins at the same speed regardless of the voltage I put through the signal pin on the controller. Does anyone have any suggestions for why it might be doing this? Or possibly any other solutions to the problem? Thanks for any help!
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-09 14:32
    It's hard to give you advice without more information about the controller and how the potentiometers are connected. A schematic would be helpful.

    If you're trying to substitute Stamp generated voltages for existing potentiometers, this is usually done with PWM, an RC network, and some kind of buffer amplifier that has an output voltage from 0-5V as determined by the Stamp's PWM statement. This buffer is needed to maintain the voltage while the Stamp does other things (like generating other voltages with other PWM statements). Have a look at the Basic Analog and Digital tutorial. Chapter 4 shows a voltage follower buffer amplifier. The PWM statement is pretty thoroughly described in the chapter on this in the Basic Stamp Syntax and Reference Manual and in the Stamp Editor's help files. This website is also a good reference for a variety of Stamp topics. Use the app-notes link at the bottom of the page.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-09 15:04
    The small four channel transmitters that come with a RTF Blade mCX or other small helicopter have a small PCB that translates a serial signal to a radio signal sent to the helicopter. It's possible to use a microcontroller to send a serial signal to this small PCB bypassing the normal joysticks of the transmitter. This way also allows control of all four channels of the transmitter with a microcontroller.

    I used this trick to fly radio controlled helicopters with a Wii Nunchuck (It doesn't make the helicopter any easier to fly though).

    I'm not sure if a BS2 would be up to doing something like this or not. (I used a Propeller chip.)
  • codysprakercodyspraker Posts: 46
    edited 2012-04-09 15:31
    Please view these videos I hope they help you see what I am working with, feel free to fast forward the easy parts, it's a bit slow and quiet but it is meant to clearly show the parts and design, thanks

    http://www.youtube.com/watch?v=6opeJXWy2vY

    http://www.youtube.com/watch?v=kwCO6wMgRm4
  • codysprakercodyspraker Posts: 46
    edited 2012-04-09 15:40
    And also I am looking to put a PWM output into my design to have full analog control over the values from the basic stamp, however I only planned on starting that design when I had been able to place individual resistors in the 5v output pin and thus change the speed of the helicopter that way. It's a proof of concept to do it that way but since I have been unable to change the speed of the helicopter that way, I didn't want to complicate the problem by adding PWM until I had been able to get past the present problem
  • SRLMSRLM Posts: 5,045
    edited 2012-04-09 15:46
    Note that you won't be able to maintain level flight without a user if you don't have an IMU or some similar variant.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-09 15:48
    Sorry to say that the videos are of little use. There's no schematic, no description. I can see there's some kind of potentiometer and an LED that flashes at a rate that seems to be related to one potentiometer's position, but I can't tell how things are connected together or what you're measuring.

    You have to either find or create a schematic for your board. It would be one thing if your project described in post #1 worked, but it doesn't. There's something about what you're doing that isn't behaving the way you expect. To sort that out, you need to supply a schematic.
  • xanaduxanadu Posts: 3,347
    edited 2012-04-09 17:12
    I'm working on something similar, and I bought an infrared controlled (instead of RF) micro heli to do it.

    Since you have to hack the entire controller, I would remove the pots and measure their resistance. Then install some wires on the pot's through holes and build a circuit to replicate the resistance range you just measured.

    To make a a variable resistor connected to a microcontroller the really easy way get some JFET's that match the resistance range you need.

    I'm not sure how the stamp would handle two channels at once with PWM to JFETs either, I know there are work arounds in the code to make it work timing wise...

    Props on the cool project too lol. You got any electronics stores by you like Fry's or Radio Shack?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-09 18:12
    SRLM wrote: »
    Note that you won't be able to maintain level flight without a user if you don't have an IMU or some similar variant.

    Some of those coaxial helicopters are pretty stable.

    I've wondered about adding a couple of IRLEDs to a coaxial helicopter and use a Wii Mote's camera to keep track of the helicopters position.

    I suppose this qualifies as a variant?
  • codysprakercodyspraker Posts: 46
    edited 2012-04-09 18:17
    Duane Degn wrote: »
    Some of those coaxial helicopters are pretty stable.

    I've wondered about adding a couple of IRLEDs to a coaxial helicopter and use a Wii Mote's camera to keep track of the helicopters position.

    I suppose this qualifies as a variant?

    The helicopter that I am using is very stable. The step I am working on only applies to the vertical control. The tilt is not an issue because of how well balanced it is naturally. I will place a ping sensor on the bottom and hopefully keep it at a steady altitude. But I have yet to decide how to keep it from drifting around the room. In the early stages I will be very close and will grab it if it drifts too far or near an object. So far my only object is to keep the height constant by controlling the potentiometer that is used for height control. This is where my problem is. If I can figure this problem out, I will be able to do the same with the x and y axis potentiometer that are used to control the turning and forward and backward stick.
  • xanaduxanadu Posts: 3,347
    edited 2012-04-09 18:49
    What brand and model copter we talking about here anyway?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-09 19:19
    I wonder if the pulses from the PWM is causing a problem.

    I think there are ways to smooth out the power from a PWM source. Would a capacitor help or some other sort of hardware filter?

    There's also the digital potentiometer option.
  • codysprakercodyspraker Posts: 46
    edited 2012-04-09 19:25
    As of now there is no PWM in use. Just a HIGH command used on a single pin on the basic stamp homework board. Yes, I will include a PWM since it will be necessary, I chose it over the digital potentiometer solution due to complexity, parts etc. compared to a PWM. Here is a link the helicopter and a video I made flying it. I have to regret that I can no longer identify specifically the name of the helicopter I believe it most of the labels were translated and I couldn't find it online. Even the manual is no help. I believe it is called an alloy shark or something along those lines but the one online under that name does not exactly match the one that I have. Anyway here is the link:
    http://www.youtube.com/watch?v=mbpVmO8BDJ4
  • xanaduxanadu Posts: 3,347
    edited 2012-04-09 19:36
    Can it lift the weight of say two AA batteries? Make sure you get your CG right, it should balance just front of the rotor mast, then see if it will lift anything. Maybe a small laser pointer, then use photo sensor array on the ground to track it.

    Either way that is jumping ahead, can't wait to see what happens with the controller hacking :)
  • codysprakercodyspraker Posts: 46
    edited 2012-04-09 20:22
    I have already put a wireless camera on it and it has a ton of lifting ability. I wouldn't expect lifting to give me any problems soon. However, battery life is a different story. Possibly, I could add a batteries to offset the excess power in order to give me more battery life but I'm not sure where to draw the line between adding weight in batteries to increase the life and how much weight affects battery life. Oh well, I am just going to be working to figure out this controller I can't seem to figure out the difference between the controllers 5v signal being changed by the pot and my 5v signal from my microprocessor. I keep changing the 5v I send it will individual resistors and it's like nothing happened it always flies with the same power.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-09 20:34
    As Mike suggested, a schematic would help a lot to let us know what you're doing.
  • codysprakercodyspraker Posts: 46
    edited 2012-04-11 04:39
    Duane Degn wrote: »
    As Mike suggested, a schematic would help a lot to let us know what you're doing.

    I just want to be sure, what exactly would help to have a schematic? Which part are you requesting a schematic for?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-11 06:58
    I just want to be sure, what exactly would help to have a schematic? Which part are you requesting a schematic for?

    One of the things that would be good to know is how the original pots are connected. I assume one end of each pot is connected to ground and the other connected to Vdd (5V). How is the BS2 connected (assuming it is) to the PCB previously occupied by the wiper of the throttle pot.

    Does the throttle joystick have more than one pot? If so what is connected to the PCB location of second pot's wiper? Edit: I see from the video there isn't a second pot.

    What is the normal voltage range seen at the wiper of the throttle pot? Does it vary all the way from 0V to 5V or does it have a narrower voltage range? Edit: From the video, It looks like it does vary from 0V to 5V

    In your first post you say:
    To mimic this I bypassed the potentiometer and tried to send my own signal between 0 and 5 volts

    And in post #13 you state:
    As of now there is no PWM in use. Just a HIGH command used on a single pin on the basic stamp homework board.

    So I wonder how you're controlling the voltage to the PCB wiper location. (As I reread this, it kind of sounds challenging. It's not meant to be. I'm just looking for clarification and it's too early in the morning for me to write more diplomatically. :smile:)

    Some RC helicopters have safety features to keep the throttle off if the throttle stick isn't in the low position when it's first turned on. This doesn't seem to be the case with your helicopter but I wonder if the controller on the transmitter doesn't like seeing the wrong initial voltage coming from the throttle pot and wont work correctly because of this.

    You also need to make sure the BS2 board and the transmitter PCB share a common ground connection.

    That helicopter of yours does look very stable. It seems like a good candidate for controlling with a microcontroller.

    Edit: I watched the two YouTube videos again. I assume you're using 0V and 5V from the BS2 to mimic the pot. There's a good chance the transmitter controller chip doesn't like this. I might want to see voltages in between the two extremes before acting on a "full throttle" command.

    Edit again (I told you it was too early for me to think straight): I see in your original post, you mention using different resistors in line with your signal from the BS2. You also mention the pot being a variable resistor. I think this is were your main problem lies. A pot is a voltage divider. A single resistor from the BS2 pin wont mimic a voltage divider.

    You might be able to mimic a voltage divider with a PWM signal. A digital pot would also do the trick. I think there's also something known as a resistor ladder that could work (this requires multiple pins from the BS2). I haven't used a resistor ladder myself since trying it out in one of Parallax's tutorials. I don't remember which of their books I read about it. It was likely either "What's a Microcontroller" or "Understanding Signals". I'm sure there are lots of references on the internet about them. Make sure and read about voltage dividers while your researching.

    I mentioned "What's a Microcontroller" and "Understanding Signals". These are both really helpful books. There are free pdf versions available to download. The other book (also a free pdf) I learned a lot from was "Robotics with the BOE-Bot". I think I used version 2.2. Version 3 is the latest version. I remember in version 2.2, there was a little box in the light sensing section that talked about voltage dividers. I didn't see the same material in version 3 of the book.
  • xanaduxanadu Posts: 3,347
    edited 2012-04-11 13:19
    Duane,

    Following your advice I found some digital potentiometers online. I had never seen these before yet have search for them I guess I was using the wrong terminology when looking. I got a few of the COM-10613 for around $1.00 each. For that price I don't see the need to try anything else, especially pumping PWM into the signal line from the existing potentiometer.

    So what I did was disconnect the potentiometer from the circuit and measure its resistance. The pot is a 5k pot, and the aileron channel's joystick throw goes from 1.3k (right) to 4.55k (left). Since those values are under the 10k value of the COM-10613 I'm assuming it will work, I'll just have less resolution and more invalid resistances available to work out in the code.

    Codyspraker,

    When I get them I'll let you know how well it works asap. That really does seem like the best way to do it though.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-11 14:20
    Jon,

    I hadn't notice those chips at SparkFun before. I'll make sure and add some to my next order.

    From what I've read on the forum, the actual resistance of the pot isn't so important in a lot of circuits. The important thing is to divide the voltage. So in your case, you'd want to vary the resitance (from whichever side you're measuring it from) from 2.6K to 9.1K to give the same voltage range at the wiper as your aileron pot.
  • xanaduxanadu Posts: 3,347
    edited 2012-04-11 17:45
    The voltage at the aileron pot's wiper output with the trim centered is: .5v full left | 1.5v center | 2.5v full right.

    There appears to be 3.3v for the potentiometer power. Only tested one channel, hopefully they're all the same. Too bad it needs to be proportional it would be pretty easy to just make a voltage divider.
  • codysprakercodyspraker Posts: 46
    edited 2012-04-11 17:48
    I have been doing a lot of research on voltage dividers and have yet to use one since I am new to the field. Could you explain why the need for proportional Vout rules out the use of voltage divider?
  • xanaduxanadu Posts: 3,347
    edited 2012-04-11 17:53
    Cody, I think that chip I mentioned earlier running 3 different channels would be very hard to accomplish using the Stamp, so we'll keep thinking along the lines of the Stamp.

    As far a proportional goes, imagine the joystick on the radio has 1024 different positions, and the servo has 1024 matching positions.

    You you to make a voltage divider it would only give you a couple of joystick positions, and for a helicopter that would be nearly impossible to fly. It would be like no throttle, half throttle, or full throttle and nothing in between those.
  • codysprakercodyspraker Posts: 46
    edited 2012-04-11 17:54
    I'm going to try to explain in the most concise way how my wiring is done because I have yet to learn how to write a schematic at a level that would be able to show the steps I am going to use.

    1) The basic stamp homework board microcontroller and the Helicopter wireless remote control require 9V power supplies so to have a common ground and one battery, this battery source is shared.

    2) The pin 0 on the basic stamp microcontroller has an out that constantly outputs 5V. This output pin connects to the MIDDLE leg pin hole where the old POT (5Kohm) was located that controlled the rotor speed of the helicopter.

    It is my assumption that by adding the use of a PWM/Digital Potentiometer instead of a constant 5V, I will be able to control the helicopter's rotor speed.

    Does this sound plausible?
  • codysprakercodyspraker Posts: 46
    edited 2012-04-11 17:57
    You you to make a voltage divider it would only give you a couple of joystick positions, and for a helicopter that would be nearly impossible to fly. It would be like no throttle, half throttle, or full throttle and nothing in between those.

    Is that because a voltage divider is constant without the changing resistance of a POT in the place of one of the resistors?
  • xanaduxanadu Posts: 3,347
    edited 2012-04-11 18:08
    I might be the wrong person to give a good answer but... As you chain the resistors in series between each resistor would give you a fixed voltage. You would need a bunch of resistors to make a bunch of different voltages. And then the question is how do you apply all of those different voltages to the controller board, it would end up being a large circuit and lots of wires.

    It sounds like an RC circuit would be better. You'd run a PWM signal into a resistor in series with a capacitor connected to ground. You tap between the resistor and capacitor to the controller board where the wiper of the potentiometer is connected. This should effectively create a variable voltage. It might be glitchy though. Hard to say without trying it. I think I might try it real quick :)
  • xanaduxanadu Posts: 3,347
    edited 2012-04-11 18:11
    It is my assumption that by adding the use of a PWM/Digital Potentiometer instead of a constant 5V, I will be able to control the helicopter's rotor speed.
    Does this sound plausible?

    Exactly. You need to be able to vary your output voltage of the Stamp in very small increments. When you add five volts it's just going to take it to full power. So you have an on/off switch, when you really need a dimmer switch.
  • codysprakercodyspraker Posts: 46
    edited 2012-04-11 18:21
    Okay this sounds like I am in good shape. My only concern was when I was putting a single resistor in the out pin of my microcontroller putting out 5V and changed it to whatever resulting voltage due to the value of the resistor, should I have been able to see a difference in the speed of the rotor? I was trying multiple individual resistors in the out pin hoping that I could change the voltage for the one instance a get a single speed that differs with each resistor. Should I have seen a speed change? It didn't matter what resistance I used the rotor speed always remained the same
  • xanaduxanadu Posts: 3,347
    edited 2012-04-11 18:41
    Here's the code I used to push 3.5v to 4.7v kind of smoothly.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    counter VAR Word                         ' for the ramping counter
    aileron PIN 0                                  'pin 0 output
    
    FREQOUT 4, 50, 4000                    'ready
    
    FOR counter = 1 TO 5000               'make voltage go up
    PULSOUT aileron, 1000 + counter   'PWM out 1000+counter
    NEXT
    
    FREQOUT 4, 50, 4000                   'done
    FREQOUT 4, 50, 4000
    

    Pin0 connects to a 100ohm resistor and then to a 100pf cap to ground. If you tap between the cap and resistor you'll see a variable voltage. Using a digital multimeter makes it look like its bouncing all over, averaged out it's no so bad. I'm wondering if I should try it on my controller?
  • codysprakercodyspraker Posts: 46
    edited 2012-04-11 18:58
    That looks great and it sounds like it'll work out fine, it would be nice to know the min and max of the volts your code outputs before doing a real test but it sounds like you had that figured out when you said 3.5v and 4.7v
    Also for your consideration:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    counter VAR Word ' for the ramping counter
    aileron PIN 0 'pin 0 output

    FREQOUT 4, 50, 4000 'ready

    DO
    GOSUB backAndForth 'Makes voltage go up and down repeatedly
    LOOP


    backAndForth: 'Makes voltage go up and down repeatedly
    FOR counter = 1 TO 5000 'make voltage go up
    PULSOUT aileron, 1000 + counter 'PWM out 1000+counter
    NEXT
    FOR counter = 1 TO 5000
    PULSOUT aileron, 6000 - counter
    NEXT
    RETURN

    I did a little tinkering, it will loop continuously back and forth. It goes up like you had before but then comes back down and repeats. I just thought that I would use this kind of code so it does not have to be reset when testing it out for real. Also just wanted to get familiar with the logic you used. Feel free to use it and let me know how it goes, just check it first!
  • xanaduxanadu Posts: 3,347
    edited 2012-04-11 19:22
    I fix the code after the project is done, yours is great though.

    Didn't go so well. Using a cheap DMM the voltage rises smoothly, on a scope it looks horrible. The controller must not like it either.

    http://www.youtube.com/watch?v=FzkMVqYsLY8&feature=youtu.be
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    counter VAR Word
    aileron PIN 0
    
    FREQOUT 4, 50, 4000
    
    DO
    
    FOR counter = 1 TO 5000
    PULSOUT aileron, 0 + counter
    NEXT
    
    FREQOUT 4, 50, 4000
    
    FOR counter = 1 TO 5000
    PULSOUT aileron, 5000 - counter
    NEXT
    
    FREQOUT 4, 50, 4000
    
    LOOP
    

    Not to say I'm giving up on the idea!
Sign In or Register to comment.