Searching \ for '[EE:] Design Challenge - Lowest cost PWM' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/io/pwm/index.htm?key=pwm
Search entire site for: 'Design Challenge - Lowest cost PWM'.

Exact match. Not showing close matches.
PICList Thread
'[EE:] Design Challenge - Lowest cost PWM'
2004\07\09@054525 by Russell McMahon

face
flavicon
face
[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
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu

2004\07\09@060720 by Alan B. Pearce

face picon face
{Quote hidden}

Check out the Intersil HIP408x series. We used the HIP4080 in a space cooler
drive application at 75Khz (it was going to be higher, but suitable rad-hard
FETs were not available to us), but if you need to get down to 25kHz then
that should be do-able. See
http://www.intersil.com/product_tree/product_tree.asp?x=15 and expand out
the trees to find the devices. They are available in DIP and SM versions.




>Dedicated PWM ICs would be fine if the price was OK. An LM324 is VERY
cheap.

This may be where the HIP408x will fall down. IIRC Jinx looked at them a
while back, and moaned about the 1 off price through RS. However the app
notes will help you with some of the other points above.

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu

2004\07\09@070640 by Mike Harrison

flavicon
face
On Fri, 9 Jul 2004 21:36:43 +1200, you wrote:

{Quote hidden}

ATTiny13 would seem a good fit - internal RC osc, on-chip ADC,  internal RC at up to 9.6MHZ
you could get about 0.1uS PWM resolution in software, so about 0.2% resolution at 20KHz

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu

2004\07\09@084521 by Martin Klingensmith

face
flavicon
face
You can use a 556 or a quad opamp.
Google works for this, really.

> [EE:] Design Challenge - Lowest cost PWM
>
> Roman Black where are you ... ? :-)
>
> APPLICATION:

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu

2004\07\09@091224 by Russell McMahon

face
flavicon
face
> You can use a 556 or a quad opamp.
> Google works for this, really.

I'm aware of Google :-)

And the 324, which is what I'm using in my actually working circuit that I
mentioned, is a quad op amp - horrible results - but could be good enough.

As I noted, I'm aware of 555, 556 and similar. The issue is turning them
into a working solution at fair price. Linearity tends to suffer where you
are using exponential cap charge - but may be OK. Getting a full 0%-100% PWM
range is often more challenging. I can play with them myself (and yet may) -
i was interested in seeing if anyone popped up with a working superior
solution rather than just the skeleton ideas.

So far the LPC901 seems the most promising processor based solution. I like
my 4060/339 idea for a non-processor alternative 0 the digital ramp would
overcome the cheap opamp setup problems.



       Russell McMahon

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu

2004\07\09@093921 by Spehro Pefhany

picon face
At 01:12 AM 7/10/2004 +1200, you wrote:

Maybe you can use a TL5001 (~0.65/1K) or something along those lines..

Best regards,

Spehro Pefhany --"it's the network..."            "The Journey is the reward"
speffspamspam_OUTinterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu

2004\07\09@095001 by Scott Dattalo

face
flavicon
face
On Fri, 9 Jul 2004, Russell McMahon wrote:

> [EE:] Design Challenge - Lowest cost PWM

I've written an all-software version that has single instruction cycle
resolution and can run on the 12-bit cores:

http://www.dattalo.com/technical/software/pic/pwm256.txt

It has an 8-bit dynamic range (though in one instance I boosted this to
12-bits). The PWM frequency is fosc/4/256, or about 20kHz for an
fosc=20Mhz.

The algorithm leaves available roughly 50% of the CPU time for other
tasks. So in your case where you need to receive either an analog or
digital control, you'd have CPU time to implement it.

I promise this routine will make your head explode! It's completely
isochronous and uses the program counter as a control variable. But with
the new PICs dropping below $0.50, I think this implementation may be
optimal in the cost * flexibility solution space. If flexibility is not a
desirable feature, then your hardware-only solutions will most probably be
cheaper.

Scott

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu

2004\07\09@100813 by Eisermann, Phil [Ridg/CO]

flavicon
face
pic microcontroller discussion list wrote:
> As I noted, I'm aware of 555, 556 and similar. The issue is turning
> them into a working solution at fair price. Linearity tends to suffer
> where you are using exponential cap charge - but may be OK. Getting a
> full 0%-100% PWM range is often more challenging. I can play with
> them myself (and yet may) - i was interested in seeing if anyone
> popped up with a working superior solution rather than just the
> skeleton ideas.

maybe I can repay your help a little. I did a prototype soft-start
circuit for a 120Vdc motor. Circuit gets the full 0-100% range. It
uses an LM2903 + current source charging a cap to generate a ramp.
The comparator discharges the cap to reset the cycle. The trick is
using diodes instead of resistors for feedback. frequency is
determined by the cap value and charging current, so you can adjust
to your needs. For lower cost, the current source can be replaced
by a resistor. The other section of the 2903 sets the duty cycle.
It worked  like a champ for what I needed. Unfortunately, someone
else beat me to it :(  So I don't even have to clutter the list
with attachments (although would be glad to send off-list). I'll
just direct you to http://www.4qdtec.com/pwmmod.html That's pretty
much what I came up with, except minor differences (my ramp goes
to 2/3Vcc,the artivle 1/3Vcc). But the theory is the same. The
author even mentions replacing the resistor with a current source....

Not sure what the commercial implications are of someone having
published this, though. It is a commercial site from someone
selling motor drives. This are my thoughts: The concept of
creating PWM is certainly well known today, and it doesn't take
a great leap of imagination to replace a charging resistor with
a current source for greater linearity. The innovative part is
the diode arrangement, which I hit upon while playing with this
circuit a year or two ago, and the author's inspiration came from
a customer...


>
> So far the LPC901 seems the most promising processor based solution.
> I like my 4060/339 idea for a non-processor alternative 0 the digital
> ramp would overcome the cheap opamp setup problems.
>


--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu

2004\07\09@101847 by Russell McMahon

face
flavicon
face
> Maybe you can use a TL5001 (~0.65/1K) or something along those lines..

Quite a good looking solution

       http://focus.ti.com/lit/ds/symlink/tl5001a.pdf

Price is better than most alternatives so far, but approaches that of an
LPC901 microcontroller. I would still need an opamp (2 sections minimum) for
another function, so add an LM324 to the cost. The tl5001 should be more
linear than simple linear solutions.

Such solutions have the disadvantage compared to a microcontroller that they
cannot be altered simply by programming, and the advantage that they don't
need any programming :-)


       RM

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu

2004\07\09@122035 by Dwayne Reid

flavicon
face
At 03:36 AM 7/9/2004, Russell McMahon wrote:

>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.

I have some very old single-sided board layouts that do this for 8
channels.  Its all analog using LM339 comparitors (I think) fed by a
ramp.  The original application was for phase control lamp dimming but I
recall using it at several KHz for at least one project.  I don't know how
well it works at supersonic frequencies and the output stages would need to
be re-worked for FET drive (add 1 transistor, diode, resistor for each
output).  But it may be a starting point.

dwayne


--
Dwayne Reid   <TakeThisOuTdwaynerEraseMEspamspam_OUTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 20 years of Engineering Innovation (1984 - 2004)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu

2004\07\09@163839 by John N. Power

flavicon
face
> From:         Russell McMahon[SMTP:apptechEraseMEspam.....PARADISE.NET.NZ]
> Sent:         Friday, July 09, 2004 9:12 AM
> To:   EraseMEPICLISTspamMITVMA.MIT.EDU
> Subject:      Re: [EE:] Design Challenge - Lowest cost PWM

>> You can use a 556 or a quad opamp.
>> Google works for this, really.

>I'm aware of Google :-)

> And the 324, which is what I'm using in my actually working circuit that I
> mentioned, is a quad op amp - horrible results - but could be good enough.

> As I noted, I'm aware of 555, 556 and similar. The issue is turning them
> into a working solution at fair price. Linearity tends to suffer where you
> are using exponential cap charge - but may be OK. Getting a full 0%-100% PWM
> range is often more challenging. I can play with them myself (and yet may) -
> i was interested in seeing if anyone popped up with a working superior
> solution rather than just the skeleton ideas.

Linearize the 555 output by charging a capacitor through a constant current
diode (or use a JFET with its gate connected to its source). Put a normal
diode in parallel with the constant current diode so that the capacitor
discharges rapidly when the 555 output goes low. The resulting voltage on
the capacitor will be very linear. Use an LM311 comparator to compare this
voltage with the input voltage.


> So far the LPC901 seems the most promising processor based solution. I like
> my 4060/339 idea for a non-processor alternative 0 the digital ramp would
> overcome the cheap opamp setup problems.

>        Russell McMahon

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu

2004\07\09@192209 by Russell McMahon

face
flavicon
face
I realise that I have not made one thing clear enough - it's in the heading
but not (strangely) spelt out as clearly as could be in the text. The object
is LOWEST COST and also a complete "analog (or equivalent input) to PWM
output" circuit. There have been many interesting ideas, but quite a few
have no prospect of being lowest cost and some address only part of the
requirement. I find ALL circuit suggestions interesting so none of this is
wasted on me, but the unspecified (as yet unthought of) virtual (aka
non-existent :-) ) prize is for a complete lowest cost solution.



       Russell McMahon

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu

2004\07\09@193035 by Marcel Duchamp

picon face
At 04:21 PM 7/9/04, you wrote:
>non-existent :-) ) prize is for a complete lowest cost solution.


How will you determine when you have arrived at the "lowest cost solution"?
MD

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspamspammitvma.mit.edu

2004\07\09@194734 by Dipperstein, Michael

face picon face
> the unspecified (as yet unthought of) virtual (aka non-existent :-) ) prize
> is for a complete lowest cost solution.

You better watch out.  You're awfully close to the infringing on the coveted
Marvel Comics "no-prize".  (I think it's Marvel Anyway)

Is there also a prize for the most Rube Goldberg like solution?

-Mike

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspamspamspamBeGonemitvma.mit.edu

2004\07\09@201715 by Russell McMahon

face
flavicon
face
Repost - says I've sent it already but I don't believe I have.


I realise that I have not made one thing clear enough - it's in the heading
but not (strangely) spelt out as clearly as could be in the text. The object
is LOWEST COST and also a complete "analog (or equivalent input) to PWM
output" circuit. There have been many interesting ideas, but quite a few
have no prospect of being lowest cost and some address only part of the
requirement. I find ALL circuit suggestions interesting so none of this is
wasted on me, but the unspecified (as yet unthought of) virtual (aka
non-existent :-) ) prize is for a complete lowest cost solution.



       Russell McMahon

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestKILLspamspammitvma.mit.edu

2004\07\09@233158 by Robert Monsen

picon face
part 1 3185 bytes content-type:text/plain; (decoded 7bit)


----- Original Message -----
From: "John N. Power" <jpowerSTOPspamspamspam_OUTBCPL.NET>
To: <spamBeGonePICLISTSTOPspamspamEraseMEMITVMA.MIT.EDU>
Sent: Friday, July 09, 2004 1:35 PM
Subject: Re: [EE:] Design Challenge - Lowest cost PWM


{Quote hidden}

enough.
>
> > As I noted, I'm aware of 555, 556 and similar. The issue is turning them
> > into a working solution at fair price. Linearity tends to suffer where
you
> > are using exponential cap charge - but may be OK. Getting a full 0%-100%
PWM
> > range is often more challenging. I can play with them myself (and yet
may) -
> > i was interested in seeing if anyone popped up with a working superior
> > solution rather than just the skeleton ideas.
>
> Linearize the 555 output by charging a capacitor through a constant
current
> diode (or use a JFET with its gate connected to its source). Put a normal
> diode in parallel with the constant current diode so that the capacitor
> discharges rapidly when the 555 output goes low. The resulting voltage on
> the capacitor will be very linear. Use an LM311 comparator to compare this
> voltage with the input voltage.
>

Actally, just hook discharge, trigger, and threshold to the current source
connected to the cap, and you get quite a nice ramp, which drops remakably
fast when discharge to ground is closed.

Use a 556, and hook the other one up as a monostable, which is again fed by
a current source; only this time, the current source should be voltage
controllable, something like a current mirror, where the controlling current
is used to modify the duty cycle. I haven't worked out the equations
specifying the correspondence of control voltage to duty cycle, but I think
its a fairly straightforward calculation. The duty cycle should be fairly
linear as a function of control voltage.

I suspect a 556 compares favorably to an LM324 in price. I've included a
circuit diagram. I've simulated this, but not built it. Using cmos parts
will up the cost, but also make the circuit use far less power.

1 LM556 (or 2 LM555s)
4 PNP transistors
4 caps
4 resistors.

Regards,
Bob Monsen

>
> > So far the LPC901 seems the most promising processor based solution. I
like
> > my 4060/339 idea for a non-processor alternative 0 the digital ramp
would
> > overcome the cheap opamp setup problems.
>
> >        Russell McMahon
>
> --
> http://www.piclist.com hint: To leave the PICList
> @spam@piclist-unsubscribe-request@spam@spamspam_OUTmitvma.mit.edu

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamKILLspammitvma.mit.edu




part 2 7409 bytes content-type:image/gif; (decode)

2004\07\09@233611 by tom_mcgahee

face picon face
Russell,

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.

Note that the 0-100% range corresponds to voltages from 1/3 Vcc to
2/3 Vcc.

Output from the comparator is 0% to 100% pwm signal.

Reversing inputs to comparator results in 100% to 0% pwm signal.

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.

PWM is independent of the 555 operating frequency.

Even though the timing capacitor waveform is a sawtooth (and not a
ramp or triangle) wave, the + and - slope waveforms are reversed
in such a way that the output linearity of the resulting pwm wave
is very close to that obtained with a linear ramp.

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.

Note that MANY comparators can share the same timing capacitor
waveform at once. A 555 circuit and a quad comparator would give
you 4 independently controllable analog to pwm outputs.

Is that low-cost enough per pwm?

If you have a bipolar power supply, the 555 circuit can be
replaced by a single comparator, two resistors and a capacitor.
Output of opamp connects to resistor and capacitor in series to
ground. Resistor/capacitor node connects to (-) inverting input.
Output also connects to two resistors in series to ground. The
node of the two resistors connects to the (+) non-inverting input.

This comprises a bilaterally symmetrical square wave generator
with 50% duty cycle. The capacitor waveform will be a sawtooth. As
before, this sawtooth wave can go to more than one comparator to
provide pwm outputs.

Note that in this case signals are all bipolar. One quad
comparator (opamp) can provide three independent pwm outputs (plus
the sawtooth waveform.)

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.

Fr. Tom McGahee




{Original Message removed}

2004\07\10@001628 by Martin Klingensmith

face
flavicon
face
Russell McMahon wrote:
>>You can use a 556 or a quad opamp.
>>Google works for this, really.
>
>
> I'm aware of Google :-)
>
> And the 324, which is what I'm using in my actually working circuit that I
> mentioned, is a quad op amp - horrible results - but could be good enough.

I should have mentioned that I used a TL074 for mine, up to about 40kHz
it worked. The 324 is probably the cheapest opamp you can find. I guess
an ATTiny11 would be cheaper at $.25 perhaps.

--
--
Martin Klingensmith
http://infoarchive.net/
http://nnytech.net/

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2004\07\10@010926 by Jake Anderson

flavicon
face
quick conceptual idea
ATtiny11 (if it has schmit trigger inputs or a comparitor)
vadj input goes through a resistor into a cap and the input leg.
to start, input leg is made an out and low.
input leg returns to being input and the cap charges via the resistor time
this with a timer, use the RC constant to work out what the input voltage
is, use that to adjust your pwm period. rinse lather and repeat.

note several assumptions made here, and I dont know if this would meet the
precision requirements but hey it'd be pretty cheap no?

> {Original Message removed}

2004\07\10@045049 by Russell McMahon

face
flavicon
face
> quick conceptual idea
> ATtiny11 (if it has schmit trigger inputs or a comparitor)
> vadj input goes through a resistor into a cap and the input leg.
> to start, input leg is made an out and low.
> input leg returns to being input and the cap charges via the resistor time
> this with a timer, use the RC constant to work out what the input voltage
> is, use that to adjust your pwm period. rinse lather and repeat.
>
> note several assumptions made here, and I dont know if this would meet the
> precision requirements but hey it'd be pretty cheap no?

That's such an utterly superb idea, and so horribly obvious with hindsight,
that it hurts to think that I didn't think of it as an alternative.

Should be plenty good enough.
At 20 kHz cycle is 50 uS.
Timer IRQ resets ramp every 50 US.
Processor needs to respond to interrupt on comparator toggle.
At 1:64 resolution this can occur in as little as 50uS/64 = 0.8 US.
That's a 1% duty cycle and may not quite be met depending on processor clock
speed - but a bit of playing would do it OK.
At $US0.25 for the tiny11 it is well down there with the $0.15 or so
opamps/comparators/555's etc.

BTW - the ideas are getting quite good. I'll try to think more on them and
comment soonish. Less enjoyable tasks beckon ...


       Russell McMahon

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2004\07\10@090941 by Russell McMahon

face
flavicon
face
> ATtiny11 (if it has schmit trigger inputs or a comparitor)
> vadj input goes through a resistor into a cap and the input leg.
> to start, input leg is made an out and low.
> input leg returns to being input and the cap charges via the resistor time
> this with a timer, use the RC constant to work out what the input voltage
> is, use that to adjust your pwm period. rinse lather and repeat.

& I said:

>That's such an utterly superb idea, and so horribly obvious with hindsight,
>that it hurts to think that I didn't think of it as an alternative.

I was rushing out when I wrote that and didn't think things through.
It IS a good idea - but it effectively translates to the dedicated software
PWM I mentioned before.
The advantage when put as you put it, is that it sponsored the idea that you
can use the input comparator trip point to trigger the PWM transition so
that the A2D and the PWM become one and the same thing. The system does not
HAVE to know what the period is per se - it can just respond to the
comparator toggling. IF the comparator output was available on a pin the
tiny11 would become a 3 pin processor that was doing soemthing else. As the
comparator output is internal only the tiny11 must get involved.

My ramblings re timing - viz

>Should be plenty good enough.
>At 20 kHz cycle is 50 uS.
>Timer IRQ resets ramp every 50 US.
>Processor needs to respond to interrupt on comparator toggle.
>At 1:64 resolution this can occur in as little as 50uS/64 = 0.8 US.
>That's a 1% duty cycle and may not quite be met depending on processor
clock
>speed - but a bit of playing would do it OK.
>At $US0.25 for the tiny11 it is well down there with the $0.15 or so
>opamps/comparators/555's etc.

suggest that you should be able to get from a few % PWM to nearly 100% PWM
using a tiny11 at 20 Khz. The not quite 0 & 100 actually violates my
original spec but would actually be OK in my application. It would be easy
to add a 0% step (it's off Jim) and 100% (it's on!) at the extremes.

So I'll have to try designing some code for this and see how it comes out.

There is another task the system has to do as well which is quite simple. It
produces an analogue voltage in response to an up and a down signal. This
voltage becomes the Vin for the PWM. (While tempting, it's not wise to
directly derive PWM period from the integration of the up and down signals.)
At present I do it with 2/4 of an LM324 but the micro will have enough time
to do this too as it's very low speed.

>BTW - the ideas are getting quite good. I'll try to think more on them and
> comment soonish. Less enjoyable tasks beckon ...

I've yet to try to come to grips with Scott's brain hurting code. If HE says
it will make one's brain hurt it must be esoteric indeed.


       Russell McMahon

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2004\07\10@093259 by Jake Anderson

flavicon
face
a (more expensive) way i had done it once.
comparitor from analouge ref voltage to output voltage
run that into a d flip flop (clocked at high speed, 5mhz is ~ equivilent to
10khz pwm) output of that goes to the fet.
not a compeditor for cheapest but pretty simple.

> {Original Message removed}

2004\07\10@094336 by Jake Anderson

flavicon
face
dont know if i read what you meant right or not, but you cant just use the
comparitor output to drive the fet otherwise it will oscilate way too fast.
some of the analouge guys may be able to come up with a way of adding
hysteris to the circuit so it will resonate at something like the right
frequency.


> {Original Message removed}

2004\07\10@100904 by Jake Anderson

flavicon
face
sorry for the tripple post but.

use some cheap form of comparitor.
RC filter on the vsense input to set frequency. Vadj input runs in direct.
Vsense probbly needs some form of dividor to get it into the right voltage
range.
So total cost is 1 cap, 3 resistors and a comparitor.

Btw i think running at 25khz you are going to need some form of mosfet
driver to get clean switching. otherwise in minimum duty cycle your mosfet
is going to sit unsaturated.
my D-Flipflop version (with a whopping 6 ma drive or so) ran fine out to
around 100khz clock freq, (about 1khz PWM)

> {Original Message removed}

2004\07\10@103232 by Russell McMahon

face
flavicon
face
> dont know if i read what you meant right or not, but you cant just use the
> comparitor output to drive the fet otherwise it will oscilate way too
fast.
> some of the analouge guys may be able to come up with a way of adding
> hysteris to the circuit so it will resonate at something like the right
> frequency.

Effectively I'm just using the comparator as a comparator and using the
interupt to tell the uP to aletr the FET drive level. If this was all the
processor was doing it could be replaced by a single comparator. But it does
this while also managing the up doen inputs and setting an analog level so
it has some work to keep it honest. Being too fast will be the least of its
problems.


       RM

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2004\07\10@103234 by Russell McMahon

face
flavicon
face
> Btw i think running at 25khz you are going to need some form of mosfet
> driver to get clean switching. otherwise in minimum duty cycle your mosfet
> is going to sit unsaturated.

FET driver will be the basic circuit that I have posted several times when
people are looking for a cheap driver. NPN emitter follower pulling FET gate
high.  case of this pulled high by a resistor or low by another NPN which
also serves as FET low side driver. Total driver circuit requires 2 cheap
NPN transistors, 3 resistors, one diode, one zener. Works very well out to a
few uS pulse width. Add a botton PNP emitter follower on low side and it
goes into the MHz range. .

The various comparator & 555 circuits are AFAICS variants on the themes
which I mentioned in my original post, but there have been some useful
details filled in.

I do want to try the 4060 counter as a ramp generator just to see how it
compares with analog ramp generators. It will take a 4060 (cheap), RC for
clock, R2R ladder x N sections (or a module with R2R in it). No cheaper than
324/339/555/... type solutions but has a nice linear (albeit quantised) ramp
with the ability to play some nice non linearising games by changing chosen
resistors along the R2R ladder.

But the tiny11 is looking like it may yet be able do the job after all.



       RM

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2004\07\10@105755 by Scott Dattalo

face
flavicon
face
On Sun, 11 Jul 2004, Russell McMahon wrote:

{Quote hidden}

Hi Russel and Jake,

This *is* a good idea. And not to take anything away from Jake, I thought
of it too when I was thinking of a way to get the analog signal into my
PWM routine. As you may remember, Walter Banks enlightened me on the
concept of turning an I/O pin into A2D converter. So I wrote this:

http://www.dattalo.com/technical/software/pic/a2d.asm

and a  brief description at the top of:

http://www.dattalo.com/technical/software/software.php

I was thinking that I could use the spare cycles in the Software PWM
routine to run this algorithm. But then I realized that the A2D algorithm
is inherently a PWM routine. As Jake points out, a comparator will certain
give you a well defined threshold. However, I managed to get on the order
of 8-bits of resolution with just a normal I/O pin and 12-bits with 2 I/O
pins.

The routine in the link above will be way too slow for your purposes since
it's attempting to measure the pulse widths. In addition, that routine
does not run continuously like what you need. However, the suggestions you
and Jake have put forth should make it work just fine!

If I were implementing this on a 10Fxxx I'd do something like this:

   ; single pin case:
     make the pin an output
     drive it low
     make the pin an input
     drive the FET control low

   ; then in a giant unrolled loop:

     BTFSC   IOPORT, ANALOG_IN_PIN
      BSF    IOPORT, FET_CONTROL_PIN

     BTFSC   IOPORT, ANALOG_IN_PIN
      BSF    IOPORT, FET_CONTROL_PIN

     ...

This gives you a 2-instruction cycle resolution and (probably) 5
instructions for a minimum pulse.

If you can afford to place the PWM input and the FET output pins next to
one another, then you can generate 1-instruction cycle resolution inverted
PWM by doing this:

ANALOG_IN_PIN    EQU 1
FET_CONTROL_PIN  EQU (ANALOG_IN_PIN - 1)

loop:

     ; make the analog in pin an output:

     MOVLW   (0<<ANALOG_IN_PIN) | (0<<FET_CONTROL_PIN)
     TRIS    IOPORT

     BCF     IOPORT, ANALOG_IN_PIN    ; discharge the cap

     ; make it an input

     MOVLW   (1<<ANALOG_IN_PIN) | (0<<FET_CONTROL_PIN)
     TRIS    IOPORT

     ; copy the state of the Analog in pin to the FET control pin:
     RRF IOPORT,F
     RRF IOPORT,F
     RRF IOPORT,F
     RRF IOPORT,F

     ...


     goto  loop

In other words, the I/O pin monitoring the voltage on the capacitor is
digitized by the PIC's input circuitry, and then copied to the output pin.
You're probably going to have a FET driver in this system any way, so
maybe you can use a PNP BJT to drive the FET - that requires an inverted
signal!

The only problem with this approach is that it's sensitive to the absolute
value of the I/O Pin's input threshold voltage. There are ways to control
this though (e.g. the other I/O pins can drive the capacitor too with
varying amounts of resistance and effectively provide a controlled DC
offset).

Scott

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2004\07\13@043140 by Russell McMahon

face
flavicon
face
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 .....listservspam_OUTspammitvma.mit.edu with SET PICList DIGEST in the body

More... (looser matching)
- Last day of these posts
- In 2004 , 2005 only
- Today
- New search...