continuous battery monitoring during charging as well as discharging

Thread Starter

viznu3391

Joined Dec 10, 2015
16
I was going to start asking question about that.
- Do the reading from the inverter and charger appear to be good..

- Disconnect the sensors one at a time and see what happens to the battery readings.
- inverter readings are coming fine.
- I'll try that.

Thanks
 

Thread Starter

viznu3391

Joined Dec 10, 2015
16
Can you post the section of programme of the ADC reader.

Just use two resistors for a divider, no op amp needed.
I used just a voltage divider before and faced this problem. Then I added the low pass filter with an voltage follower. Still same results.

C:
void InitADC(void)
{
    ADCON1  = 0x80;        // Make PORTA and PORTE analog pins
                        // Also, Vref+ = 5v and Vref- = GND
    TRISA   = 0x2f;      // Make RA5, RA3, RA2, RA1, RA0 input
    TRISE   = 0x07;        // Make RE0, RE1 and RE2 input
    ADCON0  = 0x80;        // Turn on the A/D Converter
}



unsigned int GetADCValue(unsigned char Channel)
{
    ADCON0 &= 0xc7;         // Clear Channel selection bits
    ADCON0 |= (Channel<<3); // Select channel pin as ADC input
    ADCON0  = 0x81;
    __delay_ms(10);         // Time for Acqusition capacitor
                            // to charge up and show correct value
    GO_nDONE  = 1;           // Enable Go/Done

    while(GO_nDONE);        // Wait for conversion completion
    ADCON0  = 0x80;
    return ((ADRESH<<8)+ADRESL);   // Return 10 bit ADC value
}

double Measure_Volt(unsigned channel, double Volt_Ratio)
{
    unsigned int i;
    unsigned int  sample_Volt;
    double sum_Volt = 0;
    double Vavg;//,AvgCount;
        for(i=0;i<50;i++)
        {
        sample_Volt = GetADCValue(channel);
       sum_Volt += sample_Volt;
        }
    //AvgCount = sum_Volt / 50; //
    Vavg= Volt_Ratio*(sum_Volt /50 )*(ADC_REF/ADC_MAX_COUNT);
    sum_Volt = 0; 
    return Vavg;
}

void main(){
InitADC();  
    init_serial();
while(1){
///....................
bat_volt= Measure_Volt(AN4,1);      // #define AN4 4
//other codes for sending data
}
}
Moderators note : Use code tags for C
 
Last edited by a moderator:

Picbuster

Joined Dec 2, 2013
1,049
Connect variable voltage source to input.
Disable all functions and printf the ADC value and voltage calculated from it.
Repeat using de divider.

I hope that this gives you input solving the problem.
 

Thread Starter

viznu3391

Joined Dec 10, 2015
16
Connect variable voltage source to input.
Disable all functions and printf the ADC value and voltage calculated from it.
Repeat using de divider.

I hope that this gives you input solving the problem.
ADC is working fine. My problem is when I connect inverter and charging circuit to the battery, pin that goes to the ADC is giving a constant value.
 

Picbuster

Joined Dec 2, 2013
1,049
I agree with lestraveled. measure and report we are not able to see what you do or don't.
We like to help you.
Please check ground leads and resistors are they 100k and 10K. (not to worry I have resistor failure some times)
did you connect the variable voltage source to gnd and the 100K(high end)?
measure, as stated before by lestraveled, the chip adc input and change voltage from 0 to 5V what is your reading?

it should be : Vsource*10/(100+10)
 

Dodgydave

Joined Jun 22, 2012
11,367
Do you have a variable dc power supply 0-5V, what readings are you getting if you input the variable dc psu into the A/D pin?
 
Top