The minimum and maximum output depend on the resistor, capacitor and PWM frequency. I used a variety of components without doing any math. I think I'll do it right in the morning haha.
Right now I'm using 100 ohm and .1uf cap. and can go from millivolts to 4.7v. It's nice because the max voltage of the pot input into the radio is 5v so no worries about cooking anything. Since your controller runs on less voltage I would be careful and start with 10k resistor.
There's just more too it than adding PWM freq to increase voltage like we are trying to do. I also do not see how the Stamp will be able to run all three channels at once even if we do figure this out. It would need to provide perfect timing on three separate PWM channels.
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
It would be expected not to see a change in speed with a single resitor.
You need a second resistor to make a voltage divider.
If you had used a 2.2K from the Stamp to the wiper position, and also used a 2.2K resistor from the wiper position to ground, then you should see the thottle change to half throttle.
3.3K from Stamp to wiper and 2.2K from wiper to ground would give you 2/5 throttle.
1K from Stamp to wiper and 5K from wiper to ground should give 5/6 throttle.
Using PWM as you described might work. It will depend how smooth you can make the voltage and how picky the controller is. (As Jon found.)
I think a resistor ladder may also be an option. But as Jon suggested, you'd be limited in the number of throttle positions a resistor ladder could simulate (I think, I'm no expert).
Tried playing around with a pause on the FOR/NEXT loop and got some interesting results. A PAUSE 2 makes it work almost perfect for a couple seconds then it freaks out. I got a dso203 quad once it's calibrated I'll look at it a little better.
I cannot get it to work without some kind of op amp.
I got it all hooked up with an opamp. It works the same as with just the RC circuit. It works perfectly for about 1/2 servo turn, you can put it in any position reliably well with no jitter.
OK wow... update. It's this stupid radio Dynam 2.4ghz radio only sends a total of 1/4 available servo rotation to the servo! That was the problem the whole time. So all of the different circuits I tried that 'didn't work' really worked.
' {$STAMP BS2}
' {$PBASIC 2.5}
FREQOUT 4, 2000, 1000 'reboot warning
level VAR Byte
DO
FREQOUT 4, 50, 1000
GOSUB lvl10
FREQOUT 4, 50, 2000
GOSUB lvl12
FREQOUT 4, 50, 3000
GOSUB lvl13
LOOP
lvl10:
FOR level = 0 TO 210
PWM 0, 50, 10
NEXT
RETURN
lvl12:
FOR level = 0 TO 210
PWM 0, 100, 10
NEXT
RETURN
lvl13:
FOR level = 0 TO 210
PWM 0, 150, 10
NEXT
RETURN
Wow this is embarrassing lol. I've been flying, fixing and building RC (not RC circuits haha) airplanes long enough to have realized this problem in the first place.
Now that I know the underlying problem this is very easy to do. The right RC circuit or opamp will work fine. You also need to measure your analog out voltage while it is plugged into the controller because the controller sinks a bunch of current from your AD. So I need 1.6v for center on the pot wiper, i need to output around 2.9 volts without the controller attached. That 2.9v drops to 1.6v with the controller attached.
Great post! That's great to know, luckily I have email on my phone. I was able to see your post on the way to the store, what specific opamp did you use? And does your circuit follow the link that was posted earlier with an opamp in the schematic?
I used a CA3130. I think any opamp that can handle your voltage range is fine. RS sells the LM324 which I've used in the past but have not tried with this, it should work. You'll also need one .1uf cap one 1k and one 10k resistor per channel.
The opamp in the schematic is different than mine so it doesn't follow it, it's very easy to adjust the pinouts for that though. The Parallax pdf above is a good example and easy enough to adjust for something other than the LM358.
So I managed to go to Micro Center and Radioshack and got a ton of electronic goodies, but anyway as far as the op amp goes I got a LM324 Quad OP Amp. Is this different than the one you have in function? I think the only difference is that you had a single and the one I have has multiple built in. I also got a 741 Mini DIP IC and a TL082 Dual BiFET OP Amp for good measure. Let me know if the Quad OP Amp LM324 is acceptable for your design
Just get the datasheet for the LM324 and then hook it up like this - http://www.parallax.com/dl/docs/books/sw/exp/sw22.pdf just make sure you get the pins right (they do not match) Don't use pin numbers, use the schematic symbols of the PDF then find the corresponding symbol on the LM324's PDF.
Use this code to sweep PWM and set the values unit you get the voltage range you need, increase the range as desired.
' {$STAMP BS2}
' {$PBASIC 2.5}
FREQOUT 4, 2000, 1000
level VAR Byte
DO
FOR level = 1 TO 150
PWM 0, level, 10
NEXT
FOR level = 150 TO 1
PWM 0, level, 10
NEXT
LOOP
Okay I am almost done setting up the circuit, I have everything left of the op amp wired but the 12V is confusing me on the schematic. I am assuming that is not the voltage I will be using for the LM324. What is this supposed to be?
Well, some bad news, I connected everything to do the final test, I did some looking and decided to replace the 12V in the schematic with the 5V power of the basic stamp. I changed the range to go up from 1 to 225. I tested the volts and it goes up to 3.8ish and back down to 0. I plugged it in to the controller and it and tried to turn the controller on connected to the same battery as the basic stamp. The led light for power on the controller wouldn't turn on and the volts were about half on the Voltmeter. Confused, I turned to controller on and off hoping to get a change and still nothing. Then I saw some smoke coming from the controller, then a pop. It looks like one of the little pnp or npn transistors burned and probably from the signal going to the controller with the changing volts. My circuit looks exactly like the one you showed me except instead of 12v there is 5v and there is no led or resistor on the far right side. It looks like its working fine however was the last resistor supposed to be there? It says 200 and I had assumed it was just for the led. Did I need it?
Well, some bad news, I connected everything to do the final test, I did some looking and decided to replace the 12V in the schematic with the 5V power of the basic stamp. I changed the range to go up from 1 to 225. I tested the volts and it goes up to 3.8ish and back down to 0. I plugged it in to the controller and it and tried to turn the controller on connected to the same battery as the basic stamp. The led light for power on the controller wouldn't turn on and the volts were about half on the Voltmeter. Confused, I turned to controller on and off hoping to get a change and still nothing. Then I saw some smoke coming from the controller, then a pop. It looks like one of the little pnp or npn transistors burned and probably from the signal going to the controller with the changing volts. My circuit looks exactly like the one you showed me except instead of 12v there is 5v and there is no led or resistor on the far right side. It looks like its working fine however was the last resistor supposed to be there? It says 200 and I had assumed it was just for the led. Did I need it?
Sorry to hear. The last resistor to the LED in the PDF is needed (think of the LED as your controller), but how badly depends on your output voltage. From the above it sounds more like the power wires shorted to something or it had too much input voltage maybe.
Yea I am thinking too much input because I was fairly careful with the power. Is there a chance of identifying the transistor and replacing it? Or is the board probably damaged in more than just one part? I've never popped a component on a board so I'm not sure how that's usually handled.
Yea I am thinking too much input because I was fairly careful with the power. Is there a chance of identifying the transistor and replacing it? Or is the board probably damaged in more than just one part? I've never popped a component on a board so I'm not sure how that's usually handled.
Maybe post a pic of it?
If you were pumping 5v into it before I don't see how 3.8ish volts can ruin it now though.
I had the volt meter connected when it was connected to the controller and I noticed the reading was from zero to only about 1.5ish.. It would hold there about as long as it would take for the code to have gone up to 3.8 like it did before it was connected to the the controller and then would go back down to 0V and repeat. As soon as it popped, I romoved the connections and the voltmeter immediately returned to 0-3.8ish volts. Just an observation that sounded relevant.
So I managed to bypass the broken part by using a pin on the basic stamp to output 5V and connect it to the out leg of the transistor that had popped. I looked up the model and found that it was a 5V 100mA transistor. Normally when the power turns on on the controller its led flashes fairly quickly until you take the throttle up to full and then the led goes solid and the helicopters lights go on. Its like a pairing type of thing or initializing step not really sure. Anyway I know when the controller is sending signals when the led is always lit. However when the code runs and everything is connected, the led goes from blinking quickly to blinking half as fast and there is no signal being sent to the helicopter. The voltmeter is reading this signal being sent to the controller fine and it looks like everything should be working. I even tried to connect the signal pin to the other helicopter controller that still has the throttle Potentiometer attached and tried all three pins and its like its not even there. I'm just confused because it's like there is a difference between the 0-5V the boards generates and reads itself with a potentiometer and the 0-5V that I am sending to it through PWM. Hmm.. anyone have suggestions?
Without knowing your controllers circuitry it would be very hard at this point. At least the controller is working again, that is good. You shouldn't hook it up to the Stamp until you get the LM324 setup correctly and also the controller itself needs a lot of work too.
That's why everyone was asking for schematics earlier. The controller I hacked had a broken antenna and it's worthless to me. There's no aircraft at the other end of my hack job. If your heli is something you want to continue flying I wouldn't hack the controller because it already sounds like things are starting to go wrong. I shouldn't be giving you advice on something I don't have in front of me. The code part wasn't too bad but the rest could be the end of the controller which would make the copter worthless too. That wouldn't be good.
My advice is to try this with something non-functional like I have.
Comments
Right now I'm using 100 ohm and .1uf cap. and can go from millivolts to 4.7v. It's nice because the max voltage of the pot input into the radio is 5v so no worries about cooking anything. Since your controller runs on less voltage I would be careful and start with 10k resistor.
There's just more too it than adding PWM freq to increase voltage like we are trying to do. I also do not see how the Stamp will be able to run all three channels at once even if we do figure this out. It would need to provide perfect timing on three separate PWM channels.
So you might need more hardware as well
It would be expected not to see a change in speed with a single resitor.
You need a second resistor to make a voltage divider.
If you had used a 2.2K from the Stamp to the wiper position, and also used a 2.2K resistor from the wiper position to ground, then you should see the thottle change to half throttle.
3.3K from Stamp to wiper and 2.2K from wiper to ground would give you 2/5 throttle.
1K from Stamp to wiper and 5K from wiper to ground should give 5/6 throttle.
Using PWM as you described might work. It will depend how smooth you can make the voltage and how picky the controller is. (As Jon found.)
I think a resistor ladder may also be an option. But as Jon suggested, you'd be limited in the number of throttle positions a resistor ladder could simulate (I think, I'm no expert).
Here's a really cool calculator (bottom of page) http://sim.okawa-denshi.jp/en/CRlowkeisan.htm
I cannot get it to work without some kind of op amp.
I got it all hooked up with an opamp. It works the same as with just the RC circuit. It works perfectly for about 1/2 servo turn, you can put it in any position reliably well with no jitter.
OK wow... update. It's this stupid radio Dynam 2.4ghz radio only sends a total of 1/4 available servo rotation to the servo! That was the problem the whole time. So all of the different circuits I tried that 'didn't work' really worked.
Now that I know the underlying problem this is very easy to do. The right RC circuit or opamp will work fine. You also need to measure your analog out voltage while it is plugged into the controller because the controller sinks a bunch of current from your AD. So I need 1.6v for center on the pot wiper, i need to output around 2.9 volts without the controller attached. That 2.9v drops to 1.6v with the controller attached.
Wow... just... wow...
The opamp in the schematic is different than mine so it doesn't follow it, it's very easy to adjust the pinouts for that though. The Parallax pdf above is a good example and easy enough to adjust for something other than the LM358.
Use this code to sweep PWM and set the values unit you get the voltage range you need, increase the range as desired.
Sorry to hear. The last resistor to the LED in the PDF is needed (think of the LED as your controller), but how badly depends on your output voltage. From the above it sounds more like the power wires shorted to something or it had too much input voltage maybe.
Maybe post a pic of it?
If you were pumping 5v into it before I don't see how 3.8ish volts can ruin it now though.
That's why everyone was asking for schematics earlier. The controller I hacked had a broken antenna and it's worthless to me. There's no aircraft at the other end of my hack job. If your heli is something you want to continue flying I wouldn't hack the controller because it already sounds like things are starting to go wrong. I shouldn't be giving you advice on something I don't have in front of me. The code part wasn't too bad but the rest could be the end of the controller which would make the copter worthless too. That wouldn't be good.
My advice is to try this with something non-functional like I have.