Temperature Sensor Simple

This is a simpler version of my first LMT01 temperature sensor project which used:
  1. Two Interrupts

  2. A Timer

  3. Supported multiple LMT01 sensors

This version uses a Blocking Delay instead of a Timer, one interrupt and it only supports a single LMT01 sensor.

This is also my first project using two files where:
  1. One file is for configuration only. Its filename ends in *.includes.fs and must be loaded first. This file provides all prerequisites for the second file below

  2. The second file contains Words pertaining to the higher level functions of the program itself.

I’m trying this strategy to separate the two functions of any embedded program, namely “configuration” and “program” in order to make the project more readable.

Downloads

These are all the project files including a ready to flash binary for a STM32F0 Discovery Board.
  1. f0-lmt01-temp-sensor-simple-version.fs

  2. f0-lmt01-temp-sensor-simple-version.includes.fs

  3. Standalone binary file containing everything needed for this project which will run on powerup

  4. Binary file README

  5. List of Words in the Binary above

Warning

The Standalone Binary has RTS/CTS handshaking. Connect to a 3.3v/usb dongle which supports them for correct operation. Terminal should be set to 460800 baud.Connect PA11 (CTS) to 0V (ground), ignore PC7 (code-error). PA12 (RTS) connects to the dongle CTS. PA10 (RX) connects to dongle TX, etc

Operation

Flash the board with the standalone binary file above, connect the FOUR parts to the Discovery Board as shown in the schematic below and type “t” in the terminal to read the temperature in Degrees C.

t
23.2C   ok.

Schematic

_images/f0-lmt01-temp-sensor-simple-version-schematic.png

Note

All parts (including wiring) in the big green rectangle are INSIDE the Discovery Board, you do not add them. This project has only 4 parts to be connected and they are on the left of the rectangle.

How Does It Work ?

  1. PC1 is raised high which provides power to the LMT01 temperature sensor.

  2. The LMT01 sensor
    1. Powers up and determines the temperature.

    2. Sends the temperature as a series of current pulses representing digital “high” and “low”.

    3. Q1 converts the current pulses into digital “1” and “0” voltage pulses.

  1. PCO, configured as a INPUT triggers a interrupt on each falling edge of the received pulses. These pulses are counted by the interrupt handler.

  2. After PC1 is raised high, a blocking delay of 105 milliseconds is initiated.

  3. The 105 millisecond delay allows enough time for all the pulses to be counted.

  4. When the 105 millisecond delay is finished, power to the LMT01 is removed and the temperature is calculated and displayed.

Waveforms

The Scope picture below shows:
  1. Waveform on channel 1 is the block of pulses from the LMT01 as received at PC0.

  2. Waveform on channel 2 is the power to the LMT01 from PC1.

Waveform Image

_images/f0-lmt01-temp-sensor-simple-version-waveform.png

Scope settings

        State   Volts/Div   Position    Cplg  BW Lim Inv   Probe  
Chan 1  On      2.000 V     0.000 V     DC    On     Off   10:1    
Chan 2  On      2.000 V     -5.188 V    DC    On     Off   10:1    

                      Main        Main        Time  Delayed     Delayed     
            Mode      Time/Div    Delay       Ref   Time/Div    Delay       
Horizontal  Normal    20.00ms/    0.000 s     Left  --------    -----       

Trigger Mode     Source  Level     Holdoff  Slope   Couplg  Reject  NoiseRej  
        Normal   Ch 1    2.375 V   16.40ms  Pos     DC      Off     Off 

Display Mode: Peak Det

Cursors: t1=0.000 s     t2=109.6ms     V1(1)=3.062 V     V2(1)=3.000 V