Skip to content

Conversation

@briangow
Copy link
Contributor

As pointed out by @tcpan in #515 there was a mistake in one of the formula's for calculating ADC gain. The calculation needs to compute the digital range first before mapping the physical range.

@briangow briangow force-pushed the bg_fix_gain_formula branch from 66f7411 to 4cc0267 Compare December 15, 2025 15:18
@tompollard tompollard changed the title Fix ADC gain forumla Fix ADC gain formula Jan 6, 2026
@tompollard
Copy link
Member

@briangow could you add a test for this?

@briangow briangow force-pushed the bg_fix_gain_formula branch from 7d1dbbe to 8c005b5 Compare January 6, 2026 18:38
@briangow
Copy link
Contributor Author

briangow commented Jan 6, 2026

@tompollard , I've added tests of the gain calculation for when the baseline exceeds the boundary. For each boundary (MAX_I32 and MIN_I32) the test:

  • creates a signal which will trigger the boundary overflow
  • checks that we enter the logic for adjusting the gain and baseline
  • verifies that a round-trip test of writing and reading produces the expected result within some tolerance
  • makes sure the ADC gain formula produces the expected result

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