EmbeddedRelated.com
Forums

How to measure battery voltage by ADC?

Started by nlri12002 March 8, 2010
I want to use ADC12 to measurment battery voltage on MSP430 F5435.
But I don't know how to getting started. Could anyone give me some suggestions or example code? Thanks!

Beginning Microcontrollers with the MSP430

Well, I cannot help on ADC12, neither on MSP430F5435, for I have never worked with either of them. But I can give you some hints on how to measure your battery's voltage. (I have done this last week with a MSP430F2013).

First, I assume you know how to use your ADC properly. Then, I assume you know the maximum voltage your ADC can read.
Knowing this, I guess the easiest way to do so is to create a relation between the real voltage (VBatt) and the read voltage (the one your ADC will get and read).

So, at first, you'll have to have a voltage divider between your battery and your ADC. In my case, I had a 3.5V battery and the maximum voltage to my ADC had to be 0.6V. I did it with 2 resistors. It's that simple.

After this, you'll do the following: you'll measure different values from your original voltage (VBatt) and from the ADC. ALSO, measure the approximate values your ADC reads from each of these voltages.
Set it to an excel chart, for example, and trace a graph, where the horizontal axis is the approximated value from your ADC and the vertical axis shows the real voltage you expect.
For example: in my case, 3.5V = 65535. so, I put 65535 on the horizontal axis and 3.5 on the vertical axis and so on.
When you have it set, you can calculate a tendency line, and ask excel to show its equation to you. You'll have something like
y = 6E-05x - 0.3435
Where Y will be VBatt (what you're searching for) and X will be the read ADC value (which you have from your measurements).
When you have it done, just test it and set any small adjustments you need to do.

Good luck.

________________________________
De: nlri12002
Para: m...
Enviadas: Segunda-feira, 8 de Março de 2010 11:57:00
Assunto: [msp430] How to measure battery voltage by ADC?


I want to use ADC12 to measurment battery voltage on MSP430 F5435.
But I don't know how to getting started. Could anyone give me some suggestions or example code? Thanks!

____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com



Why not just do the math on the fly?

--- In m..., Barbara wrote:
>
> Well, I cannot help on ADC12, neither on MSP430F5435, for I have never worked with either of them. But I can give you some hints on how to measure your battery's voltage. (I have done this last week with a MSP430F2013).
>
> First, I assume you know how to use your ADC properly. Then, I assume you know the maximum voltage your ADC can read.
> Knowing this, I guess the easiest way to do so is to create a relation between the real voltage (VBatt) and the read voltage (the one your ADC will get and read).
>
> So, at first, you'll have to have a voltage divider between your battery and your ADC. In my case, I had a 3.5V battery and the maximum voltage to my ADC had to be 0.6V. I did it with 2 resistors. It's that simple.
>
> After this, you'll do the following: you'll measure different values from your original voltage (VBatt) and from the ADC. ALSO, measure the approximate values your ADC reads from each of these voltages.
> Set it to an excel chart, for example, and trace a graph, where the horizontal axis is the approximated value from your ADC and the vertical axis shows the real voltage you expect.
> For example: in my case, 3.5V = 65535. so, I put 65535 on the horizontal axis and 3.5 on the vertical axis and so on.
> When you have it set, you can calculate a tendency line, and ask excel to show its equation to you. You'll have something like
> y = 6E-05x - 0.3435
> Where Y will be VBatt (what you're searching for) and X will be the read ADC value (which you have from your measurements).
> When you have it done, just test it and set any small adjustments you need to do.
>
> Good luck.
>
>
>
>
> ________________________________
> De: nlri12002
> Para: m...
> Enviadas: Segunda-feira, 8 de Março de 2010 11:57:00
> Assunto: [msp430] How to measure battery voltage by ADC?
>
>
> I want to use ADC12 to measurment battery voltage on MSP430 F5435.
> But I don't know how to getting started. Could anyone give me some suggestions or example code? Thanks!
>
>
>
>
>
> ____________________________________________________________________________________
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
>
>
>

what and how do you mean??

________________________________
De: e.tury
Para: m...
Enviadas: Segunda-feira, 8 de Março de 2010 12:55:09
Assunto: Re: Res: [msp430] How to measure battery voltage by ADC?


Why not just do the math on the fly?

--- In msp430@yahoogroups. com, Barbara wrote:
>
> Well, I cannot help on ADC12, neither on MSP430F5435, for I have never worked with either of them. But I can give you some hints on how to measure your battery's voltage. (I have done this last week with a MSP430F2013) .
>
> First, I assume you know how to use your ADC properly. Then, I assume you know the maximum voltage your ADC can read.
> Knowing this, I guess the easiest way to do so is to create a relation between the real voltage (VBatt) and the read voltage (the one your ADC will get and read).
>
> So, at first, you'll have to have a voltage divider between your battery and your ADC. In my case, I had a 3.5V battery and the maximum voltage to my ADC had to be 0.6V. I did it with 2 resistors. It's that simple.
>
> After this, you'll do the following: you'll measure different values from your original voltage (VBatt) and from the ADC. ALSO, measure the approximate values your ADC reads from each of these voltages.
> Set it to an excel chart, for example, and trace a graph, where the horizontal axis is the approximated value from your ADC and the vertical axis shows the real voltage you expect.
> For example: in my case, 3.5V = 65535. so, I put 65535 on the horizontal axis and 3.5 on the vertical axis and so on.
> When you have it set, you can calculate a tendency line, and ask excel to show its equation to you. You'll have something like
> y = 6E-05x - 0.3435
> Where Y will be VBatt (what you're searching for) and X will be the read ADC value (which you have from your measurements) .
> When you have it done, just test it and set any small adjustments you need to do.
>
> Good luck.
>
>
>
>
> ____________ _________ _________ __
> De: nlri12002
> Para: msp430@yahoogroups. com
> Enviadas: Segunda-feira, 8 de Março de 2010 11:57:00
> Assunto: [msp430] How to measure battery voltage by ADC?
>
>
> I want to use ADC12 to measurment battery voltage on MSP430 F5435.
> But I don't know how to getting started. Could anyone give me some suggestions or example code? Thanks!
>
>
>
>
>
> ____________ _________ _________ _________ _________ _________ _
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbusca dos.yahoo. com
>
>
>

____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com



I don't have the OP yet, but it's even easier than that. One of the
available A/D channels is Vcc/2. It's intended for exactly this purpose.
Channel 11 on the ADC10. The 2013 also does this on channel 5 of the
SD16. The diagram on 24-3 of the user guide shows this (my version may
be old, it's in the SD16 section anyway and easy to find.

Al

Barbara wrote:
> Well, I cannot help on ADC12, neither on MSP430F5435, for I have never worked with either of them. But I can give you some hints on how to measure your battery's voltage. (I have done this last week with a MSP430F2013).
>
> First, I assume you know how to use your ADC properly. Then, I assume you know the maximum voltage your ADC can read.
> Knowing this, I guess the easiest way to do so is to create a relation between the real voltage (VBatt) and the read voltage (the one your ADC will get and read).
>
> So, at first, you'll have to have a voltage divider between your battery and your ADC. In my case, I had a 3.5V battery and the maximum voltage to my ADC had to be 0.6V. I did it with 2 resistors. It's that simple.
>
> After this, you'll do the following: you'll measure different values from your original voltage (VBatt) and from the ADC. ALSO, measure the approximate values your ADC reads from each of these voltages.
> Set it to an excel chart, for example, and trace a graph, where the horizontal axis is the approximated value from your ADC and the vertical axis shows the real voltage you expect.
> For example: in my case, 3.5V = 65535. so, I put 65535 on the horizontal axis and 3.5 on the vertical axis and so on.
> When you have it set, you can calculate a tendency line, and ask excel to show its equation to you. You'll have something like
> y = 6E-05x - 0.3435
> Where Y will be VBatt (what you're searching for) and X will be the read ADC value (which you have from your measurements).
> When you have it done, just test it and set any small adjustments you need to do.
>
> Good luck.
> ________________________________
> De: nlri12002
> Para: m...
> Enviadas: Segunda-feira, 8 de Março de 2010 11:57:00
> Assunto: [msp430] How to measure battery voltage by ADC?
>
>
> I want to use ADC12 to measurment battery voltage on MSP430 F5435.
> But I don't know how to getting started. Could anyone give me some suggestions or example code? Thanks!
>
> ____________________________________________________________________________________
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
>
>
>
>
Thanks for the heads up. Learn something new every day.
--- In m..., OneStone wrote:
>
> I don't have the OP yet, but it's even easier than that. One of the
> available A/D channels is Vcc/2. It's intended for exactly this purpose.
> Channel 11 on the ADC10. The 2013 also does this on channel 5 of the
> SD16. The diagram on 24-3 of the user guide shows this (my version may
> be old, it's in the SD16 section anyway and easy to find.
>
> Al
>
> Barbara wrote:
> > Well, I cannot help on ADC12, neither on MSP430F5435, for I have never worked with either of them. But I can give you some hints on how to measure your battery's voltage. (I have done this last week with a MSP430F2013).
> >
> > First, I assume you know how to use your ADC properly. Then, I assume you know the maximum voltage your ADC can read.
> > Knowing this, I guess the easiest way to do so is to create a relation between the real voltage (VBatt) and the read voltage (the one your ADC will get and read).
> >
> > So, at first, you'll have to have a voltage divider between your battery and your ADC. In my case, I had a 3.5V battery and the maximum voltage to my ADC had to be 0.6V. I did it with 2 resistors. It's that simple.
> >
> > After this, you'll do the following: you'll measure different values from your original voltage (VBatt) and from the ADC. ALSO, measure the approximate values your ADC reads from each of these voltages.
> > Set it to an excel chart, for example, and trace a graph, where the horizontal axis is the approximated value from your ADC and the vertical axis shows the real voltage you expect.
> > For example: in my case, 3.5V = 65535. so, I put 65535 on the horizontal axis and 3.5 on the vertical axis and so on.
> > When you have it set, you can calculate a tendency line, and ask excel to show its equation to you. You'll have something like
> > y = 6E-05x - 0.3435
> > Where Y will be VBatt (what you're searching for) and X will be the read ADC value (which you have from your measurements).
> > When you have it done, just test it and set any small adjustments you need to do.
> >
> > Good luck.
> >
> >
> >
> >
> > ________________________________
> > De: nlri12002
> > Para: m...
> > Enviadas: Segunda-feira, 8 de Março de 2010 11:57:00
> > Assunto: [msp430] How to measure battery voltage by ADC?
> >
> >
> > I want to use ADC12 to measurment battery voltage on MSP430 F5435.
> > But I don't know how to getting started. Could anyone give me some suggestions or example code? Thanks!
> >
> >
> >
> >
> >
> > ____________________________________________________________________________________
> > Veja quais são os assuntos do momento no Yahoo! +Buscados
> > http://br.maisbuscados.yahoo.com
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
sure

________________________________
De: e.tury
Para: m...
Enviadas: Segunda-feira, 8 de Março de 2010 13:54:48
Assunto: Re: Res: [msp430] How to measure battery voltage by ADC?


Thanks for the heads up. Learn something new every day.

--- In msp430@yahoogroups. com, OneStone wrote:
>
> I don't have the OP yet, but it's even easier than that. One of the
> available A/D channels is Vcc/2. It's intended for exactly this purpose.
> Channel 11 on the ADC10. The 2013 also does this on channel 5 of the
> SD16. The diagram on 24-3 of the user guide shows this (my version may
> be old, it's in the SD16 section anyway and easy to find.
>
> Al
>
> Barbara wrote:
> > Well, I cannot help on ADC12, neither on MSP430F5435, for I have never worked with either of them. But I can give you some hints on how to measure your battery's voltage. (I have done this last week with a MSP430F2013) .
> >
> > First, I assume you know how to use your ADC properly. Then, I assume you know the maximum voltage your ADC can read.
> > Knowing this, I guess the easiest way to do so is to create a relation between the real voltage (VBatt) and the read voltage (the one your ADC will get and read).
> >
> > So, at first, you'll have to have a voltage divider between your battery and your ADC. In my case, I had a 3.5V battery and the maximum voltage to my ADC had to be 0.6V. I did it with 2 resistors. It's that simple.
> >
> > After this, you'll do the following: you'll measure different values from your original voltage (VBatt) and from the ADC. ALSO, measure the approximate values your ADC reads from each of these voltages.
> > Set it to an excel chart, for example, and trace a graph, where the horizontal axis is the approximated value from your ADC and the vertical axis shows the real voltage you expect.
> > For example: in my case, 3.5V = 65535. so, I put 65535 on the horizontal axis and 3.5 on the vertical axis and so on.
> > When you have it set, you can calculate a tendency line, and ask excel to show its equation to you. You'll have something like
> > y = 6E-05x - 0.3435
> > Where Y will be VBatt (what you're searching for) and X will be the read ADC value (which you have from your measurements) .
> > When you have it done, just test it and set any small adjustments you need to do.
> >
> > Good luck.
> >
> >
> >
> >
> > ____________ _________ _________ __
> > De: nlri12002
> > Para: msp430@yahoogroups. com
> > Enviadas: Segunda-feira, 8 de Março de 2010 11:57:00
> > Assunto: [msp430] How to measure battery voltage by ADC?
> >
> >
> > I want to use ADC12 to measurment battery voltage on MSP430 F5435.
> > But I don't know how to getting started. Could anyone give me some suggestions or example code? Thanks!
> >
> >
> >
> >
> >
> > ____________ _________ _________ _________ _________ _________ _
> > Veja quais são os assuntos do momento no Yahoo! +Buscados
> > http://br.maisbusca dos.yahoo. com
> >
> >
> >
> >
> >
> > ------------ --------- --------- ------
> >
> >
> >
> >
This only works if the battery feeds the device directly. In my app I use a Li-Ion and a 3 volt LDO regulator. Since I want the battery voltage I need to bring it in on a separate channel.

--- In m..., OneStone wrote:
>
> I don't have the OP yet, but it's even easier than that. One of the
> available A/D channels is Vcc/2. It's intended for exactly this purpose.
> Channel 11 on the ADC10. The 2013 also does this on channel 5 of the
> SD16. The diagram on 24-3 of the user guide shows this (my version may
> be old, it's in the SD16 section anyway and easy to find.
>
> Al
>
> Barbara wrote:
> > Well, I cannot help on ADC12, neither on MSP430F5435, for I have never worked with either of them. But I can give you some hints on how to measure your battery's voltage. (I have done this last week with a MSP430F2013).
> >
> > First, I assume you know how to use your ADC properly. Then, I assume you know the maximum voltage your ADC can read.
> > Knowing this, I guess the easiest way to do so is to create a relation between the real voltage (VBatt) and the read voltage (the one your ADC will get and read).
> >
> > So, at first, you'll have to have a voltage divider between your battery and your ADC. In my case, I had a 3.5V battery and the maximum voltage to my ADC had to be 0.6V. I did it with 2 resistors. It's that simple.
> >
> > After this, you'll do the following: you'll measure different values from your original voltage (VBatt) and from the ADC. ALSO, measure the approximate values your ADC reads from each of these voltages.
> > Set it to an excel chart, for example, and trace a graph, where the horizontal axis is the approximated value from your ADC and the vertical axis shows the real voltage you expect.
> > For example: in my case, 3.5V = 65535. so, I put 65535 on the horizontal axis and 3.5 on the vertical axis and so on.
> > When you have it set, you can calculate a tendency line, and ask excel to show its equation to you. You'll have something like
> > y = 6E-05x - 0.3435
> > Where Y will be VBatt (what you're searching for) and X will be the read ADC value (which you have from your measurements).
> > When you have it done, just test it and set any small adjustments you need to do.
> >
> > Good luck.
> >
> >
> >
> >
> > ________________________________
> > De: nlri12002
> > Para: m...
> > Enviadas: Segunda-feira, 8 de Março de 2010 11:57:00
> > Assunto: [msp430] How to measure battery voltage by ADC?
> >
> >
> > I want to use ADC12 to measurment battery voltage on MSP430 F5435.
> > But I don't know how to getting started. Could anyone give me some suggestions or example code? Thanks!
> >
> >
> >
> >
> >
> > ____________________________________________________________________________________
> > Veja quais são os assuntos do momento no Yahoo! +Buscados
> > http://br.maisbuscados.yahoo.com
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
On 08.03.2010 16:36, OneStone wrote:
:
> I don't have the OP yet, but it's even easier than that. One of the
> available A/D channels is Vcc/2. It's intended for exactly this purpose.
:

The OP wrote something about battery voltage, not Vcc of the MSP430.
Could be different voltages.

Hardy
The result is the same, if they check out the diagram on page 24-3 it
will show them how Ti does it (not exactly difficult, a pair of
resistors) and what channels they can connect through for a result. Of
course designing a low power app with a divider across the battery that
is in circuit all the time isn't a great idea, since it will usually
draw current all the time. why li-ion and an LDO, wasteful of energy if
this is a low power long battery life application.

Al

Hardy Griech wrote:
> On 08.03.2010 16:36, OneStone wrote:
> :
>> I don't have the OP yet, but it's even easier than that. One of the
>> available A/D channels is Vcc/2. It's intended for exactly this purpose.
> :
>
> The OP wrote something about battery voltage, not Vcc of the MSP430.
> Could be different voltages.
>
> Hardy
>