Hello, today I will show you how to make use of the internal temperature sensor, internal voltage reference and the Analog-to-Digital Converter on the RL78/G13 devices. The application monitors the voltage output by the internal temperature sensor and by the internal voltage reference. By reading both voltages we can compensate the temperature sensor output according to the ADC power supply (which, in this case, is the same for the whole MCU).

The ADC module is set to operate in continuous mode, alternating between two inputs: the internal voltage reference (1.45V) and the internal temperature sensor (the ISR switches the input channel).

Supply voltage is calculated by reading the internal voltage output (1.45V) and considering the read value is proportional to the ADC power supply (further details are shown on my free portuguese book Microcontroladores RL78: Guia Básico). Measuring the supply voltage is necessary as the temperature sensor’s voltage output is a function of the system power supply voltage.

The temperature sensor’s voltage output is calculated by using the following equation (it is written in brazilian portuguese):

RL78_temp_sensor1

Current temperature can be calculated with the following equation which uses the ADCR (ADC binary result) reading and supply voltage VDD (again the equation is written in portuguese):

RL78_temp_sensor2

After some math, the application presents the supply voltage and ambient temperature on the RL78/G13 RSK’s LCD display.

This example also illustrates a technic of data formatting for display presentation (or whatever other media) by using integer variables to represent fractional data. The LCD_wrie_frac_int function receives an integer value as a parameter and prints out data using the following format: X.YY where X is the higher than 100 part and YY is the less than 100 part, which is considered the fractional part. That way, 100 is printed as 1.00 and 9999 is printed as 99.99. Values lower than 100 are considered less than 1.00.

Notice that our application also makes use of a fixed temperature offset value (“toff” variable). This is due to the needed calibration for the internal temperature sensor. We came to the value by experimentation. On a professional environment it would be needed some kind of production calibration, storing the calibration data onto the flash during manufacturing.

The following code was taken from my portuguese Microcontroladres RL78: Guia Básico book:

Temperature measurement with the RL78
Tagged on:                                 

Leave a Reply