Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Please help: Unstable reading LTC6102 Current sense amplifier+PIC16F877A C Language

Status
Not open for further replies.

noel_t

Member
Title of Project: Multi-channel data acquisition and logger system for Solar panel

Unfortunately, I am experiencing an unstable reading of Current using Ultra-precise current sensing amplifier (LTC6102) with PIC16F877A + Hi-Tech.

Would you please have a look on my design (.pdf) and program (.c) which are both attached with this email and correct me if anywhere I am wrong. The problem is only with Current parameter.
Data sheet of LTC6102 is also included for convenience.
 

Attachments

  • Schematic.pdf
    311.1 KB · Views: 293
  • MPLAB3.c
    11.8 KB · Views: 378
  • Current sensor datasheet.pdf
    135.4 KB · Views: 350
Did you get any warnings about type conversion? I'll have to try it but .....temperature = (temp * 0.48876); might need to be cast!..... temperature = ((float)temp * 0.48876);

I did not get any warning at all. All the readings except current is accurate. temperature = (temp * 0.48876);--------> this is for temperature reading from LM35.( i don't have any difficulty with it).
The only problem is the value for current reading at here .................................>//--------------------------Current Sensor

//sensor D //CURRENT
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 in simulation, but practically now working
//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

send_char(' ');
send_char('A');
send_char(' ');
 
current=(current/0.001*1000); //This is the part i am confused about and can't fix a coefficient to get the right value???

This statement is void it equates to current / 1 which equals current.. What voltage span are you getting out of the 6102?
 
The variable current is the ADC result reading from the output of 6102 which is Voltage in fact. therefore, naturally it contains analog voltage. the voltage span is 0.1 to 4.8 V. (Based on adjustment of resistors RIN and RSENSE for sufficient output amplification)

Maybe by sending you the Proteus+MPLAB you are more comfortable to test. Please leave me your email address if possible.
 
Assuming you're using 5V as the ADC reference voltage then InputVolts=ADC_Reading*5/1024.

HTH

Mike.
 
So all you really need is an equation to change the voltage input to the current its representing.

I suppose 0.1v = zero amps... can you tell me what 4.8v represents in current?

The common scale adjustment is (Scale1span * (scale2input - scale2Zero) / scale2Span) + scale1Zero...


Sorry about the delay on the replies.... I'm at work...
 
Noel... Using a lamp at 3 ohm through 48 ohm ( 120mA up to 2 A ) I've plotted a graph.. (I'm sorry the graph reads 200, it means 2000)

It isn't linear The reason your readings are wrong is the lamp modeled had 200+ ohm.. In reality they are in the order of 6 ohm 6v, 6 ohm = 1A...

This was with an Rsense of 0.001..

You will need a curved chart to evaluate the current..
 

Attachments

  • Test on 6102.png
    Test on 6102.png
    8.3 KB · Views: 240
Last edited:
This is what I ended up with

Code:
		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"
		if (current > 56)     // equates to 120mA... lowest reading
			{
			current *= 500;                        // 5.00 volts
			current /= 1024;			// covert to voltage..  1024 bits
			}
		else current = 29;      //Minimum mV reading
		current = (188 * (current-12)) / 73 ;   // convert to current.. 188 is current span...73 is mV span.. 12 is minimum current 120mA)
		current /= 10;
 		
      	dis_num(current/10);               //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(' ');

I had to define current as a long as one of the math routines was going negative... (even though you had unsigned short... go figure)
 
Last edited:
Thanks alot Ian for your assistance

Thanks Ian so much for your efforts on LTC6102, however i found out there is no LTC6102 IC available within Malaysia. Therefore, i am going to change my design to the other ways of measuring current.
I have an idea. Lets say we measure the current using a shunt resistor of 0.01 Ohm (100Watt) and feed the small voltage (good enough not to bother PIC) to the ADC. I have already bought the expensive shunt resistor. my problem over here is that the time i put a small value load (resistance 10 Ohm) with voltage of 5 Volt, the 0.5 A makes it hot. Even though i am using 3 Watt resistor, still the same thing happens.
I feel i am confusing somehow now. Please give me a brief explanation on how i can measure the maximum Power output from Solar panel. (It is the Vmax * IMax=PMax right?) we already can measure Vmax, but how about current?
Is not it like putting a small value resistor to measure the maximum current output? why it burns my Resistor with even low voltages? I have asked from outside shop that the big big solar panels for experimental usage normally give 50Watt and 20 Volt which it means the current output basically is low in ampere, but still i am unable to come out with a stable idea or design to measure it. Please help me to clarify this for me. I feel shy that even basic electronics sometimes become confusing for me. Please see the the picture for better illustration of the design.
 

Attachments

  • Shunt  resistor-current measurement.jpg
    Shunt resistor-current measurement.jpg
    82.7 KB · Views: 388
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top