Sei sulla pagina 1di 119

MODELING AN ENHANCED E-VOTING SYSTEM WITH REAL TIME DATA COLLATION BY

EGUONO, EGUONO E. 2009112000

A PROJECT REPORT SUBMITTED TO THE DEPARTMENT OF ELECTRICAL/ELECTRONICS ENGINEERING, ANAMBRA STATE UNIVERSITY OF SCIENCE AND TECHNOLOGY, ULI IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR THE AWARD OF MASTERS DEGREE IN ELECTRICAL ENGINEERING SUPERVISOR DR. P.I. OKWU

DECEMBER, 2013

DECLARATION I hereby declare that this report was written by me and it is a record of my own research. It has not been presented before in any previous application for a Masters Degree. Authors whose works have been referred to and reference made to published literature have been duly acknowledged.

_________________________ EGUONO, EGUONO EGUONO Student

___________________ Date

Above declaration is confirmed

____________________ DR.P.I. OKWU Project Supervisor

_____________________ Date

CERTIFICATION This project titled: MODELING AN ENHANCED E-VOTING SYSTEM WITH REAL TIME DATA COLLATION BY EGUONO EGUONO EGUONO meets the regulations governing the award of Masters Degree in Electrical Engineering at Anambra State University of Science and Technology, Uli and is approved for its contribution to knowledge and literature presentation. ________________________ DR. P.I. OKWU Project supervisor _____________________ PROF. S.S.S. OKEKE Head of Department _____________________ External Examiner ____________________ Date _____________________ Date

___________________ Date

This is to certify that the thesis has been examined and approved for the award of the degree of masters in Telecommunication Engineering (M.Eng).

_____________________ External Examiner

___________________ Date

_____________________ Supervisor

_____________________ Date

_____________________ Head of Department

___________________ Date

_____________________ Dean of Faculty of Engineering

_____________________ Date

_____________________ Dean of School of Postgraduate Studies

___________________ Date

DEDICATION This project report is dedicated to the Almighty God, whose boundless mercies and love has made this research project a huge success.

ACKNOWLEDGEMENTS

I will always owe my unreserved gratitude to my lecturers: Dr. P.I. Okwu my Project Supervisor, and Programme Coordinator who worked relentlessly to make me what I have become today, and for his readiness to help at all time, despite tight schedules; Mal. Sanni Abdullahi, my HOD, for his painstaking efforts towards making the Department one of the best. Special thanks to Engr. Toyin Taiwo, Abebayo B. Michael, and Ishaya Hope Joshua for their kind support throughout the period of this Programme. I must not forget my mother: Mrs. Eunice Anagwu, and Lady, Florence Ulasi, whose love and belief in me always soured me to go for higher achievements. I will not forget my brothers ad sisters: Joy, Ngozi Anagwu, Mr. and Mrs. Chinedu Anagwu, Mr. and Mrs. Felix Chikodi Reginald, Mr. and Mrs. Chuwkunonso Anagwu, Pharm, & Mrs. Chimezie Anagwu, Okwudili, Nnamdi, your prayers have really been fruitful. To my friends and colleagues: Obinna Obi, Ikechukwu Igboebisi, Kelechi Mbagwu, Ya u, Mrs. Gloria Ndubueze and others whose name I may not be able to mention, know that your memories shall always remain with me.

TABLE OF CONTENT Title . . . . . . . . . . . . . . . . . . . . . i ii .

Declaration . . Certification . iii

Acknowledgement . iv Dedication . .

. .

. .

. .

. .

. .

v .

Table of Contents . Vi-viii List of Figures . ix List of Tables . x Abstract . xi . . .

CHAPTER ONE: INTRODUCTION 1.1 Project Background . 1 . . . . .

1.2 Aims of Objectives . 4

1.3 Significance of the Study . 5 1.4 Scope of the Work . 11 .

1.5 Block Diagram overview of the Project stages 13 1.6 Project Report Organization . 15 CHAPTER TWO: REVIEW OF RELATED LITERATURES 2.1 Review of work on temperature controllers .. 2.1.1Principle of Operation 2.1.2Technologies available . 19 2.1.3 New Trends . 22 2.2 Set-up overview . . . . . . . . . . . . . . . . .

. . .

17 17 .

25 .

2.2.1Temperature Measurement and Sensors . 25 2.2.2Microcontroller . . . .

32

2.2.3 Serial Communication RS 232 Technology 33

CHAPTER THREE: METHODOLOGY AND SYSTEM ANALYSIS 3.1 Methodology. 37 3.1.1Structured Analysis and Design method .. .. 37 3.1.2Top-Down Design . 41 3.1.3 Bottom Up Design . 42 3.1.4 Choice Design Approach . 42 3.2 Limitations of the existing system .. 43 CHAPTER FOUR: SYSTEM DESIGN 4.1 System Specification . . . . . . . 45 . . . . . . . . . . . . . . . . . .. .. . . . . . .

4.2 Hardware Subsystem design . 46 4.2.1Input interface . . .

46

4.2.2 The Control System design . 51 4.2.3

Interfacing relay drivers to the microcontroller

output port . 55 4.3 Software Subsystem design . 61 4.3.1Program block diagram and Control Algorithm 61 4.3.2 Configuring the serial port of the microcontroller 66 4.4 The input/output arrangement of the Project 68 4.5 The Project Block Diagram . 69 5.1 Hardware Subsystem Implementation . 70 5.1.1The Input Interface Implementation 70 5.1.2The Control System Implementation 72 5.1.3. 74 5.2 System Testing . . 75 The Output Interface Implementation . . . . 63 . . . 4.3.3 Configuring the PC serial port . . . . .

5.2.1 75

Test Plan

5.2.2 Hardware Subsystem Testing 76 5.2.2

Software Subsystem Testing 77 .

5.3 Performance Evaluation 77

CHAPTER FIVE: SUMMARY AND CONCLUSION AND RECOMMENDADTION 5.1 Summary of Achievement 79 5.2 Problems Encountered and Solution 79 5.3 Conclusion . . . . . 82 80 83 . 5.4 Recommendation . 81 REFERENCES . 84 APPENDIX B: Software Details 85 . . APPENDIX A: Full Schematic Diagram . . . .

5.5 Suggestion for Further Improvement .

LIST OF FIGURES

1. 2. 3. 4. 5. 6. 7. 9.

Fig. 1.1: Fig. 2.2.1:

Block diagram of a PC-Based temperature A 2 wire thermocouple

controller Fig. 2.2.2. A typical picture of a thermistor Fig. 2.2.3 A graph of resistance versus temperature for a typical thermistor Fig. 3.1.1: A structural approach to system analysis Fig. 3.1.2: A block diagram showing the existing system of temperature monitoring and control system. Fig. 3.1.3: A block diagram model of a PC based 4 point temperature monitoring and control. Fig. 3.2.1: Modularized approach to system design 10. Fig. 4.2.1: 5/12 Vdc power supply 11. Fig. 4.2.3: Pin-out diagram of ADC0804. 12. Fig. 4.2.4: Diagram showing a minimum configuration of 89C52 microcontroller. 1.3 Fig. 4.2.5: Relay interface to microcontroller 1.4 Fig. 4.2.6 Diagram showing a MAX232 pin-out. 15. Fig. 4.2.7: Connection arrangement of the microcontroller, MAX232 and DB-9 connector 16. Fig. 4.2.8: Block diagram showing the operation of the microcontroller 17. Fig. 4.2.9: Project Block Diagram.

LIST OF TABLES

1.

Table 1: Reference table showing the relationship between baud rate and length of cable for MAX232.

2. 3.

Table 4.1: Vref / 2 relationship with Vin range. Table 5.1: Test result for the analog MUX

ABSTRACT

This project is aimed at designing a temperature monitoring and controlling system which can be used to monitor the temperature of industrial processes. This system relies upon controller, which is connected to temperature, or set point, and provides an output to a control element. Mostly the control element is a heater. The controller is connected to a personal computer using RS232 protocol. The current temperature can be seen on the PC. This system offers flexibility to controlling operations because the temperature set point can also be changed through the user input. It is believed that this project will remove rigorous and unnecessary monitoring and

controlling activities and hence ensure cheaper and faster product output. A temperature monitoring system which can be used to monitor the temperature of industrial processes has been designed and implemented in the course of this project.

CHAPTER ONE: INTRODUCTION 1.1 Background of the Project

In

typical

manufacturing

industry,

temperature

monitoring makes use of analog temperature controllers. Such controllers can accept thermocouple input and offer

imprecise temperature control over a range such as 75 0C to 1000C. This seemed to pose no disadvantage to them since their products still sell in the market. However, this type of controllers used by these industry, unknowingly, possess no readable display, lack of sophistication for more challenging control tasks, and no communication ability, all of which most often expose the industry to the following problems: Non-uniform heating rate for a point that requires more than one heating element, thus causing delay in startup of production. Wastage of raw materials in test-running the line to ensure that the temperature had reached the minimum required value Poor package outlook because the sealers are not heated uniformly. Extra man-power for each extrusion line- one at the take- off and another at the panel- to ensure that machine is stopped immediately there is a sign of poor quality due to failure of one more of the heaters.

Frequent damage of heating elements as a result of no precision in control which often leads to over- heating the elements beyond upper temperature range.

In view of the above limitations, and more, a pc-based automatic multi- point temperature monitoring and control is hereby proposed to remove the limitations of analog controllers and even add flexibility to the control process. Today, with the continuous price erosion and performance increase of pc, industrial control is moving from an expensive, proprietary hardware base to one with foundation of pc-based software. Pc-based temperature control runs on personal or industrial hardened computers and provides answers to

initiatives for lean control program. With the inherent advantages of a pc-based control include flexibility, high performance, customization, convenience,

easier development, better integration with existing hard wares, portability and access, the proposed system should be able to help manufacturing industries solve their problems by providing uniform heated, precision in measurement and

control, self monitoring and extension of usage to remote, inaccessible locations in the manufacturing floor.

1.2 Aims and Objectives This project PC- based automatic multipoint temperature monitoring and control is aimed at designing a temperature monitoring device which can be used to monitor and control the temperatures of industrial machines. Thus, the complete work can be viewed as a system having three main features which serve as the objectives of the work. PC- based temperature monitoring and control. Automation facility, which enables the system to be self monitoring. Multi-point approach, a feature that makes it possible for more than one point to be monitored. Hence, this project is meant to offer flexibility to monitoring operations by allowing or providing a PCinterfacing feature Which allows an operator to monitor the ongoing process from his PC location at a more convenient and easy-accessible place, It is believed that this project will

be able to remove the rigorous activities of monitoring temperatures by personnel, and engaged him with other production activities, all aimed at ensuring cheaper and fast product output.

1.3

Significance of the Study The beginning of a sweeping change is upon the control and instrumentation world with the availability of robust hardware, open technology and real-time, window-based operating system. PC-based control is emerging as a new control paradigm for increasing manufacturing

productivity. PC base automatic multi-point temperature monitoring and control offers open and more intuitive traditional solutions at a lower total system cost and easier migration to future technologies. Easier

development, integration, portability, and access, ensure a flexible and efficient solution. Some of the inherent advantages of PC-based automatic multipoint temperature monitoring and control include the following: Custom User-Interface for Supervisory Control.

For

low-end

PID

(Proportional

Integral-Derivative)

controllers to high end programmable logic controllers (PCL) system, visualizing the control application can be very challenging. Many stand-alone controllers have fixed digital displays for configuring control set-points and viewing I/O values. PC-based automatic multipoint

temperature controller, being an advanced system, on the other hand, has a display and typically requires a separate software package and human machine interface (HMI) to view and interact with automation systems.

Easy Integrating with Existing System One may already have a control system that works well for most measurement needs but could benefit from additional or advanced control functionality to

optimize certain specialized tasks. A big advantage to using data acquisition hardware and an open PC platform is the number of options you have for connecting to existing equipment. Whether you are communicating with process instrument, PLC, or single loop controllers, you

have a variety of ways to integrate a PC-based control system with existing hardware, this is exactly what a PCbased automatic multipoint temperature monitoring and control does in the case of temperature measurement. Software-defined Control Flexibility. A PC-based automatic multipoint control system offers you complete flexibility in defining system functionality and I/O operations. In addition, even without prior technical skill in wiring a temperature controller, PC-based automatic multipoint control system enables an operator to carry out initial installation since the system just requires relocating it to another sight without rewiring process (5). Also such unskilled operator makes changes in the initial setting using the window-based control interface. Multipoint Monitoring and Control for Performance and Reliability. Beside single point digital temperature controllers which can control only one process, multipoint digital

temperature controllers control more than one point, meaning they can accept more than one input variable. Generally speaking a multipoint controller can be thought

of a device with many individual temperature controllers inside one chassis. These are typically mounted behind the panel in some industrial applications, as opposed to the front-to-panel (FTP) (9). Multipoint temperature

controllers provide a compact more modular system that operates either within a stand alone system or in a PLC environment. They provide a single point of software to access all control loops. Enhance Security PC-based automatic multipoint temperature monitoring and control systems also have enhance security such as not having buttons for a person to use and change critical settings. By having complete control over the information being read from or written to the multipoint controller, the machine builder can limit the information that any given operator can read or change, preventing undesirable conditions from occurring, such as setting a set point too high to a range that may damage products or the machine. Today, manufacturers around the world look to PC to play a bigger role in their control system. PCs are already an

accepted platform for supervisory control, monitoring and reporting, as well as off-line data management and analysis. Manufacturers have already realized the

flexibility of the PC and the easy-to-use open architecture of window-base software applications for manufacturing environment.

Following

the

trend,

PC-based

automatic

multipoint

temperature monitoring and control has emerged to facilitate efficient monitoring and control process for manufacturing industries. Such temperature controllers are used in a wide variety of industries to manage manufacturing processes or operations. Some common applications include the following. Heat Treat/Oven Temperature controllers are used in ovens and in heat treating applications within furnace, ceramic kilns, boilers and heat exchangers.

Packaging

Temperature controllers must maintain a uniform level at designated temperatures and process time length. This helps to ensure a high quality product output. Plastics Temperature control in the plastic industry is common on portable chillers, hoppers and dryers, and molding and extruding equipment, temperature controllers are mused to precisely monitor and control temperatures at different critical points in the production of plastics. Health Care Temperature control is required in laboratory and test equipment, autoclaves, incubators, refrigeration

equipment and crystallization growing chambers and test chambers where specimens must be kept or test must be run within specific temperature parameters. Food and Beverage Common food processing include: applications brewing, involving blending,

temperature

control

sterilization and cooking and baking ovens. Controllers regulate and/or process time to ensure optimum

performance.

Cable Manufacturing Insulation materials require as specific temperature which must be maintained uniformly throughout the barrel and nozzle zones to ensure good quality of product. Efficient temperature monitoring and control systems are required to achieve this. Finally, the steps taken to incorporate PC to temperature monitoring and control is one of the many steps required for a complete computer automation of industrial

processes. Thus, other parameters such as pressure, colour, texture and so on, can be computerized, providing a platform for a unified process control. 1.4 Scope of the Work This work covers the following areas: Temperature Measurement Temperature sensors are reviewed and choice made on the most applicable sensors. The sensor measures the temperature of the points and converts the reading to a voltage value. This value is then sent to the

microcontroller which compares it with the set-point value, takes appropriate action in order to restore tolerable limits.

Hardware Programming High level C-programming language is used to develop codes for the microcontroller to enable it read the values sent by the sensors and take appropriate actions. The Visual Basic Window-based software will be used to communicate with the PC operating system and the Cprogram running on the hardware in order to read the user set-point values and current temperatures. Window-based Software Programming Communication between the hardware and the PC (serial communication) is facilitated by programming the PC to be able to communicate with the serial port. The Visual Basic Window-based software will be used to

communicate with the PC operating system and the Cprogram running on the hardware in order to read the user set-point values and current temperatures. Level Conversion

In order to ensure a compatible voltage level between the hardware and the PC, the MAX 232 technology is employed. This converts the hardware voltage level to a voltage which can be handled by the serial port in the PC.

1.5 Block Diagram Overview of the Project Stages

Analog to Digital Interface Liquid Crystal Display Microcontroller Unit

Temperature Sensors

Keypad

RS232 Interface

PC-based application

Fig.1.2:

Block

diagram

of

PC-based

temperature

controller A temperature control system relies upon a controller, which is connected to a temperature sensor. It compares the actual temperature to the desired control

temperature, or set-point, and provides an output to a

control element. Mostly the control element is a heater. The controller is connected to a Personal Computer using RS232 protocol. The Current Temperature can be on the PC, whereas the Temperature Set-point can also be changed through the PC or embedded buttons. The different sections of this project are: 1. 2. 3. 4. 5. Microcontroller Analog to Digital Converter (ADC) Temperature Sensor Relay MAX 232

Microcontroller: It is the heart of the unit. It performs all the functions like getting data from ADC, comparing the current

temperature to set-temperature, turning ON/OFF the relay and communicating with the PC. Analog to Digital Converter: The ADC converts the Analog voltage received from the Temperature Sensor into digital format and gives it to the microcontroller. Temperature Sensor:

The

temperature

sensor

measures

the

current

temperature and sends value in for of voltage to the microcontroller. Some IC (e.g. LM35) sensors have output proportional to the input temperatures. MAX 232: Communication with the PC is done through the SERIAL PORT. The protocol of serial port is RS-232, for interfacing the controller to the PC using RS-232 protocol, we require MAX 232 IC. 1.6 Project Report Organization The design and simulation of the project, PC-based automatic multipoint temperature monitoring and control system, followed a systematic approach which reveals a step-by-step analysis of an existing system, until a realizable, better system is arrived at. This report covers the entire steps followed to arrive at the complete envisaged system. Diagrams and tables are employed, where necessary, to illustrate facts and results. Chapter one of this report is an introduction to the project. It covers the following areas: the project background, aims

and objectives of the work, justification and scope of the work and the block diagram overview of the project stages.

Chapter two is a literature review of related works. In this chapter, the general concept of temperature control is xrayed; different technologies of relevant components are also reviewed. In the third chapter, the temperature control technique as used in an industry is analyzed and shortcomings of the existing system outlined. Different methods of achieving a better system are also explored. Then, choice is made among all the available options. The option chosen is basically dependent on the nature of the envisaged system. Chapter four describes the proper system design. The input, output and software interfaces are systematically modularized and designed. The block diagram of the modules (put together) is also towards the end of this chapter.

The

whole

of

chapter

five

is

concerned

with

the

implementation of the designed system. This involves the wiring schedules, full schematic diagram and integration of the different modular designs and schematics,

simulation, testing and performance evaluation, costing and deployment of the achieved work. Finally, the last chapter deals with the summary of achievement, problems encountered during the project design and implementation stages and the solution proffered. Recommendations and suggestions for further improvement are also included.

CHAPTER TWO REVIEW OF RELATED LITERATURES 2.1 Review of work on Temperature Controllers 2.1.1 . Principle

A temperature controller is a device used to hold a desired temperature value (2). The simplest example of a temperature is common thermostat found in homes. All controllers, from the basic to the most complex, work on the same way. There are

two variables required by the controller; actual input and desired set-point value. The input signal is also known as the process value. The input to the controller is sampled many times per second, depending on the controller. This input or process value is then compared with the setpoint value, if the actual value does not match with the set point, the controller generates an output signal change based on the difference between the set-point and the process value, and whether or not the process value is approaching the set-point or deviating farther from the set-point. This output signal then initiates some type of response to correct the actual value so that it matches the set-point. Usually the control algorithm updates power value which is then applied to the output. The control action depends on the type of controller. For instance, if the controller is an ON/OFF control. The controller decides if the output needs to be turned on, turned off, or left in its present state. A temperature controller set control the temperature inside a room may have its set-point at 68 oC and the actual temperature 67oC. The controller would then send a signal to increase the applied heat to raise the temperature back to the set-point of 68oC.

When analog output is used, the output driver is proportional to the output power value. However, if the output is binary output type such as a relay, SSR driver, or triac, then the output must be time proportioned to obtain an analog representation. A time proportioned system uses a cycle time to proportion the output value. If the cycle time is set to 8 seconds, a system calling for 50% power will have the output ON for the 4 seconds and OFF for 4 seconds, while one for 25% power for the same 8 seconds cycle time, will be ON for seconds and OFF for 6 seconds. All things being equal, a shorter cycle time is desirable because the controller can react quickly and change the state of the ouput for a given changes on the process. Due to the mechanics of a relay, a shorter cycle time can shorten the life of a relay, and is not recommended to be less than 8 seconds. For solid switching devices like SSR driver or triac, faster switching times are better. The general rule is that, only if the process will allow it, when a relay ouput is used, a longer cycle time is desired. (2).

Typically, all controllers have input and ouput parts. In the case of a temperature controller, the measured input variable is the temperature. Temperature controller can have several types of inputs. The type of input sensors include thermocouples, resistive thermal devices (RTDs) and integrated circuits (e.g. LM35). Sensors are treated later in this chapter. In addition to inputs, every controller also have an output. Typical outputs provides with temperature controllers include relay outputs, solid state relay (SSR) drivers, triac and linear analog outputs. In some cases, the output signal may be required to retransmit the process to a programmable logic controller (PLC), recorded or personal computer (PC). In the case of a PC- based temperature controller, the controller is connected to a personal computer using the RS 232 protocol. A software program running on the PC can be used to display the values on the PC while the set-point can still be changed using the PC.

2.1.2

Technologies Available

Temperature controllers come in different styles with a vast array of features and capabilities. There is also plenty of ways

of categorize controllers according to their functionality. In general, temperature controllers and either single loop or multiloop. Single loop controllers have one input and one or more outputs to control a thermal system. On the hand, multi-loop controllers have multiple inputs and outputs, ad capable of controlling several loops in a process. More control loops permit controlling more process system functions. Thus, major

development in control technology revolves around increasing the control capabilities of the controllers. Reliable single loop controllers range from basic devices that requires single manual set point changes to sophisticated profiler that can automatically execute up to eight set-point changes over time period (2), (9).

The simplest basic controller type is analog controller. Analog controllers are low cost, simple controllers that are versatile enough for rugged, reliable process control in harsh industrial environments including those with significant electrical noise. Controller display is typically a knob dial. Analog controllers are synonymous to relay controllers which emerged in the early 60s (9).

Basic analog controllers are used mostly in non-critical or unsophisticated thermal systems to provide simple ON/OFF temperature control for direct or reverse acting application. Such controllers accept thermocouple or RTD as input sensors, and they offer imprecise measurement.

Limit controller is another type of controller. It provides safety limit control over process temperature. They have no ability to control temperature on their own. Put simply, limit controllers are independent safety to be alongside an existing control loop. Limit control is latching and part of redundant control circuitry to positively shut a thermal system down in output must be reset by an operator, it will not reset by itself once the limit condition does not exist.

By early 70s (9), the programmable Logic Controller emerged with a promising higher control capability. The PLC belongs to the general- purpose temperature controller and is used to control most typical processes in industries. Typical, they come in a range of DIN sizes; have multiple outputs and

programmable output function. These controllers can also perform PID control for excellent general control situations. They are traditionally placed in the front panel with the display for easy operator accessibility.

Value Motor Drive temperature controllers are specifically designed to control valve motors used in manufacturing applications such as gas burner control on a production line. Special tuning algorithms give accurate control and fast output reaction without the need for slide ware feedback or excessive knowledge of three-term PID tuning algorithms-proportional derivative. Valve motor drive digital controllers are used to control the position of the valve, somewhere between 0% open to 0% open, depending on the energy needs of the process at any given time. They use of ON/OFF Duplex function which is a very simple algorithm and like its counterpart, ON/OFF control, is another low cost controller with fast output reaction but low accuracy.

2.1.3

New Trends

Modern temperature controllers came out as the need for automatic calculation of PID parameters for optimal thermal system performance arose. The PC-based controllers followed the introduction of MMI/SCADA in the mid 80s (8), replaces the traditional and proprietary controllers such as PLC, with standard PC-based hardware and software. PC-based control runs on personal or industrial hardened computers and provides answers to initiatives for lean control program. This PC-based control approach provides end-users and machine builders with a platform to dramatically reduce control system design time and maintenance cost by reducing down-time with built in diagnostic, real time simulation, and consolidation of data into a single database. Some estimates indicate the PCbased control market is growing at a rate of over 70 percent a year! (8).

The PC and desktop software industries are also participating in this evolution of control with the evolution of window NT. Window NT version 4.0 is the first Window-based operation system (6) that provides a truly deterministic, real time operating system. The advent of many software OS lends PCbased control more facilities for developing better functionality.

For example, even without any prior programming experience, you can use NI LabVIEW graphical development environment to define custom control functionality and meet your unique needs. You can build onto the basic LabVIEW application to add features (6) such as Signal processing functions like filtering and averaging; Configurable dead banding and hysteresis; Data Collection and report generations; and Additional input and output channels.

Some manufacturers of temperature controllers have extended the advantages of PC-based control in designing more

sophisticated controllers such as the profiling digital controllers or profilers. Profiling digital controllers, also called Ramp-Soak controllers are controllers that will allow the operator to program a number of setpoints and the time to sit at each setpoint. The changing of the setpoint is called Ramp and the time to sit at each set point is called Soak or Dwell. One remp and one soak are considered to be one segment. A profiler offers the ability to enter a number of segments to allow complex temperature profiles. There are many

applications for a profiling controller. The profiles are often

referred to as recipes by the operator and are often kept on a computer and downloaded via a communications channel directly into the controller as needed. Most profilers allow storage of multiple recipes for later use. Smaller profilers may allow for 4 recipes with 16 segments each while more advanced profilers would allow for more. Profile temperature controllers are able to execute ramp-and-soak profiles such as temperature changes over time, along with hold and soak/cycle duration, all the while being unattended by an operator, allowing the operator to perform other tasks. Typical

applications for profile temperature controllers include heat treating, annealing, environmental chambers, and in complex process furnaces.

2.2 Set-up Overview In this section, the different technologies of the major components used in this project are explored.

2.2.1

Temperature Measurement and Sensors

Temperature monitoring is central to the majority of data acquisition systems, be it to save energy costs, increase safety,

testing time whatever your reasons, you will need a device to measure the temperature a sensor. Thermocouples,

resistance temperature device (RTDs), thermistors and infrared thermometers are all types of temperature sensor. Which can choose depends on factors like your expected maximum and minimum temperatures, the accuracy you need and your environmental conditions. The most popular sensors are thermocouples, RTDs, thermistors and ICs. These are discussed below, pointing at potential problems when using some of them in computerized temperature measurement.

Thermocouples Thermocouples are popular temperature sensors because they are cheap, versatile and sturdy. They consist of two dissimilar metals joined together, making a continuous circuit. If one junction has a different temperature to the other, an

electromotive force (voltage) is set up. This voltage varies with the temperature difference between the junctions. If the temperature at one junction is known, the temperature at the other junction can be calculated.

Types of Thermocouple There are several types of thermocouple, labeled with letters according to their constituent metals. A K-type thermocouple, for example, is made up of chrome and Alumel. The metals give the thermocouples differing properties, such as temperature ranges and accuracy.
Thermocouple Wires (2 Types) Copper wire Sensing Junction Reference Temperature Voltmeter

Figure 2.2-1: A 2 wire thermocouple

Potential Pitfalls in a Computerized Thermocouple System The Cold Junction Reference Measurement . The system depends on knowing the temperature of one of the thermocouple junctions (the cold junction). Housing this junction in an isothermal box will keep the temperature constant, and a cold junction sensor in the box will tell the system the temperature. In our plug-in card example, the

isothermal box sits outside the computer. You would connect the thermocouple wires to screw terminals in the box, and connect the terminals to the card with a ribbon cable. Attaching the Thermocouples to Metal Surfaces. if

the thermocouples are directly to a metal surface, particularly one carrying its own voltage such as heating element, you need to isolate the signals. This will prevent high voltages in the monitored item damaging the data acquisition equipment. It will also make the

measurements floating, letting you record the small thermocouple voltage in the presence of high voltages. Linearization. The voltage produced by a thermocouple does not change linearly with temperature presenting a problem for the data acquisition system. A good solution is to use software (7) to obtain the correct temperature in, say,
0

C or

F. Some custom-made software kits, e.g.

Windmill, can do this automatically for B, E, J, K, N, R, S and T type thermocouples. Using the Wrong Type of Thermocouple Lead.

You need to connect the thermocouple to the data acquisition equipment using the correct type of extension or compensation lead. This is made of either the same material as the thermocouple metals, or material with similar characteristics. Long Thermocouple Leads Noisy Signals and Added Wiring Costs. Thermocouple leads are often many metres long, and have a higher resistance than normal copper wire. This means that the lead can act as aerials, picking up environmental electrical noise that contaminates the voltage signal. It might also mean expensive wiring costs. In this case you need either to take precautions against nose, or distribute data acquisition units placing them close to the thermocouples on Modubus, RS485 or Ethernet networks for example. RESISTANCE TEMPERATURE DEVICES (RTDs) Resistance temperature devices (or detectors) rely on the principle that the resistance of a metal increases with temperature. When made a platinum, they may be known as

platinum resistance thermometers (PRTs), and when specified to have a resistance of 100 ohm at 00C, as Pt 100. Potential Pitfalls in a Computerized RTD System Errors Arising from Lead Resistance. When the resistance to be measured in small, the resistance in the leads to the RTD can significantly affect accuracy. Several methods exist for monitoring RTDs, which address the problems associated with lead

resistance. These methods include balanced bridges and constant current sources. Constant excellent including current results 2-wire, source for 3 all wire, measurements wiring 4-wire give

configurations, and 4 wire

compensated. The most accurate results are obtained using a 4 wire

arrangement. Each RTD requires the data acquisition hardware to provide a constant current source. The current flows through the RTD and the voltage drop the RTD is measured. Using Ohms law the value of the resistance of the RTD can be calculated. Converting the Resistance to a Temperature.

Software like Windmill automatically converts the resistance measurement to a temperature in your choice of engineering units (7).

Thermistors Thermistors are inexpensive, easily-obtainable temperature sensors. They are easy to use and adaptable. Circuits with thermistors can have reasonable output voltages not the millivolt outputs thermocouples have. Because of these

qualities, thermistors are widely used for simple temperature measurements. Theyre not used for high temperatures, but in the temperature ranges where they work they are widely used. Thermistoers are temperature sensitive resistors. All resistors vary with temperature, but thermistors are constructed of semiconductor material with a resistivity that is especially sensitive to temperature. However, unlike most other resistive devices, the resistance of a thermistor decreases with

increasing temperature. Thats due to the properties of the semiconductor material that the thermistor is made from. Figure 2.2-3 is a graph of resistance as a function of temperature for a typical thermistor. Notice how the resistance drops from 100000 ohms, to a very small value in a range

around room temperature. Not only is the resistance change in the opposite direction from what you expect, but the

magnitude of the percentage resistance change is substantial.

Fig 2.2-2: A typical picture of a thermistor

R 104

102

100

200

300

400

500 T (0K)

Fig 2.2-3 Graph of resistance versus temperature for a typical thermistor.

Sensor (LM 35) The LM 35 is an integrated circuit sensor that can be used to measure temperature with an electrical output signal

proportional to the temperature in degree Celsisu. Actually IC temperature sensors consist of integrated temperature dependent resistors whose output voltage increases

proportionally with increase in temperature due to increased output resistance. A brief summary of its advantages over other sensors include: more accurate and precise temperature measurement; scaled sensor circuitry so that it is not subject to oxidation and other environmental factors; output conditioning of LM35 is simpler when compared to that of thermocouples, thermistors, etc. The above inherent properties of IC temperature have made the more desirable in computerized applications.

2.2.2

Microcontroller

A microcontroller is a single chip microprocessor system which contains data and program memory, serial and parallel 1/O, timers, and internal interrupts, all integrated into a single chip. First microcontrollers were developed in the mid 70s (4). These were basically calculator-based processors with small ROM program memories, very limited RAM data memories, and a

handful

of

input/output

ports.

More

powerful

bit

microcontrollers were later developed. In addition to their improved instruction sets, these microcontrollers included onchi counters/timers, interrupt, 1/O, on-chip ultra-violet erasable EPROM memory. The 8051 family was introduced in the early 80s by Intel. Currently this family of microcontroller has many versions and some types of included on-chip analog-to-digital converters. In the 90s, the recent microcontroller, Intel 8951 evolved with all the features and instruction set of the other trends to microprocessors. This gives it the ability to be used more easily with minimum cascading, or even without additional memory devices. Still in this twenty first century, another Intel 8952, which is an advanced form of Intel 8951, has been introduced. Today, microcontrollers have moved into other more powerful, 16 bit market. They are high performance processors that find application in real-time and computer intensive fields (e.g. in digital signal processing or real-time control).

2.2.3

Serial Communication

Communication is essential in electronics system. It can be in the form or wired or wireless, serial or parallel. The main idea is to transfer information from one system to another system, communication in one direction is call a simplex communication system, and duplex means communication is in both direction at the same time. Half duplex means that communication is taking place in both direction but only one direction

communication is taking place at any one time. Communication between electronics devices usually deals with logic Is and 0s. a typical electronic system uses the concept of voltage or frequency. The choice of signal varies.

Voltage/frequency changes can be produced and detected using simple electronics, so it is relative a easier type of signal to implement. The information from the sender can be in the form of voltage. By detecting the voltage, the receiving device is able to interpret the information. The common understanding or interpretation of both the sending and receiving device is known as the communication protocol. The information

conversion to a suitable transmission signal is also known as encoding. Decoding is the other way round.

In todays wired communication system, there are a wide variety of serial communication standard from RS232, RS485, USB, CAN, and many more. They are simply the standard defined for communication hardware. Today, various serial communication interface USART are present. They are TTL version of the serial communication, represented by 5V/0V. It is similar to RS232 physical format represented by -/+IOV in the voltage. USART is not design for distance communication. To enable longer communication distance, USART signal will need further encoding into RS232 signal format before transmission. Other common names for USART (Universal Synchronous

Asynchronous Receiver Transmitter) are UART or SCI (Serial Communications Interface). Serial data in TTL format is the very basic serial communication interface to understand. RS232 is the encoded version of USART. The encoded signal allows the data to be deployed for longer communication distance. Some article may have defined a maximum communication distance of 15m for RS232 signal. You can try pulling the

communication distance further, it should still works actually. 15rn is only a general guideline.

If the data transmission rate is low, the distance can even go

further. There have been reports from the internet that some users have achieved 50m to 200m without any problem. In this project, I have tried baud rate of 9600bps over 100m without any problem. Baud-rate is presented in bps (data bits per second). The higher the value the more the data can be transmitted in a given time period. The higher the speed, the shorter the communication distance. The data transmission length of the cable can be determined by many factors. The factors include the following: - Data transmission speed - Quality of the cable, noise (unwanted signal) - Transmitted voltage ' - Receiver sensitivity - Etc. Communication distance using RS232 can be increased further if the cable is of better quality, a shield or coaxial cable for example. The most significant factor is the data transmission speed. The following is a reference diagram showing regarding the relationship between data baud rate and cable length.

Baud-rate

Length (distance)

19200bps

15m

9600bps

150m

4800bps . 2400bps .

300m 900m

Table 1: Reference table showing relationship between baud-rate and length of cable, for MAX232.

1C chip maker has come up with the integrated circuit for interfacing RS232 with TTL logic (5V for logic 1, 0V for logic 0), making the interfacing work very simple. MAX232 is one of the many 1C in the market which helps to convert between RS232 -/+10V and TTL +/- 5V. The charge pump design allows the circuit to generate +/-10V from a 5V supply. (See fig. 4.2.7).

CHAPTER THREE: METHODOLOGY AND SYSTEM ANALYSIS 3.1 Methodology Before the inception of the idea that a PC-based system can be employed to facilitate efficient monitoring and control of temperatures of industrial processes, a number of steps was explored in arriving at a conceptual model of the new system.

3.1.1 Structured analysis and design The steps began with investing and understanding the current/existing physical system. The various steps are summarized the diagram below.

EXISTING PHYSICAL SYSTEM

EXISTING LOGICAL SYSTEM

REQUIRED LOGICAL SYSTEM

REQUIRED PHYSICAL SYSTEM Figure 3.1-1: A structured approach to system analysis

Existing Physical/Logical System As earlier mentioned, Cutix Pic Nnewi, like most other manufacturing industries, make use of analog temperature controllers with thermocouple sensors as Inputs. The concept/logical model of the existing system can be viewed as shown below:

HEATER 1

SENSO R1

HEATE R2

SENSO R2

HEATE R3

SENSO R3

HEATE R4

SENSO R4

R1

R2

R3

R4

CONTROLLER 1 ON/OF F

CONTROLLER 2 ON/OF F

CONTROLLER 3 ON/OF F

CONTROLLER 4 ON/OF F

POWER SUPPLY

Figure 3.1-2: Existing physical system of temperature control and monitoring system.

Considering a four-point temperature control and monitoring requirement which already was implemented using a separate, stand alone temperature controllers. Such control can be achieved using analog controllers or even stand alone PLC. Each control unit is independent of the other. A problem

statement was formulated after attempting to provide answers to the following questions: 1. How can the temperature be measured more accurately so that quality control can be optimized? 2. Can there be a possibility of bringing the control under the supervision of only one hardware so that easy supervision an4 surveillance can be made on the process? 3. Can there be a means of establishing a common

communication interface and display so that monitoring can be done more effectively and abnormality noticed on time before having 'any damaging effect on the machine or

product. For instance, when a thermocouple or controller fails, how can we get a timely notice for its replacement? \ 4. How can more security be implemented so that somebody does not tamper with the set-point on the controller and reset the knob at a wrong setting. 5. How can the installation process be simplified so that much time is not devoted to mounting the system in a new place of interest? The problem statement can now be formulated: "a need to design and construct an automatic multipoint temperature monitoring and control system". Such system should have the following features: - ability to provide precise and accurate temperature measurement. ability to handle the control of all the four temperatures that need to be controlled. communication user interface with dip hardware for

monitoring and controlling the four points almost simultaneously. ease of installation without requiring the whole production

process be shut down. - room for integration with other systems if need be. The Proposed Logical/Physical System

Looking at the deficiencies of the existing system and the features required of the required system,, a PC-based approach to system control seems to meet the requirements for the new system. A physical representation of the proposed model is as shown below.

HEATER 1

SENSO R1

HEATE R2

SENSO R2

HEATE R3

SENSO R3

HEATE R4

SENSO R4

R1

R2

R3

R4

SINGLE CONTROLLER HARDWARE

CPU

SCREEN POWER SUPPLY

Figure 3. 1-3: A Block Diagram model of a pc-based 4point temperature monitoring and control 3.1.2 Top-down Design Top-down design is the technique of beginning with a complex project and breaking it down into its constituents. For a supra system which consists oF several systems and subsystems, a top-down design approach of such system can be represented as follows: SUPRA SYSTEM

SYSTEM

SUBSYSTEM

PROGRAM MODULES

Hence,

the

project

"PC-based

automatic

multipoint

temperature monitoring and control" is a supra system with components system as temperature controller system, made up of data acquisition

(or temperature measurement.) unit and control unit; and - temperature monitoring system, made up of hardware inletfacing with PC and user program (Window-base program)

development. Each of the individual system has its other subsystem and program modules. 3.1.3 Bottom-up Design This is a situation where one starts with simple subsystem or program modules and proceeds to constitute the main system and subsequently supra system, as the case may be.

3.1.4 Choice Design Approach The design approach used in this project design is the top-down design. The whole system is broken down into different smaller modules. MODULE 1: Design of the data acquisition system. This comprises wiring and interconnecting tlic sensors, ADC, and multiplexers to the microcontroller. MODULE 2: Configuration of the microcontroller 89C52 and its control program using C programming language. The MAX232 protocol is also configured at this stage.

MODULE 3: Design of the PC monitoring Window-based interface. Here, the Visual Basic (VB 6.0) programming languagc.is used to write a program that will enable the PC to communicate with the hardware (controller).

MODULE 1

MODULE 2

MODULE3

Fig.3.2-1: Modularized approach to the project system design The final step is integration of the different modules to form the system required. It is important to note that any of the above modules can be tackled first and important information that can be used for the other recorded appropriately for reference purpose. 3.2 Limitations of the Existing System It seems appropriate at this point to explicitly enumerate the major deficiencies of the existing system, which prompted the

design of the new system. From the on-going discussions and the analysis carried out ab initio, it will be discovered that; the old system does not provide a precise temperature measurement due to the inherent characteristics of the sensors used; monitoring and controlling the temperatures of more than one point at the same time, using the old system is more cumbersome and demanding since there are different controller for each temperature; with the old system, a staff should always go round to observe the controllers at all time to know the one which is malfunctioning or not functioning at all. This task would be made easier using a PC-based multipoint temperature monitoring and control where all events are observed at a time from one point PC screen. Also, there is the possibility of all point being interfered with by an intruder thereby distorting normal production parameter settings. Such is minimized with PC-based system.

CHAPTER FOUR SYSTEM DESIGN, SIMULATION AND PERFORMANCE EVALUATION 4.1 System Specification

The PC-based automatic multipoint temperature monitoring and control system is a system that helps users to continuously monitor the temperatures of different points of interest at the same time with the help of a personal computer (PC). The system will be able to maintain a desired temperature set by the user at a stable value. During operation, the maximum value is keyed in by the user. The current value of the point being monitored must not go above the maximum set-point. A stable set-point range is maintained by the microcontroller-based hardware which turns ON a respective heater for each point whenever the current temperature reading tends to go below the maximum set-point, and turns OFF the heater whenever the maximum set- point is reached. Thus the required temperature is maintained by the hardware for optimum production operation. For this project, the range of temperature measurable by the system is from OC to 100C; i.e. the maximum set-point must not be any value outside the range of 0 - 100,

(0oC < Tmax < 100oC). This system is capable of monitoring and controlling up to four different points of interest concurrently but independently. 4.2 Hardware Subsystem 4.2.1 Input Interface MODULE 1: Design of the data acquisition system. Mere, the following parts of the project are designed and configured. - Power supply - Sensor configuration with the ADC.

Power Supply Design The power supply requirement for all the components used in this falls within the 5VDC and 12VDC supplies. Therefore, a suitable 5V/12DC supply is designed using the following components: 240/12VAC step-down transformer, a bridge rectifier 1C, 7505-5V and IN4742 12V voltage regulators and capacitors of varying specification.

Fig. 4.1.1: A 5V/12VDc Power Supply Circuit. The input voltage to the power is to be within the range of 7 to 20 VAC. Here a step-down (240/15VAC) transformer is used to supply 15VAC to the circuit. The MC7505 5-V regulator and zener diode 1N4742 are used in the circuit to provide a fixed 5vDcand 12vDc outputs respectively for the system components. The power supply circuit can handle up to 1A of current, provided that the transformer can handle the current. The voltage regulator is provided with heat-sink for easy heat dissipation.

Sensor (LM 35) The LM 35 is an integrated circuit sensor that can be used to measure temperature with an electrical degree output signal The

proportional to

the temperature in

Celsius.

summary of its advantages over other sensors have been discussed in chapter two. The operational characteristics ofLM35 temperature sensor includes the following: - Output voltage that is proportional to the Celsius temperature; - accuracy of about +/- 0.4C at room temperature and +/0.8C over a range 0C to 100C; It draws only about 60uA from its supply and possesses allow self-heating capability (the sensor self-heating causes less than 0.1C temperature rise in still air.

Calibrating the LM35 with respect to ADC step output

The ADC0808 has 8-bit resolution with a maximum of 256 steps and the LM35 produces l0mV for every degree rise of temperature. The calibration of LM35 sensor will be such that for output of 0C to 100C, the input to the ADC ranges from 0 to 256 x l0mV, i.e, 0 - 2560mV or 0 - 2.56V. ADC CONFIGURATION The ADC used is ADC0808. It has the frequency F = 1 Hz I.IRC Where R = 10K, C = 150pF F = 606 KHz.

Fig 4.2.3: Pin-out diagram of ADC0808

Vcc: this is +5V power supply pin or a reference voltage pin when Vref/2 input pin is open. Vin(+) is used as the only input to be converted when Vin (-) is connected to the ground. WR (start conversion) is used to signal the ADC0808 to start converting the analog input of Vin to an 8-bit digital number, whenever the pin makes a low-to-high transition. CS is an active low input used to activate the ADC808. RD (output enable): A high-to-low RD pulse is used to read the converted data output of the ADC.

Another parameter to consider in configuring the ADC is the Vref/2. This determines the step-size of the ADC and subsequently the digital output of the ADC. The following table shows Vref/2 relation to Vin range. VrcI/2(V) Vin(V) Stepsize(mV) 1 Not 0 to 5 5/256 19.53

connected 2.0 .i.5 1.28 0 to 4 4/256=15.62 0 to 3 3/256-11.71 0 to 2.56 2.56/256= 10.0

1.0

0 to 2 2/256 = 7.81

0.5

0 to 1 1/256 = 3.90

Table 4.1: Vref/2 relationship with Vin range From the table above, to get a l0.0mV stepsize of the LM35 Vref/2 of value 1.28 is required. This value is achieved by connecting potentiometer to fix the voltage across the 10K pot at 25 volts. This should overcome any fluctuations in the power supply. Digital output of the ADC is given by;

Dout = Vin

Stepsize

For example, when the LM35 inputs 250mV to the ADC, the digital output, from the ADC after conversion should be

Dout = 250mV
l0mV = 25C as temperature reading. 4.2.2 The Control System Design MODULE 2: The microcontroller is the central control unit in this project. The microcontroller used in 89C52. The diagram below shows the pin-out of 89C52.

Fig.

4.2.4:

Pin-out

diagram

of

89C52

with

minimum

configuration

RST: This is the reset input. This input should normally be at logic 0. A reset is accomplished by holding the RST pin high for at least two machine cycles. Power on-reset is normally performed by connecting an external capacitor and a resistor to this pin. (See fig...) XTAL1 and XTAL2; These pins are where an external crystal should be connected for the operation of internal oscillation device. P3.0 (bit 0 of port 3): This is a bi-directional 1/0 pin with an internal pull-up resistor. It is also used as the data receive input (RXD) when the device is used as an asynchronous UART to receive serial data. P3.1 (bit 1 of port 3): This is also a bi-directional 1/0 pin with an internal pull-up resistor. This pin also acts as the data transmit output (DXT) on the 8051 family when the device is used as an asynchronous UART to transmit serial data.

P3.2 (bit 2 of port 3): This is a bi-directional 1/0 pin with an internal pull-up resistor. This pin is also the external interrupt 0 (INTO) pin. P3.3 (pin 3 of port 3): This is a bi-directional 1/0 pin with an internal pull-up resistor. This pin is also the interrupt (1NT1) pin. P3.4 (bit 4 of port 3): This is a bi-directional 1/0 pin with an internal pull-up resistor. This is also the counter 0 input (TO) pin. P3.5 (bit 5 of port 3): This is a bi-directional 1/O pin with an internal pull-up resistor. This pin is also the counter 1 input (TI) Pin. GND: This is the ground Pin. P3.6 (bit 6 of port 3): This is a bi-directional 1/O pin. This pin is not available on the 89C2025. It is also the external data memory write (WR) pin. P3.7 (bit 7 of port 3): This is a bi-directional/1/O pin. On the standard 8951, this pin is also the external data memory read (RD) pin. P1.0 (bit 0 of Port 1): This is also bi-directional 1/O pin. This

pin has no internal pull-up resistor on the 20 pin devices. It is also used as the positive input of the analog comparator (AIN0) on the 20-pin device. P1.1 (bit 1 of Port 1): This is a bi-directional 1/O pin. This pin has no internal pull-up resistor on the 20-pin devices. It is also used as the positive input of the analog comparator (AINI) on the 20-pin device. P1.1 (bit 1 of port 1): This is a bi-directional 1/O pin. This pin has no internal pull-up resistor on the 20-pin devices. It is also used as the positive input of the analog comparator (AINI) on the 20-pin device. P1.2 to P1.7: These are the remaining bi-directional 1/O pins of port 1. These pins have internal pull-up resistors. Vcc: This is the voltage supply pin.

Fig.4.2.4 shows that the following external components are required to have a working microcontroller. XI-. Crystal (e.g. 12MHz) Cl.C2:33pF capacitor

C3; l0uF / 10V electrolytic capacitor R1:8.2K,0.125W resistor. Programming requirement The microcontroller used in this project was programmed using the following: 1. Suitable C compiler which generates machine codes for the microcontroller. The M1DE-51 editor software was used in this project due to its wide compatibility with C compilers.

4.2.3 Interfacing relay driver to the microcontroller output port. The four points being monitored by this system, each has a sensor and a heater. When the maximum temperature is exceeded or the minimum temperature more than the current temperature, a control signal is sent to the respective output port of the microcontroller for switching ON or OFF a corresponding heater-as the case may be. Four separate output pins (P2.0 to P2.3) are used as output to the relay drivers. A

typical design for interfacing a relay to a microcontroller is done here.

Fig. 4.2.6: design of relay interface to a microcontroller. The function of the relay driver is to provide the necessary current typically 25 to 70mA to energize the relay coil. AN NPN is used to drive the relay. The transistor is driven to saturation

(turned ON) when logic 1 is written on the port pin thus turning ON the relay. The relay is turned OFF by writing logic 0 on the port. A diode is connected across the relay coil to protect the transistor from damage due to back emf generated in the relay's inductive coil when the transistor is turned OFF. When the transistor is switched off, the energy stored in the inductor is dissipated through the diode and the internal resistance of the relay coil. A pull-up resistor is used at the base of the transistor. The microcontroller 8052 has an internal pull up resistor of 10K, so when the pin is pulled high (logic 1), the current flows through tins resistor. The maximum output current is 5V = 0.5mA 10K BC547 has a DC current gain of 100, so the maximum collector current is 0.5x100-50mA This value is not enough to turn the transistor to saturation. Therefore, an external pull-up resistor is used. When the controller pin is high, current flows through the controller pin as well as through the pull-up resistor. For the circuit shown, a

4.7K pull-up resistor is used; so the current added to the base current is 5V = 1.1mA 4.7K Hence, the total base current is (0.5+1.1) mA = 1.6mA. The maximum collector current is I.6mAxlOO = 160mA, which is enough to turn ON the relay driver- BC547. NB: The same arrangement is connected to each of the four output pins connected to the four different heaters, Interfacing aMAX232 technology to a Microcontroller The MAX232 diagram below shows that it has two sets of line drivers: Rl, Tl and R2,T2. The communication cable from the hardware through the MAX232 is connected to the PC port using the DB-9 connector.

Fi g. 4.2.7: Diagram showing a MAX232 pin-out The diagram below shows the pin connections (pin-outs) of a 9way serial port. Each pin has a two of three letter mnemonic as follows:

GND 5 DTR 4 TXD 3 RXD 2 CD 1 RI 9 CTS 8 RTS 7 DSR 6

Pin # 1

Mnemonic Meaning CD Carrier

Detect 2 RXD -

Receive Data 3 Data 4 5 6 7 8 9 DTR GND DSR RTS CTS RI Data Terminal Ready Ground Data Set Ready TXD Transmit

Request To Send Clear To Send Ring Indicator

For a simple serial communication there are three pins that are important. Data is transmitted over one pin (Transmit Data or TXD for short) and received over another pin (Receive Data or RXD). The third wire that's needed is the Ground wire (GND) serving as a return path for the electrical signal. It is important to ensure that the TXD and RXD of the two computers are

interchanged during wiring. That is, the RXD pin of one port must be connected to the TXD pin of the second and so on. This means that when COMI transmits data (on TXD) controller hardware will receive data on RXD, and vise versa. The complete wiring between the two connectors looks like this: COMI RXD TXD GND 2 3 5 CONTROLLER TXD RXD GND 3 2 5

Also, in order to allow data transfer between the PC and a microcontroller- based system without any error, there is need to make sure that the baud rate of the PCs COM port matches the baud rate of the microcontroller. This should be taken care of during software programming.

4.3: Software Subsystem Design 4.3.1 Program Block Diagram and Control Algorithm Program Block Diagram: Various steps taken in programming the microcontroller using C programming language are shown in the following block diagram.

Initialize ADC

Initialize Serial-port

Update threshold

Controller Address change Monitor and Control Temp. Send temperature

Start Conversion Receive Temperature

Fig. 4.2.8: Block diagram showing the operation of the microcontroller The Control Algorithm The control algorithm is implemented in the control subprogram and is used by the microcontroller to control the entire system when the temperatures (Tmax) are sensed, converted to volts, digitized and displayed by the microcontroller.

BEGIN DO GET Tmax IF T < Tmax THEN Turn ON heater ELSE TURN OFF HEATER LOOP

4.3.2:

Configuring the serial ports

Before the microcontroller serial port can be used it is necessary to set various registers.

SCON: this is the serial port control register. It should be set to hexadecimal 0x50 for 8-bit data mode. TMOD: This register controls the timers for baud rate generation, and it should be set to hexadecimal 0x20 to enable timer 1 to operate in 8-bit auto-reload mode. TH1: This register should be loaded with a constant so that the required baud rate can be generated. A method for determining the values to be loaded into THI is discussed later. TR1: This register starts/stops the timer and it should be set to 1 to start timer 1. T1: This register should be set 1 to indicate ready to transmit signal. Determining TH1 value The value of be loaded into the TH1 register is dependent on the crystal oscillator value and the required baud rate. Dividing 1/12 of the crystal frequency by 32 gives the default value upon activation of the 8052 RESET pin. With XTAL = 12.00MHz, we can determine the TH1 value needed to have 9600 baud rate as follows
XTAL OSCILLATO R

12

32

BAUDRAT
E

TH1 VALUE

Give a machine cycle frequency of 8052 as 12.00MHz. We determine the TH1 value: 12.00MHz/12 = 1000 KHz; 1000 KHz/32 = 31250: the freq. of UART to timer 1 to set baud rate. 31250.9600 = 3.255: TH1 value Hence, setting TH1 value to 3(=FD hex) gives an error of 7% In programming the 8952 to transfer character byte serially; 1. TMOD register is loaded with the value 20H, indicating the use of timer 1 in mode 2 (8-bit auto-reload to set baud rate). 2. The TH1 is loaded with the value 0xFD to set baud rate for serial data transfer. 3. The SCON register is loaded with the value 50H, indicating serial mode 1, where an 8-bit data is framed with start and stop bits. 4. 5. 6. TR1 is set to 1 to start timer 1 T1 is cleared by CLR T1 instruction. The character byte to be transferred serially is written into

SBUF register.

7.

The T1 flag bit is monitored with the use of instruction JNB T1, xx to see if the character has been transferred completely.

8.

To transfer the next byte, go to step 5.

Steps 1-4 indicate how to initialize the serial port for 9600 baud rate. Using C programming language, steps 1-4 are shown below. Void serial init0 SCON = 0x50; TMOD = 0x20. TH1 = 0xFD; TR1 = 1; T1 = 1; Also, in programming the 89C52 to receive character byte serially, the same steps 1-4, except step 5, are to be followed. At step 5, R1 register is cleared by CLR R1 instruction. The same R1 flag bit is monitored with the use of JNB R1, xx instruction to see if an entire character has been received yet. When R1 is raised, SBUF has the byte. Its contents are moved into a safe place. 4.3.3 Configuring the PC Serial port using Visual Basic

MODULE 3: Visual Basic (VB) comes with a ready-made component for handling communication ports, the MsComm control. MsComm is a simplification of the underlying API call for controlling a communication port. In programming for serial communication using MsComm in VB, one has to initialize button that opens the ports and configure the settings for baud rate, parity, data bits and stop bits and sets off a polling loop. Here I have used baud rate of 9600, data bits of 8, no parity, i.e. parity (none) and one stop bit. One can initially set COM1 (and COM2) up with both RTS and DTR set off: With MSComm 1 .MsComm1-settings = 9600, 8, N, 1 .DTREnable = False .RTSEnable = False .CommPort = 1 .PortOpen = True End With One set up the program just polls for input and rest of the program can be written as shown below. The complete program is attached as part of appendix B.

Do While MSComm1. PortOpen S1 = MSComm 1. Input (Program body) : : : Else DoEvents End If Loop Program Description When microcontroller changes address and send address code to the PC serial port, the Vb program understands it to mean ready and it activates the object, say Temperature 1, and it sends the Tmax for the object. The microcontroller receives the value and stores in SBUF of the microcontroller. Then it initializes the ADC to start conversion. After, it reads and sends the value of PC as Current temperature. The VB obtains the value and displays it in the TEMP box. The microcontroller performs control operation with the current temperature, comparing it with Tmax. It then takes the required action

depending on the outcome of the comparison. After the control operation, the microcontroller changes address and sends code to the Vb on the PC to activate another object, say Temperature 2. It then repeats the whole steps taken for temperature 1. Such steps are also taken for the Temperatures 3 and 4, and cycle repeats continuously. 4.4 The Input / Output arrangement The whole system, made up of the microcontroller-based data acquisition hardware, the PC-interface and the relay outputs, is arranged having the microcontroller-based hardware as the central system. This system receives inputs from both the temperature sensors and the PC interface. The outputs that go out of the microcontroller include the following: Current temperature for display Control signal to the relay drivers to switch ON or OFF
POWER SUPPLY

the respective heaters. Control signal to ADC to start conversion of the next
SENSOR 1 MAX temperature after processing the previous reading. ANALOG 232 TO SENSOR 2 Control address bits to the MUX to switch to next DIGITAL MICROCONVERT CONTROLLER SENSOR 3 ER sensor. SENSOR 4 RELAY DRIVER

PC

4.5 Project Block Diagram


Liquid Crystal Display

RELAY

Fig.4.2.9: Block diagram of the project

4.6 SIMULATION OF THE SYSTEM Having successfully completed the designs, the block diagram, system specification and design, the actual implementation was done using simulation software. Proteus ISIS is a suitable simulation tool for microcontroller based designs. So the microcontroller hardware is implemented with proteus application software. This involves integration of different components of the system to achieve a complete working system. 4.6.1 Input interface implementation

The input interface, with respect to the microcontrollerbased hardware, is made up of: 1. 2. temperature sensor circuitry 4-channel analog-to-digital converter (ADC)

Temperature sensor circuitry Four LM35 temperature sensors are connected to four input channels of the ADC0808. The diagram below illustrates the wiring diagram of the sensors and the ADC.

Fig. 5.1.2: Circuit diagram showing the wiring schedule of the input interface to the Microcontroller. 4.6.2 The Control System Implementation

The microcontroller is configured for normal operation, i.e. connecting the power-on-reset, the crystal oscillator. Then, the controller is connected to the input interface of figure 5.1.2.

4.6.3

The Output Interface Implementation

The output of the system includes the signal that triggers the relay drivers to switch a corresponding heater ON or OFF. This signal comes from the output port 1 (p1.0 - p1.3) of the 8952 microcontroller. The implementation of the output interface connected to the input section is shown in the diagram below.

Fig. 5.1.4: Diagram showing output and input interfaces to microcontroller

4.7 System simulation test The PC-based automatic multipoint temperature

monitoring and control system essentially comprises two basic parts, namely: the hardware and the software parts. So far, the hardware has been implemented. A systematic test of the hardware on proteus is to be done. At this point, the embedded software is loaded to the

microcontroller and every aspect of the hardware tested.

The temperature inputs are simulated while the variation in the temperature is observed on the LCD. The serial virtual tool is used to view what the microcontroller is assumed to be sending to the PC. This test is carried out to determine the operational state of the software. If the coding of the software has run time error, it will be revealed at this stage. When the desired result is obtained the overall system test is certified to have met the design specification.

4.7.1Test Plan For each of the two parts of the project-hardware and software parts-different sub-parts are tested at different levels before integrating them together. The different parts and their sub-parts are listed below: Hardware subsystem Sensor circuitry ADC Sensor and ADC Relay and relay driver Software subsystem

N.B: the

C-programming

language

is

used

for

the

microcontroller while Visual Basic (Vb6.0) is used to design the Window-based interface and the PC application program.

4.7.2

Hardware Subsystem Testing

The Sensor: each of the sensors is tested by varying the two knobs on them. As the knobs are turned, the temperature value assumed to have sensed changes between 0oC to 100oC. As the temperature changes, the values are displayed on the LCD and PC virtual terminal. Heater: four heaters are tested together with their temperature sensors. As the temperature value of a sensor increases beyond the set limit for that point, the heater goes OFF. The heater will remain OFF as long as the value of the temperature is still above the set limit. Once the temperature falls below this limit, the heater comes ON. The simulation of the heater is achieved with an amber bulb indicator. However the testing of the embedded C program for the microcontroller is integrated into the overall system test just carried out.

4.7.3

Window based User Interface The PC based application for user interfacing is developed in Visual Basic. A typical sample is as shown in the diagram below. It has four columns for the four different temperatures to be captured. On each column, a textbox is used to display the temperature value received from the microcontroller. Also, the heater status for each of the four heaters is displayed on the columns.

4.8 Performance Evaluation

After the correction of the errors encountered during the subsystems test the overall system test was carried out and the required result was achieved with the hardware and software parts harmoniously working together. The heaters were observed as they were being switched OFF when the temperature exceeded the set-points, and ON when they go below the set-points.

CHAPTER FIVE Summary, Conclusion and Recommendation 5.1 Summary of Achievement The design and construction of a PC-based automatic multipoint temperature monitoring and control has been

implemented in this project. The design followed a detailed analysis of the existing system, modeling of a new system and subsequently designing the envisaged system. The end result is a PC-based system which can automatically monitor and control four different

temperatures at the same time. The system will offer flexibility to monitoring and control operations in industrial environment. 5.2 Problems Encountered and Solutions The design and implementation of this project PC-based automatic multipoint temperature monitoring and control system for industrial application was not easily achieved. The major problem emerged from choice of suitable ADC chip that can take multiple inputs. A lot of research was done before a positive solution to the problem was achieved.

Another major problem encountered is in the development of software programs both for the microcontroller and the PC Window-based a lot of program. software Obviously, this project I

involves

programming.

Though

embraced the challenge with much vigour and excitement

due to its promising exposure to software programming, I almost became afraid that I might not be able to actualize my aim after all the stresses and effort invested. However, a breakthrough came after weeks of devoted studies and consultations. Moreover, during the actual implementation of the paper design, I encountered problem in compiling the code due to limitation of demo compiler that I used. I bridged several lines of the source to ensure the code is within the size of file the demo compiler can handle. A lot of positive software errors, also, were encountered. The program was debugged and corrected with

carefulness.

5.3 Conclusion This project, PC-based automatic multipoint temperature monitoring and control system for industrial application, was designed to explore the advantage of involving a PCbased control in industrial monitoring and control

operation. The system was designed to be much userfriendly by providing the user with a PC interface where he

can

stipulate

set-point

and

monitor

the

trends

in

temperature changes. The detailed analysis of this project design is made available to expose the underlying technology of this project and related projects. This is not meant to increase the chances of pirating the project design, but rather to enhance training of other students and help researchers who may want to go in this direction of study to avoid reinventing the wheel.

5.4 Recommendation The project having been completed, I recommend the product not just for industrial application, but for sensitive laboratory processes where temperature monitoring and control is a critical issue. Also, during very cold weather, the system can also find application in household heating. 5.5 Suggestions for further improvement From the overall experience gathered during the design and implementation of the project, I discovered that the project can be made to be of more usefulness if the range of temperature measurable can be increased, and more parameters such as pressure, humidity, and other

parameters than can be of importance to industries, incorporated to be monitored (though this may increase the cost of achieving the project). Hence I suggest the following: 1. The department should consider assigning this project again to more than one student, and mandating that the complexity be increased with the incorporation of other parameters. 2. More efforts should be made to ground the undergraduate students in software programming knowledge since close links now exist between hardware and software

engineering with the invention of microcontrollers for any microcontroller-based system. 3. The department should increase her bids towards ensuring that projects be geared towards solving existing problems. 4. The department should provide software laboratory where students will have access to advanced compilers for developing complex application.

REFERENCES Joseph J. Carr, Digital Interfacing with Analog World. First Edition (1978) pp. 331 336 Danaher Industrial Control Group, Process Automation, measurement and Sensing in Danaher Control Handbook (2005). Amol Shah, Microcontroller-based temperature controller. May 2000. Website: www.dnatechindia.com. Dogan Ibrahim, Microcontroller Evolution in Microcontroller Projects in C for 8051 pp 1 3. John M. Nadon, Bert J. Gelmine, Edward D. McLaughlin, Industrial Electricity. 5th Edition, 1994. Delmar Publishers Inc. pp 615. National Instrument (NI) publication, PC-based Application. (2010). Website: www.ni.com Control

Windmill Software Ltd, Issue 5: How to use your PC to measure temperature in Windmills Monitor Newsletter Archives, (1998). Website: www.windmill.co.uk Avo Training Institute, PC-based Control. (2007). Website: www.plantservices.com West Temperature Control Solutions, Process and Temperature Controllers- Technology Overview. (2005). Muhammad Ali Mazidi, Janice G. Mazidi, The 8051 Microcontroller and Embedded Systems. Prentice-Hall, Inc. pp. 246 359.

APPENDIX A: FULL SCHEMATIC DIAGRAM

APPENDIX Bl: Software detail of the controller source code BY: OBI OB1NNA ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#inchide<8051.h> #define on 1 #define off 0 sbit at (0xa2) heater 1; sbit at (0xa1) hcalcr2; sbit at (0xa0) hcater3; sbit at (0xa0) heater4; sbit at (0xa7) entemp1; sbit at (0xa6) entemp2; sbit at (0xa5) entemp3; sbit at (0xa4) entemp4; int i,k,a,q,x; unsigned char y, verl, ver2, ver3, ver4; unsigned char z, ver, comparl,compar2,compar3,compar4; unsigned char teml_dgl,teml_dg2,teml_dg3,tcm2_dgl,tcm2^dg2,tcm2_dg3,lein3_dgl,tcm3_dg 2,lcin3_dg3,teiu4_dg 1 ,tem4^dg2,tem4__dg3; unsigned char teml_setl>teml_set2,teml_set3,tem2_setl,tem2_sct2,tetn2^set3,tem3_setl,lem3_set2,teni3_sct3,tem4_ sell ,tem4_set2,tei-n4_set3; void wait_f_sec(void) { int j for(j=0; j <= 100; j++); }

void wait_a_sec(const unsigned int dely) { int j; for(j=0;J<=:dely;j++); } void setup(void) { int j,k; for(j-0;j<=100;j++){ for( k = 0; k <= 20000; k++); } } void compare_temp(void) { Int w; for(w=::0;w<255;w++){ teml_set3; comparl++; if(teml_set3= = 0){ if(teml_set2!-0){ comparl++; tem1_set2--; tem1_set3 = 9; } }} for(w = 0;w < 255;w++) { tem2_set3--; compar2++; if(tem2_set3= =0){

if(tem2_set2 !=0){ compar2++; tem2_set2--; tem2_set3 = 9; } }} for(w = 0;w < 255;w++) {

tem3_set3--; compar3++;

if(tem3_set3=-=0){ ir(tcm3_sct2 I-compiu'3++; l.cm3_scl2"; tem3_set3 = 9; } }) for(w = 0;w < 255;w++) { lem4_set3-; compar4++; ii'(tem4_sct3==:0){ if(,tem4_sct2 1= con"ipar4++; tem4_sct2; tcm4_scl3 == 9;

} )} void healcr_chck(void) ( compareJ-empQ; void tempi 0 {

int r; r-0; Pl-Oxff; ver=Pl; wait_a_sec(1000); r = ver; tem\_dg3 r % 10; (r/10)%10 (r/100)% 10; 0x30; 0x30; 0x30; teml^dgl teml_dgl teml_dg2 tcml_dg3

tcml_dg2

) ^oidtemp2(){ intr; r-0; PI -Oxff; ver=.Pl; wait_a_scc(1000); r = ver; tem2_dg3=(r%10); tem2_dg2=(r/10)% 10; tem2_dgl =(r/100)% 10; tem2_dgl =0x30; tem2Jg2 = 0x30;

tem2_dg3 ]==0x30; } /oidtemp3(){ intr; r-0; Pl=0xff; ver = PI; wait_a_sec(1000); r = ver; tem3_dg3-(r% 10); tcm3_dg2-(r/10)% 10; lem3_dgl=(r/ 100)% 10; , tem3_dgl |=0x30; tem3_dg2 = 0x30; tem3_dg3 -0x30; } k int r; r=0; PI = Oxff; ver = PI; waim_scc(1000); r = ver; oid temp4() [

tem4_dg3==(r%10); tem4_dg2-(r/ 10)% 10; tem4^dgl-(r/100)% 10; tcm4_dgl 1= 0x30; tem4_dg2 =0x30; tem4_dg3 l== 0x30; } void store_tem_set(un signed char y) {

==

0){ teml_setl = y;/*Pl = y; displayQ;*/} === \){ teml_scl2 = y;/*Pl = y; displayQ;*/} ==2){teml__set3=y;/*Pl == y; displayQ;*/} ---= 3){ tem2_setl = y;/*Pl = y; displayQ;*/} =--= 4){ lcin2_scl2 = y;/*Pl - y; displayQ;*/} == 5){ tem2_set3 = y;/11'?! = y; displ;iy();*/} ==6)[ tcm3_sctl - y;/*Pl = y; display();*/} == 7){ tcm3_scl2 = y;/*Pl - y; disphiy();*/} == 8){ tcm3_scl3 = y;/*Pl -= y; display();*/} ==:9){lcm4^sctl =y;/*Pl = y; displayQ;*/} == 10) { lcm4_scl2 == y;/*Pl - y; displayQ;*/} == 11){ tem4_set3 = y;/*Pl = y; display();*/} } -12){x=0;} void get_temp(void) { entempi ^off; wait_f_scc(); PI = Oxff; 'tempIO; entemp2 == off; Pl=0xff; wait_f_scc(); temp2Q; entemp2 = on;

entemp3 == off;

Pl-Oxff; wait_f_scc(); tcmp3(); cnlernp3 = on; enteinp4 = off; Pl=0xff; wait_J_scc(); temp4(); cntcmp4 = on; } void imt( void ) { TMOD - 0x20; TH1 - OxFD; /''-select baud rate 9600*/ SCON = 0x50; IE - 0x90; TI=0; TR1 = I;/* start timer*/ wait_a_scc(1000); ) void serialisrQ interrupt 4 { if(RI==l){ y = SBUF; /* store contents of serial buffer in y*/ RI=0; store_tem_set(y); q++; if(q12)q=0; } if(TI==l){ TI=0;} if(z==l ){ SBUF =lcml^dgl;//'!'; whilc(Tl0){;} wait_a_sec(5);

TI=0; z== z+ 1; } if(z==2){ SBUF = tcml__dg2; //'2'; while (Tl0); wait_a_scc(5); TI==0; z = x -t- 1; //wait_a_scc(5U); } if(z-=3){ SBUF = leml_dg3; //'3'; while (TI -= 0); wait_a_sec(5); TI = 0; z=z+1; //wail_a_scc(20); ) ^^ ^^ 4 ^ SBUF = '4';// clear lextbox for 2sl Icnip tlis|}lay while (Tl0); wait_a_scc(5); TI = 0; z==z+ 1; wait_a_sec(20);} if(z==5){ SBUF = tem2_clgl; // lcm2_dgl; while (TI0); wait_a_scc(5); TI - 0; z==z+l;} if(z6 ){ SBUF - tcm2Jg2; //tcm2_Ug2; while (TI == 0); TI=0; z==z+ 1;} ifCz? ){ SBUF = tem2_dy3; //lcm2^1g3; while (TI == 0); TI=0; z-z+1;}

if(z=^8){ SBUF = '8'; //clear textbox for 3rd tciiip dis|)Iay >

while (TI==0); Tl = 0; z=z+l;} if ( z ^ 9 K SBUF = tcm3_dgl; //lcm3_dgl;, while (TI-=0); TI = 0; z=z-M;} if(z== 10 ){ SBUP - tcm3^g2; //tcm3_dg2; while (Tl0); Tl == 0; z=z+l;} if^z^UK SBUF = tcm3^1g3; //tcm3_dg3; while (TI0); TI==0; z=z+l;} if(z===:12){ SBUF ^ 'c'; //clear tcxtbox for 4th temp display while (TI == 0); TI==0; z=z+l;} if(z 13 ){ SBUF=tcm4_dgl;//tcm4_dgl; while (TI0); Tl-0; z=z+l;} if(z===14){ SBUF = tcm4_dg2; //lcm4_dg2; while (TI 0); -TI=0; z=z+ 1;} if(z=:=15){ SBUF = tcm4Jg3; //lem4_dg3; while (Tl==0); Tl = 0; z-z+l;} if(z ^= 16 ){ SBUF - 'd'; //tcm4_dg3; while (TI==0); TI == 0; z-z+1;}

void main (void) { Pl=0xff; z=l; q=0;. x=0; entcmp 1 = on; entcmp2 = on; entemp3 == on; entcmp4 == on; sctupO; initQ; PI =0xff; getJcmpQ; wait_a_scc(5000); wait_a_scc(5000); SBUF = '0'; // clear tcxtbox for 1st temp display fbr(;;){ get_temp(); //coinpai"c_tcinp(); if(z17){ wait^a^scc(lOOOO); SBUF = '0'; z=l:

APPENDIX B2: SOURCE CODE FOR THE PC BY: OBI OB1NNALEVI Dim k As Integer. J As Integer, m As Integer, n As Integer, p As Integer Dim h As integer, r As Integer, t As Integer, s As Integer, u As Integer Dim v As Integer, x As Integer, y As Integer, z As Integer, w As Integer Dim rs As Integer, rt As integer Dim tempi As Integer, temp2 As Integer, temp3 As Integer, temp4 As Integer Private Sub Command10_Click()

Timerl. Enabled = True k=1 h=5 m=5 J=5 n=5 P=5 r=5 t=5 s=5 u=5 v=5 w=5 x=5 y=5 z=5 End Sub Private Sub Command5_Ciick() Text2 ="" End Sub

Private Sub Command6_ClickO Text4 = "" End Sub Private Sub Command7_CUckO Text6 ="" End Sub Private Sub Command8_ClickO Text8 ="" End Sub t Private Sub Command9_CUck() End End Sub

Private Sub Timer1_TimerO 'txtshow = Mid$ (txtv^ord. k, 1) If (k <= Len(Text2)) Then Textl =Mid$(Jext2.M) MSCommI -Output = Text1 .Text k=K+1 Elself (k > l-en(Text2)) And (h > Len(Text2)) And m = 5 Then h=1 m=1 Text1 = "%" 'MSCommI .Output = Text1 .Text Bself (h <= Len(Text4)) Then Text1 =Mid$(Text4,h,1) MSCommI .Output-^ Text1 Text h=h+1 Elself (h > Len(Text4)) And Q > Len(Text4)) And n = 5 Then 1=1 n=1 Text1 ="%" 'MSCommI .Output = Text1 .Text Elself 0 <= Len(Text6)) Then Text1 =Mid$0'ext6,i,1)

MSCommI .Output == Text1 .Text j=j+1 Elself G > Len(Text6)) And (p > Len(Text6)) And r = 5 Then p=1 r= 1 'Text1 = "%" MSCommI -Output = Text1 .Text Elself (p <= Len(Text8)) Then Text1 == Mid$(Text8, p, 1) MSCommI .Output == Text1 .Text p=p+ 1 Elself (p > Len(Text8)) And (s > Len(Text8)) And t = 5 Then s=1 t=1 Text1 ="%" 'MSCommI -Output = Text1 .Text Timerl.Enabled = False 'Elself (s <== Len(Text5)) Then ' MSCommI .Output = Text5.Text '8=8+1

'Elself (s > Len(Text5)) And (u > Len(Text6)) And v = 5 Then ' u=1 v= 1 'Elself (u <= Len(Text6)) Then ' MSCommt. Output = Text6.Text "'u=u+1 Elself (u > Len(TextG)) And (w > Len(Text7)) And x = 5 Then " w= 1 'x=1 'Elself (w <= Len(Text7)) Then ' MSCommI .Output = Text7.Text 'w=w+1 'Elself (w > Len(Text7)) And (y > Len(Text8)) And z = 5 Then ' y=1 z=1 Elself (y<=Len(Text8)) Then ' MSCommI. Output = TextS.Text ' ' y=y+i

End If End Sub Private Sub Command2_clear_Clicl<() txtsent ="" txtalert =="" h=1 Timer2.Enabled = True End Sub Private Sub MSComm'l__OnCommO Dim sData As String, fData As String ' Holds our incoming data Dim IHighByte As Long ' Holds HighByte value - -Dim lLowByte As Long ' Holds LowByte value

' /fcomEvReceive Event then get data and display IfMSComml.CommEvent = comEvReceive Then fData = MSComml.Input /froata="A"Then Labell.Caption = "ON" Bself fData = "B" Then Labell.Caption = "OFF" Elseff fData ="C" Then Label4.Caption = "ON" Elself fData ="D" Then Labe/4.Caption = "OFF"

Elself fData ="E" Then Label/.Caption = "ON" ' Elself fData ="F" Then Labe! 7. Caption == "OFF" Elseff fData == "G" Then Label4.Caption == "ON" Elself fData = "H" Then Labei4.Caption = "OFF" End If

Elself rs = 0 Then Label13.Caption ="" ' Label13.Caption = "" 'tempi = 0 rs = rs + 1 Elself (rs=1) Then lf(rt<==2)Then rt = rt + 1 ' Convert value to a string and display Label13.Caption = Label13.Caption & fData CStr(IWord) 'tempi = tempi & Val(sData) Else rs = rs + 1 Labell 5.Caption = "" temp2 ='0 rt=0 End If Elself (rs = 2) Then lf(rt<=2)Then rt=rt+ 1 ' Convert value to a string and display Label15.Caption = Labet15.Caption & fData 'CStr(IWord) temp2 = temp2 & Val(sData) Else rs = rs + 1' Labell/.Caption ="" rt=0 End If Elself (rs = 3) Then If (rt <= 2) Then rt=rt+1 * Convert value to a string and display Labei17.Caption == Labell 7.Caption & fData 'CStr(IWord) temp3 ^ temp3 & Val(sData) Else rs == rs + 1 Labell 8.Caption = "" temp3 = 0 rt=0 End If

E!self(rs = 4) Then If (rt <= 2) Then rt=rt+1 ' Convert value to a string and display Label18.Caption = Label18.Caption & fData 'CStr(IWord) temp4 == temp4 & Val(sData) Else rs=0 Label-18.Caption="" rt=0 temp4 = 0 End If End If Endff End Sub Private Sub FormJ,oad() OpenCOMI MSComml.CommPort = 1 MSComml.PortOpen = True ' Disable DTR MSComml.DTREnable = False ' Fire Rx Event Every One Bytes MSComml.RThreshold = 1 ' When inputting Data, Input 1 Byte at a time MSCommUnputLen = 1 ' 9600 baud, no parity, 8 data bits, 1 stop bit MSComml. Settings ="9600. N,8,1" rt=0 rs=0 End Sub ..

Private Sub Form_UnIoad(Cancel As Integer) MSComml.PortOpen = False

End Sub

Potrebbero piacerti anche