Hello everyone. I'm new to Raspberry pi platform. I want to measure the current which is drawn by the CPU of my RPi 3 Model B V1.2.
Is there any option to measure the current which is drawn by the CPU when it runs any code, within the RPi hardware like a scope or oscilloscope that I can use directly?
Any suggestions would be helpful.
Regards,
Rajesh.
-
- Posts: 26
- Joined: Sun Oct 13, 2019 6:33 pm
- mahjongg
- Forum Moderator
- Posts: 13549
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Regarding the current measurement
Not really, as it would imply putting a small resistor in series with the wire transferring the current to the SoC, (and other parts comprising what you want to monitor) and measuring the voltage drop over it.
Meaning you would need to cut the connection somewhere between the power and the SoC, which is in practicality impossible to do.
Also, the SoC doesn't use power from one source either, so you have to do this multiple times, and add the energy consumptions together.
You could measure the energy flowing "into" the PI, but that energy is also distributed to other things not having to do with the SoC's current consumption, things like USB device, and current going to the HDMI 5V line.
Also, when the SoC uses external RAM, you must measure its consumption too, as its part of the PI's own current use. If you also count other chips on the board as part of the PI, then the puzzle gets even more complex.
Meaning you would need to cut the connection somewhere between the power and the SoC, which is in practicality impossible to do.
Also, the SoC doesn't use power from one source either, so you have to do this multiple times, and add the energy consumptions together.
You could measure the energy flowing "into" the PI, but that energy is also distributed to other things not having to do with the SoC's current consumption, things like USB device, and current going to the HDMI 5V line.
Also, when the SoC uses external RAM, you must measure its consumption too, as its part of the PI's own current use. If you also count other chips on the board as part of the PI, then the puzzle gets even more complex.
-
- Posts: 26
- Joined: Sun Oct 13, 2019 6:33 pm
Re: Regarding the current measurement
Yeah, and that's why I would like to know if there are any options to do it in software without risking the hardware (especially the CPU) with some code probably?
I need to measure the power being consumed by the SOC.
I need to measure the power being consumed by the SOC.
Re: Regarding the current measurement
There is no way to measure the SoC current consumption in software.
You will have to design and build your own solution using the methods outlined by mahjongg.
You will have to design and build your own solution using the methods outlined by mahjongg.
Re: Regarding the current measurement
If your goal is to measure the difference between running different code then just measure the board as a whole as long as you don't use extra stuff (like wifi, or additional usb devices etc) you'll get an accurate enough reading to approximate how much more current one code takes to execute compared to another.
If that's what your end goal was.
If not, then what are you doing that requires the current consumption of the SOC?
If that's what your end goal was.
If not, then what are you doing that requires the current consumption of the SOC?
55:55:44:44:4C
52:4C:52:42:41
Rose tinted glasses are difficult to see through.
52:4C:52:42:41
Rose tinted glasses are difficult to see through.
- mahjongg
- Forum Moderator
- Posts: 13549
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Regarding the current measurement
No!RajeshAnand10 wrote: ↑Sun Oct 13, 2019 7:29 pmYeah, and that's why I would like to know if there are any options to do it in software without risking the hardware (especially the CPU) with some code probably?
I need to measure the power being consumed by the SOC.
there is no hardware inside the SoC, to measure its own current consumption.
and as far as I know no such feature exist in the PMIC either (it has a digital interface to the SoC, so it would be theoretically possible for the voltage converter (PMIC) to signal current consumption to the SoC, if it had that feature) ignoring that AFAIK the SoC also uses 5V directly (bypassing the PMIC).
-
- Posts: 2782
- Joined: Tue Jan 19, 2016 2:17 pm
- Location: Sydney, Nova Scotia, Canada
Re: Regarding the current measurement
Wouldn't a round about way to do it be monitoring the CPU load?
-
- Posts: 2782
- Joined: Tue Jan 19, 2016 2:17 pm
- Location: Sydney, Nova Scotia, Canada
Re: Regarding the current measurement
There are devices like this, https://www.adafruit.com/product/2690 To measure total current drawn by the Pi. Might be a bit of a PITA getting the adapters for it though.
Re: Regarding the current measurement
Those things are no more accurate than a multimeter. You should use an oscilloscope, not a usb current meter.alphanumeric wrote: ↑Mon Oct 14, 2019 7:20 pmThere are devices like this, https://www.adafruit.com/product/2690 To measure total current drawn by the Pi. Might be a bit of a PITA getting the adapters for it though.
55:55:44:44:4C
52:4C:52:42:41
Rose tinted glasses are difficult to see through.
52:4C:52:42:41
Rose tinted glasses are difficult to see through.
- davidcoton
- Posts: 5655
- Joined: Mon Sep 01, 2014 2:37 pm
- Location: Cambridge, UK
- Contact: Website
Re: Regarding the current measurement
What makes you think that oscilloscopes are any more accurate than multimeters? Any instrument that produces repeatable results can be calibrated accurately.
There is also the minor problem that an oscilloscope by itself will not measure current, only voltage. Measuring current requires a voltage measurement across a known resistor -- which with most oscilloscopes requires a differential measurement using two channels, since one side of the 'scope probe is likely to be grounded.
Location: 345th cell on the right of the 210th row of L2 cache
Re: Regarding the current measurement
I'm only regurgitating what was told to me from this very forum, that a multimeter will average its readings, including transients.
If that information is incorrect then I will stop spreading it, but I would like to ask what I should believe.
If that information is incorrect then I will stop spreading it, but I would like to ask what I should believe.
55:55:44:44:4C
52:4C:52:42:41
Rose tinted glasses are difficult to see through.
52:4C:52:42:41
Rose tinted glasses are difficult to see through.
- davidcoton
- Posts: 5655
- Joined: Mon Sep 01, 2014 2:37 pm
- Location: Cambridge, UK
- Contact: Website
Re: Regarding the current measurement
Accuracy and resolution of short duration events are two different things. The multimeter will not respond to short duration peaks or dips (except in modifying the average reading), but a 'scope will show them (if you are skilful enough to capture transient events). If you are interested in average current draw, use a meter. If spikes or dips are an issue, you need a 'scope and the skill to use it properly.
Location: 345th cell on the right of the 210th row of L2 cache
-
- Posts: 26
- Joined: Sun Oct 13, 2019 6:33 pm
Re: Regarding the current measurement
Yeah, i need to know the changes in current for very short duration (micro seconds). I'm having a 12 bit ADC which i will use for fine resolution.
But is it fine if I use a small resistor (shunt resistor of 1 ohm) in series to the RPi and take the voltage signal across the shunt and measure current indirectly?
But is it fine if I use a small resistor (shunt resistor of 1 ohm) in series to the RPi and take the voltage signal across the shunt and measure current indirectly?
Re: Regarding the current measurement
1 Ohm is not small when it comes to measuring currents of 2-3 Amps. You could lose up to 3V across that resistor on a fully loaded Pi 4B with a USB disk.RajeshAnand10 wrote: ↑Thu Oct 17, 2019 3:42 pmYeah, i need to know the changes in current for very short duration (micro seconds). I'm having a 12 bit ADC which i will use for fine resolution.
But is it fine if I use a small resistor (shunt resistor of 1 ohm) in series to the RPi and take the voltage signal across the shunt and measure current indirectly?
0.01 Ohm might be better. The voltage across the shunt must be as low as possible otherwise the Pi won'r get enough.
Unreadable squiggle
-
- Posts: 26
- Joined: Sun Oct 13, 2019 6:33 pm
Re: Regarding the current measurement
Maximum current which the RPi 3B will be drawing is 2.5A ( After which the fuse blows off), So the Maximum voltage drop I can expect is 0.5V. in the shunt resistor.rpdom wrote:1 Ohm is not small when it comes to measuring currents of 2-3 Amps. You could lose up to 3V across that resistor on a fully loaded Pi 4B with a USB disk.RajeshAnand10 wrote: ↑Thu Oct 17, 2019 3:42 pmYeah, i need to know the changes in current for very short duration (micro seconds). I'm having a 12 bit ADC which i will use for fine resolution.
But is it fine if I use a small resistor (shunt resistor of 1 ohm) in series to the RPi and take the voltage signal across the shunt and measure current indirectly?
0.01 Ohm might be better. The voltage across the shunt must be as low as possible otherwise the Pi won'r get enough.
How could I give supply to the RPi from the resistor network as I will be using micro USB to power RPi and physical wires for power supply to the Shunt resistor? Any provisions are available to connect RPi through the physical wires? (as i have read somewhere powering the RPi using GPIO but it seems to be complex and risky)
Re: Regarding the current measurement
Even 2.5A through a 1 Ohm resistor will drop 2.5V!RajeshAnand10 wrote: ↑Thu Oct 17, 2019 5:32 pmMaximum current which the RPi 3B will be drawing is 2.5A ( After which the fuse blows off), So the Maximum voltage drop I can expect is 0.5V. in the shunt resistor.
Although even if the voltage drop was 0.5V that would drop the 5V to 4.5V which is well under the level required for a Pi to run stable.
You can feed the Pi through the GPIO connector (Pins 2 or 4 and pin 6, for example). It is not that risky of you make sure you connect it right.
Unreadable squiggle
Re: Regarding the current measurement
AFAIK the Pi SoC runs from an onboard switch-mode converter that drops the +5V power input down to what the processor needs (maybe it is 1.8V and 3.3V? I don't know). If you want current consumption on a microsecond timescale, I'm not sure what you can see from measuring the +5V input current due to the DC-DC converter and all the filter capacitance between you and the actual internal SoC load. The capacitors tend to smooth out the fast voltage changes on a microsecond, and perhaps even millisecond timescale.RajeshAnand10 wrote: ↑Thu Oct 17, 2019 3:42 pmYeah, i need to know the changes in current for very short duration (micro seconds).
-
- Posts: 26
- Joined: Sun Oct 13, 2019 6:33 pm
Re: Regarding the current measurement
In that case, where the SOC requires higher current to process the load, there will be an increase in current from the main +5v supply right?jbeale wrote: ↑Thu Oct 17, 2019 9:01 pmAFAIK the Pi SoC runs from an onboard switch-mode converter that drops the +5V power input down to what the processor needs (maybe it is 1.8V and 3.3V? I don't know). If you want current consumption on a microsecond timescale, I'm not sure what you can see from measuring the +5V input current due to the DC-DC converter and all the filter capacitance between you and the actual internal SoC load. The capacitors tend to smooth out the fast voltage changes on a microsecond, and perhaps even millisecond timescale.RajeshAnand10 wrote: ↑Thu Oct 17, 2019 3:42 pmYeah, i need to know the changes in current for very short duration (micro seconds).
-
- Posts: 26
- Joined: Sun Oct 13, 2019 6:33 pm
Re: Regarding the current measurement
Yes Yes. I forgot to mention the resistor which I'm planning to use ( 0.2 ohms with 5 Nos 1-ohm resistors in parallel configuration).rpdom wrote: ↑Thu Oct 17, 2019 8:09 pmEven 2.5A through a 1 Ohm resistor will drop 2.5V!RajeshAnand10 wrote: ↑Thu Oct 17, 2019 5:32 pmMaximum current which the RPi 3B will be drawing is 2.5A ( After which the fuse blows off), So the Maximum voltage drop I can expect is 0.5V. in the shunt resistor.
Although even if the voltage drop was 0.5V that would drop the 5V to 4.5V which is well under the level required for a Pi to run stable.
You can feed the Pi through the GPIO connector (Pins 2 or 4 and pin 6, for example). It is not that risky if you to make sure you connect it right.
Actually, in my case I have Unipi connected to RPi and Unipi is currently providing power for the operation of RPi (GPIO pins are currently locked to provide power to RPi). If I want to power RPi independently through MicroUSB (assuming I give power separately to Unipi and RPi), Is there any way to modify the MicroUSB where I can provide a shunt resistor for power calculations?
- Burngate
- Posts: 6401
- Joined: Thu Sep 29, 2011 4:34 pm
- Location: Berkshire UK Tralfamadore
- Contact: Website
Re: Regarding the current measurement
Yes, eventually.RajeshAnand10 wrote: ↑Thu Oct 17, 2019 11:22 pmIn that case, where the SOC requires higher current to process the load, there will be an increase in current from the main +5v supply right?
At the 5v input, just after the ideal diode, there's a 47μF capacitor.
A resistor of 0.2Ω in series with the 5v input together with the 47μF capacitor forms a low-pass filter with a turnover at about 10μS. So you're unlikely to see much change at the μS scale.
The 5v then feeds the PAM2306A converter, which runs at 1.5Mhz, so any increase in current drawn by the 3v3 & 1v8 rails can take a further 0.66μS to propagate back to its input.
Re: Regarding the current measurement
It might be possible to fit a 10ohm resistor
In series with the main 5v in/put lead to the
Pi, then using a multimeter to read the voltage
Drop. Then using the difference between the readings to calculate the current when the code
Is active. Might be worth a try use a high wattage
Resistor
Regards BoyOh
In series with the main 5v in/put lead to the
Pi, then using a multimeter to read the voltage
Drop. Then using the difference between the readings to calculate the current when the code
Is active. Might be worth a try use a high wattage
Resistor
Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong
Some Times Right Some Times Wrong
Re: Regarding the current measurement
Measuring the voltage drop across a current shunt is the plan already. However, a 10 ohm resistor is going to cause such a large voltage drop that the Pi won't boot. Even a 1 ohm resistor is too high.boyoh wrote: ↑Sat Oct 19, 2019 10:41 pmIt might be possible to fit a 10ohm resistor
In series with the main 5v in/put lead to the
Pi, then using a multimeter to read the voltage
Drop. Then using the difference between the readings to calculate the current when the code
Is active. Might be worth a try use a high wattage
Resistor
Regards BoyOh
-
- Posts: 26
- Joined: Sun Oct 13, 2019 6:33 pm
Re: Regarding the current measurement
I guess. How about I add resistors in parallel and reduce the effective resistance close to 0.2 ohms? will that be good enough to have a low voltage drop and will it be safe enough for the DAQ card which im using? since max current, I can expect from load is 1.5A (at the worst case) and 0.2ohms corresponds to 0.3V approximately.trejan wrote: ↑Sat Oct 19, 2019 10:54 pmMeasuring the voltage drop across a current shunt is the plan already. However, a 10-ohm resistor is going to cause such a large voltage drop that the Pi won't boot. Even a 1 ohm resistor is too high.boyoh wrote: ↑Sat Oct 19, 2019 10:41 pmIt might be possible to fit a 10ohm resistor
In series with the main 5v in/put lead to the
Pi, then using a multimeter to read the voltage
Drop. Then using the difference between the readings to calculate the current when the code
Is active. Might be worth a try using a high wattage
Resistor
Regards BoyOh
Re: Regarding the current measurement
0.2 ohms is still high for this situation. The under voltage lightning bolt warning comes on at ~4.6V so a 0.3V drop is going to cause problems. If you're passing 1.5A then those resistors will be dissipating 450mW.RajeshAnand10 wrote: ↑Sun Oct 20, 2019 2:23 pmHow about I add resistors in parallel and reduce the effective resistance close to 0.2 ohms? will that be good enough to have a low voltage drop and will it be safe enough for the DAQ card which im using? since max current, I can expect from load is 1.5A (at the worst case) and 0.2ohms corresponds to 0.3V approximately.