Brightness control based on temperature using FRDM-KL25Z.

In this project, I used the temperature sensor which is present on the FRDM-KL25Z board to measure/read the temperature and based on the temperature readings change the brightness of the LED using PWM.

Follwing features/functionalities of KL25Z are used:

1. GPIO

2. PWM

3. TPM

4. ADC

5. Embedded Temperature Sensor

Basic Temperature Sensor Reading

The SO8ADC module has a P-N transistor junction with temperature-dependent properties acting as an embedded temperature sensor. The voltage across this junction rises or lowers with temperature allowing silicon to act as a temperature sensor. Figure 1 shows the typical ADC readings of the temperature sensor output across a range of temperatures.


Figure 1. Typical ADC Temperature Readings

The graph shows that the temperature sensor output is linear and dependant on VDD. The temperature sensor output voltage is highest at cold temperatures and lowest at hot temperatures. For VDD = 3 V, the readings range from 277d at –40°C down to 176d at 130°C. An approximate transfer function demonstrated in the following sections represents this behavior.

The temperature sensor reading most accurately represents the temperature of the die and, due to proximity, the leads and the PCB board connected to it. For many applications, the desired temperature may differ from the die’s temperature. For example, the die temperature can differ from the temperature of a room’s air flow.

Using Typical Parameters Provided by the Data Sheet

Use the typical parameters provided by the HCS08 data sheet to perform a temperature reading. An approximate transfer function describes the temperature sensor.


Figure 2. Transfer Function.

Temperature Reading Flowchart

Figure 3. Temperature Reading Flowchart.

Screenshot

Figure 4. Shows the temperature variations observed by the temperature sensor integrated in FRDM-KL25Z

Figure 4. Temperature variations.

Learnings/Observations/Challenges

1. The temperature sensor is embedded in the chip itself.

2. The temperature sensor can be optimized by:

  • Analog-to-digital Configuration.

  • Averaging ADC readings.

  • Determine a current reading of VDD by using the bandgap voltage to calculate VDD.

  • A floating-point implementation results in more accurate math when using the approximate transfer function if you can spare the code space.

3. Accuracy of temperature sensor based on implementation.


Figure 5. Temperature sensor accuracy.

Connect with me

LinkedInEmailGitHub