Temperature sensor: LM35 Basic Centigrade Temperature Sensor (2°C to 150°C)
When using the Basic configuration we get an output swing of ~0V(20mV) to 1.5V. So, if we use a VREF of 3.3 Volts we get a resolution of 3.3V/4096 = 0.0008056V or 0.8mV since LPC1768 has a 12-bit ADC. With Vref in Volts and Scale-factor in V/°C, we can compute the temperature(T) from 12-bit ADC Result as:
The controller calculates this result very fast and the sensor almost outputs a voltage almost the whole time. So to give stable readings, we used a timer that gives a delay of 3s. Hence, the temperature changes (if there is any change) every 3s.
-
P0.4 to P0.11 ( Connector A ) as seven segment data lines.
-
P1.23 to P1.26 ( Connector B ) as decoder lines.
-
P0.24 ( Connector D, 1st bottom right pin ) as ADC input-ADD0.1
-
Timer used in the project is TIM0.
-
The function timer_init() is used to intialize and run a timer to give a delay of about 3s.
-
The function display() is used to display the calculated temperature on seven segment.
-
Pins P0.4 to P0.11 and P1.23 to P1.26 are configured as GPIO outputs for the seven segment display.
-
Pin P0.24 ( ADD0.1 ) as ADC input ( function 1 ).
-
ADC interrupts on channel 1 ( ADD0.1 ) is enabled.So whenever the controller detects a voltage on P0.24, it passes the control to the ADC_IRQHandler().
-
In the handler, the calculations are done according to the formula given in the WORKING section above. This temperature is then displayed for 3s and the temperature is recalculated after 3s and displayed again.