-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faster sampling rate #39
Comments
Yes! HX711 delivers 10 samples per second or 80 samples per second with less precision, depending on how the IC is implemented on the PCB. The typical small green HX711 breakout and Sparkfun's breakout are both configured for 10 SPS. However, this library is pretty inefficient and currently takes a lot of time to read the value once, around a second. I'm planning on improving that. |
Thanks for the quick reply. |
Any chance you could post your code?
…On Sat, Feb 27, 2021, 13:53 PAmerikanos ***@***.***> wrote:
Thanks for the quick reply.
Is there something I could do right now to improve this, like a small code
tweak, or is it only dependent on the IC?
I'd be happy even with just 2sps.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#39 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVNTWNSU7HOFTJSO4QA54TTBEPR5ANCNFSM4YJVFI7A>
.
|
I'm just running the example.py script. |
Thanks for your code bundling up, Tatobari. Hope it helps |
Hi all, thanks for your time. |
Thanks for posting it. I used this code on Rpi-Zero. It also happens for some spikes and noise. The median filter applied can filter out most of them though. |
Hi! I was wondering if anyone succeded in increasing the reading speed for one sample! :) |
I'm not sure I understand? |
I just read that this library is not super efficient when it comes to make the measurement from the pins connected to the HX711 sensor, thus I was wondering if someone succeeded in enhancing the performance. |
Sample RateHX711 sample rate will depend on how the IC is implemented on the board. According to the datasheet, pin 15 must be HIGH for 80 SPS (samples per second, aka, Hz), otherwise the rate is 10 SPS. Library PerformanceIt should work pretty fast, not having problems achieve 10 SPS (not sure with 80 SPS because there are a few unnecessary It's been a while since I last tested this library. I did it for a prototype and them moved to Arduino. But I will test and get back to you. |
I've bought a PI 4 B 8GB (amazing device) and tested the code. Well, yes, the library is pretty inefficient because the implementation is not quite the best. Long story short, I only managed to improve it to make two or three readings per second, but that's not a lot. The modifications I made to my local copy of the code were:
There are two factors that add time to the value reading. First of all, Raspberry is a full CPU and the code runs on Python, on Linux, which is not quite the best option for real-time applications such as this one because the multitask functionalities and garbage collectors might make use of the CPU at anytime, postponing the tasks the code is running. For realtime and really fast applications, and Arduino or any other MCU is probably the best option. But, my guess is that the factor that most contributes to the long reading time is that the HX711 makes you wait while it reads the value. Very briefly, the HX711 holds the I had the same problem on Arduino and I solved it by using interruptions and it worked like a charm, extremely fast at 10SPS. 80SPS is way more than necessary and reduces the precision. The interruptions based implementation can also be done on Raspberry and Python. The implementation should be such that everytime the I might work on it but I'm not sure if I can. Got a new job with a lot to learn and I barely managed to quickly write this comment while having lunch. Anyone interested in submitting a PR with this implementation will be welcomed. |
Hi all, Thanks for your contribution to this repo, Tatobari. I cannot agree more with your analysis, as it is exactly the same as what I found. I recently modified and applied the code in my project from pigpio. They used an interrupt method to detect the DOUT pin and read the values. It works like a charm.... I can create a pull request when available. But it should be very easy to keep it work with the same interface you defined. You can probably have a trial yourself. Thanks, Chen |
Tatobari, thank you for the great analysis. |
@caseypen thanks! Gonna take a look at your implementation. |
Hello,
Is there a way to make it sample data faster than ~1Hz?
Thanks
The text was updated successfully, but these errors were encountered: