EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: Skimask on September 02, 2013, 07:59:26 am

Title: LTspiceIV & OpAmp simulations
Post by: Skimask on September 02, 2013, 07:59:26 am
Trying to make a simple voltage/pulse/whatever generator.  LTSpiceIV file is attached.
Input is an 8bit DAC, 0 - 1.024v output.  Desired output is +12v/-12v (give or take, doesn't have to be dead nuts on).  Set the DAC to the midpoint (e.g. .512v), output goes to 0v.  Set the DAC to max, output goes to -12v, set the DAC to minimum, output goes to +12v.
Simple enough...or not...  |O
Issue I'm having is trying to get the simulation to output 0v @ PGOUT when the DAC input is set to .512v.
I set R4 to 17,427 ohms (ya, like I'll find a resistor that'll give me that value!...NOT!), and the output is around 110uV.  Ok, that's fine, close enough to zero for me.
But, what am I missing in the figuring/schematic/etc. that'll allow me to set the output to zero?
Is this a function of the simulation, or rather the lack of simulation in LTSpice?
What formula, what opamp spec, do I need to look at that gives me that R4 value of 17,427 ohms to get close to 0v output at PGOUT?  I got that particular value by trial/error until I got as close as I could get.  There's gotta be some math in here somewhere that'll give me the values, or at least something close to it...
Title: Re: LTspiceIV & OpAmp simulations
Post by: Rufus on September 02, 2013, 12:06:53 pm
The voltage on the +ve input of the second op-amp needs to be  (g -1)/g times whatever you want to use as a zero reference where g is the inverting gain, 22 in your case.

For 512mV that would be 488.7mV and from a 3.3v supply 27k and 4k7 for R3 and R4 will be close.

4k7 for R1 and 110k for R2 will give close to +/-12v out.
Title: Re: LTspiceIV & OpAmp simulations
Post by: ElectroIrradiator on September 02, 2013, 12:21:57 pm
There is also a standard way of generating a symmetric, bipolar output from a DAC using a single opamp, which also includes voltage amplification. Need to do a bit of resistor tweaking, but should be simple enough to do. See for instance the datasheet for the AD5066, figure 48 on page 21.
Title: Re: LTspiceIV & OpAmp simulations
Post by: Harvs on September 02, 2013, 12:24:08 pm
Looks to me like you're going the hard way about re-inventing the standard instrumentation amp circuit.  By making the circuit look like an instrumentation amp, it works basically how you want it.

Obviously lots of info on the web about this configuration and all the formulas you need.
Title: Re: LTspiceIV & OpAmp simulations
Post by: Skimask on September 02, 2013, 08:33:28 pm
Don't get me wrong.  I'm likely the first guy to say to others "RTFM" or "RTFDS" or "LMGTFY" or "LMBTFY".

Understood all responses thus far.  Makes sense now.  I was under the impression that maybe LTSpice may have been plugging in values behind my back and messing up my calculations.  I now see that's not the case.
Yes, an instrumentation amp is what I was looking for.  Research in progress...  And of course, it's all right there staring me in the face in the good book (e.g. The Art of Electronics).
AD5066 datasheet - noted, and likely will use that part (or similar) rather than this old DAC0800 and '595 I was going to use.
Title: Re: LTspiceIV & OpAmp simulations
Post by: Skimask on September 03, 2013, 04:06:17 am
Built it up.  Worked like a champ!  Used the 8bit DAC on a PIC16F1783 instead of the DAC0800.
Kept the 3.3v ref on the + input (used a LP2950-3.3), put a 27K on R3, 4.7K on R4 along with a 10-turn 100 ohm trimmer.
So far, with about 3 hours of operation on it, once tweaked for 0v output with a mid-range input from the PIC's DAC, it's staying at 0v...or at least as close to zero as my meter will indicate...whether that's absolutely correct or not...meh...close enough for me.

I feel much more ejumukated-ness now :)
Title: Re: LTspiceIV & OpAmp simulations
Post by: free_electron on September 03, 2013, 04:35:30 am
Ah the good old usage of a simulator to see if something works without knowledge of the circuit....

Simulators , at best, are to be used only if you fully understand the circuit you are trying to simulate. The reason being so you know when the simulator is lying to you!

Simulators should never be used to slap some parts together and see what the behaviour would be.. That is like shooting blindfolded , with a gun that has a bent barrel , in the opposite direction of where your target is ...
Title: Re: LTspiceIV & OpAmp simulations
Post by: Skimask on September 03, 2013, 04:40:47 am
Ya, that's pretty much why I asked the question...didn't know if LTSpice was adding stuff to the opamps behind the scenes or not.
But, now that it's built up and, most importantly, acting like I expect it to, especially since it matches the LTSpice model almost exactly, I'm happy.  And more, or most, importantly, know a lot more about opamps than I did a few days ago.