Home

How to design a simple temperature measurement application using

image

Contents

1. wa AN3964 Sf Application note How to design a simple temperature measurement application using the STM32L DISCOVERY 1 1 Introduction This application note describes a method of implementing a simple application for temperature measurement using the STM32L DISCOVERY The solution described in this document uses the integrated temperature sensor of the STM32L1 microcontroller The factory or user calibration method is described to improve the accuracy of the temperature sensor The demonstration application does not require any additional hardware Once the STM32L DISCOVERY board is updated with the associated firmware and is powered up through a USB cable connected to the host PC the application is ready to display the temperature of the STM32L1 microcontroller Reference documents m STM32L DISCOVERY user manual UM1079 m STM32L DISCOVERY Application note Current consumption measurement and touch sensing demonstration AN3413 m STM32L151xx and STM32L152xx Flash and EEPROM programming PM0062 m STM32L151xx and STM32L152xx Ultralow power ARM based 32 bit MCU with up to 128 Kbytes of Flash memory RTC LCD USB USART I2C SPI timers ADC DAC comparators datasheet The above documents are available at http www st com September 2011 Doc ID 022101 Rev 1 1 12 www st com www BDTIC com ST Contents AN3964 Contents 1 Introduction na sant ae tn i a Sia at ht i 1 1 1 Reference documents 0 0
2. The Ipp jumper JP1 must be placed in the ON position Both jumpers on CN3 must be fitted to enable communication between the STM32L microcontroller and the ST Link debugging tool through the serial wire debug SWD interface All solder bridges must be in their default state as described in UM1079 Using the demonstration application It is very easy to start using the demonstration firmware When powered up the temperature sensor application example first displays a welcome message before immediately displaying the current temperature in degrees Celsius with a 2 second refresh rate When the User button is pressed once the display shows the mean value of an array of 16 samples acquired by the ADC One more press of the User button toggles between displaying the current temperature in degrees Celsius or the averaged value The averaged value can be used later as a calibration point with a known temperature to improve overall accuracy of the temperature measurements Temperature sensor calibration The temperature sensor calibration data are stored during the manufacturing process in the protected memory area from where the user can read it and use it to improve the accuracy of the temperature measurements The two point calibration data is measured during production at ambient temperature 25 C 5 C which is stored at address 0x1FF8007A and at hot temperature 110 C 5 C which is stored at address 0x1FF8007E The temperature se
3. Schmitt triggers on unused standard I O pins are disabled to reduce power consumption LCD controller The several functions available in the firmware library for the liquid crystal display LCD are used to initialize clear display strings and scroll messages needed in the application code Clocks The high speed internal HSI RC oscillator is selected as the main clock source The application manages the peripheral clocks depending on the selected powersaving mode When the device enters Stop mode the multi speed internal MSI RC oscillator is switched OFF and the low speed external crystal LSE acts as the clock source until the device is woken up by an external event When exiting Low Power Run mode the MCU switches the MSI oscillator back ON The LSE is only switched ON during Manufacturing Test mode to check its functionality ky Doc ID 022101 Rev 1 9 12 www BDTIC com ST Conclusion AN3964 4 2 STM32L15x standard firmware library configuration The stm32 xx_conf h file of the STM32L standard firmware library allows you to configure the library by enabling the peripheral functions used by the application The header files of the library modules are included in the stm32 N xx_conf h file as listed below include stm32I1xx_adc h include stm32I1xx_exti h include stm32I1xx_flash h include stm32l1xx_gpio h include stm32l1xx_syscfg h include stm32I1xx_lIcd h include stm32I1xx_pwr h include stm32I1xx_rcc h
4. 00 e cece eee eee 1 2 Application overview 0 20 c eee ee 3 2 1 Temperature Sensor 2 ccc ec hcwt anew nee pages aa eee bee dep nawee ae 3 2 2 Temperature measurement and data processing 005 3 2 3 Application example description 00 0 ee 4 3 Getting started 2 cl tab bin apa gn A mB ch 6 3 1 Setting up the board es ansinee heehee ee Nene Eee Gene eee ReE DR 6 3 2 Using the demonstration application 00 0 e ee ee eee 6 3 2 1 Temperature sensor calibration 000 cece eee 6 3 3 Estimation of temperature sensor engineering tolerance 8 4 Software description 000 c cece ee eee eee 9 4 1 STM32L peripherals used by the application 000005 9 4 2 STM32L15x standard firmware library configuration 10 5 CONCIUSION iss sreo ndas a a E aT eee hee ee el aa 10 6 Revision history cis scene idee eke da eet eee ewes Sees 11 2 12 Doc ID 022101 Rev 1 ky www BDTIC com ST AN3964 Application overview 2 2 1 Note 2 2 Application overview This section describes how the temperature sensor works and its measurements performed by the STM32L1 microcontroller embedded on the STM32L DISCOVERY board A brief description of how the example temperature measurement application was implemented follows afterwards Temperature sensor The temperature sensor integrated in
5. and or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2011 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 12 12 Doc ID 022101 Rev 1 ky www BDTIC com ST
6. ces described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES 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 UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements
7. er the CPU is switched to Stop mode with the RTC real time clock wake up set to 2 seconds within the time interval between temperature sensor data measurements The ADC data acquisition and data transfers are managed by direct memory access DMA while the CPU is in Low power Sleep mode The CPU is in Run mode at 16 MHz based on the HSI oscillator clock only during the initialization phase and during the data processing period Doc ID 022101 Rev 1 ky www BDTIC com ST AN3964 Application overview Figure 1 Example LCD display R26 R27 MB963 B D VBAT D 97256187447 D 59390 x 4 Doc ID 022101 Rev 1 5 12 www BDTIC com ST Getting started AN3964 3 3 1 Note 3 2 3 2 1 6 12 Getting started Before getting started the firmware must be updated and hardware configured as described in the following sections Setting up the board Updating the firmware The STM32L program memory needs to be updated with the firmware associated with this application note For information on how to update the firmware please read the readme txt file in the project folder Used hardware components This application example uses the hardware components available on the STM32L DISCOVERY board the embedded peripherals of the STM32L microcontroller the 6 digit LCD glass display and the user push button No additional components are required STM32L DISCOVERY hardware settings
8. include stm32I1xx_rtc h include misc h The corresponding library modules must be included in the project for successful compilation and linking 5 Conclusion This application note shows how to use the STM32L1 integrated temperature sensor embedded in your STM32L DISCOVERY The firmware example associated with this application note allows you to explore the temperature sensing capability of STM32L1xx microcontrollers and at the same time demonstrate its ultra low power features It can be used as a starting point for your own development 10 12 Doc ID 022101 Rev 1 ky www BDTIC com ST AN3964 Revision history 6 Revision history Table 1 Document revision history Date Revision Changes 27 Sep 2011 1 Initial release Doc ID 022101 Rev 1 11 12 www BDTIC com ST AN3964 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and servi
9. nsor calibration data is a 12 bit unsigned number stored in 2 bytes acquired by the STM32L1 ADC with a 3V 10 mV reference voltage Doc ID 022101 Rev 1 ky www BDTIC com ST AN3964 Getting started Note The factory calibration data are available from revision W cut 1 3 of STM32L 15xx MCU devices The user calibration can be used to workaround missing factory calibration data for the previous silicon revisions Y cut 1 1 and X cut 1 2 The factory calibration data are tested for validity when the example application is initialized If data is present in the memory it is used for temperature calculation Otherwise the user calibration data stored during user calibration in EEPROM memory area is tested and used instead If the user calibration data is not available either the default values are used for calculation The factory calibration or user calibration data provides good accuracy of the temperature measurement The use of the default calibration data which is statistically based on the typical characteristics of the temperature sensor may provide less accurate temperature estimations due to significant variations of the temperature sensor characteristics during the manufacturing process It is recommended to use either the factory calibration data or to perform the two point calibration of the temperature sensor which respects the individual characteristics of the temperature sensor to obtain reas
10. on points has a constant tolerance with a slight increase of the tolerance outside For this reason the recommended position of the calibration points should be as close as possible to the maximum and minimum values of the measurement range Doc ID 022101 Rev 1 ky www BDTIC com ST AN3964 Software description 4 Software description 4 1 STM32L peripherals used by the application This application example uses the following STM32L peripherals with the settings described below For more information please refer to the STM32L151xx datasheet Analog to digital converter ADC The ADC performs analog to digital conversions of the internal reference voltage 4 samples and of the temperature sensor voltage 16 samples driven by DMA e ADC resolution 12 bit ADC conversion mode Scan mode driven by DMA ADC sampling time 384 cycles SysTick timer The SysTick timer is used only to generate the delay needed for display refresh and is disabled during temperature measurements General purpose inputs outputs GPIOs Ports C and E are connected to the User push button and the LEDs PB1 is set as an input floating pin with interrupt connected to User push button PB7 green LD3 and PB6 blue LD4 are set as an output push pull During low power modes I Os are placed in analog input mode to reduce power consumption except for a few pins related to the hardware interface PB7 green LD3 and PB6 blue LD4 It means that all
11. onably accurate measurements Figure 2 Transfer characteristics of the temperature sensor A TS voltage mV Temperature K The temperature can be evaluated from the digital value ValTS sampled by the ADC using linear approximation It can be applied if the coordinates of two calibration points C1 and C2 are known as shown in Figure 2 The current temperature can be evaluated as follows where the cold temperature coordinate pair is designated as TC1 ValC1 and the hot temperature pair as TC2 ValC2 Temp TC2 TC1 ValC2 ValC1 ValTS ValC1 TC1 Doc ID 022101 Rev 1 7 12 www BDTIC com ST Getting started AN3964 3 3 8 12 Estimation of temperature sensor engineering tolerance The two point calibration method significantly improves the accuracy of the measurement as can be seen in Figure 2 The bias of the temperature measurement is mainly given by two sources the temperature margin of the calibration points and the linearity of the sensor Other sources of bias such as the ADC reference voltage margin can be effectively reduced It can be neglected for factory calibrated values measured with the 3V 10 mV reference voltage The engineering tolerance of the temperature estimation is illustrated in Figure 2 where it is limited by the two boundary lines of the minimum biased values green and the maximum biased values blue The area between the calibrati
12. se of battery operated applications it must be measured in order to obtain a correct overall ADC conversion range To easily measure the power supply voltage we recommend using the embedded internal reference bandgap voltage The precise voltage of the embedded bandgap is individually measured during the manufacturing process and stored in the protected memory area at address 1FF80078 The embedded bandgap voltage calibration data is a 12 bit unsigned number right aligned bits stored in 2 bytes acquired by the STM32L1 ADC with a 3V 10 mV reference voltage The accuracy of the factory measured bandgap calibration data is provided with an accuracy of 5 mV Please see the datasheet for more details Doc ID 022101 Rev 1 3 12 www BDTIC com ST Application overview AN3964 2 3 4 12 Application example description Every 2 seconds the application acquires 16 samples from the temperature sensor voltage The ADC raw data are filtered and averaged using an interquartile mean algorithm to reduce noise from the power supply system and the result is recalculated into standard units of temperature measurement C in this example The LCD display is updated every 2 seconds either by ADC raw data or by the current temperature value in degrees Celsius The user can switch between both temperature data representations by pressing the user button To demonstrate the low power capabilities of the STM32L1 ultra low power microcontroll
13. the STM32L microcontroller provides an analog output voltage proportional to the chip junction temperature of the device Please note that the temperature information provided by sensor is the thermal chip junction temperature actual temperature of semiconductor surface and may differ from the ambient temperature Please see section Thermal characteristics of product datasheet for more details The integrated temperature sensor provides reasonably linear characteristics with a deviation typically of 1 from linear asymptotic functions and a temperature range equal to that of the device 40 C to 85 C with a maximum junction temperature of 150 C The sensor provides good linearity but quite poor interchangeability and must be calibrated to obtain good overall accuracy If the application is designed to only measure the relative temperature variations the temperature sensor does not need to be calibrated Temperature measurement and data processing The temperature sensor is internally connected to Channel 16 ADC_IN16 of the ADC analog to digital converter in the STM32L1 and is used to sample and convert the temperature sensor output voltage The raw ADC data must be further processed to display the temperature in a standardized unit of measurement Celsius Farenheit or Kelvin The ADC reference voltage is connected to the 3V Vpp power supply of the STM32L Discovery board If the Vpp value is not accurately known as in ca

Download Pdf Manuals

image

Related Search

Related Contents

KYOCERA Laserprinter FS-2000DN  DEUTSCH  Manuel d`utilisation  Philips SWV2001W User's Manual  ITALIANO pag / FRANCAIS pag / ENGLISH page / DEUTCH pag    Comprehensive USB 2.0 A, 25ft  3214NXT Service Manual  Entwicklung und Evaluierung eines meteorologischen  Installation & Operational Manual Model D6120-40  

Copyright © All rights reserved.
Failed to retrieve file