Shop OBEX P1 Docs P2 Docs Learn Events
op-amp as a differental amplifier — Parallax Forums

op-amp as a differental amplifier

JavalinJavalin Posts: 892
edited 2012-10-16 11:23 in Propeller 1
Hello,

Can somebody point me in the direction of a simple guide to using op-amps as a differential amplifer?

I have a ACS712 current sensor which gives 185mv per 1amp current, so a maximum of 925mv. It zero's at 2.5v. I want to amplify the 925mv to 2.5 so I have -5 to +5amps reading as 0v and 5v.

Similar to https://www.sparkfun.com/products/8883 - but I can't figure it out using my circuit sim program, it doesn't work!

Thanks,

James

Comments

  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-10-11 15:18
    Run the output of the ACS712 into the non-inverting input of the op-amp. The inverting input should be connected to ground and +5v through 10.2k resistors, each, and the feedback (output to inverting in) should be 8.66k. That will give you a gain of 2.698 which is close to 2.5/0.925=2.702
  • Mark_TMark_T Posts: 1,981
    edited 2012-10-11 17:51
    Javalin wrote: »
    Hello,

    Can somebody point me in the direction of a simple guide to using op-amps as a differential amplifer?

    James
    http://en.wikipedia.org/wiki/Operational_amplifier_applications#Differential_amplifier
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-10-11 19:04
    I have a ACS712 current sensor which gives 185ma per 1amp current, so a maximum of 925ma. It zero's at 2.5v. I want to amplify the 925ma to 2.5 so I have -5 to +5amps reading as 0v and 5v.

    To expand a bit more on the posts above. It is a current output so you can convert current to volts with a resistor. Normally op amp circuits are build with a + and - supply (eg +/-12V) and everything is calculated with reference to 0V. But you can create a "virtual earth" and for a 5V supply it is very convenient to make the virtual earth 2.5V. The virtual earth can be two resistors as a voltage divider, two 1k resistors for example. Or you could use two 100k resistors and then an op amp voltage follower. This latter means the virtual earth is more stable, or in technical terms, has a lower impedance.

    It so happens that what you want to do centres around 2.5V. So you don't need a differential amp - all you need is an inverting or non inverting amp. So that is just an op amp and two resistors.

    If you look at the non inverting amp circuit you can see there is the "earth". Instead of connecting this to 0V, it goes to 2.5V. If that 2.5V is from another op amp that is fine. If it comes from a voltage divider then the resistors on the divider need to be a lot less than the resistors around the op amp. Maybe 100x less. But you don't want too much current wasted in the divider. So it all becomes a compromise and maybe you use 1k dividers and resistors in the range 100k to 500k around the op amp.

    But there is another answer. Look at the inverting amplifier circuit. In that circuit the + of the op amp goes directly to the earth. So you don't need to worry so much about the impedance of the virtual earth circuit. So what you could do is use a single op amp, two 1k resistors to produce 2.5V which goes to the + of the op amp, then circuitsoft's two resistors for the gain. So that is just 4 resistors and one op amp.

    The catch there is that the signal is inverted. So no current will be 2.5V output, and 1 amp will (I think) read 2V.

    Another consideration is the rail to rail voltage. Garden variety op amps like the 741 or 324 can only go within 1.5V of the supply, which for a 5V supply means the output is only 1.5V to 3.5V. So you can use a rail to rail op amp like the CA3140 instead.

    Is this going into an A to D? If so there might be even simpler circuits and you might not even need an op amp.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-10-11 20:53
    Dr_Acula, Looking at the datasheet, I'm not sure what you're talking about. The ACS712 clearly has a voltage output, so a simple amplifier will do what he wants. The Wikipedia article on Op-Amps shows a basic circuit for a non-inverting amplifier. Since the input and output voltages at 0amps should both be 1/2vcc, Rg can be made up of a voltage divider. A voltage divider has an equivalent resistance of the two resistors in parallel. My circuit description above, with the two 10.2k resistors will provide a 1/2vcc reference voltage with a 5.1k equivalent resistance. With 5.1k Rg and 8.66k Rf, you will get a gain of (8.66+5.1)/5.1 which will provide +/-2.5v with +/-.925v input, all referenced to a 1/2vcc baseline.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-10-11 22:17
    Javalin wrote: »
    Hello,

    Can somebody point me in the direction of a simple guide to using op-amps as a differential amplifer?

    I have a ACS712 current sensor which gives 185ma per 1amp current, so a maximum of 925ma. It zero's at 2.5v. I want to amplify the 925ma to 2.5 so I have -5 to +5amps reading as 0v and 5v.

    Similar to https://www.sparkfun.com/products/8883 - but I can't figure it out using my circuit sim program it doesn't work!

    Thanks,

    James

    TI has a guide called "OP Amps for Everyone". Very well written guide to using op amps. Sec 3-6 for general diff amp, and section A 3-9 for single supply diff amp applications. Also good layout practices. IIRC, National Semi had a configuration guide of sorts showing lots of different possibilities.

    FF
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-10-11 22:37
    I'm a bit confused at this point - in the original post it says
    I have a ACS712 current sensor which gives 185ma per 1amp curren
    which implies a current output but looking at the data sheet it says
    66 to 185 mV/A output sensitivity
    which is a voltage output.

    mV/A is not the same as ma so maybe that is a typo.

    @circuitsoft, we probably need to draw up a schematic here, because the voltage divider resistor values for the virtual earth are not so important for a inverting amp but they are important in a non inverting amplifier as current is flowing from the op amp into the voltage divider and will change the value of the reference.

    If this is going into an A to D it should be possible to leave out the op amp which should simplify things.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-10-11 22:58
    Why not simply take and modify one of the reference skids provided by allegro in the data sheet for this unit. It may also be worth scaling up the output from the sensor right at that source then send it using twisted pair to a diffamp to clean up the signal prior to digitizing.
  • JavalinJavalin Posts: 892
    edited 2012-10-12 01:07
    >I have a ACS712 current sensor which gives 185ma per 1amp current
    sorry i did mean 185mv, not ma!

    Thanks for the replies chaps, I will read and digest.

    James
  • JavalinJavalin Posts: 892
    edited 2012-10-12 02:39
    Circuitsoft,

    Like this?

    op-amps.jpg


    I haven't read op-amps for everybody yet, but I will do.

    James
    812 x 414 - 26K
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-10-12 03:26
    Not quite - there is one more resistor needed. Busy at work so hopefully someone will chime in soon.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-10-12 11:05
    Javalin wrote: »
    Circuitsoft,

    Like this?

    op-amps.jpg


    I haven't read op-amps for everybody yet, but I will do.

    James
    Yes, exactly like that.

    @Dr_Acula, Javalin has drawn up exactly the circuit I have in mind. There are no more resistors needed, unless you're trying to balance the circuit for input current, in which case you'll want to add a (10.2 | 10.2 | 8.66)=3.21Kohm resistor in series with the non-inverting input, but that may not be necessary depending on what op-amp is used and how much precision is needed.
  • JavalinJavalin Posts: 892
    edited 2012-10-12 11:55
    Yes, exactly like that.

    @Dr_Acula, Javalin has drawn up exactly the circuit I have in mind. There are no more resistors needed, unless you're trying to balance the circuit for input current, in which case you'll want to add a (10.2 | 10.2 | 8.66)=3.21Kohm resistor in series with the non-inverting input, but that may not be necessary depending on what op-amp is used and how much precision is needed.

    Cool - that works on my circuit sim program (livewire)

    op_amp_2.jpg


    Thanks for the help!

    James
    1024 x 629 - 22K
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-10-12 17:00
    Cool, that works for me too. Nifty circuit.

    BTW if anyone wants to try a free online simulator, check out https://www.circuitlab.com/editor/
    1020 x 676 - 122K
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-10-12 17:22
    I've always used Java Circuit Sim.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-10-12 18:52
    Both TI and Linear Technology have simulators to run local to your machine. The TI product is called TINA, and Linear Technology is called LT Spice IV. TI's (formerly Nat. Semi) WEBENCH runs remotely from their site.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2012-10-13 15:52
    If symmetrical loading on your inputs is important to your design, look into instrumentation amplifiers.
  • JavalinJavalin Posts: 892
    edited 2012-10-16 02:28
    thanks chaps. Op-amps ordered and looks like this will be good.

    Question about resistor selection for a test circuit (as shown) to produce a 1amp, 2amp, 4amp current flow for testing/calibration purposes, etc. (obviously I will use a 12r, 6r and 3r - but 12r shown)

    v_i_r.jpg


    Confused about what wattage to select for the resistor? P=VI says 12watts?

    or is there a better way to do this?

    James

    PS - also how you do account for battery voltages, i.e. a 12.6v battery (charged) and a 12r resistor produces 1.05amps. Really want 1amp/2amp/4amp for reference testing.
    530 x 416 - 47K
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-10-16 09:12
    Javalin, you probably want actual constant-current sources. LM317 can do that pretty easily (up to 1 amp) and you can just parallel them for 2-4 amps. They will dissipate the same power that resistors would, so you'll need to have them on a good heatsink. Cheap/easy options is a CPU heat sink.

    As for resistor power, you're correct that the circuit you drew will dissipate 12 watts from the resistor, but a resistor dissipating its rated power will get very hot. Generally, you want to double power ratings of resistors. That also gives you margin-of-error for other input voltages.
  • JavalinJavalin Posts: 892
    edited 2012-10-16 11:23
    thanks again Circuit Soft.
Sign In or Register to comment.