[EE:] Design Challenge - Lowest cost PWM Roman Black where are you ... ? :-) APPLICATION: I have had and have ongoing needs to PWM modulate FETs at supersonic frequencies - typically I use 20kHz to 25 kHz as this generally produces inaudible results. Aim may be considered to be load control of various loads. May be motors or resistive or reactive loads. Lower frequency PWM is unacceptable either due to audible noise or the ability for frequency to be detected in some way. Specifics unimportant to this challenge. DO NOT address how to make low frequency better - this is not what the challenge is about. Objective: 1. Produce hardware PWM variable from 0 to 100% at at least 20 kHz. 2. Input to be an analog voltage SOMEWHERE in the 0 to 5 volt range. eg may be 0 - 3 or 2.3 - 4.2 or whatever. Circuit needs to be able to be designed to accommodate any such given voltage at construction time. eg use of designed fixed resistors OK. (Ability to accept eg binary word or lower frequency PWM signal as input may be acceptable)(Resolution should be at least 6 bits or equivalent and more is better). Input signal is essentially DC - ie may change in steps up to a few times per second. 3. Linearity and accuracy not overly crucial but the better the better. eg 1% excellent, 5% OK, 10% is rather marginal . 4. PWM waveform shape is not crucial but the sharper the rise and fall edges the better. 5 Sensitivity to component values included in 3. 6. Assessment of all up cost is informal. eg includes components, board area and assembly costs but no formula is proposed for these. Construction would probably be single sided with links as requisite. Machine assembly with manual backup as required. Assembled in PRC - labour is cheap! 7. Target volumes are low to moderate production - say 100s to 10,000 range but one off amateur applications may benefit from this. 8 Frequency of PWM is not too critical. eg 22 to 28 kHz would be OK for a nominal 25 kHz design. . It is appreciated that resolution, accuracy, linearity and other terms overlap somewhat in this application. The idea should be clear enough without tighter definition or specification. THOUGHTS: Ultra cheap processors such as Attiny11 do not have hardware PWM and software PWM with suitable number of bits resolution tends to run too slow. Conceivably an eg ATtiny11 or 12Fxxx running this task alone may be adequate. I have an all analogue version running using a 324 opamp. Two sections produce a triangle wave (Schmitt driving an integrator) and a 3rd acts as a comparator. Output waveforms are nasty but arguably acceptable. LM339 would do similar with better waveforms. I use a 4th amplifier section between integrator and comparator to add dual stage diode shaping to produce a desired delinearisation of the PWM law, but that is outside this spec. The same result can be obtained with a diode shaper on the input signal, making this spec independent of that requirement. I had a 2 opamp version running using a 1 amplifier an oscillating Schmitt and taking the capacitor signal as the output - but the exponential cap waveform was too non linear. Opamp designs need to be ware of component variation problems. eg a 324 does not pull down well and a heavy load resistor is required to help linearise the integrator drive. Other opamps do this much better but cost much more. High drive levels to integrator will vary with opamp. Frequency variation is irrelevant to spec. LEVEL variations matter. A 555 MAY be able to do most of this by itself. Prove it :-) A microcontroller with hardware PWM eats this task for breakfast - and costs far more. Dedicated PWM ICs would be fine if the price was OK. An LM324 is VERY cheap. An R2R ladder from an oscillator/counter may provide the ramp (eg CD4060 - cost is under $US0.20/1000s) but LM324 is closer to $US0.12/1000 (Digikey prices). An LM339 and a 4060 with an R2R ladder would do a fine job I imagine. LM339 is perhaps slightly cheaper than LM324. Open collector output stage but a better comparator (as it IS a comparator :-) ). I like this concept. R2R ladder from discretes is annoying but cheapish. Dedicated R2R SIPs are available and should be cost effective. Ramp is linear from 0 to reset point and can easily be biased up to start at any desired point to be in suitable range for comparator. And / or input signal can be shifted and amplitude adjusted to suit. Simply a matter of fevered basic calculation and some resistors. 339 can function as an opamp in such applications - would be at essentially DC if used to shift input signal. Russell McMahon -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu