How to measure battery Voltage usin Vsense pin in MC9S12ZVH.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to measure battery Voltage usin Vsense pin in MC9S12ZVH.

2,098 Views
rajnirajpoot
Contributor II

 

I am writing new software on MCU S12ZVH128 -144 and I want sense battery voltage (8-24V).I am using MCU pin no 86.

 

I have configured BATS component using processor expert and routed Vsense to ADC .But the ADC count  I am getting are very low not able to understand how to calculate voltage using it .  

 

Observation as below

Input voltage     Volatage at pin     Received ADC count

9                                              5.7                          142

10                                           6.3                          158

12                                           7.6                          190

14                                           8.9                          222                        

16                                           10.2                        254        

18                                           11.48                     284        

 

Snap shot of CKt connected  with Vsense

Please suggest where I am doing wrong??

 

5 Replies

1,676 Views
aaronlee
Contributor V

Hi, Radek,

My code using VSENSE voltage = (measured value / (2^n-1)) * Vref * ratio.
Which is correct?

Best Regard,

Aaron

0 Kudos
Reply

1,676 Views
RadekS
NXP Employee
NXP Employee

Hi Aaron,

your formula is correct, but even when you use formula from me, the error is negligible.

For 10bit 2^n-1 = 1023, while 2^n=1024

Did you checked external 10kOhm resistor?

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,676 Views
RadekS
NXP Employee
NXP Employee

Hi Ranji,

Such behavior is quite strange.


The VSENSE impedance is typically 350kOhm. When we use required external 10kOhm resistor, the voltage drop at this resistor shouldn’t be so high.

Please check impedance of external resistor. It looks like 200kOhm external resistor or damaged VSENSE pin.

If you can, please send me schematic for short check for any obvious or potential issue.

If you can, please send me also your project.

The VSENSE pin contains input voltage divider with ratio 9 (include external 10k resistor). So, the VSENSE voltage should be = (measured value/2^n) * Vref * ratio

Where n is number of bits used for conversion, Vref will be typically 5V and ratio is 9.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,676 Views
rajnirajpoot
Contributor II

Hi Radek ,

Issue is resolved. Thanks for your reply.

Thanks,

Rajni

0 Kudos
Reply

1,676 Views
RadekS
NXP Employee
NXP Employee

Hi Rajni,

Thank you for notification.

I am glad that it works now.

Best regards

Radek