Modeling And Design Embedded Controller For A Condenser System.

(1)

MODELING AND DESIGN AN EMBEDDED CONTROLLER FOR A CONDENSER SYSTEM

ZULMAJD HAMDAN MAY 2008


(2)

“I hereby declared that I have read through this report and found that it has comply the partial fulfillment for awarding the degree of Bachelor of Electrical Engineering

(Control, Instrumentation, and Automation)”

Signature : ………..

Supervisor’s Name : Pn. Sahazati Binti Md. Rozali


(3)

MODELING AND DESIGN AN EMBEDDED CONTROLLER FOR A CONDENSER SYSTEM

ZULMAJD HAMDAN

This Report Is Submitted In Partial Fulfillment of Requirements for the Degree of Bachelor in Electrical Engineering (Control, Automation and Instrumentation)

Faculty of Electrical Engineering Universiti Teknikal Malaysia Melaka


(4)

“I hereby declared that this report is a result of my own work except for the excerpts that have been cited clearly in the references.”

Signature :………

Name : ZULMAJD HAMDAN IC No : 850423-04-5659


(5)

iii

I dedicate this to my parent, my lovely family, my friend, my supervisor and electrical engineering education.


(6)

ACKNOWLEDGEMENT

Praise to Allah S.W.T, The Almighty that give me the strength to finish and complete this project on time. First of all, I would like to thank my parent who help, motivate, and support me in order to complete this project.

Especially honor, I would like to thank Pn Sahazati as my supervisor for this PSM.

Besides, to Mohd Faizal Muhammadon, Muhammad Firdaus Abdul Rahim, Mohd Hafifi Muhammad Hanafiah, Sahrir Alias, Mr Yu Kee Thung and Mr Chye Ching Hock who teach me a lot about a car air-conditioner system. They give me full cooperation to complete this project.

I also would like to thank to University Technical Malaysia, Malacca especially for electrical Engineering Faculty, for giving me the chance to be creative and innovative in electrical engineering. Consequently, I would like to thank all who have made sure this project is excellent. Hope God blesses all of you for your kindness. Amin…


(7)

v

ABSTRACT

The main task of this project is to design an embedded controller for a condenser system in car air-conditioner system. Air-conditioner system consists of four main parts which are evaporator, compressor, condenser, and expansion valve. Condenser is a device designed to condense a gas into a liquid. It also designs to change the high pressure refrigerant vapor to liquid. The high pressure vapor is coming from the compressor. The condenser has parallel tubing and tiny cooling fin. The fins help the air flowing through the condenser, removing the heat and change the heat into much cooler liquid. The main task of this project is to design an embedded controller for a condenser system. PIC is used to model this controller


(8)

ABSTRAK

Tujuan utama projek ini adalah untuk mereka dan menyertakan pengawal untuk sistem pemeluap penyaman udara kereta. Terdapat empat komponen utama dalam sistem penyaman udara kereta iaitu injap pengembangan, pemampat, pemeluap dan penyejat. Pemeluap merupakan sejenis alat yang digunakan untuk menukarkan udara bertekanan tinggi menjadi air yang bertekanan tinggi. Udara bertekanan tinggi ini datang daripada pemampat. Pemeluap mempunyai tiub selari dan sirip penyejuk yang kecil. Sirip ini membantu udara melalui pemeluap dan menghilangkan kepanasan pada udara bertekanan tinggi tersebut seterusnya menukarkannya menjadi cecair. Tujuan utama projek ini ialah untuk mereka pengawal untuk sistem pemeluap ini.


(9)

vii

TABLE OF CONTENTS

CHAPTER TITLE PAGE

PROJECT TITLE i

DECLARATION ii

DEDICATION iii

ACKNOWLEGEMENT iv

ABSTRACT ABSTRAK

v vi

TABLE OF CONTENT vii

LIST OF FIGURE x

LIST OF TABLE xi

1.0 INTRODUCTION 1

1.1 INTRODUCTION OF THE PROJECT 1

1.2 PROJECT OBJECTIVES 2

1.3 PROJECT SCOPES 2

1.4 PROBLEM STATEMENT 3

1.5 PROBLEM SOLVING 3

2.0 LITERATURE REVIEW 4

2.1 INTRODUCTION 4


(10)

2.3.1 THE BASICS OF C 7

2.3.2 CHARACTERISTIC OF C 8

2.3.3 I/O PORTS AND PERIPHERALS 8

2.3.4 C PROGRAM STRUCTURE 9

2.3.5 VARIABLES 9

2.4 CAR AIR-CONDITIONING SYSTEM 11

2.4.1 THE CYCLE OF CAR AIR-CONDITIONER 12

2.4.2 COMPRESSOR 13

2.4.3 CONDENSER 13

2.4.4 EVAPORATOR 14

2.4.5 THERMAL EXPANSION VALVE 16

3.0 PROJECT THEORY 17

3.1 CONDENSER 17

3.2 PIC MICROCONTROLLER 18

3.3 RS 232 SERIAL PORT 18

4.0 METHODOLOGY 20

4.1 THE METHODOLOGY OF WORKS 20

5.0 PROJECT RESULT 24

5.1 HARDWARE PARTS 24

5.1.1 LIST OF COMPONENTS 24

5.1.2 CAR AIR-CONDITIONER CONDENSER SYSTEM 25

5.1.3 COOLING FAN 27

5.1.4 PRESSURE SWITCH 27

5.1.5 PERIPHERAL INTERFACE CIRCUIT (PIC) 29 5.1.6 HARDWIRE CONNECTION DIAGRAM 30


(11)

ix

5.2 SOFTWARE PARTS 31

5.2.1 C-LANGUAGE PROGRAMMING 31

5.2.2 UPLOADING PROGRAM INTO PIC 32 5.3 THE OPERATION OF EMBEDDED CONTROLLER DESIGN

FOR CONDENSER SYSTEM 33

5.4 PROJECT RESULT 36

6.0 DISCUSSION 39

6.1 DICUSSION ON PROJECT OBJECTIVES AND PROJECT

SCOPES 39

6.2 DISCUSSION ON THE METHODOLOGY AND WORK

SCHEDULE 40

6.3 THE ADVANTAGES OF THE NEW INVENTIION 40 6.4 FUTURES SUGGESTION AND ENHANCEMENT 41

7.0 CONCLUSION 42

7.1 CONCLUSION 42

REFERENCES 44


(12)

FIGURE TITLE PAGE

2.1 PIC16F877A CONFIGURATION PINS 6

2.2 BASIC PIC CIRCUIT 7

2.3 CAR AIR-CONDITIONER PROCESS 11

2.4 COMPRESSOR 13

2.5 CONDENSER 14

2.6 EVAPORATOR 15

2.7 THERMAL EXPANSION VALVE 16

3.1 PIC16F877A 18

3.2 RS 232 SERIAL CABLE 19

4.1 METHODOLOGY FLOW CHART 22

5.1 CONDENSER SYSTEM 26

5.2 PSM CONDENSER 26

5.3 PSM COOLING FAN 27

5.4 PRESSURE SWITCH FOR PSM 28

5.5 INNER SIDE OF PRESSURE SWITCH 28

5.6 PIC BOARD 29

5.7 HARDWIRE DIAGRAM 30

5.8 C-LANGUAGE PROGRAM 32

5.9 CD2M DOWNLOADER 33

5.10 OPERATION FLOW CHART 36

5.11 FRONT VIEW 37


(13)

xi

LIST OF TABLE

TABLE TITLE PAGE

2.1 C DATA TYPE 10

2.2 PASCAL EQUIVALENT 10


(14)

CHAPTER 1

INTRODUCTION

This chapter discuss about the introduction, project objectives, project scopes, and problem statement of this project.

1.1Introduction of the project

This project is built for a condenser in a car air-conditioning system. This condenser is controlled by a PIC with an appropriate programming using C Language. This project covered electrical, mechanical, and electronic engineering field.

By using a pressure switch, the condenser that connected to a PIC circuit will detect the pressured gas from a compressor. It will trigger the pressure sensor and the PIC circuit will send a signal to the condenser’s fan to switch it ON.

Condenser is a device designed to condense a gas into a liquid. It also designed to change the high pressure refrigerant vapor to liquid. The high pressure vapor is coming from the compressor. The condenser looks like a radiator, so it has parallel tubing and tiny cooling fin. The fins help the air flowing through the condenser, removing the heat and change the heat into much cooler liquid. The function of the cooling fan is to suck the outside air and flow through the condenser. So it is easier to cool the compressed air.

For this Projek Sarjana Muda (PSM), the whole system is controlled by intelligent controller which is Peripheral Interface Circuit (PIC) compared to the old system that use only heat detector and timer to start up the cooling fan.


(15)

2

1.2Project Objectives

 To learn the basic concept of an air conditioner system.

 To model and design a condenser system.

 To design a controller for a condenser system.

 To produce a complete system by combining both hardware and software part of the project.

1.3Project Scopes

 To learn the basic process of condenser in a car air-conditioner system.

 To learn the concept of microcontroller (PIC) PIC16F877A and micro-C programming to get finest tune.

 To learn the best way of programming the micro-controller using C language.

 To determine the suitable sensor to control a condenser (pressure sensor/switch).

 To design an appropriate way to control the cooling fan using both PIC and pressure sensor.


(16)

Usually the old version of the condenser in the car used heat detector and timer to operate the cooling fan. Even though the air-conditioner did not switch on, the cooling fan still operates because the heat detector sense heat. So time spent of the battery did not last long.

 The original system used a timer and heat detector to switch on the condenser’s fan.

 The cooling fan still operates even though there is no pressure.

1.5Problem Solving

The new version of the condenser is used only PIC controller and pressure switch in order to generate the whole condenser system. The cooling fan will only operate when the pressure switch sense pressure.

 Used only a pressure sensor/switch to turn on the cooling fan.

 By using the pressure sensor/switch, the cooling fan will turn ON only with the present of the pressure.


(17)

4

CHAPTER 2

LITERATURE REVIEW

This chapter discuss about the theory, the components, and the study that used in this project.

2.1 Introduction

The basic components used in this project will be, PIC circuit using PIC16F877A, condenser, pressure switch, and C Language.

To develop the controller for the system, the researches need to be done on the microchip. For example the datasheet, the rating, and all about it. For the condenser as well, some research had to be done.

2.2 Peripheral Interface Circuit (PIC)

PIC is one of the controllers that often used in engineering field. It is simple if compared to the microprocessor. It combined all necessary needs into single Integrated Circuit (IC). PIC microcontroller also very easy for programming. A microcontroller is sometimes referred to as an embedded processor because it can be embedded into a device that has some function other than being a general purpose computer. This generally implies that microcontrollers are less expensive and less powerful than a


(18)

full-microcontroller and its program are very tightly integrated. Microcontroller is wide used because of its need, from a sensor it will go to a microcontroller and it will trigger the actuators.

There are many ways to programming the PIC. It can use assembler (MPLAB), basic programming (PIC Basic Pro, Micro Basic), and C Language (HITEC PICC, MicroC). This project using C Language as its programming language. It is because the C Language is wide used. Almost everybody use C Language because of its uncomplicated.

Figure 2.1 shows the PIC16F877A configuration pins, a well built microchip with 40 pins represents its own addresses. It is also have 33 pins just for input/output connection. The powerful microchip PIC16F877A controller running at 20 MHZ, with 368 bytes of data memory, 256 bytes of EEPROM data memory, and 8K bytes of FLASH program memory. This microchip is programmed through C Compiler. Figure 2.2 shows a basic PIC circuit where it is always consist of PIC16F877A, a 20 MHz crystal, a RS232 adapter, a 78L05 voltage regulator, and others basic components such as resistor and capacitor. It also have high performance RISC CPU with a 35 single-word instruction set and interrupts capability of up to 14 sources. Regulated +5 V dc can be sourced from several screw terminal connectors or it can be connected through a +5V circuit. RS-232 used a serial port for downloading program to the on-board PIC, via a 9-way D-type connector, which can also be used as a stand-alone serial communications port.


(19)

6

Figure 2.1: PIC16F877A configuration pins

In most microcontrollers all components are contained inside a single chip. Only a few external parts are usually required to make the microcontroller run. CPU is the most important device in this controller. It has many small micros use an 8-bit CPU, although 16 and 32 CPUs also exist. For program memory, it is used to store the program to be run Flash RAM is used in modern microcontroller. RAM also used in the microcontroller. It is a temporary memory used while the program being executed. EEPROM is a permanent storage to allow programs to save settings and other data when the power is off. Oscillator is used to support for different types of clock sources are usually available, including crystals, resonators, external clock sources, and internal clocks. The clock affects the speed of the program execution, timers and other parts. Speeds from 4-40MHz are typical. I/O Ports pins used for interfacing the microcontroller to other devices. Most microcontrollers allow individual control of each pin, making them very flexible. There are many peripherals that is widely use. Many useful peripherals are common such as USARTs; serial ports which can send and receive data at up to 1Mbps or more. The Comparators and A/D Converters are used for sensing and measuring analog signal. Timer peripheral used for counting pulses and measuring accurate time intervals. There also have a Pulse Width Modulators (PWM) peripheral. It is used to control motors, lamps, LEDs, and other control devices.


(20)

Figure 2.2: Basic PIC circuit

Figure 2.2: Basic PIC Circuit

2.3 PIC (Peripheral Interface Circuit) Programming Language

The project use C-Language coding to program the PIC chip. The C-Language is the language that commonly used among programmer because it is easier create compared to other language.

2.3.1 The basics of C

We start with brief history of C before going through the C’s basic syntax and structure. Then we look at the characteristics of the C Language.

The C language has a few characters. It has many high-level languages, similar to PASCAL, C are highly discipline and structured. However C is more flexible and free-wheeling.


(21)

8 2.3.2 Characteristics of C

This subtopic will briefly list some of C's characteristics that define the language and also have lead to its popularity as a programming language. Naturally we will be studying many of these aspects throughout the course.

Although it is in small size, it can use much extensive use of function calls. Unlike PASCALS, the C Language is loose typing. The language also very discipline and structured. It also has a low level (BitWise) programming readily available. It also has the pointer implementation where the pointer is extensive use of pointers for memory, array, structures, and functions.

C now has become widely used because of its several characteristics. The C language has high-level constructs. It also can handle low-level activities. It can produce efficient program. The last reason why it is widely used is because it can be compiled on a variety of computers.

2.3.3 I/O Ports and Peripherals

The simplest peripherals are basic I/O ports. All PICs have these. They allow simple digital input and output. We can read or write single bits, or whole bytes of data. Turn on and off something, or read the status of a switch. The PIC16F627A has two ports: A and B. Each of these ports has 8 lines/pins. And each of these 8 lines can do something different. The I/O lines are arranged in ports of 8 bits wide or less because sometimes it's useful to be able to access all 8 bits at once. But often we will use the lines individually. The important thing to remember about I/O lines is that each line can do a multitude of things. It was pack in so many features into even small PICs that each line or pin of a port has a lot of different functions. We need to understand the implications of this before using each I/O line, or else we might spend hours wondering why it doesn't work the way you expect. When we work with larger PICs, so the number of modes and functions for each pin increases. Some have five or six different functions. The good thing about the PIC is that all registers come up with known values upon power on. This


(22)

of explicitly configuring things, just so that it is clear. Code runs fast, and extra start-up code is not likely to cause even a noticeable delay. Also, PICs have lots of program memory so we are not likely to run out of code space.

The best way to ensure that we use each I/O line properly is to look at the table for each I/O port which lists the pin function of each I/O line. We need to make sure that the pins can do what we want them to do, and then make sure that other peripherals which use each pin are configured to not interfere with our intended use of the pin. For instance, on the PIC16F627A the capture and compare module needs to be specifically disabled for PORTA to work normally. Also, some of the pins on PORTA are open drain outputs.

2.3.4 C Program Structure

C program basically has the following form:

 Preprocessor Commands

 Type definitions

 Function prototypes -- declare function types and variables passed to function.

 Variables

 Functions

Its must have a main () function.

2.3.5 Variables


(23)

10 Table 2.1: C Data Type

C type Size (Bytes) Lower bound Upper bound Char

Unsigned char Short int Unsigned short int

(long) int Float double 1 1 2 2 4 4 8 - 0 -32768 0 -2^31 -3.2 x 10^98 -1.7 x 10^9.08

- 255 32767 65536 2^31 – 1 3.2 x 10^98 1.7 x 10^9.08

The Pascal Equivalents are:

Table 2.2: Pascal Equivalent

C type Pascal equivalent

Char Unsigned char

Short int Unsigned short int

Long int Float double Char - Integer - longint real extended


(24)

Figure 2.3: Car air-conditioner process

Car air-conditioning system consists of four main parts, which are condenser with a cooling fan, compressor, expansion valve, and evaporator with a blower. These parts work together as a team. They always rely on each other. Figure 2.4 shows the basic process for car air conditioning. When a high-pressure gas from the compressor flow through the condenser, the cooling fan will start to cool off the gas. The gas was condensed into liquid and flow to the evaporator through an expansion valve. The blower will blow a nice and cool air.


(1)

Figure 2.1: PIC16F877A configuration pins

In most microcontrollers all components are contained inside a single chip. Only a few external parts are usually required to make the microcontroller run. CPU is the most important device in this controller. It has many small micros use an 8-bit CPU, although 16 and 32 CPUs also exist. For program memory, it is used to store the program to be run Flash RAM is used in modern microcontroller. RAM also used in the microcontroller. It is a temporary memory used while the program being executed. EEPROM is a permanent storage to allow programs to save settings and other data when the power is off. Oscillator is used to support for different types of clock sources are usually available, including crystals, resonators, external clock sources, and internal clocks. The clock affects the speed of the program execution, timers and other parts. Speeds from 4-40MHz are typical. I/O Ports pins used for interfacing the microcontroller to other devices. Most microcontrollers allow individual control of each pin, making them very flexible. There are many peripherals that is widely use. Many useful peripherals are common such as USARTs; serial ports which can send and receive data at up to 1Mbps or more. The Comparators and A/D Converters are used for sensing and measuring analog signal. Timer peripheral used for counting pulses and measuring accurate time intervals. There also have a Pulse Width Modulators (PWM) peripheral. It is used to control motors, lamps, LEDs, and other control devices.


(2)

Figure 2.2: Basic PIC circuit

Figure 2.2: Basic PIC Circuit

2.3 PIC (Peripheral Interface Circuit) Programming Language

The project use C-Language coding to program the PIC chip. The C-Language is the language that commonly used among programmer because it is easier create compared to other language.

2.3.1 The basics of C

We start with brief history of C before going through the C’s basic syntax and structure. Then we look at the characteristics of the C Language.

The C language has a few characters. It has many high-level languages, similar to PASCAL, C are highly discipline and structured. However C is more flexible and free-wheeling.


(3)

2.3.2 Characteristics of C

This subtopic will briefly list some of C's characteristics that define the language and also have lead to its popularity as a programming language. Naturally we will be studying many of these aspects throughout the course.

Although it is in small size, it can use much extensive use of function calls. Unlike PASCALS, the C Language is loose typing. The language also very discipline and structured. It also has a low level (BitWise) programming readily available. It also has the pointer implementation where the pointer is extensive use of pointers for memory, array, structures, and functions.

C now has become widely used because of its several characteristics. The C language has high-level constructs. It also can handle low-level activities. It can produce efficient program. The last reason why it is widely used is because it can be compiled on a variety of computers.

2.3.3 I/O Ports and Peripherals

The simplest peripherals are basic I/O ports. All PICs have these. They allow simple digital input and output. We can read or write single bits, or whole bytes of data. Turn on and off something, or read the status of a switch. The PIC16F627A has two ports: A and B. Each of these ports has 8 lines/pins. And each of these 8 lines can do something different. The I/O lines are arranged in ports of 8 bits wide or less because sometimes it's useful to be able to access all 8 bits at once. But often we will use the lines individually. The important thing to remember about I/O lines is that each line can do a multitude of things. It was pack in so many features into even small PICs that each line or pin of a port has a lot of different functions. We need to understand the implications of this before using each I/O line, or else we might spend hours wondering why it doesn't work the way you expect. When we work with larger PICs, so the number of modes and functions for each pin increases. Some have five or six different functions. The good thing about the PIC is that all registers come up with known values upon power on. This


(4)

means that we do not necessarily have to change a register setting if you know that the PIC boots up with it in the right state. But it is often a good idea to go through the steps of explicitly configuring things, just so that it is clear. Code runs fast, and extra start-up code is not likely to cause even a noticeable delay. Also, PICs have lots of program memory so we are not likely to run out of code space.

The best way to ensure that we use each I/O line properly is to look at the table for each I/O port which lists the pin function of each I/O line. We need to make sure that the pins can do what we want them to do, and then make sure that other peripherals which use each pin are configured to not interfere with our intended use of the pin. For instance, on the PIC16F627A the capture and compare module needs to be specifically disabled for PORTA to work normally. Also, some of the pins on PORTA are open drain outputs.

2.3.4 C Program Structure

C program basically has the following form:

 Preprocessor Commands

 Type definitions

 Function prototypes -- declare function types and variables passed to function.

 Variables

 Functions

Its must have a main () function.

2.3.5 Variables


(5)

Table 2.1: C Data Type

C type Size (Bytes) Lower bound Upper bound

Char Unsigned char

Short int Unsigned short int

(long) int Float double 1 1 2 2 4 4 8 - 0 -32768 0 -2^31 -3.2 x 10^98 -1.7 x 10^9.08

- 255 32767 65536 2^31 – 1 3.2 x 10^98 1.7 x 10^9.08

The Pascal Equivalents are:

Table 2.2: Pascal Equivalent

C type Pascal equivalent

Char Unsigned char

Short int Unsigned short int

Long int Float double Char - Integer - longint real extended


(6)

2.4 Car Air-Conditioning System

Figure 2.3: Car air-conditioner process

Car air-conditioning system consists of four main parts, which are condenser with a cooling fan, compressor, expansion valve, and evaporator with a blower. These parts work together as a team. They always rely on each other. Figure 2.4 shows the basic process for car air conditioning. When a high-pressure gas from the compressor flow through the condenser, the cooling fan will start to cool off the gas. The gas was condensed into liquid and flow to the evaporator through an expansion valve. The blower will blow a nice and cool air.