Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[HELP]pic16877a voltages read and battery switching

Status
Not open for further replies.

mark992

Newbie level 4
Newbie level 4
Joined
Jan 23, 2013
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,322
i will incorporate this system in our final year project which is a self sustaining charger and this is one of the problem that we encounter maybe you can help me with this guys...

what i want to do with this is , i want to to monitor the battery level if its reaches low level it will switch to another battery
here is my code

unsigned int volt,volt1,voltage,voltage1;

void main()
{
TRISB=0x00;
ADCON0=0b10000001;
ADCON1=0b11000000;
TRISA=0xff;


BATTERY1:

Delay_us(20);
volt = ADC_Read(0);
voltage=(volt*5)/1024;

if(voltage<4)
{
TRISB=0x02;
goto BATTERY2;
}
else
goto battery1;
BATTERY2:
ADCON0=0b10000001;
ADCON1=0b11000000;

Delay_us(20);
volt1 = ADC_Read(1);
voltage1=(volt*5)/1024;


if(voltage1<4)
{
TRISB=0x01;
goto BATTERY1;
}
else
goto BATTERY2;

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top