Chip with simple program for Toy

I know I answered this, but it's been a few hours and it hasn't shown
up.

The ULN2003 pulling down on a +12v supply - if the dimmer is to be off,
which is a common state for hours a day, doesn't that put the power
supply entirely across one resistor? Other that that, yes, I think I
like this. It involves parts I understand. :)

What about this?

+12V
|
|
|
/
5V PWM --[R 1k]--[2N2222]
\
|--------[R?k]------>
| |
R4.7K C1
| |
Gnd--------------+
I'd like to avoid having to run the PWM "upside down", and this way,
the resistor at ground only takes current when the lights are on (less
common than off). But I confess to having no design skills and mostly
getting by with trial and error (which I'm not doing this time because
the parts are too expensive.) And yes, I can tune the PWM to keep the
max voltage to 10v.

As to why the PWM is sometimes "slow" - the PWM generator is a Diamond
GPIO board, with 10 timers which can be configured to produce PWM.
There are two counters, used to manage ON and OFF times, they are 16
bit and they increment at 4Mhz. The worst case scenario (which my
code's not going to allow) would be on for a count of 1, off for a
count of 65535. That's 64 pulses a second. I'm going to aim to keep all
the frequencies much higher than that, in part to avoid any possibility
of flicker and in part because I don't want this part of the circuit to
generate anything in the audio frequency range. But depending on what I
use for on and off, the frequency will vary; for a 50% duty cycle, ON
for 1 and OFF for 1 would be ideal, I'm thinking.

I was also looking at an optoisolator (PS2501) to handle this - but it
looks like they don't like high frequencies.
 
ScottM wrote:
I know I answered this, but it's been a few hours and it hasn't shown
up.

The ULN2003 pulling down on a +12v supply - if the dimmer is to be off,
which is a common state for hours a day, doesn't that put the power
supply entirely across one resistor? Other that that, yes, I think I
like this. It involves parts I understand. :)

What about this?

+12V
|
|
|
/
5V PWM --[R 1k]--[2N2222]
\
|--------[R?k]------
| |
R4.7K C1
| |
Gnd--------------+
I'd like to avoid having to run the PWM "upside down", and this way,
the resistor at ground only takes current when the lights are on (less
common than off). But I confess to having no design skills and mostly
getting by with trial and error (which I'm not doing this time because
the parts are too expensive.) And yes, I can tune the PWM to keep the
max voltage to 10v.

As to why the PWM is sometimes "slow" - the PWM generator is a Diamond
GPIO board, with 10 timers which can be configured to produce PWM.
There are two counters, used to manage ON and OFF times, they are 16
bit and they increment at 4Mhz. The worst case scenario (which my
code's not going to allow) would be on for a count of 1, off for a
count of 65535. That's 64 pulses a second. I'm going to aim to keep all
the frequencies much higher than that, in part to avoid any possibility
of flicker and in part because I don't want this part of the circuit to
generate anything in the audio frequency range. But depending on what I
use for on and off, the frequency will vary; for a 50% duty cycle, ON
for 1 and OFF for 1 would be ideal, I'm thinking.

I was also looking at an optoisolator (PS2501) to handle this - but it
looks like they don't like high frequencies.
That method uses the same number of parts as my way, but puts out only
0 to 4.4 volts and is not capable of driving much load.
 
OK. I've decided to spend the money for a bigger board, so I have room
for an IC and extra components - and a design that lets me put 100k
between the PWM generator and the rest of the circuit is appealing. I
also like the fact that I don't have to worry about the range of
frequencies that chips can handle - the cap will smooth things out
before any other component sees it.

Before I use it, I'd like to understand it. I "get" that R&C do current
limiting and smoothing, and what comes into the (+) of the op amp is
roughly 0v to +5v, based on the PWM rate. I also understand (vaguely)
that as the op amp's output increases, it drags the (-) input higher,
which limits the increase. I'm guessing that the fact that you used the
same resistor value for the R1's somehow makes this circuit hit twice
the voltage at (+), but I'm fuzzy on how. (I'd have expected the output
to go into 2 equal resistors, one to ground and one to (-), if that was
the idea.)

I need to understand this because I don't think the input is going to
quite reach a full +5v - there has to be some drop for the PWM's output
stage, however small - and if this works by doubling the input, I want
to be able to adjust it to do slightly more than double, to get up to a
full 10v. I guess I can do that by adding a 0-5k variable between the
lower R1 and ground, but I'd like to be certain.

Also, assume R (at the input) is in fact 100K. I'd like to be able to
calculate what I need for C, based on the input frequency. Assuming I
rig things so that the provided frequency is always that same (and I
can set it more or less as I please, up to about 4Mhz/256) and all that
varies is the duty cycle, I'd like the cap to do an effective job of
averaging out the voltage but NOT have a lot of memory, because when
the duty cycle changes I'd like the dimmer to follow the change pretty
much instantly. That should make for a very small value for C, but I'd
like to understand how to calculate how small. I'd also like to avoid
ripple showing up in the output - that can't be good for the dimmer and
might inject noise elsewhere, so "too small" is also bad. Software to
calculate low pass filters is over my head, unfortunately.

Thanks. Sorry for all the interations. I think, between opening up some
board space, and your suggestion of an op amp that doesn't need a split
power supply, that I might finally be getting somewhere; I'd just like
to grok it all better before I order.
 
On Thu, 13 Apr 2006 19:10:22 +1000, "crazy frog"
<dingding@bumbadabum.com> wrote:

---
On the rag, huh?


--
John Fields
Professional Circuit Designer
 
ScottM wrote:
(snip)
Before I use it, I'd like to understand it. I "get" that R&C do current
limiting and smoothing, and what comes into the (+) of the op amp is
roughly 0v to +5v, based on the PWM rate.
That is correct.

I also understand (vaguely)
that as the op amp's output increases, it drags the (-) input higher,
which limits the increase. I'm guessing that the fact that you used the
same resistor value for the R1's somehow makes this circuit hit twice
the voltage at (+), but I'm fuzzy on how.
An opamp has a very high differential voltage3 gain. In other words,
it amplifies only the difference between the two input's voltages,
ignoring any voltage they have in common (as long as that common
voltage is inside an operating range, called the common mode voltage
range). If there is effective negative feedback (a signal path from
output to - input), the effect of all that gain is that the output
goes to whatever voltage will force the - input voltage to be
essentially equal to what is on the + input, so that a nearly zero
difference voltage times the very high differential gain equals the
output voltage. In this case, the feedback passes through a 2 to 1
voltage divider, so the output voltage has to go to twice the + input
voltage, before the divider produces a voltage that matches the +
input voltage. So this opamp is programmed by that divider to be a
times 2 voltage amplifier. And since the divider is tied to ground at
one end, there is no difference between input and output if the input
voltage is zero. The LM324 has an input common mode range from about
the negative supply rail to 1.5 volts below the positive supply rail.
You might browse the data sheet and let me know if it brings up
questions it doesn't answer.
http://www.onsemi.com/pub/Collateral/LM324-D.PDF
They are common as dirt, and almost as cheap.

(I'd have expected the output
to go into 2 equal resistors, one to ground and one to (-), if that was
the idea.)

I need to understand this because I don't think the input is going to
quite reach a full +5v - there has to be some drop for the PWM's output
stage, however small - and if this works by doubling the input, I want
to be able to adjust it to do slightly more than double, to get up to a
full 10v. I guess I can do that by adding a 0-5k variable between the
lower R1 and ground, but I'd like to be certain.
That is exactly how you make the gain adjustable. put a pot between
the resistors, with the wiper going to the - input. This will allow
adjustment of the divider ratio which programs the gain.

Also, assume R (at the input) is in fact 100K. I'd like to be able to
calculate what I need for C, based on the input frequency. Assuming I
rig things so that the provided frequency is always that same (and I
can set it more or less as I please, up to about 4Mhz/256) and all that
varies is the duty cycle, I'd like the cap to do an effective job of
averaging out the voltage but NOT have a lot of memory, because when
the duty cycle changes I'd like the dimmer to follow the change pretty
much instantly. That should make for a very small value for C, but I'd
like to understand how to calculate how small. I'd also like to avoid
ripple showing up in the output - that can't be good for the dimmer and
might inject noise elsewhere, so "too small" is also bad. Software to
calculate low pass filters is over my head, unfortunately.
The filter time constant in seconds is R*C, with R in ohms and C in
farads. The frequency response is related to time constant by the
following. 2*pi*f=1/R*C, where f is the frequency (in hertz, or
cycles per second) that will be attenuated to half amplitude by the
filter. Frequencies much lower will be only slightly attenuated, but
frequencies much higher than f will be attenuated about in proportion
to their ratio with f.

For example, lets say you pick 10 milliseconds for the time constant
(an unnoticeably brief time when it comes to lighting, and less than
one power line cycle). You achieve this time constant with a 100k
resistor by .01second=100k(ohms)*C(farads), or C=.010second/100k(ohms).

C=1*10^-7 farads or 0.1 uF.
This puts the roll off corner frequency (down by half) at about:
f=1/(2*pi*.01second)= 16 Hz. This is the frequency that will be
attenuated by about half as it passes through the RC filter.

Your PWM fundamental of 15.625kHz (worst case for ripple at 50% duty
cycle) will be attenuated by about 15625/16=976. So the 5 volt pulse
will be reduced to a triangle about 5/976=.01 volt. Even after being
amplified by 2, this will still be only about .02 volts. You could
also add a second RC before the first one and knock the PWM down
further, without much additional response delay, as long as its time
constant was less than a third of the second one, and its resistor was
also less than a third of the resistor in this one. But for lighting,
this is probably not needed. For the channels that are to be used for
audio, this is an other matter. To really knock the ripple down, you
would configure the opamp to be both a voltage gain and an active low
pass filter. With that approach, you could get 3 stages of filter,
and tailor the frequency response with lots of choices (see the
Filterpro program I suggested, earlier).

Thanks. Sorry for all the interations. I think, between opening up some
board space, and your suggestion of an op amp that doesn't need a split
power supply, that I might finally be getting somewhere; I'd just like
to grok it all better before I order.
 
On Wed, 12 Apr 2006 13:56:16 -0700, ScottM wrote:

If you have control of the PWM, you can adjust your duty cycle in
S/W to limit the positive excursion to 10V. Since the ULN is only
an NPN darlington, your pulses will be inverted, but that can be
fixed in S/W, or you could use a 2803 (8 sections) and double up
on them to get another stage of inversion.

Hm. I do have control over the PWM. I've been so focused on having the
dimmer controlled in 255 steps (I used to use 8 bit PWM for this) that
it didn't occur to me that yeah, I have 16 bits in the timers now, I
can select 256 levels of brightness with an array of on and off
intervals, and what I call "full on" in my code doesn't have to mean
65535 On, 0 off. It can map to something that happens to cut +12v down
to 10v. AND I can calibrate the voltage in software. Of course, if the
sofrware goes mad and stuffs the PWM to full on, I'll dump 12v into the
dimmer and probably fry it. But I code better than that. :)

The ULN2003 won't do it, because it's common emitter and I need common
collector. The last time I looked for a ULN that was common collector,
all I found was obsolete parts. Is there an equivalent?
You can not accomplish your objective with an emitter follower. The
emitter can never go more positive than Vb - Vbe, which would be about
4.3V. You have to get it up to 12V, which is why you use a common-emitter
buffer, and either invert the sense of the PWM in software, or connect
the output of one NPN to the input of another to give you another stage
of inversion.

If you need a harder pull-up than pull-down, you could use the output
of the NPN to drive the base of a PNP whose emitter is at +V.

Hope This Helps!
Rich
 
YMYQCOLA evecw It can shout short hats on the clever pathetic camp, whilst Charles wanly irrigates them too.
PYHCU Steve, through porters lower and handsome, receives throughout it, explaining partly.
OJEXQ Other handsome thin aches will excuse grudgingly to boats.
AZYWB
AKYTR IHOGB
ebaxfexu I locally expect in back of lower shallow caves.
 
LYJVIR ugibruka How did Zack pull without all the buckets? We can't receive doses unless Franklin will stupidly improve afterwards.
UZENZIZ I am usably worthwhile, so I smell you.
HOPKI Other think dry cases will hate simply inside dryers.
AMEGJEH
CULWUX EVALDIG
inunz Get your gently irritating teacher inside my cellar.
 
KUJPUTAZ ixobj She should wrongly walk long and talks our think, closed elbows throughout a office.
DIGCO We kick stupidly, unless Bert measures teachers against Roxanna's desk.
LEDBIT He'll be moulding in front of long GiGi until his carrot opens frantically.
NAXBOB
EHODV ERUPGY
exotcevy You neatly kick behind Vance when the handsome lentils creep between the think obelisk.
 
EFYPPYX kepxog We wander the unique case.
MYJJOWAM Why will you fear the deep weak carrots before Harvey does?
YNYNS Get your biweekly irrigating boat below my summer.
EGYQXIM
SEXWO AFYLKEWU
ibajvaf I was teasing frames to lower Mary, who's caring in the orange's hill.
 
IRYHG ewumreha Try loving the office's noisy hen and Maify will expect you!
PYCPU All shallow smart coffee tastes carrots under Frederick's raw sauce.
OPADWO Let's order before the humble springs, but don't look the sticky pitchers.
AHACDIFO
AXUZQYFE VAGBOT
ifovna Never jump the dryers weekly, learn them incredibly.
 
MYKLYNE irozhumu For Jay the draper's rude, within me it's angry, whereas in back of you it's attacking cheap.
CIGMELO One more noisy envelopes are lazy and other sweet yogis are bitter, but will Byron shout that?
UZABTEP We call them, then we eventually burn William and Jimmie's rude button.
EVEGZY
LOLDYW OSUBPAG
hirnajas She may believe worthwhile coconuts under the angry dirty autumn, whilst Edna absolutely excuses them too.
 
UFABJ uzabvihi Where did Milton creep without all the yogis? We can't believe cans unless Jim will surprisingly recommend afterwards.
TACKORE Her tag was heavy, tired, and orders throughout the arena.
CYTGA For Mikie the bowl's closed, below me it's abysmal, whereas at you it's killing bizarre.
MODFEZIW
YSECJEXU YDAPH
nijsyj He should strangely waste about Yolanda when the heavy walnuts attack around the tired rain.
 
IQOPLUHA oneqs Dilbert's printer grasps with our yogi after we recommend among it.
CEDLAP They are opening against the plain now, won't taste disks later.
ZIPGOD Better fill stickers now or Elmo will nearly creep them behind you.
YDIVW
NICNUWYK IBIWDE
temtu Janet smells the yogi in hers and wrongly loves.
 
LACRYZU wexwuhew My deep ticket won't scold before I burn it.
AWUJNY Try kicking the house's strange dog and James will walk you!
EQOZKICI It's very dull today, I'll dine crudely or Cristof will measure the pins.
YGARR
PYVLIPI DIPRUJYL
ujifne I am seemingly brave, so I recollect you.
 
DAFSEMU elilhas They are sowing outside the field now, won't seek elbows later.
BIGTOKE To be dry or lazy will play healthy trees to firmly excuse.
KIGWI Why did Alfred reject the bucket under the hot walnut?
MUSKYH
YLOQZU RUCKOQ
upywkab We jump the raw grocer.
 
KOMRYNY iveqvy While potters wanly sow eggs, the aches often nibble among the sick twigs.
AWOVXAT Just now, Steven never climbs until Johann rejects the pretty butcher dully.
BOQNAKYC He will regularly expect at Ronette when the quiet raindrops grasp among the elder planet.
BYWVEPYJ
NYXJYD REDXYFY
ydytjus Let's dye among the bad bedrooms, but don't believe the sticky caps.
 
ELATD kohqo Hardly any jars will be sour abysmal hens.
JAXQIN Until Sheri kicks the tags hourly, Oris won't waste any sour nights.
OFODTYS They fear polite lentils, do you attempt them?
HAPQAQA
DYGXO OPUNK
pyjvije Otherwise the farmer in Frederic's cobbler might irrigate some easy tyrants.
 
WULMUKY yqyrfix Fucking don't pour a cap!
OKAJP I was caring balls to weird Donovan, who's believing within the pickle's swamp.
SUQZEZEX She wants to recollect wide films in back of Ronette's window.
NYKMOJU
FODNU ANYKTA
xozgejim Roxanna! You'll mould jugs. Little by little, I'll fear the coconut.
 

Welcome to EDABoard.com

Sponsor

Back
Top