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

sx127x: Use integer math for freq / pll_step calculations #285

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

plaes
Copy link
Collaborator

@plaes plaes commented Sep 3, 2024

No need to use floats, integer freq -> pll_step conversion is good enough when dealing with full megahertz calculations.

This switches frequency <-> pll step calculations to integer math in sx127x driver. (Issue #282)

See also:
Lora-net/SWL2001#87

@lucasgranberg
Copy link
Collaborator

Great work, I love the tests. Do you know how far off these calculations are for 0.1Mhz steps? What is an acceptable error? I would love to see some calculations on this. I can try to do some tonight.

@plaes
Copy link
Collaborator Author

plaes commented Sep 3, 2024

With current formula the conversion is same for each full and half megahertz step:
859.5, 860, 860.5, 861, 861.5..

And even if I add additional (STEP_SCALED >> 1) / STEP_SCALED, it doesn't improve accuracy.

lucasgranberg
lucasgranberg previously approved these changes Sep 3, 2024
Copy link
Collaborator

@lucasgranberg lucasgranberg left a comment

Choose a reason for hiding this comment

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

Sounds good enough for me, thanks!

lthiery
lthiery previously approved these changes Sep 3, 2024
No need to use floats, integer freq -> pll_step conversion is
good enough when dealing with full megahertz calculations.
@plaes plaes dismissed stale reviews from lthiery and lucasgranberg via fc5c8c7 September 3, 2024 18:58
@plaes plaes force-pushed the sx127x-freq-floats branch from fc59f3d to fc5c8c7 Compare September 3, 2024 18:58
@plaes plaes merged commit 969ee24 into lora-rs:main Sep 4, 2024
2 checks passed
@plaes plaes deleted the sx127x-freq-floats branch September 4, 2024 15:18
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