Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Voltage monitor for cars battery and its charging system | Embedded Lab
HOME
NETDUINO
PIC TUTORIALS
CHIPKIT
PRODUCTS
ARDUINO PROJECTS
STM32
THEORY
PIC PROJECTS
CONTACT US
Embedded Lab
Embedded Projects
Car Battery 12
Voltage Regulator
by R-B
77 comments |
Like
Battery Monitor
Search...
80
Follow
Embedded Lab
Like
SUBSCRIBE
http://embedded-lab.com/blog/?p=3096
1/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Sign Up
The ory
As I said this project is simply about making a precise digital
U S c us tom e rs buy
he re
Inte rnati onal
c us tom e rs buy he re
2/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
microcontroller-based
PIC16F1827.
Ci rc ui t di agram
continuously displaying
http://embedded-lab.com/blog/?p=3096
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Microcontroller
Programmers (6)
MSP430 Launchpad (3)
Netduino (9)
Open-source (1)
PIC Projects (87)
PIC Tutorials (45)
PIC18F (10)
Power Supply (13)
Processing (3)
Product Review (16)
Products (34)
Raspberry Pi (8)
Robotics (8)
he
Pin diagram of PIC16F1827
STM32 (6)
Tech News (107)
Texas Instruments (4)
Tips and Tricks (83)
Uncategorized (2)
XMega (4)
Power Battery
Battery to Battery Cable
Battery Socket
USB port pins of the car charger. Then I used an USB-A Male to B
Male Adapter to connect these signal lines to the microcontroller
circuit board.
Connecting the battery terminal voltage at one of the USB port data pins
http://embedded-lab.com/blog/?p=3096
4/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Re-wired USB car charger and the USB-A Male to B Male Adapter
http://embedded-lab.com/blog/?p=3096
5/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Software
The firmware for this project was developed in mikroC Pro for PIC
compiler. The equations to derive the input voltage from the 10-bit
ADC output (Digital Number, DN) are described below.
VBattery = VADC, IN * (R1 + R2/R2) = 4.13 * VADC, IN
Resolution of ADC = 4.096/1024 = 4 mV/DN
VADC, IN = DN * 4 (mV)
=> VBattery = 4.13 * 4* DN (mV) = 0.0165*DN (V)
The use of internal reference voltage for A/D conversion requires
configuration of FVRCON and ADCON1 registers. The mikroC Pro for
PIC compiler provides a library for A/D conversion, but that uses
the supply voltage, VDD , by default as the positive reference for the
conversion. So the built-in ADC library of mikroC Pro for PIC is not
useful for our case and we need to write our own ADC subroutine.
The complete source code for this project can be downloaded from
the link provided below.
D ownl oad the s ourc e c ode and HEX fi l e
O utput
Plug in the device into the cars cigarette lighter receptacle and turn
in the car key to on position (dont start the engine). This will
display the car battery terminal voltage (about 12 V). Once the
engine is turned on, the battery starts receiving the charging
voltage from the alternator. This voltage should be higher (about
13.8 V) than the actual voltage produced by the battery itself.
http://embedded-lab.com/blog/?p=3096
6/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Re c om m e ndati on
An additional LED or a buzzer can also be added to the circuit to
alarm under (say < 11.8) or over (say >14.0 V) voltage conditions.
268
11K
54
Like
88
80
Related posts:
1. Programmable digital timer switch using a PIC
Microcontroller
2. How to make a contact-less digital tachometer using IR-light
reflection technique
3. Experimenters board for enhanced mid-range PIC
microcontrollers (PIC16F1827 and PIC16F1847)
http://embedded-lab.com/blog/?p=3096
7/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Voltage
Regulator - Meba
Reliable Brand Voltage
Regulator, Large Capacity,
High Efficiency.
PIC Projects
77 COMMENTS
Tahir
Hi Raj!
How do you find the resistor value, do you try these with error and
try?
thank you!
marC:)
Reply
Marc
8/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
R-B
Hi Marc,
Using Vref = 4.096 or 2.048V makes ADC computations easier
and accurate because they may be expressed as 2^n. For
example, 4.096V = 4096 mV = 2^12. So for 10-bit ADC, the
resolution becomes exactly 4mV.
Reply
Rana Hammad
Can you do the hex file for another pic instead of 16f1827. a
pic16f88 perhaps. Thanks that would be great help!
Reply
Pingback: ????? ????? ??????? ??????? ??? ??????? - ???? ?????? NileMotors.net
Pingback: ????? ????? ??????? ??????? ??? ??????? - ???? ?????? NileMotors.net
Marc P.
Thanks Mr Raj!
Reply
Marc P.
Hey Raj!
I have bought the same type of adapter like you Raj, input voltage
12VDc, output 5vDC @ 1000mA, how do i wire them in the circuit.
Mr. Raj! i really need your help i know for you its easy!! but think
about the beginner like me, you have to give me some details
about my questions, thank you very much Raj!
I expected from you soon!
have a great evening!
thank you!
marC:)
Reply
Marc P.
9/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
can you add up the circuit diagram from the car battery voltage
regulator and place then in the ADC channel?
thank you!
marC:)
thank you!
marC:)
Reply
Marc P.
Marc,
You need two wires coming from cars battery (+12V) and a 5V
regulator to generate power supply for the microcontroller circuit.
The +12V battery voltage wire goes directly to the voltage divider
input (Vbattery in the circuit diagram). I cant tell anything from the
color of the wires. You have to find out by yourself.
Reply
Marc
Hi Raj!
I dont quite understand, theres a 5V and 12V?.. i dont understand,
sorry i would like to do this project so much for my mother
thank you!
marC:)
Reply
Marc
Raj! I have only 2 prungs, white wire and white wire, so what can i
do with your schematic with it?
thank you!
marC:)
Reply
hamid ladan
pls reply me
http://embedded-lab.com/blog/?p=3096
10/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Reply
Hamid Ladan
Share
@hamid,
The multiplication factor depends on the voltage divider resistor
values and ADC reference voltage. So, you cant tell without
knowing what resistor values is he using.
Reply
hamid ladan
Mr R-B, nice work. do you have the flow chart for the voltage
monitor for car battery and its charging system. should you have it,
can you send it to my email. Thanks in advance.
Reply
kostas
Good day,
I happen to visit your blog and really enjoyed reading it. Is there
any place where I can buy the monitor?
http://embedded-lab.com/blog/?p=3096
11/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
I dont have a commercial board for sale, but will consider it for
future.
Reply
WASANTHA
Dear Sir.
I modify this code to measure two input voltages, using pins RA0,
RA1 (16 X 2 lCD), but same voltage is shown on both outputs on the
LCD display. can you please be kind enough to correct the code for
me sa i have very little knowledge in pic programming.
thankswasantha , Email shwasantha@gmail.com
// LCD module connections
sbit LCD_RS at RB1_bit;
sbit LCD_EN at RB2_bit;
sbit LCD_D4 at Rb4_bit;
sbit LCD_D5 at Rb5_bit;
sbit LCD_D6 at Rb6_bit;
sbit LCD_D7 at Rb7_bit;
sbit LCD_RS_Direction at TRISB1_bit;
sbit LCD_EN_Direction at TRISB2_bit;
sbit LCD_D4_Direction at TRISb4_bit;
sbit LCD_D5_Direction at TRISb5_bit;
sbit LCD_D6_Direction at TRISb6_bit;
sbit LCD_D7_Direction at TRISb7_bit;
// End LCD module connections
char Message1[] = CH1=;
char Message2[] = CH2=;
char Message3[] = VOLT;
char Message4[] = PIC DUAL V METER;
char Message5[] = PIC 16F876 A ;
unsigned int ADC_Value, DisplayVolt;
char *volt1= 00.00;
char *volt2= 00.00;
void main() {
ADCON1=0b10000010;
TRISA=0XFF;
//CMCON0 = 007 ; // Disbale comparators
TRISB = 0b00000000; // PORTC All Outputs
TRISA = 0b00001111; // PORTA All Outputs, Except RA0,
RA1,RA2,RA3
http://embedded-lab.com/blog/?p=3096
12/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Why are you using ADC_Read(1) and ADC_Read(2), when you are
using AN0 and AN1 channels. You should use ADC_Read(0) and
ADC_Read(1) in your main program.
Reply
meguitarist
sorry my mistake
its running at 16MHz.
Reply
http://embedded-lab.com/blog/?p=3096
13/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
meguitarist
Hello RB,
OSCCON = 0b01110000; // oscillator running @ 8MHz rite?
Still flicker a bit. Im setting oscillator running at 32MHz solved the
problem.
OSCCON = 0b01111000; // oscillator running @ 32MHz
Reply
Meguitarist
Dear RB,
Delete the 5ms in DO loop doesnt help.
Reply
R-B
Meguitarist,
I have updated the program. Download the new program and try
it. That should solve your issue. Let me know how it goes.
Reply
Meguitarist
Hello RB,
Thanks for yr reply.
Does yr build blink too?
How to average the results say take 10 results & divided by 10 &
output it?
Reply
http://embedded-lab.com/blog/?p=3096
14/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Meguitarist
Seems correct.
Reply
meguitarist
Hi RB,
Its my mistake, segment F&G was switched. Now everything
running smooth except flickering display which blinking every
second. Was this normal? How can I smooth out the display?
Thanks!
Reply
R-B
meguitarist,
Try by deleting the Delay_ms(5) statement inside the DO loop in
the main program.
Reply
meguitarist
Hello RB,
The chip was programed on the zip socket board that I built. The
socket board have 2 LEDs on pin 17 & 18. After programs I turn on
the PICkit2 5V the LEDs doesnt lit. Was this normal???
I removed the chip from the zip socket & insert to my board. The
display blink every 1sec with weird digit instead of 00.00 if no
input on AN4. I have to re-check my board, connection from PIC to
ULN2003 & LED display is ok. Dont know where I done wrong.
http://embedded-lab.com/blog/?p=3096
15/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Thanks!
Reply
Meguitarist
Hello RB,
I try to build this project but my pickit2 cant detect pic16f1827.
After some searching on the net I found an update from microchip
& do the update now pickit2 recognised the pic I successful
program the chip. The problem now is the 47 segment showing
weird digit.
After checking rb6 is not outputing anything.
Ill try to recompileyr code & test again.
Maybe pickit2 is not program correctly?
Regards,
Meguitarist
Reply
R-B
After programming the chip, did you disconnect the PICKIT from
the circuit? RB6 and RB7 are used for programming, so the
PICKIT2 should be disconnected after programming being done.
Reply
Michael
Nice project, Raj. May I ask where you sourced the display with
colon LEDs for this project, please? Thanks
Reply
R-B
Michael,
Check on taydaelectronics.com.
Reply
Pingback: Voltage monitor for cars battery and its charging system /
Cooking Hacks Blog
Em314
16/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
hi. can you please send me the code you developed in MPLAB
using C compiler.
Reply
LB
LB,
Can you email me your code at admin (at) embedded-lab.com?
Reply
i. vlaviano
Hi MR. R.B. ! I found this project very usefull and want to use it for
http://embedded-lab.com/blog/?p=3096
17/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
Yikes! Sorry too rush you R-B, had no idea you were in that area.
Thanks for the update, Ill check out the available LED display units.
Hope you guys make it out safely.
Reply
mark
@R-B
Still there? If it means you have to build all over, dont worry about
it. I was just hoping you had it on hand.
Reply
R-B
Hey Mark,
Sorry I was little busy preparing for the Hurricane Irene. I just
checked the current consumption, and it draws about 48 mA of
current while displaying the voltage on seven segment LEDs.
The major current consuming part is the display unit, so it may
differ with different seven segment LED modules.
Reply
shivendra kumar sahu
HI MR. R.B.
pl think something about my question.
Reply
R-B
@shivendra,
Yes you can add an LED or buzzer to either RA6 or RA7 pin and
http://embedded-lab.com/blog/?p=3096
18/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
@R-B, thats correct. Total current draw from car battery (including
voltage regulator, display, chips, etc).
Reply
mark
Hey R-B, great job on the voltage monitor/write up. Is there any
chance you remember the current draw for this project (car in
standby/running)? I found this comparator based one, built it only
to find out it uses ~50mA!
Reply
R-B
@mark,
Do you mean how much current the circuit draws from the
battery?
Reply
shivendra kumar sahu
HI MR. R.B.
additional LED or a buzzer can also be added to the circuit to alarm
under (say 14.2 V to 10.5 v) voltage conditions.
when u explan it ?
Reply
shivendra kumar sahu
@shivendra
In order to display all 4 digits, each seven-segment display is
activated sequentially using an appropriate refresh frequency so
that it will appear that all the them are turned on at the same
http://embedded-lab.com/blog/?p=3096
19/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
time. The for loop and the code within it does this and display
the result for an approx. 1 sec before taking another sample of
the battery voltage.
Reply
Car Battery World
HI MR. R.B.
pl reply me ..
Reply
Shivendra
hi mr.rb. How can add hi/lo volt indication for relay drive ?
Reply
fazli
@fazli,
The link for the source code is provided in the Software section
of the project.
Reply
shivendra kumar sahu
AS Recommendation
An additional LED or a buzzer can also be added to the circuit to
alarm under (say 14.0 V) voltage conditions.
PL GIVE EXAMPLE.
also give example when we use
/A
POARTC.0= A /
http://embedded-lab.com/blog/?p=3096
20/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
POARTC.1= B / F| G | B
POARTC.2= C /
POARTC.3= D / E| |C
POARTC.4= E /
POARTC.5= F / D
POARTA.4= G /
Reply
shivendra kumar sahu
hi Mr R.B.
I was change it with PIC 16F676 . but found , lot of error pl guide
me..
Reply
shivendra kumar sahu
great dude
Reply
wwint
@harry
what i think your saying is that with the output going to full range
speakers with more than one driver per cabinet aka 2way or 3 way
speakers, youre getting good sound. but when you wire to a single
4 or 8 ohm driver it sounds bad?
if thats the case no tone control will hep you, better speakers =
better sound.
if you are referring to sending your circuits output into a stereo
system with a seperate amp in it, sounding good and then not
sounding good on speakers without this second amp inline
http://embedded-lab.com/blog/?p=3096
21/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
well then youve discovered that the lm386 is a very low power
(less than 1 watt) amp chip designed for headphone amplification or
small speakers without needing heatsinks, and doesnt sound
particularly good.
pick a better amp chip to drive 4 ohm speakers by themselves.
if none of these then i cant figure out what youre talking about as
your description of your problem is beyond vague
Reply
Pingback: Blog Archive Automotive battery voltage monitor .::
Arindam's Blog ::.
Pingback: Automotive battery voltage monitor | You've been
blogged!
Pingback: Automotive battery voltage monitor - Hack a Day
error404
@error404,
I agree with what you are saying, but the re-wired USB charger is
the part of the monitoring device and should go with it. It
shouldnt be used as a normal USB charger. I wanted to avoid
any long cables from the cigarette lighter receptacle to the
circuit board to make it compact and portable. Thanks for the
comment though, the readers will be now aware of this issue.
Reply
U guys are greati need help though: am a fast learning beginer and
am making an amlifier based on lm386D with no preamp and it
sound ok on stereo speaker but very poor on 4 or 8 ohm CD
speakers..i need a circuit diagram with tone controll to modifie
http://embedded-lab.com/blog/?p=3096
22/23
11/6/2014
Voltage monitor for cars battery and its charging system | Embedded Lab
LEAVE A REPLY
Your email address will not be published. Required fields are
marked *
Name *
Email *
Website
Comment
Post Comment
http://embedded-lab.com/blog/?p=3096
zeeDynamic Theme
23/23