I've just been going through the PWM modulator suggestions. The ATtiny11 is looking to be quite an attractive solution at present. ______________ Tom said: > Is less than 50 cents low cost enough? > I have built analog to PWM circuits as follows: > 555 timer is used in astable mode with 50% duty cycle. > The voltage across the timing capacitor is fed to one input of a > comparator. > The analog control voltage is fed to the other input of the > comparator. > PWM output is taken from output of comparator. 50 cents all up would be marvellous. For the component parts its pretty reasonable. I have do a few minor related things as well so the extra amplifier section will not be wasted. I don't know if you saw my original post - the 555/comparator solution is essentially the same as what I described I was doing initially using a 324 as the ramp generator. The 555's greater integration makes it attractive, but I have to use some amplifier sections anyway. > An opamp can be configured as a signal converter to take the > desired input range and convert it to the 1/3 to 2/3 Vcc range > needed to match the 555 timing capacitor waveform. Yes. I have to convert the input signal as it is from ground up to about 3 volts (although in the original spec I said it could be anywhere in the range of 0-5 volts as I wanted to retain flexibility). The PWM out of the 324 is pretty horrible due to its low slew rate. Also, the poor pulldown to zero means I have to take care. It does help that the symmetry of the ramp doesn't matter - as long as it is half-reasonably linear. > If using a potentiometer to manually generate the reference > voltage for the comparator, simply choose a series combination > such as Vcc connected to a 10k resistor, connected to a 10k pot, > connected to a 10k resistor connected to ground. In my case there are "up" and "down" control inputs to my circuitry that drives a voltage level on a capacitor until the input (driving) circuit is satisfied. I didn't specify t his as it seemed that a more general 'challenge' may bring out more ideas that people could use. As has been the case. > Note that MANY comparators can share the same timing capacitor > waveform at once. In my case I only need one so the ability is wasted on me :-) > If you only need a single PWM output, a dual comparator will do it > all. The few resistors and the capacitor will cost what, 10 or 15 > cents total? In quantity you can get dual opamps for 25 cents or > less. > > You can't get much cheaper than that. In my case I ended up with 2 x LM324s due to the other functionality. The PWM required 2 sections or 3 if I used an integrator for better ramp linearity, comparator took 1. As I had spares I used another to buffer the input from a diode shaper so that the input/output law was NOT linear. This is specific to my application so I didn't put it in the "challenge". This sort of idea seeking is useful as you start off thinking you've probably seen most of the ideas available and then something useful is offered. This is often obvious retrospectively and you wonder why you didn't think of it at the start. (I do anyway :-) ). Sometimes it can be an idea that you have used often elsewhere but didn't translate it. In this case one such idea is in the 1st circuit on the page that Phil Eisermann offered at http://www.4qdtec.com/pwmmod.html. There they level shift the saw tooth capacitively so it assumes the same range but the mean level is set by the voltage divider beyond the capacitor. This is an entirely standard use of capacitive coupling but is a superb idea here. I would have tended to resistively divide and shift the input and/or ramp signals to match with a higher component count. Even here you need to be careful of the affect of the various impedances. One important factor is the repeatability and stability of the circuit in a production environment. The ability to pull up and down consistently is a factor. If high and low drive voltages alter then ramp amplitude alters and PWM % for a given input level will vary. The LM324 has an ill defined pull down mode. The 555 is better in this regard. From batch to batch the amplitude of the sawtooth is liable to be better. Even the LM339 with no (ie open collector) pullup is better defined than the 324. I swamped the 324 in testing by using a 1k from outputs to ground, but this is a poor method if it can be avoided. (The 324 has an output effective resistance of about 5k at 10 uA !!! and this drops to about 1K at 100 uA BUT the absolute voltage still rises. It's best at about 10 mA where it's down to about 100r BUT you now have a relatively massive 1 volt or so Voutlow. The LM339 is superior at pulling low (33 ohms typical up to 6 mA, or about 100 ohms worst case, at 25C). How much these variations matter depend on how much accuracy you want in the PWM. And whether you can tolerate eg not reaching 0% or 100%, or instead having dead bands at each or either end of the range. Digital has its place :-) Using a current source to drive the cap removes the effect of the drive level voltage of the opamp, and in the downward direction, if a diode is used as in the offered 339 circuit then the reset time is very short so the low drive voltage less important. (The triangle wave then becomes a sawtooth which doesn't matter at all here). Enough rambling. I should go and build something to try out some of the thoughts that have come out of this. Probably won't get to use Scott's superb code directly - but the ideas will translate. At $US0.25/1000 or so the ATtiny11 seems very hard to beat IF a processor is used and IF it will do the job. The PIC10F200 looks like it costs more than twice as much (when available), hasn't got enough pins for me, and seems to be substantially less useful overall. Small size is its only apparent feature relatively. Both lack antibrownout which is extremely unwise when you are not using a reset pin. IF I use a tiny11 I will need to be able to shut off processor Vdd entirely if brownout occurs. This is doable easily enough but should not be necessary. Russell McMahon -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body