Unstable reading LTC6102 Current sense amplifier+PIC16F877A C Language

Discussion in 'Embedded Systems and Microcontrollers' started by navidbox, Jul 3, 2011.

  1. navidbox

    Thread Starter Member

    Mar 6, 2009
    Please help me to identify the reason for unstable reading.
    This is a multi-channel data acquisition system for solar panel. Three parameters can be read accurately without any issue. but for current sensing, even though i tried to use the precise current sensing amplifier which is advised for precise applications, but still have problem in reading. My knowledge is poor in understanding of Vref, Resolution, and generally ADC.

    ADCON0=CHANNEL3; //CHANNEL1=0b10001001 //CHANNEL0 is for Temperature
    read_adc(); ////It seems Reading the adc first ***important ////This function generates the average reading value of ADC
    current=read_temp(); // reading value from sensor ***important ////This function stores the generated value by ADC into the variable "temp"
    //current=0.074*current; // Last time used for ACS712 Hall Effect sensor and it worked
    current=(current/0.001*1000); //This is the part i am confused about and can't fix a coefficient to get the right value

    dis_num(current); //show the value
    send_char('.'); //this line is to show . to seprate desimal value from double value
    dis_num(current%10); //show the double value
    send_char(' ');
    send_char(' ');

    //==================subroutine ADC=========================

    void read_adc(void) ////This function generates the average reading value of ADC
    unsigned short i;
    unsigned long result_temp=0;
    for(i=2000;i>0;i-=1) //looping 2000 times for getting average value


    ADGO = 1; //ADGO is the bit 2 of the ADCON0 register
    while(ADGO==1); //ADC start, ADGO=0 after finish ADC progress
    result=result<<8; //shift to left for 8 bit
    result=result|ADRESL; //10 bit result from ADC


    result = result_temp/2000; //getting average value


    unsigned short read_temp(void) ////This function stores the generated value by ADC into the variable "temp"


    unsigned short temp;
    return temp;

  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    Could you tell me:

    What is the max current expected from the panel?

    What is the value of the current when the reading is unstable?

    What is the value of the voltage from the LTC6102 when the reading is unstable?

    Are you looking for .5 volts per amp from the LTC? (that's what I just got).

    finally, re-post the code with code tags please!