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.

Unstable reading LTC6102 Current sense amplifier+PIC16F877A C Language

Status
Not open for further replies.

noel_t

Junior Member level 3
Joined
May 31, 2011
Messages
30
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Activity points
1,592
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
lcd_goto(48);
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-34);
current=(current/0.001*1000); //This is the part i am confused about and can't fix a coefficient to get the right value
current=(current*20);

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
//current=temp;
send_char(' ');
send_char('A');
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=ADRESH;
result=result<<8; //shift to left for 8 bit
result=result|ADRESL; //10 bit result from ADC
result_temp+=result;

}


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;
temp=result;
return temp;

}
 

Attachments

  • proteus.jpg
    proteus.jpg
    309.5 KB · Views: 9
  • Current sensor datasheet.pdf
    135.4 KB · Views: 3
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top