You are on page 1of 15

ESC263

MICROPROCESSORS
PROGRAMMING AND
INTERFACING
PROJECT REPORT

AIM : To control the speed of a motor and blinking


pattern of LEDs depending on the external
temperature by using LM35 sensor and PSoC
GROUP 6
Chandan Kumar Sahu
Nikhil Khanna
K.Ravalli Reddy
Mudit Srivastava
Pradyumna
PROJECT ABSTRACT

Following is a project to gain a hands-on experience with


Cypress Semiconductor’s PSoC microcontroller. The LM35
integrated-circuit temperature sensor has been interfaced
with the microcontroller to use its property of sensing
temperature. The produced analogue voltage signal is
digitized and the corresponding temperature value is
displayed on LCD. This signal is used to vary the blinking
pattern of LEDs and control the speed of a motor
depending on whether the external temperature is
increasing or decreasing.
COMPONENTS
● LM35 Precision Centigrade Temperature
Sensor
● Motor
● PSoC microcontroller unit
○ ADC
○ LCD
○ PGA amplifiers
○ LEDs
● Connecting wires
● Softwares Used: PSoC Designer 5.0, PSoc
Programmer
LM35 SENSOR:

● The LM35 is a precision integrated-circuit


temperature sensor, whose output voltage is
linearly proportional to the Celsius
(Centigrade) temperature.
● It has very low self-heating, less than 0.1°C
in still air. The LM35 is rated to operate over
a −55° to +150°C temperature range.
● The actual temperature of the LM35 die
would be at an intermediate temperature
between the surface temperature and the air
ALGORITHM

● Connect the output of sensor (LM35) to the


ADC through a PGA of gain 4.
● Initialize the LCD.
● Start the ADC in high power mode (i.e. mode
3).
● Run the ADC continuously.
● For non-zero output, display the output on
the LCD.
● For increasing and decreasing values of
output glow LEDs in different patterns and
vary the speed of a MOTOR.
DIGITAL BLOCK ARRAY
ANALOG BLOCK ARRAY
C CODE
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "stdlib.h"
int base_speed = 50;
void main()
{
int value=0, value2 = 0,i,speed;
float v;
float tempC;
int *stat;
char *value1;
char *s;
M8C_EnableGInt; // Enable Global Interrupts
PGA_1_Start(3);
ADCINC_1_Start(3);
LCD_1_Start();
LCD_1_Init();
ADCINC_1_GetSamples(0); // Have ADC run continuously
for(;;){
PRT1DR &= 0x00;
value2 = value;
while(ADCINC_1_fIsDataAvailable() == 0); // Loop until value ready
value = ADCINC_1_iClearFlagGetData(); // Clear ADC flag and get
data
value = value + 23;
value1 = itoa(s, value, 10);
LCD_1_Init();
LCD_1_Position(1,0);
LCD_1_PrString(value1); // Display temperature on LCD
if(value2 < value) //if new value>old value, temperature is increasing
{LCD_1_Position(0,0); ,blink LEDS in ascending order and run motor at
LCD_1_PrCString("HIGH SPEED"); high speed
PRT1DR |= 0x10;
for(i=0;i<4000;i++);
PRT1DR &= 0xEF;
PRT1DR |= 0x08;
for(i=0;i<4000;i++);
PRT1DR &= 0xF7;
PRT1DR |= 0x04;
for(i=0;i<4000;i++);
PRT1DR &= 0xFB;
PRT1DR |= 0x02;
for(i=0;i<4000;i++);
PRT1DR &= 0xFD;
for(i=0;i<4000;i++);
speed = base_speed+value;
if(speed > 255)
speed = 255;
ADCINC_1_WritePulseWidth(speed);
}
if(value2 > value) //if new value<old value, temperature is decreasing
{LCD_1_Position(0,0); //blink LEDS in descending order and run motor
at
LCD_1_PrCString("LOW SPEED"); low speed
PRT1DR &= 0x00;
PRT1DR |= 0x02;
for(i=0;i<4000;i++);
PRT1DR &= 0xFD;
PRT1DR |= 0x04;
for(i=0;i<4000;i++);
PRT1DR &= 0xFB;
PRT1DR |= 0x08;
for(i=0;i<4000;i++);
PRT1DR &= 0xF7;
PRT1DR |= 0x10;
for(i=0;i<4000;i++);
PRT1DR &= 0xEF;
for(i=0;i<4000;i++);
ADCINC_1_WritePulseWidth(base_speed);
}
}
}
APPLICATION
The temperature sensor (LM35) can be used for the
automated room air conditioning. The sensor senses the
sorrounding temperature conditions and gives voltage
output which is linearly proportional to the temperature
output. The condition is expressed as –
0 V = 23 degeee celsius.
The electronic circuitary is such that whenever the
temperature sensed by the sensor is increasing(due to the
crowd increasing in the room), the ac (in the project is
linked with the motor) runs at full speed. As soon as the
temperature is decreasing(people leaving the
room),accordingly the ac reduces its value to a minimum

You might also like