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

hc_sr04: Improve accuracy by measuring microseconds #367

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

clashlab
Copy link
Contributor

@clashlab clashlab commented Feb 27, 2023

What's new

  • The furi_get_tick() function has millisecond granularity. This commit changes it to the CYCCNT counter that achieves microsecond granularity when combined with furi_hal_cortex_instructions_per_microsecond().
  • Instead of measuring by 17 cm steps (1ms = 17.2cm), we now have 0.017 cm steps.
  • Also improve speed of sound equation to show temperature and humidity variations (now using 20°C/68°F and 50% relative humidity)

Verification

  • Plug a HC-SR04 module to the gpio
  • Launch the [HC-SR] Dist. Sensor application
  • Press OK multiple times while moving away from a surface
  • The "Echo:" is given in microseconds (us)
  • The "Distance:" increases smoothly

Checklist (For Reviewer)

  • PR has description of feature/bug
  • Description contains actions to verify feature/bugfix
  • I've built this code, uploaded it to the device and verified feature/bugfix

Copy link
Member

@xMasterX xMasterX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@xMasterX xMasterX merged commit caa4ba6 into DarkFlippers:dev Feb 28, 2023
@Corinato

This comment was marked as spam.

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

Successfully merging this pull request may close these issues.

3 participants