overdischarge protection

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
gpson
Posts: 21
Joined: Sun Jul 31, 2016 6:55 am

Re: overdischarge protection

Post by gpson » Mon Mar 19, 2018 3:02 pm


User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: overdischarge protection

Post by dhylands » Mon Mar 19, 2018 3:46 pm

The stm constants are automatically generated from the CMSIS headers, and I'm going to guess that the CMSIS headers changed along the way.

I'm pretty sure that the new name for 'ADC' is now 'ADC123_COMMON'

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: overdischarge protection

Post by chuckbook » Mon Mar 19, 2018 6:06 pm

Assuming you are using a pyboard I would suggest the following as a first trial.

Code: Select all

import pyb
adc = pyb.ADCAll(12, 0x70000)
print('%.2f' % adc.read_vref())
This will give you the actual Vref which is the operation voltage of the MCU.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: overdischarge protection

Post by pythoncoder » Tue Mar 20, 2018 5:59 am

dhylands wrote:
Mon Mar 19, 2018 3:46 pm
...
I'm pretty sure that the new name for 'ADC' is now 'ADC123_COMMON'
I have a PR awaiting attention which extends the ADC functionality and replaces this outdated example code. At some point the firmware has improved so you can read individual channels without using ADCAll. And, as @chuckbook has pointed out, a mask parameter for the ADCAll object can also be used to modify its default of turning on all the ADC's.

So we now have two ways of reading voltage without needing the stm library. As so often happens the docs lag the code.
Peter Hinch
Index to my micropython libraries.

Post Reply