i have been playing around with some 50kg load cells ( bathroom scale type ) X4 wired together and the well known HX711 module.
i have managed to get data out from the module, thanks to code provide from one of our other forum members here, and get it to display on an SSD1306 0.96" i2c display but from where to go in terms of turning that basic data into a usable meaningful number of weight is where im now stuck.
after countless google searches that mostly only ever yield arduino results that use floats and negative offsets or fractional negative numbers ect, none of it makes any sense regardless.
if i send the data to the i2c oled then i get numbers that do change value with weight difference but the value decreases to underflow or vice versa, and if i output the data to terminal via usart then i get random numbers that seem to not make much more sense.
how do i go about making use of the data from the module and converting it so i can weigh things lol.
Not seen this sensor. But...to interface with the HX711 using integer maths, you may need to use the following steps:
Set the gain of the amplifier. The gain can be set to 128 or 64.
Configure the ADC. The ADC can be configured to work in single-shot or continuous mode.
Read the ADC value. The ADC value will be a 24-bit number.
Convert the ADC value to weight. The weight can be calculated using the following formula:
weight = (ADC_value * gain) / 1024
For example, if the ADC value is 1000 and the gain is 128, then the weight will be 1000 grams.
Here is an example of how to interface with the HX711 using integer maths:
// Set the gain of the amplifierHX711setGain(128);// Configure the ADCHX711setMode(CONTINUOUS)// Read the ADC valueadc_value=ReadADC(ANn)// Convert the ADC value to weight// SysCalcTempX contains the remainder. weight=(adc_value*128)/1024
And, looking are you code. Is the TwoCompliment correct? I would use.
functionTwoCompliment( in RawWordValue as long )asInteger' Is this a negative value? 'XORwith65535andaddonetoget2'scomplimentIfRawWordValue.15=1thenRawWordValue=(RawWordValueXOR65535)+1'convert twos complement to decimal by xor'ingwith65535andadding1TwoCompliment=0-RawWordValueelseTwoCompliment=RawWordValueendifendfunction
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks for the response, honestly im not sure about the 2's compliment as ive not used it before and had to rely on found code more or less just to get started but i have data of sorts being retrieved to start with lol.
im just lost on how the data should be converted, i know you gave a pseudo example however i dont have to get the data via adc just clocking out the 24bits that the hx711 adc processed.
the HX711 combines a PGA IN-AMP to boost the low mv then feeds it to the 24bit adc which as the datasheet says sends out in 2's compliment format as a 24bit result MSB first.
i have added the datasheet in case it is more usefull, sorry i should have added that last night as well.
ok ill give that a whirl, but from reading the datasheet i assume it is needed to tell the module what the gain is desired for the next conversion, i will let you know.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Shift 25 bits in the Long. That should give a gain of 128. Then, delete the extra clock.
Because at the moment you are shifting 24bits, bit of a clock rest then an extra clock. I know this give 25 clocks but the I think you need 25bits out.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
well not much difference really, i still get data out of it that varies when load is placed removed.
all i know is the adc outputs the data in 2's complement, but as to how i can go about being able to convert that into a meaningful value of pounds or kiligrams is the part that i cant get any real insight to.
i have tried to make sense from all the info out their but im still not sure as to how i convert the data and thats where im stuck so far.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi everyone,
i have been playing around with some 50kg load cells ( bathroom scale type ) X4 wired together and the well known HX711 module.
i have managed to get data out from the module, thanks to code provide from one of our other forum members here, and get it to display on an SSD1306 0.96" i2c display but from where to go in terms of turning that basic data into a usable meaningful number of weight is where im now stuck.
after countless google searches that mostly only ever yield arduino results that use floats and negative offsets or fractional negative numbers ect, none of it makes any sense regardless.
if i send the data to the i2c oled then i get numbers that do change value with weight difference but the value decreases to underflow or vice versa, and if i output the data to terminal via usart then i get random numbers that seem to not make much more sense.
how do i go about making use of the data from the module and converting it so i can weigh things lol.
thanks
tony
Not seen this sensor. But...to interface with the HX711 using integer maths, you may need to use the following steps:
Read the ADC value. The ADC value will be a 24-bit number.
weight = (ADC_value * gain) / 1024
For example, if the ADC value is 1000 and the gain is 128, then the weight will be 1000 grams.
Here is an example of how to interface with the HX711 using integer maths:
And, looking are you code. Is the TwoCompliment correct? I would use.
hi anobium,
thanks for the response, honestly im not sure about the 2's compliment as ive not used it before and had to rely on found code more or less just to get started but i have data of sorts being retrieved to start with lol.
im just lost on how the data should be converted, i know you gave a pseudo example however i dont have to get the data via adc just clocking out the 24bits that the hx711 adc processed.
the HX711 combines a PGA IN-AMP to boost the low mv then feeds it to the 24bit adc which as the datasheet says sends out in 2's compliment format as a 24bit result MSB first.
i have added the datasheet in case it is more usefull, sorry i should have added that last night as well.
What happens when you remove the last clock?
Comment out this code.
The goal ( I think ) is just to get stability in the read operation. So, I think the extra clock is confusing the device.
ok ill give that a whirl, but from reading the datasheet i assume it is needed to tell the module what the gain is desired for the next conversion, i will let you know.
No... ignore that.. sort of .
Shift 25 bits in the Long. That should give a gain of 128. Then, delete the extra clock.
Because at the moment you are shifting 24bits, bit of a clock rest then an extra clock. I know this give 25 clocks but the I think you need 25bits out.
well not much difference really, i still get data out of it that varies when load is placed removed.
all i know is the adc outputs the data in 2's complement, but as to how i can go about being able to convert that into a meaningful value of pounds or kiligrams is the part that i cant get any real insight to.
i have tried to make sense from all the info out their but im still not sure as to how i convert the data and thats where im stuck so far.
So, at the moment you are not getting a consistent value from the sensor ?
I would not worry about data conversion yet. I would want to see the the same set of data being returned consistently.