hi Bogde,
Thank you for your HX711 library code. I used it on HX711 and it worked well.
I tried to used same on another MCU.
I observed that the values returned by Read() on Arduino is significantly different from that on another board (NRF52832) though the HX711 module and the loadcell is the same. Yes, have used 3.3v in both.
Following are the sample values returned by Read() as recorded on each. Please share your opinion on what maybe going wrong. I have also pasted the code of long HX711::read() below. I have modified it to use bit operations than nested for loop to form the 24 bit value. Kindly check.
As recorded on Arduino:
HXvLOG:HX711Read():RetVal 8315205
HXvLOG:HX711Read():RetVal 8315038
HXvLOG:HX711Read():RetVal 8314981
HXvLOG:HX711Read():RetVal 8315190
HXvLOG:HX711Read():RetVal 8315342
HXvLOG:HX711Read():RetVal 8315221
HXvLOG:HX711Read():RetVal 8315107
HXvLOG:HX711Read():RetVal 8314698
HXvLOG:HX711Read():RetVal 8315440
HXvLOG:HX711Read():RetVal 8315588
As recorded on other board(NRF52832)
HXvLOG:HX711Read():RetVal 16746359
HXvLOG:HX711Read():RetVal 16746363
HXvLOG:HX711Read():RetVal 16746310
HXvLOG:HX711Read():RetVal 16746301
HXvLOG:HX711Read():RetVal 16746294
HXvLOG:HX711Read():RetVal 16746298
HXvLOG:HX711Read():RetVal 16746318
HXvLOG:HX711Read():RetVal 16746303
HXvLOG:HX711Read():RetVal 16746311
HXvLOG:HX711Read():RetVal 16746311
Following is the source code -->
long HX711::read() {
byte readVal=0;
long retVal=0;
// wait for the chip to become ready
while (!is_ready())
{
}
for (int j = 23; j >= 0; j--)
{
digitalWrite(PD_SCK, HIGH);
readVal=digitalRead(DOUT);
digitalWrite(PD_SCK, LOW);
retVal |= readVal & 0x01;
retVal = retVal << (1 && j);
}
for (int i = 0; i < GAIN; i++)
{
digitalWrite(PD_SCK,HIGH);
digitalWrite(PD_SCK,LOW);
}
retVal^=0x800000;
//Serial.print(F("HXvLOG:HX711Read():RetVal %d Diff %d\n",retVal, (retVal-pHX711State->OFFSET));
Serial.print(F("HXvLOG:HX711Read():RetVal "));
Serial.print(retVal);
Serial.print(F(" Diff "));
Serial.println((retVal-OFFSET));
return retVal;
}
hi Bogde,
Thank you for your HX711 library code. I used it on HX711 and it worked well.
I tried to used same on another MCU.
I observed that the values returned by Read() on Arduino is significantly different from that on another board (NRF52832) though the HX711 module and the loadcell is the same. Yes, have used 3.3v in both.
Following are the sample values returned by Read() as recorded on each. Please share your opinion on what maybe going wrong. I have also pasted the code of long HX711::read() below. I have modified it to use bit operations than nested for loop to form the 24 bit value. Kindly check.
As recorded on Arduino:
HXvLOG:HX711Read():RetVal 8315205
HXvLOG:HX711Read():RetVal 8315038
HXvLOG:HX711Read():RetVal 8314981
HXvLOG:HX711Read():RetVal 8315190
HXvLOG:HX711Read():RetVal 8315342
HXvLOG:HX711Read():RetVal 8315221
HXvLOG:HX711Read():RetVal 8315107
HXvLOG:HX711Read():RetVal 8314698
HXvLOG:HX711Read():RetVal 8315440
HXvLOG:HX711Read():RetVal 8315588
As recorded on other board(NRF52832)
HXvLOG:HX711Read():RetVal 16746359
HXvLOG:HX711Read():RetVal 16746363
HXvLOG:HX711Read():RetVal 16746310
HXvLOG:HX711Read():RetVal 16746301
HXvLOG:HX711Read():RetVal 16746294
HXvLOG:HX711Read():RetVal 16746298
HXvLOG:HX711Read():RetVal 16746318
HXvLOG:HX711Read():RetVal 16746303
HXvLOG:HX711Read():RetVal 16746311
HXvLOG:HX711Read():RetVal 16746311
Following is the source code -->
long HX711::read() {
}