[HELP]pic16877a voltages read and battery switching

Status
Not open for further replies.

mark992

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

Cookies are required to use this site. You must accept them to continue using the site. Learn more…