dangrie158 / opencushion

A c++ driver and a node binding for the HX711 Load Cell Amp
MIT License
14 stars 17 forks source link

read function #11

Open Swompet opened 4 years ago

Swompet commented 4 years ago

Hello, my values that I get are kind of inacurate. So I debuged the read function. This is the output: data: -459753 | data: -459702 | data: -459744 | data: 5307 | data: -459832 | sum read: -1833724 | Units : -4.040000 data: -459705 | data: -459789 | data: -459790 | data: 5421 | data: -459839 | sum read: -1833702 | Units : -4.040000 data: -459685 | data: -459687 | data: -459728 | data: -459731 | data: -459694 | sum read: -2298525 | Units : -0.000000 data: -459751 | data: -459752 | data: -459734 | data: -459759 | data: -459747 | sum read: -2298743 | Units : -0.000000

You can see that the data is kind of wrong sometimes. Also I noticed while printing that to my screen that there is a small delay when the data is wrong. Do you habe any idea how to fix that? thank you

dangrie158 commented 4 years ago

Hi, I'm currently not able to quickly test any changes, but I have a suspicion. could you please change Line 71 in hx711.cpp to:

read |= 0xFF000000UL;

then recompile the lib and try again? If it works I can issue a patch to help others with the same problem

Thanks!

Swompet commented 4 years ago

Hi,

i guess you mean "data |= 0xFF000000UL"?

dangrie158 commented 4 years ago

A, yeah sure! (y)

aqmattil commented 4 years ago

Hi,

I've encountered similar issues with getting some odd readings between 'correct' ones. For example, I'm getting quite stable readings between 1.25 and 1.35 (I think the actual values are not important here), and every now and then a reading of -8.78... What's odd is that the negative value is always the same (the value changes with different settings, but after initing the load cell the negative value doesn't seem to change). Fwiw, the 'spike' is always below the readings, never above.

I tested this with different load_cell_read_times (1 reading, 3 readings) and with different read_intervals (100 ms and 1000 ms) with same results.

I applied the patch mentioned above (data |= 0xFF000000UL), but it didn't solve this issue. It might've made the odd readings rarer (before the patch I sometimes got multiple negative values in a row), but I might be imagining this.

Is there anything else that I could try?