0% found this document useful (0 votes)
9 views29 pages

Interface_project

Uploaded by

natnaelmessay70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views29 pages

Interface_project

Uploaded by

natnaelmessay70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Addis Ababa University

Addis Ababa Institute of Technology


School of Electrical and Computer Engineering
Microcomputers and Interfacing
Temperature Control System Using
LPC2148 Microcontroller

Group Members ID No
1. Bezawit Berhane UGR/3912/13
2. Ami Birhanu UGR/9923/13
3. Amin Geleto UGR/5191/13
4. Getaw Yeha UGR/1867/13
5. Selamawit Dache UGR/7203/13

Submitted to: Mr Kinde M.


Submission Date: May 29, 2024
Contents

List of Figures II

Abstract 2

Introduction 3
Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

System Design 5
Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
LPC2148 Microcontroller . . . . . . . . . . . . . . . . . . . . . 5
Temperature Sensor(LM35) . . . . . . . . . . . . . . . . . . . 6
Display Unit(LCD display) . . . . . . . . . . . . . . . . . . . . 7
Relay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
DC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
LED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Microcontroller Configuration . . . . . . . . . . . . . . . . . . . . . 7
Software Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Software Implementation 9
Programming Environment . . . . . . . . . . . . . . . . . . . . . . 9
Code Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Simulation in Proteus 14
Simulation Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Simulation Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Testing and Results 16

Discussion 18
System Performance . . . . . . . . . . . . . . . . . . . . . . . . . . 18

I
Conclusion 20
Future Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . 20

References 22

Appendix 23

II
List of Figures

1 Block diagram of temperature control system . . . . . . . . . 5


2 Simulation Diagram . . . . . . . . . . . . . . . . . . . . . . . . 15
3 Result of test at T = TEMP LIMIT . . . . . . . . . . . . . . 16
4 Result of test at T > TEMP LIMIT . . . . . . . . . . . . . . 17
5 Result of test at T < TEMP LIMIT . . . . . . . . . . . . . . 17

1
Abstract

This project involves the design and simulation of a temperature control sys-
tem using the LPC2148 microcontroller. The system is simulated in Proteus,
a software tool that allows for virtual testing of microcontroller-based sys-
tems. The objectives, methods, results, and conclusions of the project are
presented in this report.

2
Introduction

Background
Temperature control systems are essential in various applications, ranging
from industrial processes to household appliances. These systems maintain
desired temperature levels to ensure safety, efficiency, and comfort. In indus-
trial settings, precise temperature control can improve product quality and
process efficiency, while in residential environments, it enhances comfort and
reduces energy consumption.
Microcontroller-based systems are at the heart of many modern tempera-
ture control applications. Microcontrollers offer a compact, cost-effective so-
lution for implementing control algorithms and interfacing with sensors and
actuators. The LPC2148 microcontroller, in particular, is a popular choice
due to its powerful features, including a 32-bit ARM7TDMI-S core, multiple
analog-to-digital converters (ADC), and numerous input/output (I/O) ports.
These features make it well-suited for real-time control applications such as
temperature regulation.
Proteus is a versatile simulation tool that allows designers to create and
test embedded systems in a virtual environment. Using Proteus, developers
can prototype and debug their designs before moving to physical hardware,
saving time and resources. This project leverages Proteus to simulate a
temperature control system based on the LPC2148 microcontroller, enabling
thorough testing and validation of the control algorithms and system behav-
ior.
Existing temperature control technologies employ various methods, such
as on/off control, proportional-integral-derivative (PID) control, and model
predictive control. While effective, these methods can face challenges such as
overshooting, lag, and stability issues, especially in dynamic environments.
This project aims to address some of these challenges by implementing an ef-
ficient and reliable temperature control system using modern microcontroller
technology.
In today’s rapidly advancing technological landscape, the demand for

3
smarter, more efficient control systems is increasing. This project aligns
with current trends by integrating advanced control algorithms and utilizing
simulation tools to optimize system performance. The insights gained from
this project can contribute to the development of more sophisticated and
robust temperature control solutions in the future.

Objective
The primary objective of this project is to design and simulate a tempera-
ture control system using the LPC2148 microcontroller. The system aims to
maintain a specified temperature within a given environment by reading tem-
perature data from a sensor, and activating appropriate actuators to adjust
the temperature as needed. The specific objectives are as follows:

ˆ Develop a software model for a temperature control system using the


LPC2148 microcontroller.

ˆ Simulate the system in Proteus to validate its functionality and perfor-


mance.

ˆ Interface the microcontroller with virtual components in Proteus, in-


cluding a temperature sensor, LCD display unit, and actuators.

ˆ Evaluate the system’s response to various temperature conditions.

ˆ Document the design process, simulation results, and any challenges


encountered during the project.

By achieving these objectives, the project will demonstrate the feasibil-


ity and effectiveness of using the LPC2148 microcontroller in temperature
control applications, providing insights that could be applied to real-world
systems.

4
System Design

Block Diagram

Figure 1: Block diagram of temperature control system

Components
LPC2148 Microcontroller
The LPC2148 microcontroller is a versatile and powerful member of the
LPC2000 series from NXP, designed for embedded applications requiring
high performance and low power consumption. The following key compo-
nents within LPC2148 were used for the temperature control system in this
project:
ˆ Analog-to-Digital Converter (ADC): The 10-bit ADC with 14
channels allows for accurate and high-resolution reading of analog sig-

5
nals from temperature sensors, crucial for precise temperature moni-
toring and control.

– A/D Control Register (ADCR): It has the following uses:


* Selecting the ADC channel (for both ADC0 and ADC1)
* Setting the clock frequency for the ADC
* Specifying the resolution (number of bits in the result)
* Initiating the start of a conversion Power control (enabling/dis-
abling the ADC)
* Burst conversion mode control
– A/D Global Data Register (ADGDR): provides access to the
conversion results from both ADC0 and ADC1. It also has bits
for status flags like indicating if a conversion is complete.

ˆ General-purpose I/O Pins: Numerous GPIO pins provide flexible


interfacing options for connecting to different components such as ac-
tuators (fans, heaters) and user interfaces.

– General Purpose I/O Port Direction Registers (IODIR0,


IODIR1): define the direction (input or output) of each pin on
their respective ports.
– General Purpose I/O Port Data Registers (IOPIN0, IOPIN1):
read the input state or control the output state of each pin on their
respective ports.
– General Purpose I/O Port Set and Clear Registers (IOSET0,
IOCLR0, IOSET1, IOCLR1): provide operations for setting
or clearing the output pins.

Temperature Sensor(LM35)
The LM35 is a popular integrated circuit (IC) used for measuring temper-
ature. The LM35 is an analog temperature sensor. It produces a voltage
output that is directly proportional to the Celsius temperature it’s sensing.
The scale factor is a constant 10mV per degree Celsius. This means for every
1°C rise in temperature, the output voltage increases by 10mV. This linear
relationship allows for straightforward conversion of voltage to temperature.
The LM35 operates over a wide temperature range, typically from -55°C to
150°C. As its output is analog voltage, it can be interfaced with LPC2148
using ADC.

6
Display Unit(LCD display)
An LCD is a flat-panel display that uses liquid crystals to produce images.
16 × 2 LCD was used for this project. It role within the project is to display
the current temperature and show whether it is above, the same as or below
the limit set.

Relay
A relay is an electrically operated switch. It consists of a set of input termi-
nals for a single or multiple control signals, and a set of operating contact
terminals. The switch may have any number of contacts in multiple contact
forms, such as make contacts, break contacts, or combinations thereof. Its
role within the project is to turn DC motor on and off based on the sensed
temperature. It is also connected to LED.

DC motor
A DC motor is an electrical motor that uses direct current (DC) to produce
mechanical force. It was used within the project to simulate fan. It is
connected to the relay.

LED
As it is not possible to simulate heater in proteus, LED was used to show
more clearly if the temperature control system was working fine.

Microcontroller Configuration
1. ADC settings
AD0 was selected as ADC. Hence the settings made are for AD0.

ˆ P0.4 was set as AD0.6 with PINSEL0.


ˆ Power on the internal ADC module by setting AD0CR.PDN bit
(ADCR’s 21st bit).
ˆ AD0.6 channel was selected for A/D conversion by setting the
corresponding bits in AD0CR.SEL.
ˆ AD0CR.START bit was set for starting the A/D conversion for
the selected channel (ADCR’s 24th bit).

7
ˆ AD0GDR was used to check the completion of conversion. The
DONE bit will be set once the conversion is over.
ˆ AD0GDR was used to read the 10-bit A/D value.

2. GPIO configurations
The GPIO pins were used to interface with relay and LCD display.
LCD RS, RW and E pins were connected to P1.16,P1.17 and P1.18
respectively. The data pins D0 to D7 were connected to P1.24 to P1.31.
The two relays were connected to P0.22 and P0.23.

ˆ I1DIR for these pins was set as output.


ˆ I1SET and I1CLR were used to set and clear the pins as needed.
ˆ I1PIN was used to set the pins to wanted values.

Software Architecture
1. initialize LCD

2. set LCD cursor to top left

3. set the pins of the relays as output

4. while(1)

5. get the temperature from A/D

6. display temperature on LCD

7. check whether the temperature is below or above the specified limit

8. if temperature is above the set limit

9. turn on the fan and display high temperature

10. else if the temperature is below the set limit

11. turn on the led simulating the heater and display low temperature

12. else

13. display normal temperature and turn both fan and led off

8
Software Implementation

Programming Environment
The development and implementation of the temperature control system
were carried out using the Keil µVision integrated development environment
(IDE). Keil provides a comprehensive suite of tools for ARM microcontroller
development, including an editor, compiler, and debugger. These tools facil-
itated efficient coding and debugging processes for the LPC2148 microcon-
troller. The IDE’s robust support for ARM architecture and its seamless
integration with the hardware allowed for precise control over the system
components. The use of Keil significantly streamlined the development work-
flow, enabling rapid prototyping and testing of the temperature control logic.
Additionally, Keil’s simulation capabilities provided a reliable platform for
validating the system’s performance before deployment, ensuring a stable
and functional implementation.

Code Structure
Functions within the code

1. LCD.H
void LCD_CMD(unsigned char cmd){
IO1PIN = ((IO1PIN & 0x00FFFFFF) | (cmd << 24));
delay(2);
IO1SET |= (1<<18);// enable = 1
IO1CLR |= (1<<16)|(1<<17);
delay(2);
IO1CLR |= (1<<18); // enable = 0
delay(5);
}

9
The LCD CMD function is used to send command to the LCD which
is useful for initialization of the LCD and setting cursor position at any
time to display.
void LCD_WRITE(unsigned char* data){
unsigned int k=0;
while(data[k]!=0){

IO1PIN = ((IO1PIN & 0x00FFFFFF) | (data[k] << 24));


IO1SET |= (1<<18);
IO1CLR |= (1<<17);
IO1SET |= (1<<16);
delay(1);
IO1CLR |= (1<<18);
k++;
}
}

The LCD WRITE function is used to display any character array. This
function is used to display the ambient temperature.
void LCD_INIT(){
IO1DIR |= 0xFF070000;
//delay(10);
LCD_CMD(0X38);
LCD_CMD(0X0C);
LCD_CMD(0X06);
LCD_CMD(0X01);
LCD_CMD(0X80);
}

The LCD INIT function is used to initialize the LCD. It sets the LCD to
8-bit, auto-increments the cursor, clears the screen and sets the cursor
position to top left.
2. ADC.H
unsigned int GET_ADC_DATA(void){
unsigned int mydata;
unsigned int v;
float v1;
PINSEL0 |= 0x000000300;
AD0CR = 0x00;
AD0CR |= (1<<6) | (13<<8) | (1<<16) | (1<<21);

10
AD0CR |=(1<<24);
//check end of conversion
while((AD0GDR&(1<<31))==0);//check for done bit
mydata = AD0GDR;
mydata = mydata>>6;//ADC result avialable from 15:6
mydata&=0x3FF;
v1 =((float)mydata*3.3)/1024;
v = (int)(v1*1000);
v = ((int)v/10);
return v;
}

The function GET ADC DATA is used to get the sensed temperature
from LM35.

3. CLOCK INIT.H
void PLL_INIT(void){
PLL0CON = 0X01; // enable PLL
PLL0CFG = 0x24; // set CCLK to 69MHz
PLL0FEED = 0xAA; // feed sequence
PLL0FEED = 0x55;
while((PLL0STAT&(1<<10))==0); // Check whether CCO
latched
PLL0CON = 0x03; // enable and connect PLL
PLL0FEED = 0xAA; // feed sequence
PLL0FEED = 0x55;
VPBDIV = 0x00; //PCLK = 1/4 CCLK;
}

The function PLL INIT is used to initialize the clock. PLLk was set
to 1/4 of CCLK.
void ms_delay(unsigned int ms){
//using timer 0
T0CTCR = 0x00; // set as timer
T0PR = 60000-1; // define PR
T0TC = 0; // reset timer
T0TCR = 0x01; // enable timer
while(T0TC < ms);
T0TCR = 0x00; // disable timer

11
The function ms delay is used to provide delay in ms. It accepts input
in ms and provides delay.

4. Main.c
#include <LPC214X.H>
#include <stdio.h>
#include <CLOCK_INIT.h>
#include <UART.H> // TXD0 RXD0
#include <LCD.H> //RS=P1.16 RW=P1.17 E=P1.18 D0-D7=P1.24 -
P1.31
#include <ADC.H> //ADC PIN = AD0.6/P0.4
void LCD_STATE(unsigned int T);
unsigned int TEMP_LIMIT;
int main(void){
unsigned char *str;
unsigned int temp;
char val[10];
int ADC_val;
TEMP_LIMIT = 35;
PLL_INIT();
LCD_INIT();
LCD_CMD(0x0C);
LCD_CMD(0x80);
LCD_WRITE("Temperature=");
IO0DIR |= 0xC00000;
while(1){
temp = GET_ADC_DATA();
LCD_CMD(0x8C);
sprintf(str,"%iC",temp);
LCD_WRITE(str);
LCD_CMD(0xC0);
LCD_STATE(temp);
}
}
void LCD_STATE(unsigned int T){
if ( T > (TEMP_LIMIT)) {
IO0SET = 0x800000;
LCD_WRITE("HIGH TEMP ");
}
else if(T < (TEMP_LIMIT)){
IO0SET = 0x400000;
LCD_WRITE("LOW TEMP ");
}

12
else {
IO0CLR = 0xC00000;
LCD_WRITE("NORMAL TEMP");
}
}

The function LCD STATE(unsigned int T) accepts temperature input


and checks whether the temperature is below or above the set limit. It
displays the temperature. If the temperature exceeds the set limit, it
turns the motor on and if temperature is below the set limit, it turns
LED on.

13
Simulation in Proteus

Simulation Setup
LPC2138, LCD display, LM35, relay, DC motor and LED was added to
scheme.
The Vss pins of the LPC2138 were connected to ground. VREF, V3A,
V3 pins were connected to 3.3V power.
The RS, RW and E pins were connected to P1.16, P1.17 and P1.18 re-
spectively. The pins D0 to D7 were connected to P1.24 to P1.31.
Pin 1 of LM35 was connected to 5V DC source and pin 3 was connected
to ground. Pin 2 was connected to P0.4.
Two relays were used. They were connected to the ground and 3.3V
source as shown in the figure. They were also connected to pins P0.22 an
P0.23. DC motor and LED were connected to the each relay.

14
Simulation Diagram

Figure 2: Simulation Diagram

15
Testing and Results

1. Test at Normal temperature


The test was made with the temperature set to TEMP LIMIT.

Figure 3: Result of test at T = TEMP LIMIT

2. Test at High temperature


The test was made with the temperature set to higher than TEMP LIMIT.

16
Figure 4: Result of test at T > TEMP LIMIT

3. Test at Low temperature


The test was made with the temperature set to lower than TEMP LIMIT.

Figure 5: Result of test at T < TEMP LIMIT

17
Discussion

1. Temperature Monitoring: The system continuously monitors the


temperature using a sensor interfaced with the LPC2148 microcon-
troller. The temperature readings are compared against a predefined
threshold limit.

2. Temperature Below Limit: When the temperature falls below the


threshold limit, the system activates a relay, which in turn powers an
LED indicator. This visual cue signifies that the temperature is below
the desired range.

3. Temperature Above Limit: Conversely, when the temperature ex-


ceeds the threshold limit, the system triggers a different relay. This
action starts a motor, indicating that the temperature is too high and
corrective action is being taken to cool down the environment.

4. Normal Temperature: If the temperature remains within the accept-


able range, the system remains inactive, and no relays are engaged.
This indicates that the temperature is stable and within the desired
parameters.

System Performance
The system demonstrates reliable performance in maintaining the desired
temperature range. The use of relays to control the LED and motor pro-
vides a clear and immediate response to temperature changes. This ensures
that the environment remains within the specified limits, thereby preventing
potential damage or inefficiencies caused by extreme temperatures.

Advantages
ˆ Real-time Monitoring: The continuous temperature monitoring al-
lows for immediate detection of any deviations from the desired range.

18
ˆ Automated Control: The automated activation of the LED and
motor relays eliminates the need for manual intervention, enhancing
the system’s efficiency and reliability.

ˆ Application in constant temperature systems:

– Biological Incubators: Used for growing and maintaining mi-


crobiological cultures or cell cultures, requiring precise tempera-
ture control to support growth conditions.
– Green Houses: maintain stable temperature to optimize plant
growth and development, often incorporating heating and cooling
systems.
– PCR machines: used in molecular biology to amplify DNA re-
quring precise temperature cycling for denaturation, annealing
and extension steps.

19
Conclusion

In conclusion, the temperature control system implemented using the LPC2148


microcontroller, LM35 temperature sensor, ADC interface, and various actu-
ators (DC motor, relay, and LED) has successfully demonstrated a practical
and efficient method for maintaining a desired temperature range. The sys-
tem accurately measures the ambient temperature through the LM35 sensor
and processes the data via the ADC of the LPC2148.
The control logic ensures that the DC motor, representing a cooling mech-
anism, activates when the temperature exceeds a preset limit, thereby pre-
venting overheating. Conversely, the relay controls an LED, simulating a
heater, which turns on when the temperature falls below the set threshold,
maintaining warmth. The integration of an LCD display enhances the sys-
tem’s user interface by providing real-time temperature readings.
This project not only highlights the LPC2148 microcontroller’s capability
in handling analog-to-digital conversion and output control but also under-
scores the importance of embedded systems in developing automated tem-
perature regulation solutions. The approach is scalable and can be adapted
for various applications, demonstrating the flexibility and reliability of using
LPC2148 for environmental monitoring and control.

Future Improvements
For further improvements to the temperature control system, several en-
hancements could be considered:

ˆ Precision and Accuracy:

– Higher Precision Sensors: Replace the LM35 with a more precise


temperature sensor, such as the DS18B20, to improve temperature
measurement accuracy.
– Calibration: Implement a calibration routine for the sensor to
ensure accurate readings across different operating conditions.

20
ˆ Advanced Control Algorithms:

– PID Controller : Integrate a Proportional-Integral-Derivative (PID)


control algorithm to provide more precise temperature regula-
tion by continuously adjusting the motor speed and heater output
based on temperature deviations.

ˆ User Interface and Interaction:

– Touchscreen Display: Upgrade the LCD to a touchscreen display


to allow users to set temperature limits and view system status
more intuitively.
– Mobile App Integration: Develop a mobile application for remote
monitoring and control of the system via Bluetooth or Wi-Fi,
adding convenience and flexibility.

ˆ Energy Efficiency:

– PWM Control : Implement Pulse Width Modulation (PWM) for


the DC motor to regulate its speed more efficiently, reducing power
consumption.
– Smart Power Management: Add power-saving modes for the sys-
tem to reduce energy usage when the desired temperature is main-
tained for extended periods.

ˆ Extended Functionality:

– Multiple Zones: Expand the system to control multiple temper-


ature zones, each with its own set of sensors and actuators, for
more comprehensive environmental control.
– Integration with Home Automation: Connect the system with ex-
isting home automation platforms (e.g., SmartThings, Alexa) to
enable seamless integration with other smart devices.

By incorporating these improvements, the temperature control system


will become more robust, user-friendly, and efficient, making it suitable for
a wider range of applications and enhancing its overall functionality and
reliability.

21
References

[1] Maxim Integrated. DS18B20 Programmable Resolution 1-Wire Digital


Thermometer. https://datasheets.maximintegrated.com/en/ds/
DS18B20.pdf. 2015.
[2] Michael J. Pont. Embedded C. 1st. Boston, MA: Addison-Wesley, 2002.
[3] Alberto Suarez and Ivan Gomez. “Integration of Home Automation Sys-
tems with Smart Devices”. In: Proceedings of the 2018 International
Conference on Smart Homes and Smart Solutions. Los Angeles, CA,
2018, pp. 23–30.
[4] Texas Instruments. LM35 Precision Centigrade Temperature Sensors.
http://www.ti.com/lit/ds/symlink/lm35.pdf. 2000.
[5] NXP Semiconductors. LPC2148 User Manual. https://www.nxp.com/
docs/en/user-guide/UM10139.pdf. 2007.
[6] LAB SET III. Interrupt handling and LCD interfacing.
[7] LAB SET IV. ADC, UART, PWM.

[1–7]

22
Appendix

Full Source Code


//LCD.H
void LCD_CMD(unsigned char cmd);
void LCD_WRITE(unsigned char* data);
void LCD_INIT(void);
void delay(int ms);
void delay(int ms){
unsigned int i,j;
for(i=0;i<ms;i++){
for(j=0;j<6000;j++){;}
}
}
void LCD_CMD(unsigned char cmd){
IO1PIN = ((IO1PIN & 0x00FFFFFF) | (cmd << 24));
delay(2);
IO1SET |= (1<<18);// enable = 1
IO1CLR |= (1<<16)|(1<<17);
delay(2);
IO1CLR |= (1<<18); // enable = 0
delay(5);
}
void LCD_WRITE(unsigned char* data){
unsigned int k=0;
while(data[k]!=0){

IO1PIN = ((IO1PIN & 0x00FFFFFF) | (data[k] << 24));


IO1SET |= (1<<18);
IO1CLR |= (1<<17);
IO1SET |= (1<<16);
delay(1);
IO1CLR |= (1<<18);

23
k++;
}
}
void LCD_INIT(){
IO1DIR |= 0xFF070000;
//delay(10);
LCD_CMD(0X38);
LCD_CMD(0X0C);
LCD_CMD(0X06);
LCD_CMD(0X01);
LCD_CMD(0X80);
}
// ADC.h
unsigned int GET_ADC_DATA(void);
unsigned int GET_ADC_DATA(void){
unsigned int mydata;
unsigned int v;
float v1;
PINSEL0 |= 0x000000300;
AD0CR = 0x00;
AD0CR |= (1<<6) | (13<<8) | (1<<16) | (1<<21);
AD0CR |=(1<<24);
//check end of conversion
while((AD0GDR&(1<<31))==0);//check for done bit
mydata = AD0GDR;
mydata = mydata>>6;//ADC result avialable from 15:6
mydata&=0x3FF;
v1 =((float)mydata*3.3)/1024;
v = (int)(v1*1000);
v = ((int)v/10);
return v;
}
// CLOCK_INIT.H
void PLL_INIT(void);
void ms_delay(unsigned int ms);
void PLL_INIT(void){
PLL0CON = 0X01; // enable PLL
PLL0CFG = 0x24; // set CCLK to 69MHz
PLL0FEED = 0xAA; // feed sequence
PLL0FEED = 0x55;
while((PLL0STAT&(1<<10))==0); // Check whether CCO latched
PLL0CON = 0x03; // enable and connect PLL
PLL0FEED = 0xAA; // feed sequence

24
PLL0FEED = 0x55;
VPBDIV = 0x00; //PCLK = 1/4 CCLK;
}
void ms_delay(unsigned int ms){
//using timer 0
T0CTCR = 0x00; // set as timer
T0PR = 60000-1; // define PR
T0TC = 0; // reset timer
T0TCR = 0x01; // enable timer
while(T0TC < ms);
T0TCR = 0x00; // disable timer

}
//MAIN.C
#include <LPC214X.H>
#include <stdio.h>
#include <CLOCK_INIT.h>
#include <UART.H> // TXD0 RXD0
#include <LCD.H> //RS=P1.16 RW=P1.17 E=P1.18 D0-D7=P1.24 -
P1.31
#include <ADC.H> //ADC PIN = AD0.6/P0.4
void LCD_STATE(unsigned int T);
unsigned int TEMP_LIMIT;
int main(void){
unsigned char *str;
unsigned int temp;
char val[10];
int ADC_val;
TEMP_LIMIT = 35;
PLL_INIT();
LCD_INIT();
LCD_CMD(0x0C);
LCD_CMD(0x80);
LCD_WRITE("Temperature=");
IO0DIR |= 0xC00000;
while(1){
temp = GET_ADC_DATA();
LCD_CMD(0x8C);
sprintf(str,"%iC",temp);
LCD_WRITE(str);
LCD_CMD(0xC0);
LCD_STATE(temp);
}

25
}
void LCD_STATE(unsigned int T){
if ( T > (TEMP_LIMIT)) {
IO0SET = 0x800000;
LCD_WRITE("HIGH TEMP ");
}
else if(T < (TEMP_LIMIT)){
IO0SET = 0x400000;
LCD_WRITE("LOW TEMP ");
}
else {
IO0CLR = 0xC00000;
LCD_WRITE("NORMAL TEMP");
}
}

26

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy