i have the load cell of 100kg i have a ADC NAU7802. i have to calculate weight through this ADC. can anyone have idea how to convert ADC value to weight.
void initialize_7802(void) { unsigned char xdata Byte=0x00,temp;
/* Send Reset command into NAU7802 */ i2c_device_write1(0x54,0x00,0x01);
delayms(1000);
/* Enable PUD to power on the chip digital logic */ i2c_device_write1(0x54,0x00,0x02);
do { temp=i2c_device_read1(0x54,0x00); }while((temp&(1<<3))==0); delayms(20);
/* Enable PUA and AVDDS to support analog power, and enable CS to start ADC conversion */ i2c_device_write1(0x54,0x00,0x96);
/* Set the LDO output to 4.5V; PGA to 128x to 1X*/ i2c_device_write1(0x54,0x01,0x00);
/* Turn off the chopper function */ i2c_device_write1(0x54,0x15,0x30);
/* Enable the Cfilter for high PGA gain (> 4) */ i2c_device_write1(0x54,0x1c,0x80);
/* Disable the Cfilter for low PGA gain */ //i2c_device_write1(0x54,0x1c,0x00);
/* External Calibration: Force the current conversion data to be around zero*/ i2c_device_write1(0x54,0x02,0x06); //optional
delayms(1000); /* i2c control registor*/ i2c_device_write1(0x54,0x11,0x30);
delayms(1000); } ///////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
unsigned long int adc_data2() { unsigned char xdata buff1,buf1[15]; unsigned long int adc_data;
do { buff1=i2c_device_read1(0x54,0x00);
}while((buff1&(1<<5))==0);
adc_data=0; memset(&buf1[0],0,8); buff1=0; buff1=i2c_device_read1(0x54,0x12);
adc_data=adc_data|buff1; adc_data=(adc_data<<8);
buff1=0; buff1=i2c_device_read1(0x54,0x13);
adc_data=adc_data|buff1;
adc_data=(adc_data<<8);
buff1=0; buff1=i2c_device_read1(0x54,0x14);
return adc_data; }
now give me calculation of weight when i get adc_data
if you add 8 more bits you will get 32 bit precision. but will they fit into the processor? it can be too much weight.
weight = unsigned long int adc_data2() * 1478 / 29;
"if you add 8 more bits you will get 32 bit precision."
Why not fix a 64-bit integer variable and suddenly have 64 bits of precision?
Do you understand the meaning of precision? The quality of the measurements will not improve just because a processor with support for wider integers is used.