Skip to content
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

Use async non-blocking for ADS measurements #77

Open
taesungh opened this issue May 25, 2024 · 0 comments
Open

Use async non-blocking for ADS measurements #77

taesungh opened this issue May 25, 2024 · 0 comments
Assignees

Comments

@taesungh
Copy link
Member

Following from #34/#62 and #37/#47, we used nb::block to acquire readings from the ADS1015 units used in LimCurrent and LimTemperature (which we'll have two of). This is because the ADS measurement takes three steps:

  1. Set the channel configuration and start the measurement
  2. Wait for the unit to report the conversion is complete
  3. Read the result of the conversion register

However, the blocking macro will require the FSM to wait for measurements sequentially from all three units which may take a notable amount of time. In practice, we would want to measure the three units concurrently to avoid busy waiting.

  • Implement an async version of the blocking macro to allow other tasks to run while waiting for ADS measurement
    • Await a small amount of async sleep in between loops
    • Consider an exponential backoff approach
    • Use this macro instead of nb::block in LimTemperature::read_lim_temps and LimCurrent::read_currents
  • Include a synchronization primitive (e.g. tokio::sync::Mutex) to prevent more than one pin measurement (of a single unit) from running at the same time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants