1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

LM385 vs LM393 with Nano

Discussion in 'Arduino' started by SPDCHK, Apr 14, 2016.

  1. SPDCHK

    SPDCHK Member

    Joined:
    May 26, 2006
    Messages:
    446
    Likes:
    17
    Location:
    South Africa
    I am not afraid to admit that I am a complete idiot when it comes to Op-Amps. I always have to look for examples on the internet, and most often or not, I need to get help (like now)

    I am busy with a PWM Lead-Acid solar panel battery charger unit. Original design by Julian Ilett. (Converted for Arduino Nano)

    That all works like a charm. Then I decided to measure the current from Solar panel and battery. Using shunt resistors of about 0.073 ohm, I used a LM385 dual op-Amps and built two differential amplifiers (one for the Solar panel and the other for the battery). I used 8V supply on the LM385 (because of the output vs supply voltage problem and I need 0..5V for the Nano AI PIN’s)

    On the bench it calibrated 100%. Current range of 0..2A gives about 0..148mV, and through the differential amplifier I got the 0..5V required for the Nano.

    As can be seen from the circuit, I also measure the the Solar Panel and Battery voltages. The problem comes in the moment I connect the LM385 output to the Nano. On the DMM voltmeter the output is as steady as a rock, but the indication on the Nano is going nuts. It swings around as if the input pin has nothing connected to it.

    I see on the forum that the LM358 is just a tad better than the 741, which is to say the least 1% better than “cr@p”. I used the LM358 on PIC 16F88 before using it to amplify the volt drop of a 1N4148 diode for temperature measurement, and then that worked well, but now with the Nano, not so well.

    I have other shields that makes use of the LM393. (Unfortunately they are SOIC packages and I cannot re-use them in my project). So, before I go off and buy there Op-Amps, will they work? Is this a good enough replacement for the LM358? Or, should I rather use something else?
     

    Attached Files:

  2. fezder

    fezder Well-Known Member

    Joined:
    Dec 11, 2011
    Messages:
    1,665
    Likes:
    100
    Location:
    Mikkeli, Finland
    lm358 is opamp yes, but, lm393 is comparator, there are major differences between them; comparator only compares levels, output is either 1 or 0, and mostly open collector output (sinks current). opamps can be used as comparators also, but they tend work better in amplifiaction and other opamp stuff. :)
    I don't have much experience with opamps, lm358 is quite old, noisy, you get the idea, It'll get some jobs done. That's bit confusing that this works on pic, but not on nano? Grounds are connected I presume as it worked in pic?
     
    Last edited: Apr 15, 2016
  3. SPDCHK

    SPDCHK Member

    Joined:
    May 26, 2006
    Messages:
    446
    Likes:
    17
    Location:
    South Africa
    Thank you fezder.
    I managed to salvage a LM393 from my junk box. You are correct. LM393 does not work in my application.
    I also managed to salvage a TLC27M3CP with the same layout as the LM358. This one works fine until the output voltage exceeds about 1.25V, then the reading on the Nano goes crazy again. Very erratic and fluctuating a lot.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. fezder

    fezder Well-Known Member

    Joined:
    Dec 11, 2011
    Messages:
    1,665
    Likes:
    100
    Location:
    Mikkeli, Finland

    Hmm, I can't find datasheet for TLC27M3CP, but since we're dealing with single supply, that is one main feature we're looking for any suitable opamp, as well as vcc-rating. I see form schemtaics that power supply for opamp is 8v yes? Only few opamps I could suggest from more modern ones are these, mcp does have 5.5v max supply voltage, so that isn't direct replacement, but I use it mostly nowadays, much better than LM358. Another model is from TI, but for some reason I'm not happy with this model. It's odd that your opamp acts oddly if voltgae exceeds 1.25, would make sense if it would be lower (no-rail-rail opamp) Can you test whether it works linear fashion as voltage follower?
    http://fi.farnell.com/microchip/mcp6022-e-p/ic-op-amp-dual-10mhz-dip8-6022/dp/1332125 (5.5v max supply)
    http://fi.farnell.com/texas-instruments/tle2142cp/op-amp-dual-low-noise-2142-pdip8/dp/8454779

    edit; found data for that your opamp:
    http://www.bdtic.com/TI/TLC/TLC27M3.html
     
  6. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,474
    Likes:
    191
    Location:
    Lancashire UK
    If the DVM is connected to the output of the OP amp and that is reading the correct voltages then the problem must be with the way you have connected it to the nano or the way you have written the software. Post the FULL schematic of how its is wired up. Also are you sure that the reference voltage for the ADC in the nano is stable. A better solution may be to use one of these modules based on the ACS712 hall effect current sensor chip. This has total galvanic isolation between the current being measured and the measuring circuit.

    Edit.
    Another thought occurred to me. This is that the op amp may be oscillating. The DVM may still read correctly (Due to input filtering.) but the ADC in the nano would be taking readings for a very short time for each sample. Check the op amp output with an oscilloscope. If you do not have an oscilloscope connect your multimeter set to a low AC range to the op amp output via a capacitor. If you get a reading the op amp is oscillating

    Les.



     
    Last edited: Apr 16, 2016
    • Like Like x 1
  7. MrAl

    MrAl Well-Known Member Most Helpful Member

    Joined:
    Sep 7, 2008
    Messages:
    11,049
    Likes:
    961
    Location:
    NJ
    Hello there,

    The LM358 is a standard op amp that runs off of 5v for example. The output can go from 0 to 3.5v typical with a supply of +5v only.
    The LM358 should be more than enough, but you'll have to do the ADC code to handle 0 to 3.5v instead of 0 to 5v.

    If you have any doubts, wire the LM358 as a buffer and get that to work with the Nano ADC first. A buffer just as output connected to inverting input, then use the non inverting input as the input to be measured. Make sure the grounds are connected together right too, make sure the Nano ADC still works properly with a voltage divider on the input for example.

    Note that the amp can only be used as a non inverting device with a power supply of only +5v unless you bias it at 1/2 of Vcc.
    So a typical amplifier would have the input to be measured going to the non inverting input, with resistors from the inverting input to ground and inverting input to output for the gain set.
     
    • Agree Agree x 1
  8. SPDCHK

    SPDCHK Member

    Joined:
    May 26, 2006
    Messages:
    446
    Likes:
    17
    Location:
    South Africa
    Well spotted there Les. Yes, the circuit is a PWM charger. Obviously the output to the battery will be pulsing :banghead:. The DVM reads steady but the scope shows the PWM pulses clearly. When I calibrated the Differential amplifier, I used a Battery, the Shunt resistor and a Variable load resistor. No PWM output there. No wonder it was 100% then. :facepalm:

    Now the question is, do I now filter the mV signal measured over the Shunt resistor to give a more uniform mV source to the OpAmp or will that have a knock on effect on accuracy of the mV signal measured?

    Schematic circuit attached.
     

    Attached Files:

  9. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,474
    Likes:
    191
    Location:
    Lancashire UK
    I would suggest connecting a capacitor in parallel with the feedback resistor. The value of the capacitor required will depend on the PWM frequency.

    Les.
     

Share This Page