Continue to Site

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.

How to convert ADC value to weight

Status
Not open for further replies.

DivyaKrishnappa

Newbie level 6
Joined
Apr 23, 2014
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
103
Hi..


I am interfacing 24 bit ADC with micro controller, It is giving different increasing values to increasing load on load cell. I don't know how to convert these values into weight. Any one who has knowledge about Digital Weight Measurement, please suggest your ideas..
 

your load cell should be calibrated output voltage against weight
you would then have an amplifier and knowing the gain calculate the input voltage to the ADC
you should be able to calculate ADC value read against weight
otherwise use known weights to calibrate the system, i.e. have a known weights, read ADC, repeat for range required gives you a calibration equation or table
 
Hi,

put no load on your sensor and read out the value (ADCv),this is your offset. Store it in EEPROM of the controller.

put 1 kg on your sensor and calculate gain:

gain = 1000g / (ADCv - offset)

Store gain in EEPROM

calibration finished.

To measure:

Weight in gramms = gain * (ADCv - offset)

finished.

Hope this helps
Klaus
 
Hi Klaus,

Does the value ADCv vary for different weights..? should I measure it by putting the load on sensor or should I calculate it..?

"put no load on your sensor and read out the value (ADCv),this is your offset"

gain = 1000g / (ADCv - offset)

offset-offset will become zero.. Please tell me How I could measure this ADCv..?


Regards,
Divya
 

The process you need to undertake is called Calibration, and you have to do it yourself.
You will need a weight that you know beforehand. Example 10 kg, put it on the load cell and note the ADC value.

Then you have to solve the equation:
10 kg = ADCvalue * Scale;
In this equation Scale factor is unknown. You may have to perform a division to obtain the scale factor.

When you know the Scale factor, you program the PIC to perform the multiplication of ADCvalue * Scale.

If you want to make it a little more complicated, you may use two different known loads. Example 10 kg and 50 kg. Note the two different ADC values.
Weight1 = ADCvalue1 * Scale + Constant;
Weight2 = ADCvalue2 * Scale + Constant;
Now you have two equations and two unknown values, Scale and Constant, to solve.
 
Hi..

When we connect the Load cell to ADC, we cannot measure the voltage externally from Load Cell as you have told. Here I may require to convert the ADC_reading into voltage by some calculation and should perform the above calculation..

Regards,
Divya
 

first of all which ADC u have to use and which micro controller use to perform this task ?
 

Hi Klaus,

Does the value ADCv vary for different weights..? should I measure it by putting the load on sensor or should I calculate it..?

"put no load on your sensor and read out the value (ADCv),this is your offset"

gain = 1000g / (ADCv - offset)

offset-offset will become zero.. Please tell me How I could measure this ADCv..?


Regards,
Divya

Hi Divya,

ADCv is the current ADC value, or in other words the ADC reading.

To measure weight, you have to connect your load cell with the ADC input.
Your ADC reading in 24 bits wide.

Now with no load your ADC reading is 0x000123; this is your OFFSET, because thes value means 0 kg
Now put 1kg on the load cell and the ADC reading maybe is 0x0ABC39. subtract the offset and get 0x0ABB16. this is the "true" value for 1kg.
lets say 1000 per 0x0ABB16 this gives = 1000/703254 = 0.001422:

with all further ADC readings first subtract the OFFSET and then multiply the value with 0.001422 and get the weight in grams

Hope this helps
Klaus
 
Hi..

Anybody helps me or give an idea "How to display float values e.g. my converted ADC value i.e, weight in terms of float on Graphic LCD"

Regards,
Divya
 

Hello!

Anybody helps me or give an idea "How to display float values e.g. my converted ADC value i.e, weight in terms of float on Graphic LCD"

This has been extensively discussed on this forum less than a week ago. Well, it wash't a graphic LCD, but basically
it's the same method: transform your float value to a string and display the string.
I suppose you can write a string to your LCD, right?

Dora.
 

As per this method i can't get 1 gram accuracy from 40 kg load cell ( czl601 ).I am using HX711 24 bit ADC and Arduino(atmega328p).I got result like 30,60,90 and 120
 

Hi,

1 gram accuracy
is an absolute error of 0.0025% ... hard to achieve.

but maybe you mean "resolution" instead of "accuracy". With a 24 bit ADC and 40kg full scale, the resolution should be 2.38mg.

I got result like 30,60,90 and 120
i don´t know what this means..
are those values in gramms? or LSB, or do you mean that the value is constantly increasing????

Klaus
 

Thanks for your reply.My requirements is 1 gram resolution in 40 kg loadcell like i want to measure from 1 gram weight to 40 kg weight but i got result multiple of 30 grams like 30,60 and 90 if i put 128 gram weight means it gives 120 as output in serial monitor and lcd
 

Hi,

ahh, you are missing resolution. It´s time for you to show us your code....

either this is caused by an calculation overflow, a wrong data representation, wrong calculation....

your ADC gives 24 bits of data.
When it is 0x000000, what grams should this give?
When it is 0x800000, what grams should this give?
When it is 0x7FFFFF, what grams should this give?
When it is 0xFFFFFF, what grams should this give?

Klaus
 

Code:
#include <LiquidCrystal.h>

#define HX711_SCK A0
#define HX711_DT A1

LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
extern void Init_Hx711();
extern unsigned long HX711_Read(void);
extern unsigned int Get_Weight();
extern void Get_OFFSET();

long HX711_Buffer = 0;
long Weight_OFFSET = 0,Weight_Real = 0;
int Weight = 0;
unsigned long M_Weight=0,ADC_Value=0;

void setup()
{
        Init_Hx711();				//IO setting initialization module connected HX711
        lcd.begin(16, 2);
        analogReference(INTERNAL);
	Serial.begin(9600);
	Serial.print("40 Kg Loadcell reading!\n");

	delay(2000);
	Get_OFFSET();		//Get fur

}

void loop() 
{
        ADC_Value=HX711_Read();
        M_Weight=(ADC_Value-8409088)*0.00793457031;
        Weight = Get_Weight();	//Calculated on the weight of the weight sensor
	Serial.print(M_Weight);	//Serial Display Weight
	Serial.print(" g\n");	//Display Units
	Serial.print("\n");		//Display Units
	delay(1000);				//Delay 1s

        lcd.setCursor(0, 0);
        lcd.print(M_Weight, 1);
        lcd.print(" g");
        lcd.print("       ");
        delay(200);

}


//****************************************************
//Initialization of HX711
//****************************************************
void Init_Hx711()
{
	pinMode(HX711_SCK, OUTPUT);	
	pinMode(HX711_DT, INPUT);
}


//****************************************************
//Get Weight No load
//****************************************************
void Get_OFFSET()
{
	HX711_Buffer = HX711_Read();
	Weight_OFFSET = HX711_Buffer;		
} 

//****************************************************
//Get Weight at Actual load
//****************************************************
unsigned int Get_Weight()
{
	HX711_Buffer = HX711_Read();
	HX711_Buffer = HX711_Buffer;

	Weight_Real = HX711_Buffer;
	Weight_Real = Weight_Real - Weight_OFFSET;				//Get AD sampling value in kind .
	
	Weight_Real = (unsigned int)((float)Weight_Real/7.35+0.05); 	
		// Calculate the actual physical weight
		// Because different sensor characteristic curve is not the same, so that each sensor and to correct the divisor 4.30 here
		// When they find out of the test weight is too large, increase the value.
		// If the test out of the weight is too small, decrease the value change .
		// This value is generally about 7.16 . Because different sensors may be.
		// +0.05 Percentile to rounding

	return Weight_Real;
}

//****************************************************
//Function for HX711 reading
//****************************************************
unsigned long HX711_Read(void)	//Gain 128
{
	unsigned long count; 
	unsigned char i;
	bool Flag = 0;

	digitalWrite(HX711_DT, HIGH);
	delayMicroseconds(1);

	digitalWrite(HX711_SCK, LOW);
	delayMicroseconds(1);

  	count=0; 
  	while(digitalRead(HX711_DT)); 
  	for(i=0;i<24;i++)
	{ 
	  	digitalWrite(HX711_SCK, HIGH); 
		delayMicroseconds(1);
	  	count=count<<1; 
		digitalWrite(HX711_SCK, LOW); 
		delayMicroseconds(1);
	  	if(digitalRead(HX711_DT))
			count++; 
	} 
 	digitalWrite(HX711_SCK, HIGH); 
	count ^= 0x800000;
	delayMicroseconds(1);
	digitalWrite(HX711_SCK, LOW); 
	delayMicroseconds(1);
	
	return(count);
}
 
Last edited:

I didnt used the full code just take the adc value only
 
Last edited:

Code:
M_Weight=(ADC_Value-8409088)*0.00793457031;

where did you get those values? please try Serial.print(ADC_Value) or even better Serial.print(ADC_Value>>8) and check the changes on the terminal...

the >>8 value should be enough filtering but maybe use >>7 or >>6 and post your results here...
 

Code:
M_Weight=(ADC_Value-8409088)*0.00793457031;

where did you get those values? please try Serial.print(ADC_Value) or even better Serial.print(ADC_Value>>8) and check the changes on the terminal...

the >>8 value should be enough filtering but maybe use >>7 or >>6 and post your results here...

Thank u friends i different results with Serial.print(ADC_Value>>8) with >>7 or >>6

Results:
ADC_Value>>8 = the value will be multiple of 16
ADC_Value>>7 = the value will be multiple of 32
ADC_Value>>6 = the value will be multiple of 64

iADC_Value>>12 = the value will be multiple of 1

- - - Updated - - -

As per my view i didnt get 24 bit value because i get result with multiple of 37.5 now like the values are 37,75,112,150 etc.If i use inbuild ADC like 10 bit 0 to 1023 values will come so for 40 kg loadcell 40000/1024= 39. So 10 bit ADC only give the values with multiple of 39 but here i used hx711 24 bit adc.Please correct my mistake in code or loadcell selection (loadcell is czl601,40 kg,precision 0.02)
 

ok, just remember, your HX711 gives you a 24 bit answer, but in my experience, from those 24 bits, only 16 or less are really useful, hence, the >>8 is to discard those noisy 8 lower bits...

even then with 16 bits you should attain a granularity of about 1 gram with a good 40kg load cell with a 2mV/V output, powered with 5V (and your HX711 also powered with 5V) are you sure you have a good load cell? are you sure you are using the Chanel A from the HX711 and not the chan.B?
 

ok, just remember, your HX711 gives you a 24 bit answer, but in my experience, from those 24 bits, only 16 or less are really useful, hence, the >>8 is to discard those noisy 8 lower bits...

even then with 16 bits you should attain a granularity of about 1 gram with a good 40kg load cell with a 2mV/V output, powered with 5V (and your HX711 also powered with 5V) are you sure you have a good load cell? are you sure you are using the Chanel A from the HX711 and not the chan.B?


Sorry i dont know about loadcell quality but I have mentioned as loadcell is czl601,40 kg,precision 0.02 in previous text.So please check that loadcell data sheet and give me your feedback otherwise please tell me any other good loadcell with 1 gram resolution.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top