You are on page 1of 80

Andra i

Intelligent Load Monitoring and control Using Supervisory Control and Data Acquisition for Textile Industry

Madhu Andra University College University of Denver TELE 4901: Capstone Project November 21, 2008

___________________ Van Kistler. Capstone Advisor

___________________ Thomas J. Tierney. Academic Director of Telecommunications

Upon the Recommendation of the Department

_____________________ James R. Davis, Ph.D. Dean

Andra ii Abstract The textile industry is one industry where many machines are utilized. Data acquisition cards connected to the machines are used to collect data. These cards are taken out and connected to a computer to retrieve data. Disadvantages of these cards are, on-load monitoring is not possible and fault detection is difficult. This project proposes a redesign for data acquisition using a microcontroller, analog to digital converter and diodes as main components of a system for collecting data (voltages, status-on/off), and transferring data to a computer for monitoring and controlling. For any mismatch between the actual and anticipated values an error report is generated and saved in an error log file. An administrator checking the error report easily finds out the fault from the data and rectifies the problem.

Andra iii Contents Abstract............................................................................................. ii List of Tables ..................................................................................... vi List of figures ....................................................................................vii Abbreviations ................................................................................... viii Introduction ....................................................................................... 1 Load locking .................................................................................... 3 Literature Review ................................................................................ 5 Problem Definition ............................................................................ 8 Theoretical Analysis............................................................................. 9 Hardware Analysis ............................................................................ 9 Microcontroller AT89S52 ................................................................. 9 Interfacing the Switches with 89c52 Microcontroller.......................... 14 Analog to Digital Converter Unit..................................................... 16 Analog to Digital Converter Interfacing with 89s52 Microcontroller...... 19 Power Supply Unit ....................................................................... 19 Serial communication (RS232) ...................................................... 22 Operation of MAX232 ................................................................... 23 MAX232 Connections in the Circuit ................................................. 24 ULN 2003 ................................................................................... 24 555 Timers ................................................................................. 25 Relay ......................................................................................... 26

Andra iv Interfacing Relay to The Microcontroller ......................................... 27 LED ........................................................................................... 27 Software Analysis.............................................................................. 28 Block Diagram .................................................................................. 31 Circuit Diagram .............................................................................. 32 Working ........................................................................................ 32 Analog Channel ........................................................................... 33 Digital Channel............................................................................ 33 Flow Charts ...................................................................................... 34 Microcontroller Side Flowcharts ........................................................ 34 Flow chart to get values from ADC .................................................... 36 Flow Chart for Error Report Generation.............................................. 37 PC Side Flowchart........................................................................... 38 Experimental Investigations................................................................ 39 Load Locking Functional Requirements .............................................. 39 Acquisition .................................................................................... 39 Locking and Storage ....................................................................... 40 Display ......................................................................................... 40 Report Generation .......................................................................... 40 Expected Results............................................................................... 41 Serial communication device ............................................................ 41 Power Circuit Testing ...................................................................... 42

Andra v Output Results.................................................................................. 42 Data Base: Status Monitoring........................................................... 43 Data Base: Error Report Generation .................................................. 43 Discussions of Results........................................................................ 44 Serial communication testing ........................................................... 44 Potentiometer Settings.................................................................... 44 Analog to Digital Converter .............................................................. 45 Summary and Conclusions ................................................................. 46 Summary ...................................................................................... 46 Advantages of Load locking.............................................................. 46 Applications of Data Acquisition Load locking for textile industry ........... 47 Recommendations .......................................................................... 47 References ....................................................................................... 49 Appendix 1....................................................................................... 52

Andra vi List of Tables Table 1Port 0 connections .................................................................. 11 Table 2 Port 1 connections ................................................................. 12 Table 3 Port 2 connections ................................................................. 12 Table 4 Port 3 connections ................................................................. 13 Table 5 Components used to construct Microcontroller unit ..................... 15 Table 6 connection to the microcontroller ............................................. 16 Table 7MAX232 Pin Connections .......................................................... 22

Andra vii List of figures Figure 1 Overall data flow .................................................................... 4 Figure 2 Interfacing Switches with 89c52 Microcontroller ........................ 15 Figure 3ADC Interfacing With 89c52 Microcontroller ............................... 19 Figure 4 Power Supply Unit generating 5V ............................................ 20 Figure 5 5 MAX-232 Pin diagram ......................................................... 24 Figure 6 ULN Pin Diagram .................................................................. 25 Figure 7 555 Timer circuit .................................................................. 26 Figure 8 Interfacing Relay to Controller ................................................ 27 Figure 9 Block diagram of Data Acquisition ........................................... 31 Figure 10 circuit diagram with all components assembled ....................... 32 Figure 11 Microcontroller side flow chart............................................... 35 Figure 12 Flow chart to get values from ADC......................................... 36 Figure 13 flow Chart for Error Report Generation ................................... 37 Figure 14 Pc side flow chart ................................................................ 38 Figure 15 status monitoring ................................................................ 43 Figure 16 Error report ........................................................................ 43 Figure 17 Error report ........................................................................ 44

Andra viii Abbreviations ADC ALE ADD AC CMOS C CLK EOC GND ISP IC IN LED MAX232 OE PCB PEROM RXD START SCADA TXD Analog to Digital Converter Address Latch Enable Address Input Alternating Current Complementary Metal-Oxide Semiconductor C language Clock End of Conversion Ground In System Programming Integrated Circuit Analog Input Light Emitting Diode MAXIM 232 Output Enable Printed Circuit Board Programmable Erasable Read Only Memory Receive Data Start of Conversion Supervisory Control and Data Acquisition Transmit Data

Andra 1 Introduction A data acquisition system is the process used to collect information to document or analyze any electrical parameters or other phenomenon. In other words a technician logging the voltage of the load on a piece of paper can be called data acquisition. But as technology developed, this type of process has been simplified and made more accurate, versatile, and reliable through electronic equipment (omega 2008). Data acquisition equipment ranges from simple recorders to sophisticated computer systems. Data means information and acquisition means recording. Recording equipment can be stand-alone, battery-powered devices that are equipped with a microcontroller, memory for data storage and sensor(s). This paper explains how data acquisition can be done on board and data such as voltage and status transferred to a computer using serial port communication. Load locking refers to setting the values according to user inputs or from external probes, as well as from existing transducers, sensors and gauges. The system interfaces with a personal computer or laptop and operates through software designed to view/analyze the collected data. The data acquisition also provides several intelligent functions: i. It can be programmed to collect data automatically from the loads which are locked automatically as per the user input. ii. iii. It contains its own memory for storing data. It contains circuits for timing and measuring voltage.

Andra 2 These special features can be monitored independently from a computer connected through a serial bus communicator. The range includes simple economical single channel fixed function locking to more powerful programmable devices capable of handling hundreds of inputs. Measurement of weight, voltage, distance, pressure, current, light intensity, etcetera are very common aspects of a daily life. In every industry there is a need for measurement and sequence of operation, which is used to monitor motors, and their operation. With increasing requirements for speed, accuracy, reliability, need for storage of these measurements, the old analog methods of measurement need to be changed. The old method of measurement uses mechanical parts which are prone to errors because of aging, stress, and other factors. Some necessary parts of data acquisition systems are sensors for converting physical quantities into electrical quantities followed by an Analog to Digital Converter (ADC) which converts these electrical levels of data into a digital format. This digitized data must be presented with the necessary conversions and analysis for recording future reference or for controlling other equipment etcetera. A controlling and computational device is required for these systems. Even for the ADC to operate, it needs some control a signal, which is accomplished by using a microprocessor or microcontroller. In the data acquisition process, the 89s52 microcontroller is used for obtaining, analyzing, controlling and displaying the data. Displaying

Andra 3 the data can be done with a communication channel technique such as serial communication technique for displaying data on a personal computer Load Locking With the development of the personal computer in the 1970s and 80s, its usage for analysis of data, storage, report generation and control of load parameters increased (zone 2008). In textile industries the motors are switched ON and OFF by using the timers. A spinning motor has its own timer and the changes to this timer can be made only offload, that is when the motor is not turned on. When the motor is turned on, load monitoring is not possible. A microcontroller is used to control and synchronize the operation of motors. Depending upon the user inputs the loads are locked. The loads status is predefined and the status cannot be changed by any person other than the concerned authority and in this way the malfunctioning of the loads is eliminated. One more advantage of on-load monitoring and controlling is, the load status set points monitoring and voltage controlling. This can be achieved from the recorded data of every load sent from microcontroller from time to time (Spencer 1990). This data must be transferred to the personal computer (PC) for analysis, permanent storage, and report generation. Data is typically transferred either by manually moving a storage device (such as a floppy disk) from the load locking to the computer or by connecting the data locking to the PC through a serial communication channel.

Andra 4

Figure 1 Overall data flow This paper mainly deals with locking of the loads depending upon the user input and monitoring to control the load voltages. The ADC converter updates the voltage values and the digital channel updates the loads status in the controller. The code for the controller is written in keil vision. The controller is programmed using an In System Programming (ISP) programmer. The front end programming is written in C language. The circuit is designed in Orcad software and the Printed Circuit Board (PCB) is designed using Protel. The main goal is to explain how data acquisition is done and load locking is achieved. The different hardware and software analysis made to solve the problem, the hardware components and their interfacings to the controller, the software used to design the circuit, PCB, and software used to write the programming are also explained. The next chapter Experimental Analysis deals with analysis made with respect to the

Andra 5 assembled hardware followed by Experimental Results explaining actual results for different input voltages. The section Discussion of Results deals with the step by step explanation of the output of each part and the explanation of the end results. Literature Review This chapter presents the conclusions derived from articles , journals taken from different publications written by prominent authors which are the basis for the ideas used in this paper. Designing and implementing Supervisory Control and Data Acquisition (SCADA) Subsystem for Textile Industry This paper presents the possibilities of data acquisition in the textile industry, and the issues pertaining to questions like how to choose Supervisory Control And Data Acquisition (SCADA) equipment and whether or not SCADA is feasible for the organization (Kumar and kamal 2004). The main idea for this capstone was taken from this paper in other words a high level practical application is designed using information from this paper. Data Acquisition Module with Large Number of Inputs This paper describes the process of developing a new load locking module and its use for different purposes. With newly developed design many more sensor inputs can be available for less cost in comparison to the solution for adding load locking modules in a computer (Gaberbeges 2002). The conclusions drawn from this paper are:

Andra 6 i. This kind of system is cheaper easy to control and more reliable than the complex commercially available systems with the same number of inputs, it also meets the requirements of measurement uncertainty and traceability. ii. iii. Presentation of available data acquisition modules and their features Developments in data acquisition module

Real-Time Information Exchange between Load locking and Control Systems at Axially Symmetric Divertor Experiment (ASDEX) Upgrade This paper presents how load locking systems and control at the ASDEX Upgrade fusion experiment communicate during the setup of an experimental discharge only. While control executes the discharge based on recipes and a fixed number of input and output channels, diagnostic measurements are done under a predefined schema (Buhler 2000). The ideas drawn are i. ii. iii. Design of control and data acquisition systems Real time diagnosis to acquire data How to couple the control system and the acquisition module

Solar Load Locking Wireless Network for Agricultural Applications This paper describes the implementation of a wireless load locking network for agricultural applications based on the Microchip PIC 16C7 1, and the Intel 87C592 microcontrollers. Experimental tests have performed since

Andra 7 mid June 1996, and the results obtained show that the communications were performed without errors and no loss of data (Aulmorais 1998). The Conclusions drawn from this paper are: i. A low cost wireless load locking network was implemented and applied to collect environmental data from a set of greenhouses. ii. From the results obtained it was concluded that the communications between the stations were performed without errors and no loss of data. iii. With the data acquired in these experiments we are developing identification techniques for the greenhouse climate dynamic models. Afterwards, optimal control strategies will be simulated and implemented to compare its performance with respect to energy saving and tighter regulation. Conclusions With reference to the above papers the following conclusions drawn are: i. The automation of loads can be done by combining the data acquisition and loads ii. Data can be transferred to the computer and a record can be maintained for future reference iii. Mode of transmissions plays an important role in the transmission speed (serial or parallel).

Andra 8 iv. v. The parameter monitored from the digital channel is temperature. Load locking with database maintenance is very essential for predicting the load changes vi. Cost of the system depends on the mode of data transfer and the locking system. Problem Definition The main problem is to give the sequence of operation for the loads and check at predefined intervals whether the sequence is followed and generate an error report if the actual sequence deviates from the required sequence. The loads are monitored and controlled. The status monitor controls the voltages of the load. The electric supply to the load should be

turned off when the voltages are exceed the specified limits. Technical Specifications Circuit operating voltage 5V Digital and analog channel voltage...2.5V Number of channels monitored.2(analog and digital) Crystal operating frequency ..11.059Hz Serial baud rate ...9600 Output frequency of 555 timer..18.7 KHz Operating voltage range 2-2.5 V

Andra 9 Theoretical Analysis This chapter deals with the theoretical analysis, its classifications, different components used, their interfaces and the software used. The theoretical analysis is mainly classified into i. ii. Hardware analysis Software analysis

Hardware Analysis The hardware analysis deals with the analysis of each component that is the features, description, interfacing units. The components used i. ii. iii. iv. v. vi. vii. viii. Microcontroller AT89S52 Analog to Digital Converter ADC0808 Power supply Serial communication RS232 ULN 2003 driver 555 timer Relay LED (Light Emitting Diode)

The analysis and the connections of each component is given below. Microcontroller AT89S52 The AT89S52 is a low-power; high-performance Complementary metaloxide semiconductor (CMOS) 8-bit microcomputer with 8K bytes of Flash

Andra 10 programmable and erasable read only memory Programmable Read-Only Memory (PROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is Compatible with the industry-standard 80C51 and 80C52 instruction set and pin out (Sunroom 2008). The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8bit controlling unit with flash memory on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. Features i. Compatible with MCS-51 Products (Intel's official designation for the 8051 family of Cs is MCS 51) ii. iii. iv. v. vi. vii. viii. ix. x. xi. 8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Programmable Serial Channel Low-power Idle and Power-down Modes

Andra 11 The digital data from the ADC is transmitting to the microcontroller unit through ADC data lines. 8 data lines of ADC are connected to Port 0 of microcontroller. Port 0 is an 8-bit bi-directional I/O port. Four switches are connected to the first four pins of the microcontrollers Port 1.The main functions of the switches are to store the data. If Switch 1 is pressed then the temperature will be displayed on computer monitor using serial communication and temperature will be stored in a separate file with corresponding date and time. For serial communication we are using port 3.0 and port 3.1 pins. Port 3.0 that is serial input port Receive Data (RXD) is connected to 12th pin of MAX232 (MAXIM 232) (R1out) and port 3.1 that is serial out port Transmit Data (TXD) is connected to 11th pin of MAX232 (T1in). Table 1Port 0 connections Port Pin Pin Description Connected to

P0.0

AD0

17th data pin of ADC

P0.1

AD1

14th data pin of ADC.

P0.2

AD2

15th data pin of ADC.

P0.3

AD3

8th data pin of ADC.

Andra 12 P0.4 AD4 18th data pin of ADC.

P0.5

AD5

19th data pin of ADC.

P0.6

AD6

20th data pin of ADC.

P0.7

AD7

21st data pin of ADC

Table 2 Port 1 connections Port Pin P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 Connected to Switch 1. Switch 2. Switch 3. Switch 4. No Connection. No Connection. No Connection. No Connection.

Table 3 Port 2 connections Port Pin P2.0 Pin Description A8 Connected to SOC-6th pin of ADC.

Andra 13 P2.1 P2.2 P2.3 A9 A10 A11 EOC-7th pin of ADC. OE-9th pin of ADC. ALE-22nd pin of ADC. P2.4 P2.5 P2.6 P2.7 A12 A13 A14 A15 No Connection. No Connection. No Connection. No Connection.

Table 4 Port 3 connections Port Pin P3.0 RXD (serial input port) 12th pin of MAX232 (R1out). P3.1 TXD (serial output port) 11th pin of MAX232 (T1in).. P3.2 INT0 (external interrupt 0) P3.3 INT1 (external interrupt 1) P3.4 T0 (Timer 0 external No Connection No Connection No Connection Pin Description Connected to

Andra 14 input) P3.5 T1 (Timer 1 external input) P3.6 P3.7 WR RD No Connection No Connection No Connection

Interfacing the Switches with 89c52 Microcontroller Four switches are connected to the first four pins of the microcontrollers Port 1.The main functions of the switches are to store the data when the switch is pressed. If we press the Switch 1, the microcontroller will transmit the particular temperature through serial communication unit and that particular temperature will display on the computer monitor with date and time. And also, the temperature will be stored in a separate file with corresponding time and date. The stored data may be used in the future. Similarly Switch 2, 3, 4 are used to store the temperature. The switch diagram which we used in our project is shown below. Four switches are connected to port 1 of microcontroller to display and store the voltage when pressed.

Andra 15 Table 5 Components used to construct Microcontroller unit No. Component Name Number of Components Used 1. 2. 3 4 5. 89s52 Microcontroller Switches Oscillator 11.059MHz Resistors: 4.7K,8.2K Capacitors: 33PF, 10PF 1 4 1 1(each) 2, 1

With the components given in the table 3.4 the microcontroller is interfaced with the switches. They are connected to the port1 of the microcontroller.

Figure 2 Interfacing Switches with 89c52 Microcontroller

Andra 16

Analog to Digital Converter Unit The ADC0808 data acquisition component is a monolithic CMOS device with an 8-bit analog-to-digital converter, 8-channel multiplexer and microprocessor compatible control logic. The 8-bit Analog to Digital (A/D) converter uses successive approximation as the conversion technique. The converter features a high impedance chopper stabilized comparator, a 256R voltage divider with analog switch tree and a successive approximation register. The 8-channel multiplexer can directly access any of 8-single-ended analog signals (National 2008). Table 6 connection to the microcontroller Pin number 1 2 3 4 5 6 IN3 - Analog Input 3 IN4 - Analog Input 4 IN5 - Analog Input 5 IN6 - Analog Input 6 IN7 - Analog Input 7 START Start of Conversion 7 EOC - End of Conversion Output Input Input Input Input Input Input No Connection No Connection No Connection No Connection No Connection 21st pin of Microcontroller 22nd pin of Microcontroller Pin Description Input/Output Connected To

Andra 17 8 2(-5) - Tri-State Output Bit 5 Output 36th pin of Microcontroller(AD 3) 9 OE - Output Enable Input 23rd pin of Microcontroller 10 11 12 CLK Clock Vcc - Positive Supply Vref+ - Positive Volt Ref Input 13 14 GND Ground 2(-7) - Tri-State Output Bit 7 Input Output Ground 38th pin of Input Input Input 555 Timer circuit Vcc Vcc

Microcontroller(AD 1)

15

2(-6) - Tri-State Output Bit 6

Output

37th

pin of

Microcontroller(AD 2)

16

Vref- - Volt Ref Negative Input

Input

Ground

17

2(-8) - Tri-State Output Bit 8

Output

39th

pin of

Microcontroller(AD 0)

18

2(-4) - Tri-State Output

Output

35th

pin of

Andra 18 Bit 4 19 2(-3) - Tri-State Output Bit 3 Output controller(AD4) 34th pin of

Microcontroller(AD 5)

20

2(-2) - Tri-State Output Bit 2

Output

33rd

pin of

Microcontroller(AD 6)

21

2(-1) - Tri-State Output Bit 1

Output

32nd

pin of

Microcontroller(AD 7)

22

ALE

Input

24th

pin of

Microcontroller. 23 24 25 26 27 28 ADD C - Address Input C Input ADD B - Address Input B Input ADD A - Address Input A Input IN0 - Analog Input 0 IN1 - Analog Input 1 IN2 - Analog Input 2 Input Input Input Ground Ground Ground Output of sensor No Connection No Connection

Andra 19

Analog to Digital Converter Interfacing with 89s52 Microcontroller The ADC0808 is interfaced to the port 0 pins of the 89s52 microcontroller.

Figure 3ADC Interfacing With 89c52 Microcontroller Power Supply Unit Every electronic system requires one or more Direct Current (DC) voltages for its operation. Most of the time it is essential and always desirable that these DC voltages are filtered and well regulated. The power supply does the job of providing required DC voltages from available Alternating Current (AC) mains in case of mains operated systems and DC input in case of portable systems. Power supplies are often classified as linear power supplies depending upon the nature of the regulation circuit Design of a Power Supply Unit generating of 5 Volt (V) and Regulated DC

Andra 20 The power supply unit designed for 5V D.C. output is used as power supply for 89c52 Microcontroller.

Figure 4 Power Supply Unit generating 5V DC Description Main Transformer: It is a Step-Down power transformer that operates at power line frequency of 60Hz. It converts 110V AC into 0 to 12V DC. Rectifier Circuit IN4007 diodes. Filter Section : It consists of a capacitor C1, which has a capacitance : It is a Full-Wave Bridge Rectifier consisting of four

of 1000micro farads. It is large enough to supply a constant current to the load during the non-conduction period of the diode. Regulators Operation The transformer provides voltage transformation and produces AC voltage required for producing the desired DC voltages across its secondary windings. It also provides electrical isolation between the power supply input that is, AC mains and DC output. The rectifier circuit changes the AC : 5V voltage regulator-7805 .

Andra 21 voltages appearing at transformer secondary to DC. Commonly used rectifier circuits include half-wave rectifier, conventional full-wave rectifier requiring a tapped secondary or a bridge rectifier. The rectified voltage will always have some AC content known as power supply ripple. The filter circuit smooths the ripple of the rectified voltage. The filtering action of the capacitor connected across the output of the rectifier comes from the fact that it offers a low reactance to AC components. The ripple in nature is inversely proportional to capacitance. Thus, the capacitor connected across the output of the rectifier, which provides the filtering action, must be large enough to reduce the ripple to the desired level. The regulated circuit is a type of feedback circuit that ensures the output DC voltage does not change from its normal value due to changes in line voltage or load current. It is the nature of the regulator circuit that distinguishes the linear power supply from a switching supply. In a linear power supply, the active device (linear regulator) that provides regulation, usually bipolar transistor is operated anywhere between cut-off and saturation that is, in active region whereas in switching mode power supply, switching regulator is operated either in cut-off or in saturation. 7805 are linear, fixed voltage series regulators, which provide regulated 5V DC respectively. In case of a series regulator a change in the output voltage due to a change in input voltage or load current results in a change in the voltage drop across the regulator transistor so as to maintain a constant

Andra 22 output voltage across the load.5V regulated DC is obtained across 10 micro farad capacitor. Serial communication (RS232) Serial means one event at a time Serial communication means it transmits one bit at a time. Serial communication is commonly used with modems and for non-networked communication between computers, terminals and other devices. Table 7MAX232 Pin Connections Pin Name Pin Description no. + connector for 1 C1+ capacitor C1 2 V+ output of voltage pump No connection. - connector for 3 C1capacitor C1 + connector for 4 C2+ capacitor C2 - connector for 5 C2capacitor C2 6 Voutput of voltage pump Positive terminal capacitor C3. Negative terminal capacitor C2 Positive terminal capacitor C2. Negative terminal capacitor C1. Positive terminal capacitor C1. Connected to

Andra 23 / inverter 7 8 9 10 T2out Driver 2 output R2in Receiver 2 input No connection. No connection. No connection. No connection. 11th pin of microcontroller 11 T1in Driver 1 input (TXD). 10th pin of microcontroller 12 R1out Receiver 1 output (RXD). 13 R1in Receiver 1 input RS-232 probe receiver terminal. RS-232 probe transmitter 14 T1out Driver 1 output terminal. 15 16 GND VCC Ground Power supply RS-232 probe ground terminal. Vcc

R2out Receiver 2 output T2in Driver 2 input

Operation of MAX232 Receiver 1 output (R1out) and Driver 1 input (T1in) pins of MAX232 are connected to 10th pin (RXD) and 11th pin (TXD) of microcontroller

Andra 24 respectively. Receiver 1 input (R1in), Driver 1 output (T1out) and ground pins of MAX232 are connected to receiver, transmitter and ground terminals of one end of RS-232 interface probe. The other end of RS-232 probe is connected to male 9-pin D- connector. This male 9-pin D-connector will connect to the com port 2 of the computer which is used for Asynchronous Data transmission. When we pressed switches which are connected to port 1 of microcontroller then that particular voltage will be transmit to computer using serial communication to display and for storage in memory for future use. MAX232 Connections in the Circuit

Figure 5 5 MAX-232 Pin diagram ULN 2003 The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It consists of seven N-P-N (diode) Darlington pairs that feature high-voltage outputs with common-cathode. Clamp diode for switching inductive loads. The collector-current rating of a single Darlington

Andra 25 pair is 500mA. The Darlington pairs may be paralleled for higher current capability (Datasheets 2008). Features i. ii. iii. iv. 500mA rated collector current High-voltage outputs: 50V Inputs compatible with various types of logic. Relay driver application DIP-16

Figure 6 ULN Pin Diagram 555 Timers

The 555 timer Integrated Circuit (IC) was first introduced around 1971 by the Signetics Corporation as the SE555/NE555 and was called "The IC Time Machine" .It is the very first and only commercial timer IC available. It is a relatively cheap, stable, and user-friendly integrated circuit (Roon, 2008) .It can be operated in both mono stable and astable applications. In the present project we are using it in the astable mode, to generate clock pulses to be supplied to the ADC

Andra 26

Figure 7 555 Timer circuit Relay

The purpose of relay is to make the final control element ON/OFF depending on the parameter that is below or above the set point. The parameters regulated are voltages and status of loads. Electromagnetic relay provides a good all-around solution, although they have limitations in package size, switching speed, and mechanical lifetime.

Andra 27 Interfacing Relay to The Microcontroller


+5V

+5V

C4 40 U3

+5V +12V 17 23 24 39 38 37 36 35 34 33 32 27 28 26 25 21

S1
10 11 12 13 14 15 16 22 1 2 3 4 5 6 7 8 RXD TXD INT0 INT1 T0 T1 WR P2.1 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7

S3

R14
Q1

VC C

RD P2.2 P2.3 P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 P2.6 P2.7 P2.5 P2.4 P2.0

K1 CN 3 3 2 1

D14

+5V C5

S2

9 18

RESET X1 19 X2 Y1

29 PSEN 30 ALE/P EA/VP 31

S4
+5V

GND 20

R3 R2 C6

C7

Figure 8 Interfacing Relay to Controller LED A light-emitting diode (LED) is a semiconductor device that emits incoherent narrow-spectrum light when electrically biased in the forward direction. This effect is a form of electroluminescence. The color of the emitted light depends on the chemical composition of the semi conducting material used, and can be near-ultraviolet, visible or infrared.

Andra 28 Software Analysis In order to use sensors for taking readings in a science experiment, a data-logging program must be loaded into the computer. The common functions of a data-logging program are as follows: i. Take readings from the sensors at regular intervals. It is possible to take many readings at time intervals ranging from a few microseconds to hours or even days. A collection of readings is normally referred to as 'data'. ii. Present the data in a suitable form for display on the screen. This could take the form of tables of numerical values, large digits, bar charts or most commonly as conventional graphs. The graph plotting facility is particularly useful since the computer can generate them very quickly allowing comparison of several sets of results in succession. Also, the program provides aids for accurately analyzing the results and performing calculations on the data. iii. Store the data on a computer disc for future use.

Keil Software is used to develop the data logger circuit. Keil Software provides the software development tools for the 89s52 microcontroller derivatives. Keil compiler is a cross compiler which is used to compile that code designed for different chips on the host machine and to get the hex code (file type for program written in keil). General procedure in working with Keil compiler is as follows:

Andra 29 i. ii. iii. iv. Create source file in 'C' or assembly. Compile or assemble source files. Correct errors in source files. Load the .HEX file into 89s52 Flash Memory with the help of Programmer. Compile with the cx51 Compiler The directives listed below allow you to compile the Cx51 compiler - Direct the Cx51 compiler to generate a listing file - Control the amount of information included in the object file - Specify optimization level and memory models Running cx51 from the Command Prompt To invoke the C51 or Cx51 compiler, enter C51 or Cx51 at the command prompt. On the command line you must include the name of the C source file to be compiled as well as any other necessary control directives required to compile your source file. The format for the Cx51 command line is: C51 sourcefile_directives..._ Cx51 sourcefile_directives...._ OR C51 @commandfile Cx51 @commandfile Where: Source file - is the name of the source program you want to

Andra 30 compile. Directives - are the directives you want to use to control the function of the command. Command file - is the name of a command input file that may contain source file and directives. A command file is used, when the Cx51 invocation line gets complex and exceeds the limits of the windows command prompt. C51 Sample Debug Code Preprint The Cx51 complier displays the following information upon successful compilation. C51 COMPLIER V6.10 C51 compilation complete 0 warning(s), 0 error(s) Error level: After the compilation the number of errors and warnings detected is displayed on the screen. The Cx51 complier then sets the ERRORLEVEL to indicate the status of compilation. Values are listed in the following table: ERRORLEVEL 0 1 2 3 MEANING No errors or warnings Warnings only Errors and possible warnings Fatal errors

You can access the ERROR Level variable in batch files. Refer to the windows command index or to batch commands in the Windows on-line

Andra 31 help for more information on ERRORLEVEL or batch files..HEX file will load into 89s52 Flash Memory with the help of Programmer to work with our circuit. Softwares The software used in our project is i. ii. Orcad : to design the circuits Protel: to design the PCB Once the PCB is manufactured, all the individual components are assembled and the load is loaded on the controller. The values are taken and given from controller from time to time. The front end programming to receive the data serially is written in C. The database is maintained in a text file for future references. Block Diagram The block diagram is shown below.

Figure 9 Block diagram of Data Acquisition

Andra 32 Circuit Diagram


VCC U1 31 33P 19 33P 10U 11.0592MHz 18 9 12 13 14 15 1 2 3 4 5 6 7 8 EA/VP X1 X2 RESET INT0 INT1 T0 T1 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 P2.0 P2.1 P2.2 P2.3 P2.4 P2.5 P2.6 P2.7 RD WR PSEN ALE/P TXD RXD 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 17 16 29 30 11 10 U2 26 27 28 1 2 3 4 5 12 16 5K 10 9 7 IN0 IN1 IN2 IN3 IN4 IN5 IN6 IN7 D0 D1 D2 D3 D4 D5 D6 ADC0808 D7 A0 A1 A2 START ALE 17 14 15 8 18 19 20 21 25 24 23 6 22 P3.4 P3.7 P3.6 P3.5

OUTPUTS OF SENSORS
(INPUTS TO ADC) VCC

VCC

8.2K

89S52

REF+ REFCLK OE EOC

4.7K

4.7K

4.7K

4.7K

SW4

SW3

SW2

SW1

TO P1.0

VCC

INPUTS

C5

OUTPUTS TO RELAYS

OUTPUTS

13 8 11 10 1 3 4 5 2 6

R1IN R1OUT R2IN R2OUT T1IN T1OUT T2IN T2OUT C+ C1C2+ C2V+ VMAX232 16

12 9 14 7

8.2K

4 7
37K

8 CLK OUT 3

ULN2003

vcc
C2

555
6 2 1
0.1U

C4

AS INPUT

15

C6 C7

P1.0 vcc
D3 D4

33P

db9 to Computer

P1.1
D5

P1.2
D6

P1.3

Figure 10 circuit diagram with all components assembled Working The two power supplies used are 5V and 12V dc supply. The 12V supply is provided to the relay and the rest of the components are provided with 5V. All the loads simulated are dc loads. The main process has been carried out is the monitoring of two channels i. Analog channel ii. Digital channel

Andra 33

Analog Channel The voltage from the loads is transferred to the controller through the ADC. The potentiometer is given 5V supply, the variation in the potentiometer results in change in voltage. The analog values for the voltage are predefined. Whenever the voltage exceeds the set points the relay operates and turns off the supply to the load and the supply is automatically restored when the voltages are at normal values. This is called on-load monitoring. The potentiometer is varied from o to 5v but the actual variation is seen from 0 to 110V. One step variation results in 20mV change in voltage so whenever voltage exceeds 2.5V (160*20mV) the relay is operated. Digital Channel The load locking is implemented with predefined load status. The controller is programmed such that the user defined sequential operations are carried out. The status of each and every load is taken from time to time and stored in the database. The administrator is given a user identification and password to change the load status if required and no other person can change the status without administrative privileges. Whenever there is a mismatch in the sequential operations the error report is generated and stored in the database. The administrator can come and check, when and on which load the fault has occurred and at what time. In this way the malfunctioning can be eliminated as only a person with administrative

Andra 34 privileges has full access to the system.

Flow Charts The flow charts for the controller end, system end and the flowchart for the error report generation are given. The main process which is being carried out is, to take the values from the controller from time to time and compare that with the actual sequence and generate error reports for any mismatches. At the controller side the process going on is to take the value from the analog and digital channels and transfer that to the pc serially. Microcontroller Side Flowcharts Microcontroller side program to check the status of the machine and to send the related voltage to PC.

Andra 35
Start

1Initialize input and output ports.


0,1 - input port. 2-output port.

Initialize the serial communication Set the baud rate as 9,600bits/sec. SCON=50H TMOD=20H TH1=FDH,TR1=1(To Start Timer 1 for baudrate)
B

Initialize ADC control lines. ALE = 0;OE = 0;SOC = 0.

Monitor 4 machine status configurations which are connected to port 1 of Microcontroller

OFF

OFF

OFF

OFF

If machine1 is ON

If machine2 is ON

If machine3 is ON

If machine4 is ON

ON

ON

ON

ON

Call Read the voltage using DATAAQUA subroutine DATAAQUA ( )

Send the machine information and the related voltage to PC in the format that is machine number, time, date and followed by voltage using serial communication.

Stop

Figure 11 Microcontroller side flow chart

Andra 36

Flow chart to get values from ADC

GETDATA ()

Initialize ADC control lines. ALE = 1; OE = 1.

Select the required channel using ADC channel select pins.

Start of Conversion SOC = 1 No

Wait for EOC = 1

Yes Read the data from ADC data lines and store in accumulator of 89s52.

Convert ADC readings which are stored in accumulator into decimal values using DAA instruction

Return

Figure 12 Flow chart to get values from ADC

Andra 37

Flow Chart for Error Report Generation

Start A Read the load status

Compare the status with Locking status

Status== load status

Generate error report

Figure 13 flow Chart for Error Report Generation

Andra 38 PC Side Flowchart PC side turbo C program for displaying and store the machine number, time, data and voltage
Start

Display: The current year is: The current day is: The current month is:
DATA LOGGING PROGRAM PRESS ESC TO QUIT

Initialize the serial communication Set the baud rate as 9,600bits/sec.

No

Wait for terminal response

Yes
Compare the machine information

Access the CPU time and data

Display the machine ON time, data and voltage as follows: Machine number MACHINE OPERATED AT time ON date VOLTAGE IS x

Open a file named as datalog.txt, display the information and store the information in that file.

Figure 14 Pc side flow chart

Andra 39 Experimental Investigations Load Locking Functional Requirements Every load locking application, from manually recording weather patterns in the 15th century, to locking the experimental parameters of a fusion reactor test in the 21st century can be broken down into a set of five common functional requirements. Acquiring is the process of actually measuring the physical parameters and bringing them into your locking system. Online analysis consists of any processing done to the data while you are acquiring it. It includes alarms, data scaling, and sometimes control, among others. Locking, or storing, the data is an obvious requirement of every load locking system. Offline analysis is everything done with the data after it has been acquired in order to extract useful information from it. The final functional block includes display, reporting, and data sharing. These are all the requirements that fill out the functionality of a load locking system. Lets examine how each of these functional blocks is addressed with modern, PC-based load locking systems. Acquisition The acquisition function is one of the most critical components of every load locking system. In a PC-based system, the acquisition is accomplished by the measurement hardware, which can be further broken down into sensors, signal connectivity, signal conditioning, and analog-todigital conversion.

Andra 40 Locking and Storage The locking (or storage) functional block is, by definition, required in every load locking system. Methods of storing data vary widely across different systems. Strip chart recorders use paper, traditional data locking can use internal nonvolatile memory, floppy disks, or a variety of other media. PC-based load locking systems typically use the hard drive of the PC. Software is of critical importance in PC-based load locking systems, because well-written locking software determines how data is stored, how quickly data can be written to disk, and how efficiently disk space is used. Display Most load locking applications require some form of display to view the measurements that are being recorded. The display function can be further broken down to viewing live data and historical data. Live data display is necessary if you need to view data as it is being acquired. Historical display lets you view data that was previously acquired. Most stand-alone load locking requires you to move the data to a PC for historical viewing. With PC-based load locking applications, you combine both live display and historical display into the same user interface. Report Generation Report generation is a function that is often not considered part of the load locking application. In reality, almost every load locking application requires some form of reporting capability, for the simple reason that if

Andra 41 youre recording the data, somebody needs to see it in a usable format. Report generation can be integrated into PC-based load locking applications for increased efficiency. The 89s52 is the microcontroller used. Its port 0 is connected to the ADC. The output from the ADC is set to port zero. Port 1 is connected to the switches and the switches are connected to loads (LED).Port 2 is connected to the ULN driver that acts as the current sink and drives the relay to operate when voltage values are exceeded. The timer is connected to interrupt and time mode pins. The read, write, ALE/P, TXD< RXD modes are connected to the MAX232 that is, serial communicating device. The value from MAX232 is sent to PC serially using serial cable. Expected Results In this chapter the module is tested and the results are taken. Before testing the main module the individual components are to be tested. Serial communication device After constructing the serial communication unit and developing the code, the code is loaded into the MAX232 chip using programmer. One end of RS232 probe is connected to MAX232 chips corresponding pins and the other end is connected to com port 2 of the PC. Then serial communication output is observed. Switch on the board and connect the serial cable and open the hyper terminal. The T E S T letters are transferred from the board to check whether serial communication is working properly or not. If

Andra 42 T E S T are properly transmitter it indicates that serial communication is proper. If any of the letters are missing we have to check the device. Power Circuit Testing After construction of the power circuit, the output of the circuit is tested and we observed the output voltage as 5VDC and 12V dc by using digital multimeters. The source code for the load locking is developed in assembly language. This code is loaded into Atmel 89s52 chip using programmer and the working condition of the final circuit is tested. Output Results Hardware circuit for load locking which displays and stores the voltage in a file for future use is developed and tested. The developed hardware circuits power supply probe is connected to mains and the RS-232 probe is connected in between the MAX-232 chip pins and PC side com port 2.The display program which is developed in C language is compile and run. The four machines (that is switches) are load locking circuits. When checked for machine 1 the particular voltage is displayed on computer monitor with respect to time, date and the same information is stored in a separate file which is entitled as datalog.txt for future use. Like this the working of machine 2, machine 3 and machine 4 are similar. The displayed output content and stored content in a file format is as follows:

Andra 43 Data Base: Status Monitoring

Figure 15 status monitoring Data Base: Error Report Generation The outputs will be stored in the data base as following

Figure 16 Error report

Andra 44 Discussions of Results The expected results are discussed in this chapter Serial Communication Testing The serial transmission of data is proper only when the T E S T letters are transmitted.

Figure 17 Error report If the T E S T is not properly transmitted then the serial communication devices and ports are to be checked. Potentiometer Settings The variation of voltage is done by varying the potentiometer. The potentiometer shows 20mV change for one step change in the setting. But is actually due to some manufacturing errors the step change in potentiometer indicates a 21mV change .This error in the settings as when compared to the final result can be neglected.

Andra 45 Analog to Digital Converter The voltage variations (analog) are converted to digital form by ADC. But when the same digital data is converted back to analog there will be some slight variations in the actual data. Since the ranges in the project are in volts these slight changes cause only a very minor change in mill volts that can be neglected. End Results The results for the load locking are as follows: i. The current time is: 2:24:47 The current date is: 07-04-2008, voltage is 2.3V ii. The current time is: 2:24:51 The current date is: 07-04-2008, voltage is 2.3V iii. The current time is: 2:24:54 The current date is: 07.04-2008. Voltage is 2.3V iv. The current time is: 2:24:56 The current date is: 3-1-2008, voltage is 2.3V The load status and the voltages are displayed in the database file as shown above. The results for error report generation Actual status: on Load status: off

Andra 46 If the actual status and the load status are same the error report is not generated. If there are any mismatches in the status the error report is generated and written in the database file. When the voltages exceed the prescribed limits the relay operates and the supply to the load is automatically cut off. On normal voltages the supply is automatically restored. Summary and Conclusions Summary Depending upon the user inputs the loads are locked. The loads status is predefined and cant be changed by any person other than the authorized user and thus malfunctioning of the loads is eliminated. The load status and the voltages of every load is sent to the microcontroller from time to time and recorded. The data is transferred to the computer for analysis, permanent storage and report generation. Data transmitted through serial communication to the computer is stored either in a floppy disk (removable storage) or on the same computer. Advantages of Load locking

One of the primary advantage of using load locking for system monitoring is the ability to collect data on a 24-hour, around-the-clock basis. The load locking process can take readings at regular intervals, 24 hours a day, for months or even years on end. Another advantage of load locking is that regular data can be collected over very short or very long time periods

Andra 47 that would be impossible or impractical for a human operator. The load locking process can record hundreds of readings in less than a second. Load locking is less expensive, more accurate and more reliable than chart recorders and the data is stored in a digital format which allows for more convenient analysis, presentation and storage. .

Applications of Data Acquisition Load locking for textile industry

These are the advantages of using a data acquisition in textile industry

1. Voltage recording.

2. HVAC (Heating, Ventilation, Air-Conditioning).

3. Replace costly strip chart recorders Implement.

Recommendations i. The ADC can be used to monitor more parameters other than voltage, like temperature, pressure, and other load parameters. ii. Number of loads monitored can be increased depending on the vacant controller pins. iii. Usage of parallel communication speeds up the process of data transmission, but the physical connections become more complex and the system becomes complex.

Andra 48 iv. Many modules can be used to control the loads in the textile industry by connecting the entire individual modules to master controller. v. The transmission of data can be through wireless technology that is through RF modems, GSM modems etc,.

Andra 49 References Krutz, Ronald. 2006. Securing Scada Systems, Wiley Publishing Inc. Kumar, R. Kamal and S. A. Khan. 2004. Designing and implementing SCADA Subsystem for textile industry, E-Tech: 88 91. Gaberbeges and Pusnik. Igor. 2002. Data Acquisition Module With Large Number of Inputs, IEEE Instrumentation & Measurements. Belher, k. Buhler and A. Druber. R. 2000. Real-Time Information Exchange between Load locking and Control Systems at ASDEX Upgrade. Aulmorais and Boaventura. J. 1998. Solar Load Locking Wireless Network for Agricultural Applications. Simon. McBeath. 2002 Competition Car Data Logging: A Practical Handbook, J. H. Haynes & Co. Simon. S. Young. 2000. Computerized Data Acquisition and Analysis for the Life Sciences, Cambridge University Press. Leo. W. R. 2000. Techniques for Nuclear and Particle Physics Experiments Roon, Van. Tony. 2008 http://www.uoguelph.ca/~antoon/gadgets/555/555.html (Accessed on 16 October,2008). Spencer Charles. D. 1990. Digital Design for Computer Data Acquisition, Cambridge University Press.

Andra 50 Christian. Schorn and Brian. Taylor. 2004. NMR Spectroscopy: Data Acquisition, Wiley-VCH. Mellicham. A. Duncan and Reinhold. Van Nostrand.1983. Real-time Computing With Applications to Data Acquisition and Control. James. Kevin.2000. PC Interfacing and Data Acquisition Techniques for Measurement, Instrumentation and Control, Newness. Austerlitz. Howard. 1991. Data Acquisition Techniques Using Personal Computers, Academic Press. Cline Ben. E. 1983. An Introduction to Automated Data Acquisition, PBI. Arnold H. VanDoren. 1982. Data Acquisition Systems, Reston. Frederick F. Driscoll, Robert F. Coughlin and Robert.S.Villanucci. 1994. Data Acquisition and Process Control with the M68HC11 Microcontroller, Maxwell Macmillan International. Zdravko. Karakehayov, Knud. Smed. Christensen and Ole. Winther. 1999. Embedded Systems Design with 8051 Microcontrollers: Hardware and Software, CRC Press. Adrian. Chepetan, Chepetan and Adrian. 2002. Microcontroller Based Data Acquisition System.National Library of Canada. Elwyn. Davies.1994. Microcontroller Based 12-bit Data Acquisition Using the TLC2543 Serial-out ADC, Texas Instruments. Han-Way. Huang. 2004. PIC Microcontroller: An Introduction to Software and Hardware Interfacing, Cengage Learning.

Andra 51 Omega. 2008. Introduction to Data Acquisition Systems http://www.omega.com/prodinfo/dataacquisition.html (Accessed on September 22, 2008) Zone. 2008 A Review of PC-Based Data Logging and Recording Techniques http://zone.ni.com/devzone/cda/tut/p/id/2693 (Accessed on September16, 2008). Sunrom technologies. 2008. on October 1 2008). Goldwasser. Samuel. M.2008. Troubleshooting and Repair of Small Switch mode Power Supplies http://www.kellerstudio.de/repairfaq/sam/smpsfaq.htm (accessed on October 11 2008). Darlington Transistor Arrays. 2008. http://www.datasheet4u.com/html/U/L/N/ULN2003AN_TexasInstrume nts.pdf.html (accessed on October 18th, 2008). http://www.sunrom.com/p-18.html (Accessed

Andra 52

Appendix 1 Front end code in C language processing the data received though serial communication : #include <dos.h> #include <stdio.h> #include <conio.h> #include <string.h> #define PORT1 0x3F8 /* Port Address Goes Here */ #define INTVECT 0x0c /* Com Port's IRQ here (Must also change PIC setting) */ /* Defines Serial Ports Base Address */ /* COM1 0x3F8 /* COM2 0x2F8 /* COM3 0x3E8 /* COM4 0x2E8 struct dostime_t t; struct dosdate_t d; int bufferin = 0; int bufferout = 0; unsigned char ch; unsigned char buffer[1025]; */ */ */ */

Andra 53 void interrupt (*oldport1isr)();

void interrupt PORT1INT() /* Interrupt Service Routine (ISR) for PORT1 */ { int c; do { c = inportb(PORT1 + 5); if (c & 1) {buffer[bufferin] = inportb(PORT1); bufferin++; if (bufferin == 1024) {bufferin = 0;}} }while (c & 1); outportb(0x20,0x20); } void main(void) { int c, i, n = 0; unsigned char comstate=0,anflag=0,digflag=0,digout=0,update=1; float anout; unsigned char digstatus[]={0xff,0xff,0xff,0xff}; char *name, *pass; FILE *dbase; outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */

oldport1isr = getvect(INTVECT); /* Save old Interrupt Vector of later

Andra 54 recovery */ setvect(INTVECT, PORT1INT); /* Set Interrupt Vector Entry */ /* COM1 - 0x0C */ /* COM2 - 0x0B */ /* COM3 - 0x0C */ /* COM4 - 0x0B */ /* PORT 1 - Communication Settings */

outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */ outportb(PORT1 + 0 , 0x0C); /* Set Baud rate - Divisor Latch Low Byte */ /* Default 0x03 = 38,400 BPS */ /* /* /* /* /* /* 0x01 = 115,200 BPS */ 0x02 = 57,600 BPS */ 0x06 = 19,200 BPS */ 0x0C = 0x18 = 0x30 = 9,600 BPS */ 4,800 BPS */ 2,400 BPS */

outportb(PORT1 + 1 , 0x00); /* Set Baud rate - Divisor Latch High Byte */ outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */ outportb(PORT1 + 2 , 0xC7); /* FIFO Control Register */ outportb(PORT1 + 4 , 0x0B); /* Turn on DTR, RTS, and OUT2 */ outportb(0x21,(inportb(0x21) & 0xeF)); /* Set Programmable Interrupt Controller */

Andra 55 /* COM1 (IRQ4) - 0xEF */ /* COM2 (IRQ3) - 0xF7 */ /* COM3 (IRQ4) - 0xEF */ /* COM4 (IRQ3) - 0xF7 */

outportb(PORT1 + 1 , 0x01); /* Interrupt when data received */ back: fflush (stdin); n = 0; clrscr(); printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*"); printf("\nprintf("* printf("printf("* printf("printf("* printf("-\n"); *\n"); -\n"); *\n"); -\n"); *\n"); -\n");

printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*\n"); gotoxy (2,5);

Andra 56 delay(500); printf(" delay(500); printf(" and"); delay(500); printf("control Using "); delay(500); printf("Supervisory Control and Data Acquisition "); delay(500); printf("Data Acquisition "); gotoxy(10,10); delay(500); printf(" \nENTER THE NAME |"); gets(name); if(strcmp( name, "user1") != 0) { printf("\nAUTHENTICATION ERROR!!\n"); getch(); goto back; } else { Intelligent Load Monitoring ");

Andra 57 printf(" \nENTER THE PASSWORD |"); gets(pass); if( strcmp(pass, "du") != 0) { printf("\nAUTHENTICATION ERROR!!\n"); getch(); goto back; } } printf("\n Enter the load status 1 - ON/ 0 - OFF\n"); do { printf("\n Enter load %d status | ", n+1); scanf("%d", &c); if( c == 0 ) digstatus[n] = 0xff; else if( c == 1) digstatus[n] = 0x00; n++; outportb(PORT1, 0xff); outportb(PORT1, 'S');

Andra 58 outportb(PORT1, n); outportb(PORT1, c); outportb(PORT1, 0xfe); }while(n < 4); printf("\n\nPRESS 'm' to set the STATUS of the LOADS, ESC to QUIT\n\n"); gotoxy(1,20); for(i=10;i!=65;i++) { gotoxy(i,19); printf("-"); } gotoxy(10,20); printf("|ANALOG STATUS|"); gotoxy(25,20); printf("L1-STATUS|"); gotoxy(35,20); printf("L2-STATUS|"); gotoxy(45,20); printf("L3-STATUS|"); gotoxy(55,20); printf("L4-STATUS|"); gotoxy(10,22);

Andra 59 printf("|"); gotoxy(10,23); printf("|"); gotoxy(10,24); printf("|"); gotoxy(10,25); printf("|"); gotoxy(10,26); printf("|"); gotoxy(24,21); printf("|"); gotoxy(24,22); printf("|"); gotoxy(24,23); printf("|"); gotoxy(24,24); printf("|"); gotoxy(24,25); printf("|"); gotoxy(24,26); printf("|"); gotoxy(34,21);

Andra 60 printf("|"); gotoxy(34,22); printf("|"); gotoxy(34,23); printf("|"); gotoxy(34,24); printf("|"); gotoxy(34,25); printf("|"); gotoxy(34,26); printf("|"); gotoxy(44,21); printf("|"); gotoxy(44,22); printf("|"); gotoxy(44,23); printf("|"); gotoxy(44,24); printf("|"); gotoxy(44,25); printf("|"); gotoxy(44,26);

Andra 61 printf("|"); gotoxy(54,21); printf("|"); gotoxy(54,22); printf("|"); gotoxy(54,23); printf("|"); gotoxy(54,24); printf("|"); gotoxy(54,25); printf("|"); gotoxy(54,26); printf("|"); gotoxy(64,21); printf("|"); gotoxy(64,22); printf("|"); gotoxy(64,23); printf("|"); gotoxy(64,24); printf("|"); gotoxy(64,25);

Andra 62 printf("|"); gotoxy(64,26); printf("|"); gotoxy(10,26); for(i=10;i!=65;i++) { gotoxy(i,21); printf("-"); } gotoxy(10,11); for(i=10;i!=65;i++) { gotoxy(i,27); printf("-"); }

dbase=fopen("daq.txt","a");

for( n=0; n<4; n++) { gotoxy(27+ n*10, 24); if( digstatus[n] == 0x00)

Andra 63 printf("ON"); else printf("OFF"); }

do {

if (bufferin != bufferout){ch = buffer[bufferout]; bufferout++; if (bufferout == 1024) {bufferout = 0;} } _dos_gettime(&t); _dos_getdate(&d);

gotoxy(1,15); printf("The current time is: %2d:%02d:%02d\n", t.hour, t.minute, t.second); gotoxy(1,16); printf("\nThe current date is: %d-%d-%d\n",d.day,d.month, d.year);

//MYCODE STARTS HERE if(comstate==0)

Andra 64 { if(ch!=0xff) goto tt; else comstate++; tt: } else if(comstate==1) { switch(ch) { case 'A':anflag=1; comstate++; break; case 'D':digflag=1; comstate++; break; } }

else if(comstate==2) {

Andra 65 if(anflag==1) anout=ch; else if(digflag==1) digout=ch; comstate++; } else if(comstate==3) { comstate=0; if(ch==0xfe) update=1; else continue; } else comstate=0; if(update==1) { update=0; fprintf(dbase,"\nThe current time is: %2d:%02d:%02d", t.hour, t.minute,t.second);

Andra 66 fprintf(dbase,"\nThe current date is: %d-%d%d",d.day,d.month, d.year,dbase); if(anflag==1) { anflag=0; gotoxy(12,24); printf("%3fVOL",(anout*20e-3)); fprintf(dbase,"\nVoltage is | %fVOL\n",(anout*20e3)); } } if(digflag==1) { digflag=0; switch (digout) { case 1: gotoxy(27,12); digstatus[0]=~digstatus[0]; if(digstatus[0]==0xff) { printf(" ");

Andra 67 gotoxy(27,12); printf("OFF"); fprintf(dbase,"\nLOAD 1 OFF\n"); } else { printf(" ");

gotoxy(27,12); printf("ON"); fprintf(dbase,"\nLOAD 1 ON\n"); } if( digstatus[0] == 0xff) fprintf(dbase,"\nActual Status is ON\n"); else fprintf(dbase,"\nActual Status is OFF\n"); fprintf(dbase,"\nError in Load 1 status\n\n"); break; case 2: gotoxy(37,12);

Andra 68 digstatus[1]=~digstatus[1]; if(digstatus[1]==0xff) { printf(" ");

gotoxy(37,12); printf("OFF"); fprintf(dbase,"\nLOAD 2 OFF\n"); } else { printf(" ");

gotoxy(37,12); printf("ON"); fprintf(dbase,"\nLOAD 2 ON\n"); } if( digstatus[1] == 0xff) fprintf(dbase,"\nActual Status is ON\n"); else fprintf(dbase,"\nActual Status is OFF\n");

Andra 69 fprintf(dbase,"\nError in Load 2 status\n\n"); break; case 3: gotoxy(47,12); digstatus[2]=~digstatus[2]; if(digstatus[2]==0xff) { printf(" ");

gotoxy(47,12); printf("OFF"); fprintf(dbase,"\nLOAD 3 OFF\n"); } else { { { printf(" ");

gotoxy(47,12); printf("ON"); fprintf(dbase,"\nLOAD 3 ON\n"); }

Andra 70 if( digstatus[2] == 0xff) fprintf(dbase,"\nActual Status is ON\n"); else fprintf(dbase,"\nActual Status is OFF\n"); fprintf(dbase,"\nError in Load 3 status\n\n"); } break; case 4: gotoxy(57,12); digstatus[3]=~digstatus[3]; if(digstatus[3]==0xff) { printf(" ");

gotoxy(57, 12); printf("OFF"); fprintf(dbase,"\nLOAD 4 OFF\n"); } else {

Andra 71 printf(" ");

gotoxy(57,12); printf("ON"); fprintf(dbase,"\nLOAD 4 ON\n"); } if( digstatus[3] == 0xff) fprintf(dbase,"\nActual Status is ON\n"); else fprintf(dbase,"\nActual Status is OFF\n"); fprintf(dbase,"\nError in Load 4 status\n\n"); break; } } } } if (kbhit()) { c = getch(); if( c == 's')

Andra 72 goto back; }

} while (c !=27); fclose(dbase); outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */

outportb(0x21,(inportb(0x21) | 0x10)); /* MASK IRQ using PIC */ /* COM1 (IRQ4) - 0x10 */ /* COM2 (IRQ3) - 0x08 */ /* COM3 (IRQ4) - 0x10 */ /* COM4 (IRQ3) - 0x08 */ setvect(INTVECT, oldport1isr); /* Restore old interrupt vector */ }

You might also like