Connect with us

Monitor Circuit for MicroController

Discussion in 'Microcontrollers, Programming and IoT' started by Morgan881, Apr 27, 2015.

Scroll to continue with content
  1. Morgan881

    Morgan881

    11
    0
    Apr 27, 2015
    Hi everyone, thanks for reading this. I've just started putting basic circuits together and am trying to move onto something a little more advanced. In this circuit I'm trying to monitor several things. Essentially I want to make a battery powered device that can monitor the output voltage, current and load resistance of a power module using a microcontroller (probably an ATMEL/ATMEGA) . If possible could you guys take a look at it and let me know about problems/errors I've made, component selection etc.. ?

    Many thanks
    M


    [​IMG]



    BATT+ and BATT- are 2 x Li-Ion cells in series
    VOUT is the output from a 20A variable power module that can output from 0.6V to 6.6V
    VSENSE goes to a 10 bit 3.3V ADC so a divider is used to bring the maximum 8.4V supply voltage down to 3.3V and is used to detect the battery level.
    OSENSE goes to a 10 bit 3.3V ADC so a divider is used to bring the maximum 6.6V output down to 3.3V and is used to detect the output voltage.
    ISENSE goes to a 10 bit 3.3V ADC and is used to detect the voltage across the load. The opamp amplifies the difference between the VOUT and the voltage after the shunt by a factor of 11. The output is then put through a divider to bring it down to the 3.3V ADC tolerance.
    RLOAD is a removable and replaceable load that can vary from 0.2 ohms to 5 ohms although I'm never going to use anything much lower than 1 ohm.

    The microcontroller can then use the following to work out the data (some degree of calibration will be required to fine tune)

    VOUT = OSENSE / 155.2 (Output voltage of module)
    BATT = VSENSE / 121.9 (Battery level)
    ASHUNTV = ISENSE / 155.2 (Amplified voltage drop)
    SHUNTV = (VOUT - ASHUNTV) / 11 (Voltage across the shunt)
    IOUT = SHUNTV / 0.01 (Output current)
    RLOAD = (VOUT-SHUNTV) / IOUT (Resistance of RLOAD)
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,662
    2,697
    Nov 17, 2011
    Welcome to electronicspoint.

    Your image is not showing. Try to upload it to the forum using the "Upload a file" button at the bottom right.
     
  3. Morgan881

    Morgan881

    11
    0
    Apr 27, 2015
    Hi Harald, thanks for the welcome, it's nice to be here.

    Sorry about the image, it is showing for me so I didn't realise others couldn't see it, must be some weird postimg geographical thing. I couldn't edit the original post so I've uploaded it on this reply. I've also done an LTSPICE simulation although I had to use a different opamp, it seems to behave itself in the simulation, but that's a world away from real life I know. The sub circuit on the bottom left of the LTSPICE image is a representation of the power module, it has no actual purpose in the image, it was just there so I could test out biasing of the feedback resistor so I can use a PWM output from the microcontroller to adjust the power module's output voltage.

    Cheers,
    M

    circuit2.jpg

    circuit1.jpg
     
    Last edited: Apr 28, 2015
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    11,662
    2,697
    Nov 17, 2011
    I don't think this circuit can work:
    The "+" input of the opamp (IC1) is connected to the low side of the currrent sense resistor "Shunt". When current flows, this input will be lower than the "-" input. This will drive the output of the opamp negative. Here's an article on high side current monitoring which may help you to set up the measurement correctly.
     
    Morgan881 likes this.
  5. Morgan881

    Morgan881

    11
    0
    Apr 27, 2015
    Hmmm the way I saw it in my head was to start the output of the ap-amp at 0v in which case the 0v output would pull the inverting input down making it lower than the non inverting input, this causes the output to rise which in turn causes the inverting input to rise until it matches the non inverting input at which point the output should be an negatively amplified difference in the voltage drop. Similarly if I start the output high, this pulls the inverting inpput higher than the non inverting input causing the output to fall until the inputs matched. It seems to work in several simulators but maybe I need to re-think how op-amps work, I'll check out the link you supplied. Thanks.
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    11,662
    2,697
    Nov 17, 2011
    Your thinking is not entirely wrong. However, you're using the opamp "backwards": the potential at the upper end of the shunt is the fixed reference (although it varies with supply voltage, but it doesn't vary with current). You sense the potential at the lower end of the shunt, which varies with current. But your amplifier is set up as an inverting amplifier, amplifying the voltage at the negative terminal.

    To monitor the current irrespective of the supply voltage, you need to use a differential amplifier. That's what a high side current monitor does.
     
    Morgan881 likes this.
  7. Morgan881

    Morgan881

    11
    0
    Apr 27, 2015
    Right, I can see from the link you gave me what you mean. I just thought seeing as the device has to sense VOUT as part of its operation, I may as well use that reading to facilitate the current sensing and allow me to use a multiple op-amp (say a quad) to do the entire job. Using a microcontroller makes me lazy :) This is my first venture into current sensing so naturally I'm a little green. I'd have used the simpler low side sensing if the load wasn't chassis earthed, but it is unfortunately,. Thanks for the help.
     
    Last edited: Apr 28, 2015
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    11,662
    2,697
    Nov 17, 2011
    Here's a short simulation of mine:
    [​IMG]
     

    Attached Files:

    Morgan881 likes this.
  9. Morgan881

    Morgan881

    11
    0
    Apr 27, 2015
    Let me see if I can dry run that circuit in my head so I understand what's going on. The NII gets 10/11 of the supply voltage, so that sets the NII at a constant 10.9 (ish) volts. If the output starts at 0V this pulls the II lower than the NII and the output rises enough to make the inputs match, at which point the output voltage represents the current.

    EDIT: Yes, I've built a similar circuit to yours in LTSPICE except I've increased the output to 200mV:1A instead of 100mV:1A to increase the detection resolution a little and it is a far better solution than what I came up with. That's perfect Harald, thank you very much. You can mark this as [SOLVED] if you do that here :)
     
    Last edited: Apr 28, 2015
  10. Harald Kapp

    Harald Kapp Moderator Moderator

    11,662
    2,697
    Nov 17, 2011
    Glad I could help.
    We do not mark threads as solved.
     
  11. Morgan881

    Morgan881

    11
    0
    Apr 27, 2015
    Are my maths correct here ?

    VOUT is sensed through a 1:1 voltage divider to a 10 bit 3.3V ADC ( A0 ) so the reading I get will be 0-1023 giving me a 0-6.6V sensing ability, so dividing the reading by 155.15 will give me VOUT.'s voltage call this Vout
    The output from the diff-amp goes to ( A1 ) and is 200mV per amp giving me a detectable maximum of 16.5A so dividing the reading by 62.06 will give me the amperage, call this Iout
    The voltage across the shunt will be Iout * 0.01 , call this Vshunt
    The voltage across the load will be Vout - Vshunt call this Vload
    The resistance of the load will be Vload / Iout call this Rload

    Dry running.
    I get a reading of 590 at A0 which gives me 3.8V for Vout
    I get a reading of 193 at A1 which gives me 3.11 for Iout
    3.11 * 0.01 = 0.0311V for Vshunt
    Vout - Vshunt
    = 3.7689V for Vload
    Vload / Iout
    = 1.21Ω for Rload

    I'm prototyping this up now, kinda exciting :)
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-