AIR CONDITIONING CONTROL SYSTEM

MICROPROCESSOR ASSIGNMENT
LECTURER: MR. SATHISH KUMAR STUDENT NAME: MOHAMAD MUDDASSIR GHOORUN 1/13/2012
STUDENT NUMBER: TP018073 INTAKE CODE: UC4F1110EEE

1

TABLE OF CONTENTS: 1. INTRODUCTION AND OBJECTIVES 2. BLOCK DIAGRAM OF PROPOSED SYSTEM 2.1 EXPLANATION OF PROPOSED SYSTEM 3. INNOVATION TO ENHANCE THE SYSTEM 4. SIMULATION OF EACH BLOCK OF THE SYSTEM  UNIPOLAR STEPPER MOTOR CONCEPT  HALF STEPPING TECHNIQUE 5. FLOWCHART 6. EMBEDDED C PROGRAMMING 7. HARDWARE IMPLEMENTATION AND RESULTS 8. DISCUSSION 9. CONCLUSION 10.REFERENCES

2

1. INTRODUCTION AND OBJECTIVES:
The electric expansion valve (EEV) in an air conditioning system is what regulates the inflow of refrigerant to the evaporator thereby affecting the temperature of the environment as shown in the figure below. The objective here is to design and construct a prototype for an air conditioning control system for 8 floors to regulate the air flow on each floor (1) using a low cost microprocessor or a microcontroller. A knob (5) will then be used to regulate the amount of air flow speed in 8 steps (2) (0-7) for each floor. Step 0 is fully closed mode where no refrigerant flows into evaporator while step 7 is fully open mode. The temperature of the surrounding (3) is also to be taken in consideration and kept constant. Furthermore, there should be two modes to the operation (4) of the system which comprises of both “summer mode” and “winter mode”.

3

2.1 BLOCK DIAGRAM OF PROPOSED SYSTEM:

TEMPERATURE SENSOR

BUZZER

STEPPER MOTOR DC MOTOR PIC16F877A KEYPAD HEATER

4

LCD

2.1EXPLANATION OF PROPOSED SYSTEM:
Temperature sensor LM35 (3) is a precision integrated-circuit centigrade temperature sensor whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. It will thus be used to sense the temperature changes of the environment. A buzzer is included in the design to indicate unusual temperature range, a dc motor used to force the refrigerant into the evaporator of the air conditioner while a unipolar stepper motor controls the valve (1,2)opening by regulating the step angle (0 -7). Since we have two modes, that is the “summer mode” and the “winter mode”, the block diagram includes a heater to be switched on during “winter mode” (4) while during “summer mode”, only the DC motor will be on. Moreover, all the data including the floor number is made available on the LCD and the valve may be regulated from the keypad
(5)

itself (0-7), while the LCD also displays the temperature of the LM35 sensor.

5

3.0 INNOVATIONS TO ENHANCE THE SYSTEM’S OPERATION:
An LCD screen is made to interface the PIC16F877A so as to assist the personnel using the system. The proposed system first asks whether the person wants “summer mode” or “winter mode”. The floor number is displayed, followed by temperature sensor readings, and finally the step control of valve. Moreover, a buzzer is also included in the design so as to indicate unusual temperature i.e. greater than 29 degrees Celsius. Furthermore, the keypad is used to choose “summer” or “winter mode”, the floor number and the valve control between 0 to 7. Simulation of the enhancement can be shown below:

At temperature of 29 Degrees Celsius, we can see that the buzzer connected at RD7 is off. Now, if temperature is further increased i.e. 30 degrees Celsius, the buzzer is to be on as shown below:

6

4.0 SIMULATION OF EACH BLOCK OF THE SYSTEM:
Part 1:

As explained earlier, the system asks us which mode of operation we need. Buttons „*‟ and „#‟ on the keypad are used to choose the required mode selection.

7

Part 2:

After choosing the “summer mode” or “winter mode”, the system asks us to choose the floor number. It should also be noted that the DC motor and LED usage at port B are the outputs used to differentiate between the 2 modes. When “summer mode” is chosen, only DC motor is on and if “winter mode” is chosen, both the DC motor and the heating element (usually an inductor; simulated as LED in our design) are on.

8

PART 3:

As shown above, the selected floor number is being displayed on the row 1 of the LCD screen. PART 4:

9

Next is the step control option where we can choose between 0 to 7 which will control the step angle of the motor. Also to note the buzzer right next to the keypad due to temperature being less than 30 degrees Celsius. Furthermore, the relative temperature of the environment from the LM35 sensor is also made available on the second line of the LCD. PART5:

10

11

12

13

The above displayed the concept of the knob control whereby the stepper motor‟s angle of rotation is controlled by using the keypad. See the pressed key and rotation angle for clearer view. Also the concept of the unipolar stepper motor and connection is explained on the next page.

14

PART 5B: UNIPOLAR STEPPER MOTOR CONCEPT The below unipolar stepper motor has 90orotation step. The coils are activated in a cyclic order, one by one. The proper angular movement of the rotor is determined by giving a „1‟ to the specific coil as shown below. The coils are energized by giving a „1‟ to the pin to which they are connected from the PIC. Thus, a proper sequence of the motor is achieved. However, this unipolar motor moves only 4 steps that is 0 – 90 -180 -270 – 0. In order to achieve our 8 step regulated valve concept, the half stepping technique will be used as shown on the next page.

15

PART5C: HALF STEPPING TECHNIQUE:
In the previous examples, only one coil has been activated at a time which hence made the rotor move at an angle of 90 degrees. However, if two successive coils were to be energized equally at the same time, the rotor will move half way the two coils, i.e. 45degrees. Thus, we can conclude that half stepping technique can be used for doubling the amount of steps of a unipolar stepper motor. This is a very important concept as it can increase efficiency of systems such as solar trackers or other projects like robotic arms amongst others.

Thus referring back to the assignment the discussed technique has been used to regulate the control valve from 0 to 7 with the help of the table below:
ROTATION ANGLE(DEG) 45 90 135 180 225 270 315 360/0 RB PINS ON (1) 4 4, 5 5 5, 6 6 6, 7 7 7, 4 RB PINS OFF (0) 5,6,7 6, 7 4,6,7 4,7 4,5,7 4,5,6 4,5,6 5, 6 STEP 1 2 3 4 5 6 7 0

16

5.0 FLOWCHART:

Initialize PIC and LCD

Display “summer mode” on line 1 and “winter mode” on line 2

If „*‟ chosen, DC motor on, inductor off

If „#‟ chosen, DC motor on, inductor on

Clear screen of lcd “WELCOME” displayed line1 “Choose floor no” on line 2

Clear screen Display “air conditioned” on line 1 Erase line 1 Display “floor number =” on line 1 Display “rel. temp=” on line 2

READ KEYPAD AND DISPLAY FLOOR NUMBER ON LINE 1 AFTER “=” SIGN READ TEMP. AND DISPLAY TEMPERATURE ON LINE 2 AFTER “=” SIGN

B

17

B

If temp>=30 degrees, activate the buzzer

Clear line 1 and display „step control =‟ for the stepper motor

Display step (0-7) as pressed on the keypad after “step control =” Call stepper function to move unipolar stepper motor to specific angle as shown in the half stepping technique in 5C.

Continue to monitor the keypad to change step angle whenever another key is pressed (0-7) and call repeat last step If no key is pressed, display “-” after “step-control =”

18

6.0 EMBEDDED C PROGRAM:

//header file #include<pic.h> //========================================================== ================

//pic configuration __CONFIG (0x3F32);

//defining ports #define #define #define #define //#define #define //#define //#define #define //#define lcd RS E CHANNEL1 buzzer fan fanB ledA heater pushbutton RE2 RB0 RB3 RB2 RB1 PORTC RA2 RA5 0b10001001 // AN1 RB5 //buzzer at pin RB5

#define col_1 RD0 #define col_2 RD1 #define col_3 RD2 #define row_1 RD3 #define row_2 RD4 19

#define row_3 RD5 #define row_4 RD6 //========================================================== ================

//function prototypes void e_pulse(void); void delay(unsigned short i); void send_char(unsigned char data); void send_config(unsigned char data); void lcd_goto(unsigned char data); void lcd_clr(void); void dis_num(unsigned long data); void increment(unsigned long data); void read_adc(void); unsigned short read_temp(void); char keypad_read2 (); unsigned short result; unsigned short temp; void first(); //just to break the program //========================================================== ====================

void main(void) {first(); } //========================================================== 20

//big function being invoked

void first() {

ADRESH=0; ADRESL=0;

//clear A/D result //clear A/D result

//setting ADCON1 Register ADCON1=0b11000101; //and RA5 as digital I/O // A/D result right justified, // configure RA2

TRISA=0b11011011; TRISB=0b00000000;

//configure PORTA I/O direction //configure PORTB as output--------we'll

//configure this one only for the implementation of our inductor for heating and the //fan for cooling concept here &stepper motor TRISC=0b00000000; TRISD=0b00000111; PORTA=0; PORTD=0; PORTB=0; //configure PORTC as output

while(1) { send_config(0b00000001); lcd 21 //clear display at

send_config(0b00000010); send_config(0b00000110); send_config(0b00001100); send_config(0b00111100);

//Lcd Return to home //entry mode-cursor increase 1 //diplay on, cursor off and cursor blink off// //function set 5*10 dot matrix

//========================================================== lcd_goto(0); send_char('*'); send_char(':'); send_char(' '); send_char('S'); send_char('U'); send_char('M'); send_char('M'); send_char('E'); send_char('R'); send_char(' '); send_char('M'); send_char('O'); send_char('D'); send_char('E');

lcd_goto (20); send_char('#'); send_char (':'); send_char(' '); send_char('W'); send_char('I'); 22

send_char('N'); send_char('T'); send_char('E'); send_char('R'); send_char('-'); send_char('M'); send_char('O'); send_char('D'); send_char('E');

delay(10000000000000); delay(10000000000000); delay(10000000000000); delay(10000000000000); delay(10000000000000); delay(10000000000000); delay(10000000000000); delay(10000000000000); lcd_clr(); //========================================================== char z; z= keypad_read2(); if (z == '*') { fan=1; } else if (z == '#') 23

{ fan=heater=1; } //========================================================== send_char('#'); send_char('#'); send_char('#'); send_char('#'); send_char('W'); send_char('E'); send_char('L'); send_char('C'); send_char('O'); send_char('M'); send_char('E'); send_char('#'); send_char('#'); send_char('#'); send_char('#'); lcd_goto(20); send_char('C'); send_char('H'); send_char('O'); send_char('O'); send_char('S'); send_char('E'); send_char(' '); 24

send_char('F'); send_char('L'); send_char('O'); send_char('O'); send_char('R'); send_char(' '); send_char('N'); send_char('O');

delay(10000000000000); delay(10000000000000); delay(10000000000000); delay(10000000000000); lcd_clr();

//==========================================================

//========================================================== //display character on LCD lcd_goto(1); send_char('A'); send_char('I'); send_char('R'); send_char('-'); send_char('C'); send_char('O'); 25

send_char('N'); send_char('D'); send_char('I'); send_char('T'); send_char('I'); send_char('O'); send_char('N'); send_char('E'); send_char('D'); delay(10000000000000); delay(10000000000000);

//========================================================== lcd_goto(1); send_char('F'); send_char('L'); send_char('O'); send_char('O'); send_char('R'); send_char('-'); send_char('N'); send_char('U'); send_char('M'); send_char('B'); send_char('E'); send_char('R');

26

send_char('='); send_char(' '); char c; c = keypad_read2(); send_char( c );

lcd_goto(20);

//cursor go to 2nd line of the LCD

//display character on LCD

send_char('R'); send_char('E'); send_char('L'); send_char('.'); send_char('T'); send_char('E'); send_char('M'); send_char('P'); send_char('='); delay(10000000000000);delay(10000000000000); delay(10000000000000);delay(10000000000000); delay(10000000000000);delay(10000000000000); while(1){ lcd_goto(1); send_char ('S'); send_char ('T'); 27

send_char ('E'); send_char ('P'); send_char ('-'); send_char ('C'); send_char ('O'); send_char ('N'); send_char ('T'); send_char ('R'); send_char ('O'); send_char ('L'); delay(10000000000000);delay(10000000000000); delay(10000000000000);delay(10000000000000); delay(10000000000000);delay(10000000000000); keypad_read2(); lcd_goto(15); char u; u= keypad_read2(); send_char(u); if (u=='1') {RB4=1;RB5=RB6=RB7=0;} else if (u=='2') {RB4=RB5=1;RB6=RB7=0;} else if (u=='3') {RB5=1; RB4=RB6=RB7=0;} else if (u=='4') {RB5=RB6=1; RB4=RB7=0;} else if (u=='5') 28 //This is stepper motor control bit config

{RB6=1; RB4=RB5=RB7=0;} else if (u=='6') {RB6=RB7=1;RB4=RB5=0;} else if (u=='7') {RB7=1;RB4=RB5=RB6=0;} else if (u=='0') {RB7=RB4=1; RB5=RB6=0;} RB0 = 1; stepper is on //This one is here because dc motor stops rotating when

//LM35 TEMPERATURE SENSOR ADCON0=CHANNEL1; //CHANNEL0=0b10000001 lcd_goto(30); read_adc(); temp=read_temp(); if (result>0b0100101000)//> 30 { RD7=1; } else// if (result<0b100101100)// < 300 {RD7=0; } [CHANGEABLE]

dis_num(temp/10); 29

send_char('.'); dis_num(temp%10); send_char(0b11011111); send_char('C'); delay(2000); }

} }

//==================subroutine LCD setting ===================================================

void send_config(unsigned char data) { RS=0; lcd=data; delay(500); e_pulse(); }

void e_pulse(void) { E=1; delay(500); E=0; delay(500); 30

}

void send_char(unsigned char data) { RS=1; lcd=data; delay(500); e_pulse(); }

void lcd_goto(unsigned char data) { if(data<16) { send_config(0x80|data); // question: why is 0x80? Answer is simple remember bit 7 must be set for //display.This is command to jump to specific address for display } else { data=data-20; the Current Cursor //Position send_config(0xc0|data); } } 31 //Write a Character to the Display at

void lcd_clr(void) { RS=0; send_config(0x01); delay(600); }

void dis_num(unsigned long data) { unsigned char hundred_thousand; unsigned char ten_thousand; unsigned char thousand; unsigned char hundred; unsigned char tenth;

hundred_thousand = data/100000; data = data % 100000; ten_thousand = data/10000; data = data % 10000; thousand = data / 1000; data = data % 1000; hundred = data / 100; data = data % 100; tenth = data / 10; 32

data = data % 10;

if(hundred_thousand>0) { send_char(hundred_thousand + 0x30); //0x30 added to become ASCII code

send_char(ten_thousand + 0x30); send_char(thousand + 0x30); send_char(hundred + 0x30); send_char(tenth + 0x30); send_char(data + 0x30); }

else if(ten_thousand>0) { send_char(ten_thousand + 0x30); //0x30 added to become ASCII code

send_char(thousand + 0x30); send_char(hundred + 0x30); send_char(tenth + 0x30); send_char(data + 0x30); } else if(thousand>0) { send_char(thousand + 0x30); //0x30 added to become ASCII code send_char(hundred + 0x30); send_char(tenth + 0x30); send_char(data + 0x30); } 33

else if(hundred>0) { send_char(hundred + 0x30); //0x30 added to become ASCII code

send_char(tenth + 0x30); send_char(data + 0x30); } else if(tenth>0) { send_char(tenth + 0x30); //0x30 added to become ASCII code send_char(data + 0x30); } else send_char(data + 0x30); } //0x30 added to become ASCII code

void increment(unsigned long data) { unsigned short j; for(j=10;j>0;j--) { lcd_goto(32); data=data+1; dis_num(data); delay(10000); }

}

//==================subroutine ADC=========================== 34

void read_adc(void) { unsigned short i; unsigned long result_temp=0; for(i=2000;i>0;i-=1) { ADGO = 1; while(ADGO==1); //ADGO is the bit 2 of the ADCON0 register //ADC start, ADGO=0 after finish ADC progress result=ADRESH; result=result<<8; result=result|ADRESL; //shift to left for 8 bit //10 bit result from ADC //looping 2000 times for getting average value

result_temp+=result; } result = result_temp/2000; //getting average value

}

unsigned short read_temp(void) { unsigned short temp; temp=result; return temp;

}

35

//==================subroutine DELAY========================= void delay(unsigned short i) { for(;i>0;i--); }

//==========================================================

char keypad_read2() {

//setting row 1 high and others low while scanning the 3 columns int a; row_1 = 1; row_2 = row_3 = row_4 = 0; if (col_1 == 1) { a = '1'; return a; } else if (col_2 == 1) {a = '2'; return a; } else if (col_3 == 1) {a = '3'; 36

return a; } //setting row 2 high and others low while scanning the 3 columns row_2 = 1; row_1 = row_3 = row_4 = 0; if (col_1 == 1) { a = '4'; return a; } else if (col_2 == 1) {a = '5'; return a; } else if (col_3 == 1) {a = '6'; return a; }

//setting row 3 high and others low while scanning the 3 columns row_3 = 1; row_1 = row_2 = row_4 = 0; if (col_1 == 1) { a = '7'; return a; } 37

else if (col_2 == 1) {a = '8'; return a; } else if (col_3 == 1) {a = '9'; return a; }

//setting row 4 high and others low while scanning the 3 columns row_4 = 1; row_1 = row_2 = row_3 = 0; if (col_1 == 1) { a = '*'; return a; } else if (col_2 == 1) {a = '0'; return a; } else if (col_3 == 1) {a = '#'; return a; } else a='-'; 38

return a; } //========================================================== =========================================================== =========================================//================= =========================================

39

The above codes have been developed on MPLAB IDE version 8.46 and was successfully compiled and loaded on the Proteus hardware design. Simulation results as shown previously contained both hardware and software simulations.

7.0 HARDWARE IMPLEMENTATION AND RESULTS:

========================================================== 8.0 DISCUSSION:
Among the difficulties faced in the project, the concept for analog to digital conversion had to be revised throughout fully while the interfacing concept of keypad had also to be learnt. Before going to the coding part, the keypad had to be broken down into smaller rows and columns and activating one column by one and scanning the rows to see which key has been pressed. Thus columns were connected as inputs to the PIC and rows as outputs. The coding was simulated on

40

MPLAB version 8.46 using embedded C programming as shown in the coding. keypad_read2() function was thus made in order to detect which key has been pressed. Another problem encountered was how to control a motor in 8 steps. Among the choices of either a servo or a stepper motor, the unipolar stepper motor was chosen and a proper algorithm linking the keypad pin pressed and angle moved by the motor was another problem to be solved. This was mainly done by using functions to activate specific pins on the stepper motor whenever a pin is pressed on the keypad. Moreover, enhancing the system by activating a buzzer when the temperature is greater than 30 degrees Celsius was also included in the coding so as to render the system a more complete one. Furthermore, the concept of using and LCD and its configuration were very helpful as we may use it in 2 modes: nibble mode and 8 bit mode. Though nibble mode (4 bits) uses less data lines, the 8 bit mode was preferred due to complexity issues.

9.0 CONCLUSION:
Thus, the work accomplished is a system which detects temperature using the analog pin with a reference voltage and displayed on the lcd. Other new things learned about lcd is the usage of either 5*7 dot matrix or 5*10 matrix. Other concepts learnt further helped to enhance actual knowledge in such a way that as other bigger keypads can also be coded and interfaced as the main concept still remains same and the control steps can be further increased by using other stepper motors. LCDs can also be interfaced in the nibble mode and the coding was done separately as a separate work to this project. The concept of using bipolar stepper motors was also viewed before going for unipolar as it is more suitable for the specific application. Half stepping technique was also viewed so as to increase number of steps and applied so as to match the 8 required steps. Thus after grouping all the concepts, the PIC is the mastermind which does all the data manipulations of the system while the LM35 sensor used (already calibrated) was used for temperature sensor. LCD was used in 8 bit mode was made more user friendly and guides the user throughout the process. Even the control step is also displayed on the LCD and the angle the unipolar stepper motor is also available as shown in the hardware results. Linking LCD concept and keypad concept though was a bit difficult, was finally solved. Though not used in this project, other concepts like controlling brushless DC motor through a motor driver instead of stepper motor was also gone through. Finally, the system was successfully accomplished as planned and system is fully functional. Also increasing number of control steps can be done for future improvements.

41

10.0 REFERENCES: 1. 2007, How stepper motors work [online], Images scientific instruments, available from http://www.imagesco.com/articles/picstepper/02.html, accessed on 28/01/12 2. Kiate, 2010, simple stepper motor calculator[online], Tutorials by citron technologies, available from: http://tutorial.cytron.com.my/2010/06/30/1835/, accessed on 28/01/12. 3. 2012, Datasheets- keypad input unit [online], Electronics in schools ltd, available from: http://www.ectinschools.org/page.php?ps=2&p=927, accessed on 28/01/12. 4. Lazaridis, G., 2010, simple unipolar stepper motor full step controller [online], Electronic workbench pcb heaven, available from: http://pcbheaven.com/circuitpages/Simple_Unipolar_Stepper_Motor_Full_S tep_Controller/ accessed on 28/01/12. 5. Laidman, R., 2000, stepper motor and control[online], stepperworld.com, available from: http://www.stepperworld.com/Tutorials/pgBipolarTutorial.htm accessed on 28/01/2012 6. Table of ASCII characters[online], available from: http://www.cs.mun.ca/~michael/c/ascii-table.html, accessed on 28/01/2012 7. Matrix keypad interfacing with PIC microcontroller[online],available from: http://www.mcuexamples.com/PIC-Matrix-Keypad-tutorial.php , accessed on 28/01/2012 8. Thoolen, S., 2011, Matrix keypad- driver[online], available from: https://stefan.co/electronics/matrix-keypad-driver/, accessed on 28/01/2012

42

Sign up to vote on this title
UsefulNot useful