Author Topic: Op amp relaxation oscillator and PWM advice?  (Read 13614 times)

0 Members and 3 Guests are viewing this topic.

Offline IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 12406
  • Country: us
Op amp relaxation oscillator and PWM advice?
« on: February 20, 2012, 07:04:03 am »
I have the circuit simulation below that I built up in LTspice to explore the ideas contained in it. It is a fairly ordinary kind of circuit that uses op amps to generate a triangle wave and then produce a PWM output.

Various "practical" issues came up that I am interested in advice about from those more knowledgeable than me.

Firstly I was interested in single supply operation (presuming the output of such a circuit might be used to control a load). A single supply is usually more available and more convenient than a dual supply. I'm not sure practically what the difference is between a "single supply" op amp and a "dual supply" op amp and whether it would make any difference to this circuit? My reading tells me the problem may lie with any DC offset voltage between inputs referenced to the real ground and inputs referenced to virtual ground. It doesn't look like this would be an issue here.

Secondly for reasons of symmetry the upper and lower limits of the output range should be equally far from the voltage rails. In case of lower supply voltages it would be nice if the output went all the way to the rails. This applies in particular to U2.

Thirdly I found that input bias current became an issue with U4 when the two inputs were far apart. With some op amps this could become milliamps or more. This amplifier is acting as a comparator, but it would be convenient if it could be one quarter of a four op amp package and thus be the same as U1-U3.

I found that the LTC1053 chopper amplifier works nicely in this circuit, but it is expensive and surely overkill for the application.

What might be a cheap "jelly bean" amplifier that could be used in this application? It seems I am looking for rail-to-rail output, single supply operation and low input bias currents. Parametric searches throw up a lot of choices that might fit, but I'm wondering if there is a "go to" choice for what seems like a fairly simple configuration?

« Last Edit: February 20, 2012, 07:08:30 am by IanB »
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7549
  • Country: 00
  • +++ ATH1
Re: Op amp relaxation oscillator and PWM advice?
« Reply #1 on: February 20, 2012, 07:22:07 am »
MCP6021/2/3/4 ???

Edit : Sorry, just realized your circuit is powered using 10 volt, the mcp6021 max supply volt is at 5 volt only.  :-\
« Last Edit: February 20, 2012, 07:55:26 am by BravoV »
 

Offline IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 12406
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #2 on: February 20, 2012, 08:10:01 am »
Oh, I didn't notice that either  :-[

I was just now trying to incorporate Microchip's spice model for the MCP6021 into my simulation, but LTspice doesn't like it for some reason. It barfs at the start of the simulation with this message:

  Analysis: Time step too small; initial timepoint: trouble with node "u1:21"

It looks like it can't get started with the initial time step.

I should mention I'm kind of a beginner when it comes to electronics, so if my op amp selection question seems a bit elementary, it probably is. There is no expert subtext or hidden gotcha involved. I'm just a novice trying to figure out how I could build that circuit in a practical way.
 

Offline IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 12406
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #3 on: February 20, 2012, 09:14:55 am »
I tried the LT1881 and that seems to simulate OK. Except the virtual ground really didn't like the capacitor on the output. Went horribly unstable. And it's not all that inexpensive. And suppliers don't seem to stock it very much. So it is not what I would call jelly bean.
 

Offline slateraptor

  • Frequent Contributor
  • **
  • Posts: 833
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #4 on: February 20, 2012, 12:12:09 pm »
What might be a cheap "jelly bean" amplifier that could be used in this application? It seems I am looking for rail-to-rail output, single supply operation and low input bias currents.

If you want a slap-it-on-a-board-and-go sol'n, the op amp you're looking for won't be a jellybean. That being said, you can swing on down to your local Radioshack and pick up a LM324 quad jellybean. With a bit of compromise, you can surely make it a winner. Based on your simulation pic, the "gotchas" will be in the upper rail and slew rate. Also, I don't see any need for a bypass cap on U1 output.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19996
  • Country: gb
  • 0999
Re: Op amp relaxation oscillator and PWM advice?
« Reply #5 on: February 20, 2012, 09:49:12 pm »
#You could even try a comparator such as the LM339.
 

Offline IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 12406
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #6 on: February 20, 2012, 10:16:31 pm »
#You could even try a comparator such as the LM339.

Even for the integrating op amp that generates the triangle wave?

I've been having an interesting time with simulations. When I import op amp models from other vendors I find that LTspice doesn't like them and it keeps failing to integrate the model properly. For example the LM324 model refused to work, as did the MCP6021.

I have the simulation running with the LT1014 which is described as a drop in replacement for the LM324. The difference is that the LM324 costs 50 cents and the LT1014 costs $5. Some drop-in replacement!
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19996
  • Country: gb
  • 0999
Re: Op amp relaxation oscillator and PWM advice?
« Reply #7 on: February 20, 2012, 10:38:19 pm »
#You could even try a comparator such as the LM339.

Even for the integrating op amp that generates the triangle wave?
There's a an application note on the datasheet showing a similar thing. It's probably worth trying with your circuit.

http://www.ti.com/lit/ds/symlink/lm339-n.pdf
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: Op amp relaxation oscillator and PWM advice?
« Reply #8 on: February 21, 2012, 12:15:29 am »
Not sure why you would have any problem with the LM324 in LTspice.

Attached is a simple integrator test with the LM324 files.
Copy LM324-national.asy into the LTSpice lib/sym/Opamps folder,  and copy lm324.MOD into the  LTSpice lib/sub folder.

Should work fine. Just about all opamps nowadays are single supply opamps in that unlike the very first opamps like the uA702, they do not need three supply rails such as a +ve, -ve and 0v supplies into the opamp for the opamp to function. However, when an opamp does not have any inputs that can work near one of the supply rails, and its outputs cannot go to at least one of the supply rails, then the opamp of probably better suited to using with +/- supplies.

When manufacturers call an opamp a single supply opamp, it just means that they think it is a good one to use if you are running in a single supply circuit. So the description is more of a recommendation then a specification of the opamp. In a similar way, a "Switching transistor" is one optimized for fast saturated switching, but you can use a switching transistor in an audio amplifier, and you can use a standard audio-amp type transistor as a switching transistor.

Richard.
« Last Edit: February 21, 2012, 12:30:47 am by amspire »
 

Offline IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 12406
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #9 on: February 21, 2012, 02:05:20 am »
Not sure why you would have any problem with the LM324 in LTspice.

Neither am I. And yet...

Here is the result of trying to simulate my circuit. And the circuit itself. I don't know how to dig in and diagnose what might be going wrong. Is there a diagnostic file or trace facility somewhere? (Of course there is, but I have not discovered how to generate enough diagnostic information to figure out the problem yet.)

 

Offline slateraptor

  • Frequent Contributor
  • **
  • Posts: 833
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #10 on: February 21, 2012, 02:13:09 am »
I've been having an interesting time with simulations. When I import op amp models from other vendors I find that LTspice doesn't like them and it keeps failing to integrate the model properly. For example the LM324 model refused to work, as did the MCP6021.

For TI's LM324 model

1) Download model from their website and unzip the LM324.5_1 file (rename if you want to) to the LTspceIV\lib\sub directory. Open the file in a text editor and observe the comments for component pin out.
2) Use the opamp2 symbol; right-click and put LM324 in the SpiceModel field. This is an appropriate symbol because if you open opamp2.asy in a text editor, you'll notice that the pin out matches the LM324 model.
3) Add the spice directive .include LM324.5_1 or whatever you might have renamed the file to.


When manufacturers call an opamp a single supply opamp, it just means that they think it is a good one to use if you are running in a single supply circuit. So the description is more of a recommendation then a specification of the opamp.

More important is that an op amp denoted single-supply is also characterized for at least one common supply (typically Vcc=5V or 3V) in the datasheet.
 

Offline IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 12406
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #11 on: February 21, 2012, 02:20:03 am »
When I say "fails to integrate" I mean the numerical integrator fails when attempting to solve the model in the time domain. I can incorporate the model into LTspice and add it to a circuit without trouble.
 

Offline slateraptor

  • Frequent Contributor
  • **
  • Posts: 833
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #12 on: February 21, 2012, 02:46:53 am »
When I say "fails to integrate" I mean the numerical integrator fails when attempting to solve the model in the time domain. I can incorporate the model into LTspice and add it to a circuit without trouble.

I don't know what you might be doing wrong...probably nothing. I suspect something with the model you're using, although I haven't looked at it.
« Last Edit: February 21, 2012, 02:49:48 am by slateraptor »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: Op amp relaxation oscillator and PWM advice?
« Reply #13 on: February 21, 2012, 03:04:25 am »
Welcome to the world of simulation!

Sometimes the model is too perfect, and so it just cannot find a way to even start oscillating. It ends up in infinite loops until it has to give up.

I have added some in-perfect startup conditions so it can start.

Richard
 

Offline slateraptor

  • Frequent Contributor
  • **
  • Posts: 833
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #14 on: February 21, 2012, 03:10:22 am »
Richard got it. Add the startup flag to the transient directive, viz. .trans 10m startup

That will get National's model to work.
 

Offline IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 12406
  • Country: us
Re: Op amp relaxation oscillator and PWM advice?
« Reply #15 on: February 21, 2012, 03:37:14 am »
Welcome to the world of simulation!

There is greater irony in that comment than you could possibly imagine. In my professional life I design and implement computer simulation software, however this is my first foray into circuit simulation--here in the unaccustomed role of the sucker er, innocent user, rather than the designer  ;D

I see the problem now. The initial state was balanced on a knife edge, with the possibility to go up or down. When the solver tried to determine the initial direction it got a numerically singular system and consequently couldn't start. A common way to solve this problem in software is to apply a small random perturbation to appropriate variables, thus nudging the system away from the singularity. This is the kind of thing you have to do if you want to be friendly to your simulation users.

For completeness I have shown below my solution to the problem, now I understand what it is. Doubtless experienced spice users get bitten by this problem only once...

 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Op amp relaxation oscillator and PWM advice?
« Reply #16 on: February 21, 2012, 04:19:25 am »
I see the problem now. The initial state was balanced on a knife edge, with the possibility to go up or down.

Read up on the .IC statement which can to force any node to a particular voltage at the start of transient analysis.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf