Autonomous Helicopter With Basic Stamp
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!
Comments
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.
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.)
http://www.youtube.com/watch?v=6opeJXWy2vY
http://www.youtube.com/watch?v=kwCO6wMgRm4
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.
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?
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.
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.
http://www.youtube.com/watch?v=mbpVmO8BDJ4
Either way that is jumping ahead, can't wait to see what happens with the controller hacking
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:
And in post #13 you state:
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.
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.
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.
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.
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.
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.
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?
Is that because a voltage divider is constant without the changing resistance of a POT in the place of one of the resistors?
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
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.
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?
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!
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
Not to say I'm giving up on the idea!