|Measuring Power Consumption||Etienne Le Sueur||4/26/09 11:33 PM|
Does anyone have any linux code which can use the ADC's on the TWL4030
|Re: Measuring Power Consumption||horse_dung||5/20/09 12:58 PM|
I've been looking at the exact same thing - I've not quite got the
solution working yet - but I'm pretty close... Here's my summary...
If anyone can spot any mistakes in the calculations, or knows why all
my ADCINs are reading 0 then please please please comment...!!!
First lets look at the electronics. In the Rev. C boards there is a
resistor (R6) which can be used to measure the BeagleBoard's current.
R6 is 0.1 ohms which means the current going through it is 10 times
the voltage drop across it. Either side of R6 is connected (using a
resistor bridge) to the TWL4030's ADCIN3 and ADCIN5 pins. The
resistor bridge is a 10K/12K bridge which means approx. 46% of the
real voltage is seen by the TWL4030. The TWL4030's ADC is 10-bit
which means 1024 distinct values from 0V to 2.5V. The TWL4030 is
connected via an I2C bus to the OMAP CPU and the Multichannel ADC
(MADC) component of the TWL4030 uses I2C device 0x4a.
Okay, next step some mathematics. If "x" is the difference in the
values measured by the ADC, then the voltage difference at the ADC
input is: x*2.5/1024. Taking into account the resistor bridge, the
real voltage across R6 is x*2.5/1024*(10+12)/10, which when simplified
becomes x*11/2048. So, the current usage is x*110/2048 which
simplifies down to x*55/1024. Okay, we've got the formula we need to
use on the ADC input values as seen by the software.
Now a little note on accuracy. I haven't looked up the accuracy of
the resistors or the ADC's accuracy but these too will have an
impact. A change in value of x by just 1 equates to a current change
of around 54mA. So the accuracy of the current drawn is going to be
approximate...! If the TWL's MADC is anything like others I've used
then they tend to fluctuate/jitter quite a lot - so a nice idea to
measure the board's current usage might end up being effectively
Okay, enough already, onto the linux code. There is already fairly
comprehensive support for the TWL4030 in the linux kernel. There is
even a module (twl4030-madc.ko) that provides an interface for the
MADC functionality. However, I've not been having much luck it. I
added some printk() debug statements to drivers/i2c/chips/twl4030-
madc.c and the init function twl4030_madc_init() is being called, but
the driver's probe function twl4030_madc_driver() is not being
called...?! That said, the module has a lot of code in it that shows
how to use the twl4030-core module's function to perform the I2C
communication and talk to the MADC. Being somewhat impatient, I just
knocked up my own kernel module... :)
Now, my module fails to get any useful values from any of the ADCIN
pins... everything works, but all the ADCIN come back as zero. Since
R6 is pretty much at supply voltage I would have expected values at or
near 1024 for both ADCIN3 and ADCIN5... :(
You don't have to code I2C communications in the kernel (although for
complex devices its probably a good idea) - so I installed i2c-tools
and started poking the TWL4030 from userland. Again, I can't seem to
get anything useful back from the MADC other than zeros. I've got the
TWL4030 datasheet/manual, so I'm going to take a read of that later
on... I will post back here if, no WHEN, I get it working :)
|Re: Measuring Power Consumption||horse_dung||5/26/09 8:13 AM|
I've got a lot further now and I'm getting proper readings from the
ADC... My problem before was that I wasn't setting the SEL_MADC_MCPC
bit of the CARKIT_ANA_CTRL register so the ADCIN3 through 6 pins
weren't connected anywhere useful. From the U-Boot command you can
issue the following commands and from a booted linux if you have "i2c-
tools" installed there are equivalent i2cget and i2cset commands:
# turn on MADC and connect the ADC pins...
imw 0x4a 0x00 0x01 1
imw 0x48 0xbb 0x08 1
# set which ADCs to read/average
imw 0x4a 0x06 0x28 1
imw 0x4a 0x07 0x00 1
imw 0x4a 0x08 0x28 1
imw 0x4a 0x09 0x00 1
# start read and get results
imw 0x4a 0x12 0x20 1
imd 0x4a 0x3d 2
imd 0x4a 0x41 2
To convert the output to the ADC value divide the first number by 64
and add on the second number multiplied by 4. So, if the imd command
produced "0047: c0 b2" as the output then the ADC value would be
192/64 + 178*4 = 715.
As I originally feared, the accuracy is pretty poor and compared to a
volt-meter across J2 it is around +/- 75mA.
Now here's a surprise...! ADCIN5 is connected to the output of the
TPS2141 chip (which manages the power from the USB-OTG port and the DC
plug). The voltage out from the TPS2141 chip drops off as the current
drawn increases and this can be measured by ADCIN5 alone. However,
the real surprise is that this method proved to be more accurate than
using the difference between ADCIN5 and ADCIN3 giving an accuracy of
around +/- 25mA.
Finally, for my project I actually need to know the current drawn by
the USB devices attached to the non-OTG port. ADCIN8 on the TWL4030's
MADC provides a measurement of VBUS which again drops out as the
current drawn increases and so can be used to measure the load.
(Note: ADCIN8 is an internal connection within the TWL4030 and there
is no need to set the pinmux before reading ADCIN8. Also, the
measured range for ADCIN8 is 0-7volts)
My results (download PDF here: http://rapidshare.com/files/237452999/results.pdf)
are consistent although I haven't yet tried a different power supply
(or indeed a number of them yet). Anyone out there want to try these
tests to see if they get similar results...? If so, let me know.
|Re: [beagleboard] Re: Measuring Power Consumption||Gerald Coley||5/26/09 4:13 PM|
The accuracy is not that great because of three reasons.
1) The C2 uses 5% resistors. On rev C3 we changed to 1% resistors.
2) The current is constantly changing which causes the voltage across the resistors to change making for a delta from when you read the first ADC and then the second. The current is calculated on the delta of those two voltages. In affect the current you are measuring is affected by the code you are running.
3) The voltage delta is very small. If we made the resistor larger, it would in affect be easier to read the voltage drop across the resistor, but the voltage drop would be greater causing a lower voltage to be presented to the system.
|Fwd: Measuring Power Consumption||Quist||10/5/09 11:57 AM|
After reading the post by horse_dung it got me thinking of a way to
increase the precision of the current reading. I looked at different
high-side current measure ICs and then I ordered some INA138 from TI.
Required HW mods:
This will give a precision of 2mA per LSB on ADCIN3, which should be
While waiting for the INA138 to arrive I been have looking at i2c-
Comments and thoughts are very welcome!
|Re: Fwd: Measuring Power Consumption||Quist||10/6/09 12:48 AM|
When I try to turn on the MADC this is what i get:
root@beagleboard:~# i2cset 1 0x4a 0x00 0x01
Error: Could not set address to 0x4a: Device or resource busy
Is the kernel limitting me from writing to the register in the
|unk...@googlegroups.com||10/13/09 4:24 AM||<This message has been deleted.>|
|Re: Fwd: Measuring Power Consumption||Quist||10/13/09 4:53 AM|
Now I have mounted the INA138, and a 61k9 resistor instead of the 62k.
Then I read the ADC in U-Boot(see description by horse_dung):
OMAP3 beagleboard.org # imd 0x4a 0x3d 2
003d: 80 30 .0
The value 0x3080 needs to be shifted left 6 bits and converted to
decimal which gives 194. With 2mA/LSB this gives 388mA where my
voltmeter measures 38.3mV -> 383mA. So the ADC reads a current a
little over 1% too high, which is fine!
Below is a link to a pic of the modification
Now I just need to find a way to read the ADC with a shell script. If
you have experience with that please post!
|Re: Fwd: Measuring Power Consumption||tapas kundu||11/5/09 11:38 AM|
I am also trying to measure beagleboard current for my project. I
have a REV C2 beagleboard. I have not modified my board. I have
entered following commands at U-Boot prompt:
Hit any key to stop autoboot:
OMAP3 beagleboard.org # imw 0x4a 0x00 0x01
OMAP3 beagleboard.org # imw 0x48 0xbb 0x08
OMAP3 beagleboard.org # imw 0x4a 0x06 0x28
OMAP3 beagleboard.org # imw 0x4a 0x07 0x00
OMAP3 beagleboard.org # imw 0x4a 0x08 0x28
OMAP3 beagleboard.org # imw 0x4a 0x09 0x00
OMAP3 beagleboard.org # imw 0x4a 0x12 0x20
OMAP3 beagleboard.org # imd 0x4a 0x3d003d: 00
OMAP3 beagleboard.org # imd 0x4a 0x41
0041: c0 f5 ..
Could you please tell me how to calculate current values? I have got
two data values : 0x00f4 and 0xc0f5 .
I am a beginner. Please help me.
Thanks in advance
> Below is a link to a pic of the modificationhttp://img201.yfrog.com/i/beagle.jpg/
> > TPS2141 chip (which manages thepowerfrom the USB-OTG port and the DC
|Re: [beagleboard] Re: Fwd: Measuring Power Consumption||Gerald Coley||11/5/09 12:41 PM|
|Re: Fwd: Measuring Power Consumption||Quist||11/6/09 3:57 AM|
If you take my example from above:
OMAP3 beagleboard.org # imd 0x4a 0x3d 2The ADC has a 10 Bit resolution and 0x80 is the two least sinificant
bits shifted 6 bit left, 0x30 is the most significant bits. If you
then combine the two byte to 0x3080 and then shift it 6 bit to the
right(or devide by 64 dec or 40 hex) you have the value.
|Re: Fwd: Measuring Power Consumption||Quist||11/10/09 3:03 AM|
Please reply to the board and not just to me!
The dynamic range of the ADCs you are reading is 2.5V, so the ADC
The input voltage is devided by the voltage devider connected to the
ADC. The input-to-ADC ratio is 10k/(10k+22k). This gives you the
voltages at each side of R6:
So your current through R6 (0R1 resistor) is:
Don't expect a good resolution on the current measurement, since you
have 54mA per LSB on the ADC.
I guess you should try to lower you input voltage, since it is not
recommended to go above 5.2V, take a look here:
2009/11/10 tapas kundu <tapas...@gmail.com>
I don't want to rewire my REV C board as u did. As I said in my
earlier post , I have got two data values : 0x00f4 and 0xc0f5. I
interpreted this two value using your method and divided by 40h.
I got 0xf400/0x40=0x3D0 = 976 in dec and 0xf5c0/0x40=0x3D7 =983
Could you please tell me what is board current? I am not worried
accuracy of my result. I just want to calculate board current
|Re: Fwd: Measuring Power Consumption||tapas kundu||11/9/09 8:41 PM|
I don't want to rewire my REV C board as u did. As I said in my
|Re: Fwd: Measuring Power Consumption||tapas kundu||11/9/09 8:40 PM|
I don't want to rewire my REV C board as u did. As I said in my
|Re: Fwd: Measuring Power Consumption||haribabu.narayanan||12/7/09 9:44 PM|
If I wish to measure the power consumption without SW
intervention., is there any tap point on the BeagleBoard to measure
I am assuming if i measure VDD1 and also the current (using R6) .,
i can say power consumed is the product of these two. Am i missing
> > > > > tests to see if they get similar results...? If so, let me know.- Hide quoted text -
> - Show quoted text -
|Re: Fwd: Measuring Power Consumption||Quist||12/8/09 1:18 AM|
If I remember correctly VDD1 is only the core voltage, and I guess you
want to measure the power consumption of the entire board. Correct?
If you measure the voltage across R6 you will get 1mV/10mA, and this
is the current consumption of the entire board.
On 8 Dec., 06:44, "haribabu.narayanan" <haribabu.naraya...@gmail.com>
|Re: [beagleboard] Re: Fwd: Measuring Power Consumption||Gerald Coley||12/8/09 7:43 AM|
No, there are no taps on Beagle to measure VDD1. The only measuremnt point is the total board power.
|Re: Fwd: Measuring Power Consumption||haribabu.narayanan||12/9/09 8:41 AM|
>>The only measuremnt point is the total board power.I guess you are talking about R6 here? As per the responses above.,
this will give me the current consumed by the board. Should I just
multiply with 5V to get the power consumed by the entire board (even
though the software might be changing vdd1 periodically)?
I am planning to have a system with the power-management branch and
would want to measure the power consumed under different conditions
(including vdd1 changes). Is there any better way to go about it?
The total power consumed by the board would be an ideal measurement
variable. Power consumption of individual components (chiefly that of
the core) might also suffice if the former is not possible.
> > beagleboard...@googlegroups.com<beagleboard%2Bunsubscribe@googlegroups.com>
> > .
> > For more options, visit this group at> >http://groups.google.com/group/beagleboard?hl=en.- Hide quoted text -
|Re: [beagleboard] Re: Fwd: Measuring Power Consumption||Gerald Coley||12/9/09 9:24 AM|
This is tough to do beacuse it is so dymanic and hard to collect the short bursts of low current. The best way is to define states and put the board in these states and then measure the total power for each state.
|Re: Fwd: Measuring Power Consumption||haribabu.narayanan||12/9/09 10:02 AM|
That looks clean. I guess the power states offered by the kernel would
be a good place to start looking at....
However, even with each state (which would probably decide what is the
state of each HW unit), wouldn't the power consumption vary depending
on how much usage each unit is being subject to? Or does it stay
and assuming the current consumption at each state stays fixed., how
would I measure the power for each state?
> read more »- Hide quoted text -
|Re: [beagleboard] Re: Fwd: Measuring Power Consumption||Gerald Coley||12/9/09 10:38 AM|
Current will always be fluctuating. That is the main point. You can't pin it down because it depends on what is running. In essence what you will get if you were to capture the current in real time is a waveform that looks like noise on a power supplying. It will be constantly changing. So, you would need to average it. In reality you are not talking about current here, but overall power consumption that would be an average based over time and during a particular state. The state would dictate what types of things are available and which ones are turned off not to be used.
|Re: Fwd: Measuring Power Consumption||haribabu.narayanan||12/9/09 10:57 AM|
I understand....and so, how would I measure the avg. power consumption
for each state? do avg.current * 5V?
|Re: [beagleboard] Re: Fwd: Measuring Power Consumption||Gerald Coley||12/9/09 11:03 AM|
Bascially. Another idea is to set the base kernel running. Then turn on one thing or application at a time and see the difference in current. That will give you a rough idea what each application or interface consumes.
|Re: [beagleboard] Re: Fwd: Measuring Power Consumption||Vladimir Pantelic||12/10/09 1:24 AM|
haribabu.narayanan wrote:not really, you are not interested in kernel power states, you are interested
in your app use cases, e.g. idle, mp3 playback, video decode etc...
If you have a way to get your app into one of the use cases, then just measure
the avg. power in that use case. the kernel will of course all the time change
OPPs e.g. during mp3 decode, but that will average out over a few seconds...
|Re: Fwd: Measuring Power Consumption||haribabu.narayanan||1/11/10 1:07 PM|
Do all these current calculation formulations apply only to
I am a bit confused with the latest board reference manual section
|Re: [beagleboard] Re: Fwd: Measuring Power Consumption||Gerald Coley||1/11/10 2:37 PM|
Rev C2 onwards.
On Mon, Jan 11, 2010 at 3:07 PM, haribabu.narayanan <haribabu....@gmail.com> wrote:
|Re: Fwd: Measuring Power Consumption||valeswararao||1/22/10 8:39 AM|
i am new to Beagle Board,
I was trying to measure the Entire board(Rev C3) power consumption
While playing certain video file .
Is there any way to measure avg.power consumption through software
( In Rev C3 Board) ?
On Jan 12, 3:37 am, Gerald Coley <ger...@beagleboard.org> wrote:> > beagleboard...@googlegroups.com<beagleboard%2Bunsubscribe@googlegroups.com>
|Loading Android using WinPC?||Mike B. Petersen||1/22/10 3:05 PM|
Has anybody been fool-hardy enough to try load pre-built Android onto the
My intention is to run some simply GUI apk's communicating serially to he
Thanks all for any thoughts and insight.