3
\$\begingroup\$

I chose to use an STM8L101F3P6 low power microcontroller for a sensor node. This microcontroller, however, lacks an ADC and instead implements 2 comparator units with a block diagram presented on its reference manual : comparator units on stm8l101

I was going to use the comparators and a combination of zeners/voltage-references to implement a basic battery level monitor. However to my surprise, the reference pin (the "-" pin) of comparators are not available on some packages as an IO, and instead, is permanently connected to ground; so basically, as much as I understand, the comparator is reduced to a crude digital pin which activates on a non-zero signal!

The funny note

And in the register description we can see: The external reference would be open

  1. Is there any option to use this ground-referenced comparators to measure battery level?
  2. Is there any benefit at all to use a comparator with one leg referenced to ground, and the other leg available only within positive voltage range?
\$\endgroup\$
5
  • \$\begingroup\$ Have you checked the manufacturer's product web page for application notes? This is the usual source of such information, beside the data sheet and the reference manual. What did they tell you about the usage? \$\endgroup\$ Nov 21, 2022 at 7:06
  • \$\begingroup\$ @thebusybee Yes I did, they have a note about making a software-backed ADC using these comparators, but only on packages with an available COMP_REF pin. couldn't find something about packages lacking COMP_REF. \$\endgroup\$ Nov 21, 2022 at 7:08
  • \$\begingroup\$ I'm sure there are some words why they optionally (or unconditionally) provide ground as reference. Is the other input capable of taking negative voltages? \$\endgroup\$ Nov 21, 2022 at 7:12
  • \$\begingroup\$ @thebusybee I've updated the question with a register description which mentions the IO would be open if the reference is internal \$\endgroup\$ Nov 21, 2022 at 9:12
  • 1
    \$\begingroup\$ input can take -0.25VSS which seems a bit short to have anything useful. Reference is indeed ground which is surprising. \$\endgroup\$
    – Damien
    Nov 21, 2022 at 9:52

1 Answer 1

1
\$\begingroup\$
  • Is there any option to use this ground-referenced comparators to measure battery level?
  • Is there any benefit at all to use a comparator with one leg referenced to ground, and the other leg available only within positive voltage range?

Lacking an ADC, it is possible to use this comparator to implement a slope-type ADC to measure voltage or current. A counter, is employed along with software to implement integrating ADCs: some microcontroller software resources will be required.

Comparing against ground adds some complication, since a reference voltage above ground in this particular case is not an option.
A negative-voltage reference could be used with a resistor divider so that the positive voltage can be measured with a ground-referenced comparator. A microcontroller charge-pump circuit can generate a negative reference. A very simple version of this employs an oscillating GPIO pin with diodes:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.