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;
}