Skip to content

Measure voltage supplied to chip #2213

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

Merged
merged 4 commits into from
Oct 15, 2019
Merged

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Oct 12, 2019

Add microprocessor.cpu.voltage to measure the regulated voltage supplied to the chip. Monitoring of this value can detect when the regulated voltage is slumping due to a low battery.

This is typically 3.3V. Note that this does not measure the actual on-chip voltage used to urn the CPU, which is often lower due to an on-chip regulator (e.g., 1.2V).

Note that we also already have brownout-detection enabled, but that simply prevents causes a reset or makes the chip refuse to start. This can catch eventual brownout in advance, before the battery gets much too low.

I use the on-chip bandgap reference and compare it with a scaled version of the supplied voltage. The SAMD51 is very touchy about how to use this reference. See https://community.atmel.com/forum/samd51-using-intref-adc-voltage-reference.

  • I did some code cleanup in the atmel-same Processor.c as well, to remove some confusion I introduced about ADC channels vs MUXPOS choices.
  • The nRF chips have a simple way to calibrate the ADC, which is recommended on startup. I added this.
  • I attempted to use the INTREF for the temperature measurement as well, based on new info about using it for the voltage, but this still does not work.

Tested using a variable bench power supply. The SAMD chips can clearly measure sag. On the nRF52840, I lost the USB connection very early when testing sag, but it still seems to work.

@dhalbert dhalbert requested review from tannewt and ladyada October 12, 2019 19:56
@ladyada
Copy link
Member

ladyada commented Oct 12, 2019

yay! ill check next week i think

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Neat! One question but looks good otherwise

@dhalbert
Copy link
Collaborator Author

@tannewt all updated to handle recent PR's

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Great! Looks good. Thanks!

@tannewt tannewt merged commit b80048b into adafruit:master Oct 15, 2019
@dhalbert dhalbert deleted the cpu-voltage branch October 15, 2019 16:50
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