Author Topic: Not-quite constant current charging of cap. in ramp generator  (Read 1602 times)

0 Members and 1 Guest are viewing this topic.

Offline aneevuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: gb
Not-quite constant current charging of cap. in ramp generator
« on: February 27, 2020, 03:47:03 pm »
I have a ramp generator circuit that I've been playing around with. It's based on a non-inverting LM311 with some offset hysteresis:

939348-0

The voltage at point A looks as shown in the saved image from a scope:

939352-1

When the cap. starts to charge, there is a distinct non-linearity at the start. I had assumed that this was due to the fact that when Q2 is off, then the current source is feeding the cap. in parallel with the 47K and 120K resistor chain, and I "proved" this by disconnecting point A from the 47K, and driving point B with a ramp from a sig. gen. under which circumstances the cap. charges nice and linearly as expected.

However, having analysed the response of a current source feeding a parallel RC circuit, it turns out that it doesn't look much like what I'm seeing on the scope trace at all (it's roughly a \$1-e^{-{t/RC}}\$ curve, which is very linear for small \$t\$).

So the question: can anyone explain what's going on at the start of this voltage ramp, given the circuit as shown? I'm baffled.

« Last Edit: February 27, 2020, 03:48:47 pm by aneevuser »
 

Offline Tom45

  • Frequent Contributor
  • **
  • Posts: 556
  • Country: us
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #1 on: February 27, 2020, 04:02:07 pm »
What do you see at A if you replace the capacitor with a 4.7K resistor?  The trace seems to start at close to 2 volts now. That makes me think there is something wrong with your constant current circuit. Or maybe Q2 isn't turning on fully?
 

Offline aneevuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: gb
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #2 on: February 27, 2020, 04:11:43 pm »
What do you see at A if you replace the capacitor with a 4.7K resistor?  The trace seems to start at close to 2 volts now. That makes me think there is something wrong with your constant current circuit. Or maybe Q2 isn't turning on fully?

The upper and lower thresholds of the Schmitt trigger are about 3.4V and 1.5V so the cap. only charges and discharges between those levels. I don't think that there's a problem with the current source.

Though you've made me think about Q2 now - maybe I'm overdriving it and it's taking time to turn on fully - excess base charge and all that?
 

Offline Tom45

  • Frequent Contributor
  • **
  • Posts: 556
  • Country: us
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #3 on: February 27, 2020, 04:49:46 pm »
It would be interesting to look at A on channel 1, base of Q2 on channel 2, and emitter of Q1 on channel 3. Then expand the time base to better see what is happening when Q2 switches off.
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #4 on: February 27, 2020, 06:02:46 pm »
Q2 will overshoot and stay on a bit but that doesn't explain the strange curve, it would be curved the other way.
If nothing else fixes it I'd add a 100n decoupling to the inverting input. :-//
« Last Edit: February 27, 2020, 06:05:01 pm by StillTrying »
.  That took much longer than I thought it would.
 

Offline aneevuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: gb
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #5 on: February 27, 2020, 07:52:11 pm »
Q2 will overshoot and stay on a bit but that doesn't explain the strange curve, it would be curved the other way.
If nothing else fixes it I'd add a 100n decoupling to the inverting input. :-//
Thanks. I've taken a look at the inverting input, and it bounces a bit when the o/p transitions - your suggestion of a 100nF decoupling cap fixes that nicely. It doesn't fix the other issue though.

However, having thought about the base resistor of Q2, it seems that 120K or thereabouts is enough to drive the transistor into saturation, so 1K is massive overkill - I've swapped this out for a 200K pot, and the charging ramp looks far more linear (though not perfect :-( ) with base resistances > 100K.

I'll put up some traces taken at A, the base and the emitter of Q2 tomorrow or at the weekend when I have some time.

Anyway, I'm still confused but slightly less so - Q2 seems to be the culprit, I think. Maybe it'd be better with a FET?
 

Offline Renate

  • Super Contributor
  • ***
  • Posts: 1460
  • Country: us
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #6 on: February 27, 2020, 09:44:48 pm »
Let's do the math!
It ramps about 1.5V in 1mS, right?
1.5V*1mS*0.1uF=150uA

If you look at the base of your current source, you will probably see it moving all over.
You could connect that to a real voltage source, or make the base resistors much smaller, or put a big cap on it.
I like current mirrors, I'd probably replace it with two transistors.
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #7 on: February 27, 2020, 10:43:01 pm »
"If you look at the base of your current source, you will probably see it moving all over."

Yes, could its base voltage be being temporarily charged by the fast edge through its own collector-base capacitance.

The whole of the slope will have some slight curve because at its top ~10% of the constant current is then flowing though the 47k and 120k.

« Last Edit: February 27, 2020, 10:48:59 pm by StillTrying »
.  That took much longer than I thought it would.
 

Offline aneevuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: gb
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #8 on: February 28, 2020, 11:07:26 am »
Let's do the math!
It ramps about 1.5V in 1mS, right?
1.5V*1mS*0.1uF=150uA
The current is now set to about 250uA - it may have been 150uA when I took that picture

Quote
If you look at the base of your current source, you will probably see it moving all over.

Here are the traces for:

Q2 collector - channel 1
Q1 collector - channel 2
Q1 base - channel 3

939906-0

There's some movement but I don't know if you'd classify that as "moving all over"
 

Offline Renate

  • Super Contributor
  • ***
  • Posts: 1460
  • Country: us
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #9 on: February 28, 2020, 12:20:10 pm »
Well, just throw a cap on the Q1 base and see how much it changes.

Your emitter resistor is only having 0.25 V, that's not a lot.
The more voltage on the emitter resistor, the more accurate your current will be.
Normally you'd use a zener supply on the base and a couple of volts from the emitter resistor.
Ok, you don't have the headroom, because you're running 3V signal on a 5V supply.

Since you don't have the headroom, just use a current mirror, the least headroom topology you can do.
Another PNP with the collector/base going to the only resistor to ground.
Q1 emitter to +5, base to new transistor collector/base, collector to cap.

I presume that you actually want to do something with the ramp and not just take the comparator output?
Put a unity follower opamp between the cap and the comparator.
Now you have a low impedance output that you can use.
That will get rid of the 10 microamps that the comparator is taking.

 

Offline Tom45

  • Frequent Contributor
  • **
  • Posts: 556
  • Country: us
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #10 on: February 28, 2020, 02:51:45 pm »

Here are the traces for:

Q2 collector - channel 1
Q1 collector - channel 2
Q1 base - channel 3

Something not right here. Q1 collector and Q2 collector are connected together. Yet the channel 1 and 2 traces are not the same.

The base and collector of Q2 plus the base and emitter of Q1 would be interesting. Trigger on the Q2 base.

 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #11 on: February 28, 2020, 03:17:31 pm »
I've simulated it, Q2's emitter and collector are reversed - maybe. :)

If I simulate it with Q2 the right way around Q2 shorts the cap down to 0V, with Q2's emitter and collector the wrong way around the cap only goes down to 1.6V which is very similar to your first scope image.

« Last Edit: February 28, 2020, 03:38:45 pm by StillTrying »
.  That took much longer than I thought it would.
 

Offline aneevuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: gb
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #12 on: February 28, 2020, 03:24:22 pm »

Here are the traces for:

Q2 collector - channel 1
Q1 collector - channel 2
Q1 base - channel 3

Something not right here. Q1 collector and Q2 collector are connected together. Yet the channel 1 and 2 traces are not the same.

The base and collector of Q2 plus the base and emitter of Q1 would be interesting. Trigger on the Q2 base.
Yeah sorry - I screwed up - channel 2 is looking at Q1 emitter. I'm a moron.
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21686
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #13 on: February 28, 2020, 03:25:54 pm »
You have the hysteresis resistors loading the capacitor; use the 311's "emitter" output and swap the input pins.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #14 on: February 28, 2020, 08:17:57 pm »
It looks to me like the 311 is having trouble shutting Q2 off.  I would add a 10s of picofarads bypass capacitor around the base series resistor.

I've simulated it, Q2's emitter and collector are reversed - maybe. :)

If I simulate it with Q2 the right way around Q2 shorts the cap down to 0V, with Q2's emitter and collector the wrong way around the cap only goes down to 1.6V which is very similar to your first scope image.

Capacitor discharge circuits sometimes reverse the collector and emitter of the discharge transistor to reduce saturation voltage but this requires much higher base drive because the current gain will be lower unless a chopper transistor is used.
 

Offline aneevuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: gb
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #15 on: February 29, 2020, 11:17:47 am »
You have the hysteresis resistors loading the capacitor

This was my first assumption - when Q2 is off, the hysteresis resistors are in parallel with C and being fed by a current source, but this doesn't seem to explain the observed behaviour AFAICS - see my first post.

Quote
use the 311's "emitter" output and swap the input pins.

I'm not sure what you're suggesting here - you mean drop the +ve hysteresis? Can you exapnd?

Anyway, I'm not going to have time to look at this till next weekend now, but thanks for all the replies - I ought to add that at the moment my concern is not specifically to improve the ramp, but to understand why this specific configuration is behaving as seen.
 

Offline Renate

  • Super Contributor
  • ***
  • Posts: 1460
  • Country: us
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #16 on: February 29, 2020, 12:22:19 pm »
This is just going 'round and 'round with everybody speculating what the problem is without any experiments or changes to the circuit.
So here's an experiment:

Disconnect the collector of Q2.
Set the scope on single trace.
Ground the capacitor, then release it.
Now try this with the 47k resistor disconnected.

Right now we are only seeing 1.5V of ramp.
We don't actually know how good the current source is.
If we can see the whole 0-5V ramp we can tell if there are problems.
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21686
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #17 on: February 29, 2020, 12:56:31 pm »
I'm not sure what you're suggesting here - you mean drop the +ve hysteresis? Can you exapnd?

Still need hysteresis of course, but it can be applied to -in this way, so +in can be straight off the cap with no resistors.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline aneevuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: gb
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #18 on: February 29, 2020, 01:45:06 pm »
This is just going 'round and 'round with everybody speculating what the problem is without any experiments or changes to the circuit.
So here's an experiment:

Disconnect the collector of Q2.
Set the scope on single trace.
Ground the capacitor, then release it.
Now try this with the 47k resistor disconnected.

Right now we are only seeing 1.5V of ramp.
We don't actually know how good the current source is.
If we can see the whole 0-5V ramp we can tell if there are problems.

In my first post, I mentioned that I've tested this by disconnecting the current source from the 47K and driving point B from a sig. gen. Anyway, here's a trace of the Q1 collector when doing so, with the sig. gen. adjusted to allow complete charging of the cap. It looks reasonably good (if not perfectly linear) to me.

940870-0

Anyway, I have no more time for this this weekend so I shall have to leave it for now. Thanks to all.
 

Offline aneevuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: gb
Re: Not-quite constant current charging of cap. in ramp generator
« Reply #19 on: February 29, 2020, 01:49:26 pm »
I'm not sure what you're suggesting here - you mean drop the +ve hysteresis? Can you exapnd?

Still need hysteresis of course, but it can be applied to -in this way, so +in can be straight off the cap with no resistors.

Tim
Can you put up a sketch of this? I know how to apply offset hysteresis in both inverting and non-inverting forms, but you seem to be suggesting something different - not quite sure what you're getting at here.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf