Connect with us

How to measure DC precision Volt+Amp using microcontroller?

Discussion in 'Microcontrollers, Programming and IoT' started by Farukh Khan, Oct 14, 2018.

  1. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    Hello Guys,

    For my home automation project I am trying to implement a new feature to the setup. I want to measure the IoT system's dc voltages and currents at certain points accurately using arduino, raspberrypi or any other microcontroller. Not really sure how to proceed with this because I want to use these measurements for over voltage protection, over current protection, reverse voltage protection, lower current cut-off, lower voltage cut-off, short circuit protection, keep high precision measurement logs etc. So, basically I need very accurate and efficient measurements for the dc part to almost mV and uA for some particular sensors.

    I want to measure 3.3V from uA lvl to 25A max. Also, 5V for also uA to 25A max. and +12 for uA to 70A and -12V for uA to 3A.

    I don't want the measurement part to create any sort of interference with the source I am measuring or the signal I am using to measure on my microcontroller by any means.

    Should I use a totally separate microcontroller for the power measurement system and use I2C or any other fast standard communication method to feed the data to my main microcontroller? or perhaps to the raspberrypi? Or I can safely use the main microcontroller for also the power measurements. (the main microcontroller is taking measurements from the sensors and controlling the relay modules.)

    Do I need to use any type of opto-coupling?

    In youtube I saw a video of GreatScott who made a similar power logger using the INA219 module. But the results doesn't seem so accurate as it is fluctuating so much. Also the voltage and amps his system can measure doesn't fall under my requirements. Link to the video:


    Thanks.
     
  2. kellys_eye

    kellys_eye

    4,289
    1,143
    Jun 25, 2010
    Sounds like you're over thinking stuff (again!).

    Why the need for 25A - on the 3.3V line????? What on earth are you driving???

    12V at 70A?????? Do you know what size cable you'll need to take 70A to the load? If it is any distance from the source then the cable size gets to be 'ridiculous' and putting the source closer to the load is a far cheaper and easier solution.

    Measuring voltage levels at greater than <1% is a lot more difficult than at 5% and most (all) equipment will tolerate voltage variations of at least 5% and many up to 10% without problems.

    By over-designing stuff you open yourself to errors and problems that you don't need or want in construction, calibration and maintenance not to mention additional (unnecessary) cost.

    Time to sit back and work out - realistically - what your requirements are/will be.
     
    Arouse1973, Harald Kapp and davenn like this.
  3. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    @kellys_eye actually the ratings I gave you are for my power supply's rails. My power supply can able to output 12V 70A continuous and on the 3.3V rail 25A. Thats why at the beginning I was talking about buck convertors to boost down the overall amperage capacity to my equipments from the 24V rail, so that if any short circuit happens the buck convertor blows, not my important equipments.

    Anyway, trying to re-think the plan again. By the way, I was also planning to run some AIO computers and TV of my home using the same power supply. That's why I was considering amp and volt meters on the rails.
     
  4. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    and sorry for my mistake. on the previous post I said 24V 30A(mistake) power supply that I had. But it's actually a beefy power supply of 750W and can deliver different types of current on different rails. Sorry for the confusion.
     
  5. kellys_eye

    kellys_eye

    4,289
    1,143
    Jun 25, 2010
    Simple fuses can protect equipment. Equipment draws what it needs - no more or less.

    The PSU you suggest will provide all the supplies you need without any additional regulation. Local filtering will take care of noise and if you need to monitor voltage/current then fit the PSU in a PC that offers the supply line monitoring as part of it's BIOS/OS. You can tap the PSU output as required and use the PC for much of the controlling you want to do anyway.

    A micro sized Mobo with USB controlled peripherals would be far easy to implement, program and operate than all the individual stuff you seem stuck on!
     
  6. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    Dont have any pc with that kind of bios layig around at this moment. And for the controlling I was actually using raspberry pi. Is there any way to implement the line monitoring on the pi?

    What is a mobo btw?
     
  7. kellys_eye

    kellys_eye

    4,289
    1,143
    Jun 25, 2010
    mobo = motherboard.
     
  8. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    ow. cannot actually fit a PC in the project at this moment. Need to consider overall electricity cost with a PC running 24/7, overall heat etc. for now what solution you think is gonna do for volt+amp measurements with a raspberry pi as controller?
     
  9. kellys_eye

    kellys_eye

    4,289
    1,143
    Jun 25, 2010
    You're planning to run a 'Platimum PC power supply' - how much power will THAT consume? A micro-AT motherboard runs at under 50W, potentially much less at idle. If energy is a genuine concern you'd be looking to run most items at standby for most of their time so your intended monitoring current at 30A seems a bit in-congruent......

    You still seem to have no overall concept of what it is you want to achieve. Draft something on paper - a list of all devices you need, what it is you want to monitor/control, peripherals etc etc and determine what your actual NEED is. This constant to-ing and fro-ing of what you 'seem' to want and what you would 'like' to achieve is in conflict and doesn't help us offer any assistance in respect to answering any queries.
     
  10. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    A platinum grade SMPS if I use, might consume very less at idle for around ~25W just to keep everything up n idle. The power supply I currently have might also consume around that same ~30-35W on idle (Considering if my math is correct). I have very less to no experience of what type of mini ITX or micro-AT motherboard and stuff is out there. I will need some help in picking parts if I am really gonna do that.

    BTW, I am currently preparing a paper draft for the whole system and as soon as am finished I will try to post it out here, so that it becomes easier for you guys to help me out.


    Thank You.
     
  11. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    @kellys_eye need some help so that I can complete the drawing. I was thinking whether to use an UPS to power up the PSU and then using the PSU power up all the other things? If I follow this procedure then during the conversion will I loose any efficiency on the overall system? or the later solution will cost me more efficiency? Also, is there any recommendation of UPS module or circuitry that might be of high efficiency with gel cell batteries? Or perhaps an UPS brand? Also, I want to keep the longivity of the gel cell batteries as good as possible.

    Or use the PSU to power up a separate battery charge controller or balance charger and use a relay to switch from PSU to battery during an outage? But if I follow this step then, I have to use SMPS or buck convertors before every components anyway, because the batteries will be 12V usually. This approach seems rather complicated because more than one SMPS will be subjected to / prone to more overall noise levels and decreased efficiency.

    Which one of the above seems reasonable? Or any other solution you might think will be best fitted?
     
  12. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    On the picture one I have the basic +3.3V and +5V usage setup that I am planning. I have represented the volt meter and amp meter together as a power meter on the diagram. I have showed some measuring probes to the 3.3V and 5V output connections. But I would also like to measure the V and A or P in the same manner on all the devices connection wires also, to see in overall, a total line consumption + each device in the system consumption and feed all the data to raspberrypi for processing and do some acts upon the data if necessary. Also, I would like to get the volts(RMS), amps data from the PSU AC power line hot wire to monitor it's watt usage in the software through raspberry pi.

    On the picture 2 I have shoed the sensor box and whether or not I should decouple the power and couple the signals for more accurate results? is the question.

    On picture 3 I have showed the 12V part of my plan. The relay modules will be far away from the main power source and the control system. So, on the relay boards I already have low esr decoupling capacitors. Cannot add coupling film cap on the signal because the arduino will be sending digital 0 or 1 to the relay modules. BTW all the relay module signals go to the arduinos which are placed a but far way in the system box. Then I will add couple of Class D amplifiers in the 12V rail for home automation bot. The audio signal for these amplifiers will come from the raspberry pi stereo audio output jack (both raspberrypi and amplifier will be located in the same system box - only the speakers will go individually to each room). Also, I want to measure VA or PA in both the output rail of 12V 70A and the components connection to measure each components draw from 12V rail and the overall 12V rail draw for monitoring. The power meter sensor power will be coming from the 3.3V PDB.


    If the diagram isn't clear enough at certain parts feel free to ask me so that I can clarify. Don't mind my newbie diagram drawing and electronics approaches. Thank You.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      150.7 KB
      Views:
      3
    • 2.jpg
      2.jpg
      File size:
      129.2 KB
      Views:
      3
    • 3.jpg
      3.jpg
      File size:
      140.6 KB
      Views:
      3
  13. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    Also, I am not sure where to put the gel cell batteries in this system. Please suggest me on that part also. I am willing to do a three 12V 7AH Gel Cell Battery approach. And I want to use raspberry pi or the arduino to do some smart battery charging controls for the battery charger. Along, with some backup battery switching system.

    So, basically I want to use two of the 12V 7AH Gel Cell in parallel for 14AH backup capacity for the whole system. But when the system switches to the battery from the mains, raspberry pi will trigger some software based low power mode in the whole system. Also, raspberry pi will keep monitoring the safe battery discharge voltage all the time and if it falls below the recommended, the pi will try to safely shutdown everything in the system and afterwards shut down itself properly. And for the third battery, the raspi will command the charge controller to keep it in storage charge voltages for all the time. And when any of the two parallel batteries in use fails, the pi will detect the weird voltage and AH cycles and close that battery from the circuit and automatically take in the fresh storage battery in for the system. And probably sent an alert out that one of the battery has reached EOL.

    That's the overall plan with the battery system.
     
  14. kellys_eye

    kellys_eye

    4,289
    1,143
    Jun 25, 2010
    1. Yes, your diagram is awful!
    2. I can't see any parts of your system drawing more than 5A from any source - your use of a computer PSU is overkill.
    3. The INA**** type current monitoring range of devices will work for all the measurements you need.
    4. The system could be powered from a single 12V battery that is 'maintained' using the appropriate charging/supply circuit that would have automatic fail safe to the battery-only condition therefore removing the need for a UPS.
    5. What distance are you intending to run the serial signals? This will determine the protocol used as different forms of serial comms each have their limitations.
    6. You can't use 'high power' for LoRa - it's basic principle is 'Lo' and there are legal implications for exceeding power output.
    7. Simple 'brown out' detection is common for micro processor controlled devices and easily implemented for shut down or rebooting.
    8. Monitoring power consumption at the input is easily done using a current transformer if using an AC source.
     
    Farukh Khan likes this.
  15. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    @kellys_eye

    1. Again sorry for my bad drawing, I am very new to these block diagrams. Doing circuit schematics is the only thing I knew till now.

    2. Yes, you are right actually. But I forgot to mention something on the diagram. I am planning to hack into two Sony TV and one HP AIO computers which draw very low amount of overall wattage and connect those with the PSU 12V 70A rail. Just to get the most efficiency out of the PSU. By the way, the PSU will be in the system box. And the distance from the PSU to those two TV and one AIO PC is approximately ~3m each. The two tv under load max consumption would be 135W each and the PC max consumption under load would be around ~200W. If I connect them directly to the PSU unit then the overall consumption will get less because of the higher efficiency on the PSU unit compared to the stock PSU the tv and AIO PC comes with.

    3. Will the INAxxxx models be able to provide me somewhat accurate results? What about shunt resistor approach? Is that more accurate in any manner compared to the INA? What about efficiency on the INA vs shunt? And what type of measurement ranges I can get from the INA devices? will it be able to measure the output V and A on the computer and TV lines from the 12V 70A rail?

    4. Where do I fit this single 12V battery and it's circuitry on the diagram? and what type of battery specification are you proposing? and the dead battery fail over mechanism that I was hoping doesn't seem feasible to you? And by the way, I don't want to power the extra two TV and one AIO PC using batteries. Only the overall system battery backup is good enough excluding those high load tv and pc.

    5. Most of the sensors signals and the controller will be on the same system box. Only the relay signals will be around 3m - 5m apart depending on each room distances from the system box. Also, some temp and humidity sensors will be located in each room thus making them also 3m-5m distance apart from the system box. And for the amplifier, only the speakers and microphone wires will be individually on each room so those two devices will also be 3m-5m apart. That's all for the distant connections from the system box.

    6. I know I cannot use high power in LoRa natively, but can't I design a signal booster in the middle of the output signal and antenna to just increase the overall power of the circuit? Because I want to reach long distances with lora signal for only emergency control commands, because my wifi at home is crap most of the time. I think I will be well within law, while using 433MHz or 900MHz high powered devices in my area.

    7. Please can you explain a brown out detection and how it will help shutdown or reboot the system?

    8. I am actually using an AC source and AC to DC PSU unit. The AC source is 230VAC ~50Hz. Can you explain the current transformer system in a bit detail?


    Thank You.
     
  16. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    And btw, are my power decoupling with Low ESR caps on different PDB and devices an accurate approach? Or should I go for and LC filter or RLC perhaps? Or nothing?

    Do I need to do any type of reverse voltage protection on any of the PDB or devices? Note: the relay modules already have a coil reverse voltage protection using diode on each relay module.
     
  17. kellys_eye

    kellys_eye

    4,289
    1,143
    Jun 25, 2010
    Sorry, but my time is limited and I can't get involved in this project any deeper than I already have.

    If you come back with a proper and complete schematic - a decent block diagram will do - we could discuss the issues further. There are data sheets for any/all the devices you want to use that give all the specifications and means to control them. Google is also useful in finding out about things like 'brown out detection' etc.

    Any response that refers to such data sheets should have links attached.

    If I went any deeper in to this right now I'd be doing all 'your' work for you! Basically, until YOU know precisely what it is YOU want then we could bang these comments back and forth for ever!

    Please review what has already been discussed and do some more research - then ask about any specific issues that trouble you rather than attempting to discuss the 'whole' project as a single item.
     
    Farukh Khan likes this.
  18. Farukh Khan

    Farukh Khan

    123
    2
    Jun 12, 2015
    I got your point. So, let me state particular issues I am having rather than discussing the whole project at once.

    For now, the main issue I am trying to mitigate is to how to put the battery and it's circuitry on that block diagram provided. I already have a PSU providing me the necessary 12V, 5V and 3.3V rails. So, if I put a 12V in between these rails then I will have to step down the 12V using buck convertors to exactly the accurate rail voltages and also put some sort of reverse voltage and current protection on both end. That's why I was thinking about an UPS as the AC source of the PSU itself. Please if possible clarify this part.

    Thank You.
     
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.