Giter Club home page Giter Club logo

Comments (5)

techman83 avatar techman83 commented on August 11, 2024

Interesting, I wonder what it should be? I'd like to refactor a bunch of this to make it a bit easier to add test cases.

from filament-scale-enhanced.

ali1234 avatar ali1234 commented on August 11, 2024

I just noticed that this is trying to sleep 10 usec, so it won't behave differently in 2 vs 3. It will sleep 60+ usec on both however. It isn't really possible to sleep less than that in Python - time.sleep(0) returns "instantly" and the delay is just due to Python being not very fast.

HX711 datasheet says the minimum clock time is 0.2 usec, so just calling time.sleep(0) (or basically any Python function) should be long enough. However leaving the current sleep won't hurt, as long as you never change it to sleep while the clock is high.

Here is the relevant cpython code from 2.7:

https://github.com/python/cpython/blob/v2.7.18/Modules/timemodule.c#L1041-L1044

The number of microseconds is converted to a long, so it has to be equal or greater than 1 usec.

In modern Python it is rounded up instead of down: https://github.com/python/cpython/blob/main/Modules/timemodule.c#L2072

from filament-scale-enhanced.

techman83 avatar techman83 commented on August 11, 2024

I've never had to really care that much about tight timing, so that's really neat. Though I note that python can't time down to the microsecond level, at best it'll be in the realm of millisecond accuracy. And I'm guessing we're talking about the output settling time here, which has 2 values:

time (ms)
RATE = 0 400
RATE = DVDD 50

So we're either not waiting long enough or really not waiting long enough. It's probably largely academic at this point, but I might change it to ensure that it's actually doing what is intended.

from filament-scale-enhanced.

ali1234 avatar ali1234 commented on August 11, 2024

I hadn't considered the effect of the settling time, although that only applies when the chip is powered down. Sleeping for 50 to 400 milliseconds is not a problem though.

The tricky one is the PD_CLK timing (page 5, T3 and T4) - measured in microseconds not milliseconds.

from filament-scale-enhanced.

techman83 avatar techman83 commented on August 11, 2024

Yeah, likely an academic problem at this point. It works as is, so I'm inclined to leave it for now.

from filament-scale-enhanced.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.