how to measure dc current through device

Travm

Joined Aug 16, 2016
363
This is block diagram only.

I want to measure DC current through load and load is connected at output of mobile charger

output of ADC goes to pi and Pi GPIO runs at 3V3 so I need to run mcp3008 at 3 v DC

View attachment 159472

Edit mcp3208 used just for connection originally I am using mcp3008
Vref and agnd need connected I'm sure. This is not a complete circuit diagram.
Where is the 3v3 coming from?
Many more questions....
 

Thread Starter

Fanfire174

Joined Mar 13, 2018
240
You have R2 & R3 as a divider and I see no reason for R1? So Vout of the ACS712 will be Vout/2. That means the 2.5 volt offset will be 1.25 volts plus whatever it is measuring at .066 volt/amp. You are not showing what you are using for Vref on your A/D converter pin 15? I also assume everything labeled Ground is ground? You also are not showing what VDD is on your A/D converter?

Ron
This is wiring connection

MCP3008 VDD to Raspberry Pi 3.3V
MCP3008 VREF to Raspberry Pi 3.3V
MCP3008 AGND to Raspberry Pi GND
MCP3008 DGND to Raspberry Pi GND
MCP3008 CLK to Raspberry Pi SCLK
MCP3008 DOUT to Raspberry Pi MISO
MCP3008 DIN to Raspberry Pi MOSI
MCP3008 CS/SHDN to Raspberry Pi CE0

https://myelectronicslab.com/raspberry-pi-3-gpio-model-b-block-pinout/
 

Travm

Joined Aug 16, 2016
363
This is wiring between pi and mcp3008
View attachment 159476
Almost there,
Now put everything on 1 (one) diagram so I can read it without clicking all over the internet or drawing it for you.
I dont think you have this connected properly. VREF should be +5v, and ideally a precision reference. Connecting AGND and DGND side by each is also not a very good idea.
 

Reloadron

Joined Jan 15, 2015
7,892
I dont think you have this connected properly. VREF should be +5v, and ideally a precision reference.
The chips VDD Single supply operation: 2.7V - 5.5V and the Vref can be the 3.3 volts he is using. I agree Vref should be stable. Personally I would have powered the Raspberry pi with 5 volts, the A/D with 5 volts including the A/D reference and the current transducer with 5 volts. I have no clue why the thread starter is using mixed voltages other than this was cobbled together using pieces and parts found online. This is why he is coming off the current transducer into a voltage divider.

Ron
 

Reloadron

Joined Jan 15, 2015
7,892
You can do it the way you did, there are several ways to go about it. I would have done it differently but here nor there. When you post a full drawing try and post your code. I don't know why you are reading just a single number. If you have a multi-meter you could check the analog out of the current sensor and see if that varies. That is where I would likely start.

Ron
 

Reloadron

Joined Jan 15, 2015
7,892
MCP3008 both grounds should be connected to your ACS712 ground. When you measure the junction of the two divider resistors to ground you should see a changing analog voltage as the current changes. Finally your code should be setting up your MCP3008 input channels as single ended or differential, you want a single ended input. That is all part of the code and if it's written in Python we need someone good with Python and that is not me.

Ron
 

Thread Starter

Fanfire174

Joined Mar 13, 2018
240
MCP3008 both grounds should be connected to your ACS712 ground. When you measure the junction of the two divider resistors to ground you should see a changing analog voltage as the current changes. Finally your code should be setting up your MCP3008 input channels as single ended or differential, you want a single ended input. That is all part of the code and if it's written in Python we need someone good with Python and that is not me.

Ron
I measured output voltage of acs712 without divider it gives 2.v which is half of vcc 5v Dc

When I measured output voltage of acs712 with divider it gives 2.5v I think this is wrong

upload_2018-9-8_9-5-50.png
 

Thread Starter

Fanfire174

Joined Mar 13, 2018
240
What is the purpose of the divider?
Connecting your ACS output to ground like that doesnt seem right.
I saw the blog they are using divider to protect input of ADC

I am measuring output of acs sensor with multimeter. input voltage is 5v DC.

If there is no load sensor give output 2.5 volt and If I connect 10 K load it gives 2.5 v at the output of acs.

I have doubt with second reading it doesnt seem right. I think if i connect load the output voltage of ACS should be change but It doesn't happen in my case I have been check with 15k , 2.5 k load it always show 2.5 v at output of ACS

upload_2018-9-8_17-54-42.png
 

Travm

Joined Aug 16, 2016
363
With a 2.5 k load current is very close to 0. You need a load that draws some amps. Especially if you have it set to measure 30-30A. Just plugging signal resistors in isn't going to do anything.
 

Travm

Joined Aug 16, 2016
363
The scale factor is 66mv per amp. So you would need a 1amp load to make your voltage reading be 2.566. if your not using a precision reference, and a cheap multimeter on a noisy PCB (or don't say breadboard) this much voltage could easily be error.
Get a real load and hook it up.
I wouldn't necessarily use a voltage divider on the ADC unless it's specified in the ADC data sheet. It will just complicate your math and intriduce more error.
 

Thread Starter

Fanfire174

Joined Mar 13, 2018
240
I wouldn't necessarily use a voltage divider on the ADC unless it's specified in the ADC data sheet. It will just complicate your math and intriduce more error.
okay what should be correct value of voltage current and adc value for this with load and without load
upload_2018-9-8_18-50-21.png
 

Thread Starter

Fanfire174

Joined Mar 13, 2018
240
whats the load?

You read the data sheet right?
as per my knowledge the voltage at the output of acs712 would be different not should 2.v DC with load

I am sure if i connect any load the output voltage of acs712 would be change that's what I want to see

For the experiment What should the value of load if i take 5v power from PI
 
Last edited:

Reloadron

Joined Jan 15, 2015
7,892
What is the purpose of the divider?
Connecting your ACS output to ground like that doesnt seem right.
Here's what is going on. The ACS712 is powered by 5.0 Volts. The ACS712 has a few versions and in this case it is an ACS712ELCTR-30A-T which is the 30 Amp version. The optimized Accuracy Range is -30 to 30 Amps. The chip is designed to measure both AC and DC current. Keep in mind the chip operates off a single supply. To make this work the chip uses an output offset Zero Current Output Voltage = Vcc * 0.5 or with a Vcc of 5 Volts the offset is 2.5 VDC. This is done so when measuring AC above and below zero the chip can output. So there is always that 2.5 Volt DC offset. The sensitivity of the ACS712 with the 30 Amp version is 0.066 Volt / Amp. So you get 30 * .066 = 1.98 Volts. Therefore -30 Amps would be 2.5 Volt Offset - 1.98 Volts = 0.52 Volts and 30 Amps would be 2.5 Volt Offset + 1.98 Volts = 4.48 Volts. So -30 to 30 Amps will give an output of 0.52 Volts to 4.48 Volts.

The problem at this point becomes using the MCP3008 A/D converter. Single supply operation can be: 2.7V - 5.5V and running the Chip on 3.3 volts both Vcc and Vref the max input to the chip is 3.3 Volts and since it is a 10 bit (2^10) Analog to Digital converter with an input of 0 to 3.3 volts the output will be 0 to 1023 bits. That gives 1024 quantization levels. The problem is the ACS712 output under normal -30 to 30 Amp conditions would be 0.52 Volt to 4.48 Volts with the latter exceeding the now maximum 3.3 Volt level of the A/D converter. So what they have done is placed a 2:1 voltage divider at the output of the ACS712 current transducer. This gives us the output * 0.5 or Output/2 which gets us an out range of 0.52/2 = 0.26 Volts and on the high end 4.48/2 = 2.24 Volts within the range of the MCP3008 A/D converter when using Vcc = 3.3 Volts and Vref = 3.3 Volts. The MCP3008 can use a Vcc = 5.0 Volts and can have a Vref = 5.0 Volts and I would run it that way. However if we run it on 3.3 Volts with a 3.3 Volt Vref using the 2:1 divider at its input that should work also.

Now the 2.5 VDC offset of the ACS712 becomes 1.25 Volts. With the MCP3008 0 to 3.3 volts is 0 to 1024 bits.From this point on it is a matter of the code. Again, I would have run the ACS712 on 5.0 Volts and the MCP3008 on 5.0 Volts, both Vref and Vcc. I also would have used an Arduino which has native analog inputs but here nor there.

While I don't know what your actual load is as the load changes the ACS712 output should change proportionally. With no load and nothing on the output, no divider you should be seeing 2.5 VDC between Vout and Ground of the ACS712.

I mentioned earlier your code needs to address the MCP3008 as to some setup data and which channel(s) you want to use. That is all covered in the MCP3008 data sheet.

Ron
 
Top