background image

AN3248

Analog voltage monitoring

Doc ID 17758 Rev 1

5/19

Analog voltage monitoring

The STM32L15xxx embeds a 12-bit analog-to-digital converter (ADC) which is very fast with 
a sampling rate of 1 Msample/s. However, with a 1.45 mA typical consumption, it can 
jeopardize battery life time if left powered-on continuously. It is therefore recommended to 
use analog comparators in application cases when analog input voltage (sensor output) 
needs to be measured as soon as a pre-defined threshold is exceeded. In STM32L15xxx 
devices, analog comparators are useful for monitoring the analog input voltage and 
powering on the ADC when it is required. While monitoring the analog voltage, the device 
can enter Stop mode at the same time that both comparators are still powered on. 
Consequently, better consumption is achieved and power is saved. 

Note:

Analog comparators are powered by the internal reference voltage, V

REFINT

, which is still 

powered on in Stop mode, and can be disabled by configuration. Once V

REFINT

 is disabled, 

the comparators can no longer be used.

In an analog voltage monitoring application, where the sensor output voltage is lower than 
the threshold, the MCU remains in Stop mode thereby saving power. As soon as the sensor 
output exceeds the threshold, the MCU is woken up, the ADC is powered on, and the analog 
input voltage is measured. When the sensor output is under the threshold, the MCU re-
enters Stop mode.

Average power consumption is dramatically reduced when compared with an application 
that continuously measures the analog voltage whatever the input value.

Figure 1

 shows how to connect a sensor output (temperature sensor, pressure sensor, 

pyroelectric infrared detector, photodiode sensor) to an STM32L15xxx device in an analog 
voltage monitoring application using comparator 2 (COMP2). COMP2 monitors the analog 
voltage in Stop mode while the ADC measures it in Run mode.

Figure 1.

Sensor output connection to COMP2

1.

Legend for 

Figure 1

ADC_CHx: AC channel x
COMP2_INP: comparator 2 non-inverting input

2.

Only if required.

!NALOGVOLTAGE

3ENSOR

!MPLIFIER

 

&ILTER

 

!$##(X
#/-0).0

34-,XXX

AI

Содержание AN3248

Страница 1: ...ent resistor LDR The six application cases demonstrate the usefulness of analog comparators and show how they are integrated with other peripherals for example the digital to analog converter DAC and...

Страница 2: ...Introduction 1 1 Analog voltage monitoring 5 2 Analog watchdog during Stop mode 8 3 Pulse width measurement 10 4 PWM signal control 12 5 Capacitance measurement 13 6 Brightness control using a light...

Страница 3: ...AN3248 List of tables Doc ID 17758 Rev 1 3 19 List of tables Table 1 Document revision history 18...

Страница 4: ...ned in window mode 8 Figure 6 Analog watchdog during stop mode 9 Figure 7 COMP2 with output redirection feature 10 Figure 8 Pulse width measurement COMP2 output redirection to timer 11 Figure 9 PWM si...

Страница 5: ...op mode and can be disabled by configuration Once VREFINT is disabled the comparators can no longer be used In an analog voltage monitoring application where the sensor output voltage is lower than th...

Страница 6: ...utput connection to COMP1 1 Legend for Figure 2 COMP1_INP ADC CHx comparator 1 non inverting input shared with ADC channel x 2 Only if required Figure 3 shows the gain in power consumption in an analo...

Страница 7: ...nd non inverting inputs Figure 4 COMP2 configuration 1 Legend for Figure 4 DAC_OUT1 DAC channel 1 output DAC_OUT2 DAC channel 2 output VREFINT Internal reference voltage CMP2OUT Comparator 2 output in...

Страница 8: ...U is stopped Consequently lower consumption is achieved and power is saved Figure 5 displays the configuration of two such analog comparators in window mode Threshold1 is set to the internal reference...

Страница 9: ...witching to Run mode Figure 6 gives an overview of an analog watchdog application with threshold1 higher than threshold2 Figure 6 Analog watchdog during stop mode 1 While the MCU is in Stop mode the i...

Страница 10: ...ve the timer counter at both rising and falling edges When the input signal goes above the reference voltage COMP2 output is at a high level generating a rising edge on the timer input capture When th...

Страница 11: ...timers Note Signal frequency can be achieved by configuring the timer input capture channel to save the counter value on only a rising or falling edge Note DAC outputs DAC_OUT1 or DAC_OUT2 can be used...

Страница 12: ...on inverting input In this situation the reference voltage is connected to the COMP2 inverting input When the current sensor output exceeds the selected threshold the COMP2 output goes high and the PW...

Страница 13: ...sists of charging and discharging the capacitor through the resistor The charge discharge function follows an exponential curve The charge function is given by Example 1 Example 1 where VDD is the pos...

Страница 14: ...uation 1 Equation 1 where tc is the time when the input voltage crosses the threshold Using Equation 1 the capacitance value can be computed by Equation 2 Equation 2 Usually R the threshold and VDD ar...

Страница 15: ...AN3248 Capacitance measurement Doc ID 17758 Rev 1 15 19 Equation 3 where K is solved using Equation 4 Equation 4 C t K K R 1 threshold VDD ln...

Страница 16: ...can be connected to an LDR resistor through a voltage divider VIN The threshold can be set externally to PB3 or set internally to VREFINT 3 4 VREFINT 1 2 VREFINT or 1 4 VREFINT The COMP2 output CMP2O...

Страница 17: ...he CMP2OUT level switch from a high level to a low level or vice versa Figure 13 Comparator output behavior versus light intensity The LDR resistor can be used in other microcontroller based applicati...

Страница 18: ...Revision history AN3248 18 19 Doc ID 17758 Rev 1 7 Revision history Table 1 Document revision history Date Revision Changes 10 Jan 2011 1 Initial release...

Страница 19: ...ARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLE...

Отзывы: