Page 1 of 1
Measuring Voltage
Posted: Fri Nov 24, 2017 5:14 pm
by sorrytoask
Hello,
Please correct me if this is the wrong Forum for my problem.
I would like to ask how you would realize a simple DC Voltage measurement on a 48V DC line on a Rpi3.
I am currently finishing my masters in renewable energies at university in germany ( I am german so please excuse if my english isn't perfect).
I can program python and have basic understanding of electronics.
Unfortunately my electronics knowledge is really only basic.
In the end the project is a bit more complex but it would help me alot if I do it step by step with learning the basics first.
So let's assume I have an externally powered RPi3 and want to measure 48V DC on my power line.
How could I do that?
Thanks alot
Johannes
Re: Measuring Voltage
Posted: Fri Nov 24, 2017 8:26 pm
by OutoftheBOTS
OK to measure an analog voltage on a RPi you will need a ADC (analog to digital converter). There are many around I tend to use the ADS1115 myself and it has a programmable gain (programmable voltage level to detect) off memory the largest gain is for detecting voltages between 0 and 6v. So if you want to read voltages around 48v you will need to first use a voltage divider to reduce it down to within the 0 to 6v range of using the ADS1115.
Re: Measuring Voltage
Posted: Sat Nov 25, 2017 9:09 pm
by sorrytoask
So if I assume the Resistance of my Load that uses the 48V with 1000Ohm and I want to reduce the voltage to 4V.
Could i just put a 77Ohm Resistance in series to the load?
I calculated it with U_reduced/U_total = R_divider/R_total
with U_reduced= 4V
U_total = 48V
R_total = 1000Ohm + R_divider
R_divider = ?
so if i could use this basic equation R_divider would be 77Ohm.
I would then connect an ADC converter to + and - of the R_divider and would then get a digital signal which i could readout with the rpi.
Is that correct?
Re: Measuring Voltage
Posted: Sat Nov 25, 2017 10:46 pm
by pcmanbob
This is how I would wire a potential divider circuit assuming the 48v circuit with the motor represents your existing circuit.
resistor values chosen to give 4.8V at ADC input when input voltage is 48V, assuming ADC can measure up to 5v.
Resistor R1 is shown as a variable resistor to enable calibration of voltage as resistors are never exactly the value they are marked as, all grounds are commend together.
Re: Measuring Voltage
Posted: Sun Nov 26, 2017 4:42 am
by rpdom
The problem with that diagram is if the variable resistor is turned right up, the full 48V would be fed to the ADC. I'd use an 82K resistor, then a 10K pot (potentiometer = variable resistor) in series. The 10K can then be tweaked to give the correct maximum voltage, while the 82K resistor will prevent the maximum voltage going too high (5.2V when turned right up, 4.7V turned right down).
Re: Measuring Voltage
Posted: Sun Nov 26, 2017 9:48 pm
by OutoftheBOTS
Although it is cool to have a hardware calibration pot, it is not necessary and I would just use fixed resistors and calibrate in software, it will need to be scaled in software anyway even if you have a hardware pot.
The ADC will give a 16bit value of a scale of the voltage between 0 and vref (6v) then you need to scale what this means for your 48v source.
Although you can do the maths and work out what the scale factor should be you will find that the resistors have a certain amount of error (buy a 80k resistor but it only have 75k resistance) especially if you buy cheap ones and this error will cause the scaling to need to be slightly different. What I would do is hook it up and put a multimeter on the source and read the real voltage and then work out how much the number from the ADC needs to be scaled to correspond to the real voltage
Re: Measuring Voltage
Posted: Sun Nov 26, 2017 10:22 pm
by sorrytoask
Why 82K Ohm?
Re: Measuring Voltage
Posted: Mon Nov 27, 2017 1:20 am
by pcmanbob
82K + 10K pot = 92K which gives you just over the required resistance for R1 in my diagram, gives you a possible safe Max/min voltage for input to the ADC.
Always best to have some hard ware calibration to make sure you don't exceed the max input voltage to the ADC audit go can get 48v to equal 4.8v input in to ADC it makes scaling simple.