3

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?
Tirdad Sadri Nejad
  • 1,735
  • 1
  • 9
  • 17
  • 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? – the busybee Nov 21 '22 at 07:06
  • @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. – Tirdad Sadri Nejad Nov 21 '22 at 07:08
  • 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? – the busybee Nov 21 '22 at 07:12
  • @thebusybee I've updated the question with a register description which mentions the IO would be open if the reference is internal – Tirdad Sadri Nejad Nov 21 '22 at 09:12
  • 1
    input can take -0.25VSS which seems a bit short to have anything useful. Reference is indeed ground which is surprising. – Damien Nov 21 '22 at 09:52

1 Answers1

1
  • 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

glen_geek
  • 23,591
  • 1
  • 22
  • 50