generate 5v PWM with the propeller?
Hello,
I'm working on a project that involves zigbees (3.3v logic) and also requires a PWM signal at 0-5v. I've been debating between using an arduino or a propeller for the controller. Arduinos can generate the 5v PWM, but don't natively interface with the 3.3v zigbee. Props can talk to the zigbee, but I haven't found a way to generate a PWM signal above 3 volts. I was wondering if there's some kind of external PWM IC that would work, or what my other options might be for generating the 5v PWM signal.
Thanks for any suggestions!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com
I'm working on a project that involves zigbees (3.3v logic) and also requires a PWM signal at 0-5v. I've been debating between using an arduino or a propeller for the controller. Arduinos can generate the 5v PWM, but don't natively interface with the 3.3v zigbee. Props can talk to the zigbee, but I haven't found a way to generate a PWM signal above 3 volts. I was wondering if there's some kind of external PWM IC that would work, or what my other options might be for generating the 5v PWM signal.
Thanks for any suggestions!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com
Comments
And amplifier?
If all that is too complicated, an OpAmp?
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com
There are many "rail-to-rail" opamps available. Obviously, you need 5V. Is that the problem?
OTOH, as it is PWM, do you really need the 5V?
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
The 0-5v signal is being sent to the control pin on an LED dimmer. It doesn't necessarily need to be a PWM signal, just a voltage between 0 and 5v. I was just assuming PWM was the way to go. The whole 0-5v range is needed to get the whole range of dimming. I've never worked with an op-amp before. Would it smoothly convert the whole range?
Thanks for your help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com
I'm sure that would give you as much 0V/5V swing as you'd get from an Arduino or any other 5V microcontroller.
> just a voltage between 0 and 5v. I was just assuming PWM was the way to go.
So in fact you need a simple DAC with an output range of 0..5V. Not a PWM signal.
The easiest way to get that is to use a comparator (LM2903, a dual comparator) and filter the output-signal with an R/C.
You feed the comparator with a PWM and the output is "smoothed" to get a variable output.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
Nick, thanks for the info! I'll try that out as well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com
Just a suggestion...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Austin Bowen,
Robo-freak.com
"One must watch out for mechanics. They start out with a sewing machine, and end up with the atomic bomb" - A quote from someone that I saw on Addall.com
Post Edited (Robofreak) : 12/16/2007 12:17:25 PM GMT
The other way is simply to have a 74HCxx logic gate powered from +5V and driven from the 3.3V PWM signal to give a 5V PWM signal. Most gates should work fine when driven from 3.3 but there is a rather remote possibility that the 74HCxx maximum input levels may just be outside of 3.3V.
A transistor circuit is more trouble than it's worth and really requires npn and pnp plus an npn to drive it. A single transistor would have to be used in a grounded emitter configuration with a low value of collector resistance, as long as it was fast enough and the load was very light. The humble opamp is far easier to use.
*Peter*
The problem with this design is, that you don't have that much guarantee about the Prop's output-voltage. But for the required accuracy good enough.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
BTW, even if a garden variety comparator were able to switch fast enough to preserve your PWM waveform accurately (which is doubtful), most have open collector outputs, so don't provide the symmetrical switching currents needed for a simple RC filter downstream. The same would apply to any single-transistor output.
-Phil
> (which is doubtful), ...
300ns should be enough?
> ... most have open collector outputs, so don't provide the symmetrical switching currents needed for a simple RC filter downstream.
A pull-up and the R of the following filter by a magnitude bigger.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
-Phil
Yes, PWM works with the dimmer. I've tested it with an arduino's 0-5v PWM and it worked great. So a logic gate seems like the simplest approach with least components. I tried a 3904 but it didn't seem to be switching fast enough.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com
Its biggest challenge will be to output 5V.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
1. 74HCT is CMOS and as such will give you rail to rail output swings.
2. "A pull-up and the R of the following filter by a magnitude bigger" means it needs to be buffered with an opamp anyway as the output will be high impedance.
3. "The problem with this design is, that you don't have that much guarantee about the Prop's output-voltage. But for the required accuracy good enough" assumes that you can't guarantee your regulator voltage?
We don't try to be right more than we try to be helpful. In these forums we are better off coming up with answers rather than a "should be". That way we all benefit from workable solutions. The forum is a jam session for propheads, let's make some music.
*Peter*
You can always argument. Here, you failed.
> 1. 74HCT is CMOS and as such will give you rail to rail output swings.
I doubt that you have read the data-sheet of any HCT. 0.1V drop at 20µA, 1.1V at 4mA. 'Nuff? Impedance?
> 2. "A pull-up and the R of the following filter by a magnitude bigger" means it needs to be buffered with an opamp anyway as
> the output will be high impedance.
According to my crystal ball, 100k is enough.
> 3. "The problem with this design is, that you don't have that much guarantee about the Prop's output-voltage. But for the required accuracy good enough" assumes that you can't guarantee your regulator voltage?
I can guarantee it as much as you can guarantee it for a HCT, for an OpAmp or whatever. But still I can read the prop's data-sheet.
Have a nive day!
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
The point I am trying to make is if we do have an argument, then good!. But let us be forthwith with the rationale behind the argument so that others can benefit from your insight in this instance rather than unsupported negative assertions.
Thank you, I am having a nice day.
*Peter*
Oh yes!
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
other possible scenario's can be explored ... all digital... set and forget type solutions...
Digital pot....
I2C chip PCF8591 ( has analog in and analog out ) works on the pins 28 and 29..
cheers Ron Melbourne Australia
Seems like there's lots of ways to skin this cat.
You can of course add some ICs (DACs, OPAMPs, voltage converters,..) - maybe even include your laptop in the chain
To my opinion (and also to my experience now) the Propeller is well suited to not need all that, except for very special high precision tasks...
(A) When you need (low) current, a n-bit current DAC consisting of n resistors is fine, when you need voltage a R-2R ladder is commonly used (it is not perfect, 8-bit ICs rather use 256 integrated single valued resistors...).
Charging a cap from a PWM source through a resistor is the third way how to implement an DAC:
Be x the "duty cycle" for a given pulse period of t.; V the voltage at the cap.
Charging: Q = CV = Ic*x*t; Ic = (Vdd-V)/R
Discharging: Q = CV = Id*(1-x)*t; Id =V/R
Equiibrium: (Vdd-V)/R*x*t = V/R*(1-x)*t
Vdd*x -V*x = V - V*x
V = Vdd*x
This is the surprisingly simple equation, without any impact from R or C in the perfect situation, or the "mean voltage" in a less perfect situation.... You can compute the "ripple" caused by the finite period of the used frequency yourself.
This analysis is equivalent to more classical "low pass filter" considerations.
You can yield very good results when using the "duty cycle mode" of the counters, sending "spikes" of 12.5 ns, which is not strictly PWM...
But you can never establish a voltage above pin voltage...
(B) Using PWM on the other hand has nothing to do with voltage altogether. In fact things as PWM (or even FM) have been invented to become independent of any voltage (or "amplitide"). The only information in a PWM signal should be its "duty cycle", or - when a fixed period is required! - the absolute pulse width.
When someone requests a specific amplitude for a PWM signal, it should be investigated what he needs it for:
- just to overcome a trigger threshold?
- to load a cap upto a specific voltage (without internal signal conditioning)?
(C) It is a very old controversy how to best control an LED
- by short high current pulses
- by steady low current
Looking into data sheets of LEDs you can find highly interesting diagrams about short pulse current....
Main advantage of PWM control is the finite voltage needed (of 2 to 3.5 V) and the most simple interface
Steady current needs a current source, a simple transistor is close to perfect for it. Its base current can be generatet by a simple current DAC or a smoothed PWM signal
3V3 >---|>|---.----|>|---.------> Vout __|__ __|__ --.-- --.-- ___ | | PWM >--|___|--' -^- 0V
I'm trying to come up with a simple solution that doesn't require too many extra components. Lately I've even been thinking about just soldering a Boarduino (www.ladyada.net/make/boarduino/) directly to the propeller proto board. With a serial connection between the prop and the boarduino, I can use the boarduino's PWM and ADC from the prop without too much fuss, and the boarduino can run off of the same 7.5v power supply that the proto board uses. The boarduino costs $17, which isn't too much more than the handful of 74HCTs and ADC chips I'd need to handle it all from the prop.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com
Using standard (non-Schottky) diodes, your circuit should be able to generate up to 5.4 volts with no load. (C1 charged to 3.3 - 0.6 = 2.7V, then 2.7 + 3.3 - 0.6 = 5.4V on C2.) If you went to ultra-fast-recovery diodes, you might even be able to do it with the DUTY mode output, which would help with the ripple and/or allow smaller caps. In theory, you could close the loop by means of a voltage feedback to the Prop and by using software to maintain the desired voltage. This would eliminate the need for any active components, but the total component count does begin to mount...
-Phil
The charge pump will at best generate unprecise triangles, depending on the drawn current at it's output...
But adventurous persons can try this scheme... It has proven useful for some LCD display's segment control..
I used a 2-input OR gate with one of the inputs tied to ground, and the other coming from a prop pin generating a PWM signal.
I need three of these gates for my project, so I got a 14-pin dip chip from digikey that has 4 gates on chip, so basically my problem is solved with just one component! Very cool.
Thanks Phil!!
- Jason
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com
BTW: You should connect both unused input gates to ground as well.
Post Edited (deSilva) : 2/2/2008 11:46:45 PM GMT