Battery Charge Level Viewer is a microcontroller based small project which shows charge level of battery using 5 LEDs . Generally battery becomes full at 5volts . Remember that an ADC channel of pic18f2550 can count from 0 to 1023 . Because it's ADC channel register is 10bits. As we like to measure 5volt . We will read the value of adc channel and will convert it to voltage . After converting into voltage we get a understandable value and we shows it through 5 green LEDs. It's the basic concept .
ADC(Analog to Digital Converter ) :
We need a basic knowledge about ADC . Let's take a look at here :![]() |
ADCON1 Register |
Basically ADC is like as voltage divider . According to voltage It produce output .
bit 5 : VCFG0: Voltage Reference Configuration bit (VREF- source)
1 = VREF- (AN2)
0 = VSS or 0 volt
bit 4 :VCFG0: Voltage Reference Configuration bit (VREF+ source)
1 = VREF+ (AN3)
0 = VDD or 5volt
We will set VCFG0[bit 5]=0and VCFG0[bit4]=0 . So we will get highest value 5volt[1023] and lowest value 0volt[0].The ADCON1 is a 10 bit register that means 2 to the power 10 is it's highest counting capacity and result is 1024 . So this register can count from 0 to 1023 . When 0 volt , we get reading at RA0 pin 0 .When 5 volt , we get reading at RA0 pin 1023. It means 5volt equivalent to 1023 .
If 1023 reading value equal to 5 volt.
So 1 reading value equal to 5/1023 volt
So 'read_val' reading value equal to (5/1023)*read_val volt
Source Code :
void main() {
int source=0;
int read_val=0;
int read=0;
ADCON1=0x0E; // Configuring RA0 pin as input
CMCON=7;
TRISB=0x00;
ADC_Init(); // Initialize ADC
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=0;
PORTB.F4=0;
while(1){
source=ADC_Read(0);
read_val=(source*5.50)/1023;
read=read_val;
if(read==1){
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=0;
PORTB.F4=1;
}
if(read==2){
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=1;
PORTB.F4=1;
}
if(read==3){
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=1;
PORTB.F3=1;
PORTB.F4=1;
}
if(read==4){
PORTB.F0=0;
PORTB.F1=1;
PORTB.F2=1;
PORTB.F3=1;
PORTB.F4=1;
}
if(read==5){
PORTB.F0=1;
PORTB.F1=1;
PORTB.F2=1;
PORTB.F3=1;
PORTB.F4=1;
}
}
}
Circuit :
![]() |
circuit |
So So much help full for me this topic . many many thanks
ReplyDeleteWhen I try to download I first I got a 404 error and now it shows the site has malicious software and my Malware Bytes blocks it. I am actually looking for this exact design. Is there any other place to download from?
ReplyDeleteI am glad you take pride in what you write. This makes you stand way out from many other writers that push poorly written content. dime cart
ReplyDeletevanity leads to more plastic surgery procedures. people are becoming more conscious about their appearance’ https://rvprofy.com/best-rv-battery-monitors/
ReplyDelete
ReplyDeleteSo nice I am enjoying for that post as for u latest version of this Security tool Available
bluetooth-battery-monitor-keygen download
https://www.buyyoutubesubscribers.in/2021/12/30/how-hide-subscribers-youtube/ The YouTube partner package application process provides videographers a wonderful opportunity to upload and monetize their video by allowing YouTube to place advertisements next to their content. TTo cash in on your creativity, YouTube asks you in the initial application process to answer a few questions. Basically YouTube partners are independent video creators and media companies who are looking for online distribution and who meet YouTube's qualifications. Becoming a partner gives you the ability to share in ad revenue from your YouTube videos.
ReplyDeleteThanks for sharing this Great article.Dairy Wastewater Treatment Company in India
ReplyDeleteAt long last, Li+ batteries have no memory impacts and don't have to topped off.
ReplyDeleteWholesale LiFePO4 Battery