Paper Title (use style: paper title)

1 downloads 0 Views 896KB Size Report
exercises can significantly contribute to better understanding of the planned curriculums. I. INTRODUCTION. Non scholae, sed vitae discimus (not for school but ...
PC and microcontrollers applications in the laboratory exercises of the electrical engineering Olivera Tasić*, Viša Tasić**, Darko Brodić***, Vladimir Despotović***, Marijana Pavlov**, Dragan R. Milivojević** *Mechanical and

Electrical High School, Bor, Serbia Metallurgy Institute, Bor, Serbia *** Technical Faculty in Bor, University of Belgrade, Bor, Serbia e-mail: [email protected] **Mining and

Abstract - Development of the new technologies in telecommunications, electronics and electrical engineering is a very dynamic process. It creates the need of constantly improving teaching programs in the field of electrical engineering. That includes exercise-related items like the use of computers and microcontrollers in automatic control systems. Accordingly, the presented examples of laboratory exercises can significantly contribute to better understanding of the planned curriculums.

I.

INTRODUCTION

Non scholae, sed vitae discimus (not for school but for life we learn). The old Latin phrase describes the goal of any educational system. Mechanical and Electrical High School Bor was established in 1990 by the decision of the Municipal Assembly of Bor, on the basis of Secondary Education Low, as an independent institution for education pupils in mechanical and electrical engineering [1]. School covers three education profiles: electrical engineering, mechanical engineering and transportation. The educational scope in electrical engineering covers several educational profiles, such as electrical technician for: multimedia, computers, computer networks, automation, and electronics and electrical energy. Rapid development of the new technologies in electronics, telecommunications and electrical engineering creates the need to constantly improve teaching Practical experience that pupils gain in the laboratory is of particular importance for their understanding of the applicability of theoretical knowledge. Simple, clear, and interesting experiments and exercises are essential to motivate them to expand their knowledge.

II. COMPUTER AND MICROCONTROLLERS APPLICATION IN A UTOMATIC C ONTROL S YSTEMS In this part of paper, some examples of laboratory exercises that use Intel, Motorola, Siemens, and Microchip microcontrollers and microprocessors will be shown. It is well known that microcontrollers are designed for embedded applications. A microcontroller is a single chip that contains the processor (CPU), non-volatile memory for the program (ROM or flash), volatile memory for input and output (RAM), a clock and an I/O (Input/Output) control unit. A. Traffic Light The first example is a simple control application for programming the traffic light using different microcontrollers and PC software. The first control application is realized using Siemens Logo! 12/24RC logic module. In its basic configuration it has integrated display and operator panel, 8 digital inputs, of which 2 can be used in analog mode and 4 relay outputs. Number of inputs/outputs can be increased using the extension modules. The Logo control system is perfectly suited for educational purpose, as it simplifies the automation process by replacing many time switches and relays, counters and protective relays with logic modules. Well designed exercises can encourage pupils to realize their own small-scale automation projects.

Selected examples of laboratory exercises based on the application of microcontrollers and computers in automatic control systems are presented in the paper. Due to well cooperation established between educational institutions and commercial enterprises, our pupils perform their practical exercises not only in laboratories within the school, but also in laboratories of other scientific institutions and enterprises within the town [2].

Figure 1. Simple model of traffic light realizes with Siemens Logo! 12/24RC logic module

Figure 2. Programming the traffic light in Logo! Soft Comfort software using the functional block diagrams

Figure 1 presents a model of traffic light, realized with Siemens Logo logic module [3]. Figure 2 shows an example of the program created with Siemens Logo! Soft Comfort software. This programming software enables control programs to be created, tested, edited, archived and printed out on a PC. The process of creating a program involves positioning and linking up program components from the predefined library (see left side in the Figure 2) on a "drawing board". One particularly userfriendly feature is the offline program simulation facility which enables simultaneous display of multiple function statuses. Except in simulation mode programs can be also uploaded into the Logo logic controller and executed in real-time. Logo! Soft Comfort provides two options for creating circuit programs: a) functional block diagram (see Figure 2) or b) ladder diagram (see Figure 3). Ladder logic is a programming language that represents a program by a graphical diagram based on the circuit diagrams of relay logic hardware. Ladder diagram programming is important when a programmable logic controller (PLC) is used primarily to replace relays, timers, and counters [4]. Analog quantities and arithmetical operations are unsuitable to be expressed in ladder logic, and each manufacturer has different ways of extending the notation for these problems [5]. Programming the same application in many different programming environments is very rewarding experience for pupils and students. For this reason, the same exercise was realized using the Microchip PIC16F877A CMOS FLASH-based 8-bit microcontroller (see Figures 4 and 5). MPLAB Integrated Development Environment (IDE) is used to develop the embedded application for PIC microcontrollers. It runs under Microsoft Windows operating systems and includes code editor (supports assembler and C languages), simulator with the debugger, and project manager [6]. However, a special development environment, named DLadder, is developed in Borland Delphi 7 programming language, for programming the PIC16F877A microcontroller. It allows programming using ladder logic, interpretation and compilation of programs into native code, debugging and the real-time simulation. It also allows the contents of the microcontroller ports and

Figure 3. Programming the traffic light in Logo! Soft Comfort software using the ladder diagrams

Figure 4. The traffic light electric scheme realized with the PIC16F877A microcontroller [5]

memory locations real time presentation [5]. The primary motive for DLadder IDE developing is a desire to develop programs for PIC microcontrollers using the concept of visual programming. Although there are a number of development environments for PIC microcontrollers on the market, few of them allow writing the programs in ladder logic. Writing a ladder diagram is performed by selection the required elements from the object toolbar (shown in Figure 6) and setting them in the appropriate position on the screen.

Figure 5. Model of traffic light realized with the PIC16F877A microcontroller

Figure 6. Programming the traffic light in DLadder software

The function objects support the arithmetic operations, logic operations, etc. An example of a simple ladder program, which simulates operation of the traffic light, is shown in Figure 6. Once the code has been built and checked from the syntax point of view, it should be tested. When SIMULATOR option in DLadder is selected, the program appears on the screen with the energized (true) branches highlighted (red color), as shown in Figure 6. The debugging process is simplified in this way. Furthermore, the traffic light program can be written in assembler language for 8086 microprocessor and executed under the assembler and microprocessor emulator EMU8086 [7], as shown in Figures 7 and 8. EMU8086 supports user-created virtual devices that can be accessed from assembly language program using in and out instructions. The traffic light lamps are controlled by sending data to I/O port 4 [8]. There are 12 lamps: 4 green, 4 yellow, and 4 red. One can set the state of each lamp by setting its bit: 1 - the lamp is turned on, 0 - the lamp is turned off. Only 12 low bits of a word are used (0 to 11), last bits (12 to 15) are unused. For example: MOV AX, 0000001011110100b OUT 4, AX

Figure 7. The semaphore example: assembler language code in the emulator EMU8086 editor window [7]

Figure 8. The semaphore simulation in the emulator EMU8086 [8]

B. Stepper motor Next exercise is related to the development of the program to control a stepper motor. Stepper motor is an electric motor that can be precisely controlled by signals from a computer. The motor turns through a precise angle each time, when it receives a signal. By varying the rate at which signal pulses have been produced, the motor can be run at different speeds or can be turned through an exact angle and then stopped [8]. The first part of this exercise refers to the use of a stepper_motor.asm example in the emulator EMU8086 [7]. Figure 9 shows a basic 3-phase stepper motor. It has 3 magnets controlled by bits 0, 1 and 2. Other bits (3..7) are unused. The stepper motor is controlled by sending data to I/O port 7. When a magnet is working, it becomes red. The arrow in the Figure 9 shows the direction of the last motor move. In the stepper motor example, the code below will do three clock-wise half-steps: MOV AL, 001b; initialize. OUT 7, AL MOV AL, 011b; half step 1. OUT 7, AL MOV AL, 010b; half step 2. OUT 7, AL MOV AL, 110b; half step 3. OUT 7, AL

Figure 9. The stepper motor simulation in the emulator EMU8086 [8]

Figure 10. The pin assignment of PC parallel port connector Figure 13. The interface board realized to control the stepper moto

Figure 11. The electric scheme realized to control the stepper motor by use of the PC parallel port

The second part of this exercise refers the use of the PC parallel port (shown in Figures 10, 11 and 13) to control the stepper motor. For this purpose, an appropriate program is created in Borland Delphi 7. The input parameters of the program are: number of steps, direction of rotation, and delay between steps, coil to be switched on, and parallel port address, as shown in Figure 12.

Figure 14. The temperature control example: assembler language code in the emulator EMU8086 editor window [7]

C. Temperature Control This example is also very simple, but very practical. The short program, shown in Figures 14 and 15, written in the assembler language for Intel 8086 microprocessor presents how to keep a constant temperature using the heater and the thermometer [7].

Figure 12. The main window of the program to control the stepper motor with four coils

Figure 15. The temperature control example [7]

Shown exercises can be equally used in the courses that deal with programming languages, as well as in the courses that deal with the elements of automatic control systems. One should note that good cooperation between educational institutions and commercial enterprises is essential to the quality of the teaching process, which enables the use of external laboratories as education bases.

Figure 16. The interface board realized to control the temperature by use of the PIC18F4550 with the LM35 temperature sensor

The second part of this exercise refers to the use of the microcontroller PIC18F4550 to measure the temperature. The LM35 integrated temperature sensor is used [10] (linear scale factor is +10 mV/°C). It does not require any external calibration or trimming to provide typical accuracies of ± 1⁄4 °C at room temperature. Appropriate program is created in DLadder environment and uploaded to microcontroller. While the program is running, the actual value of temperature has been displayed on LED display, as shown in Figure 16. The sensor output is connected to one of the microcontroller analog inputs, as shown in Figure 17. D. Other Lab Exercises Laboratory exercises in the field of process control and distributed control systems on the various types of industrial microcontrollers are also carried out. MMS (Microprocessor Measuring Station) is the representative of such equipment, which is still in use [2]. Pupils learn how to configure the MMS and to adjust and verify its validity. The dedicated software for real time operation is executed at the PC workstation, with standard SCADA functions, designed for the use in network environment [9]. Pupils learn and practice how to set the monitoring properties of the program related to the configuration of the input parameters. Furthermore, MMS with power transducers serves to introduce pupils to the principles of measurement of electrical power and control of power consumption [2]. Power transducer output signals are led to the MMS analog inputs. Measurement procedure consists of input signal A/D conversion, and processing of obtained numerical values. The power transducer gives the standard voltage signal (0 - 5 V DC) as an output, proportional to the active and reactive power. Laboratory exercise consists of setting of the output signal from the power transducers by setting the value of consumer's load and setting of MMS analog inputs based on A/D conversion results from readings [2]. III.

CONLUSION

Interesting and simple experiments and exercises are essential to motivate pupils to expand their knowledge.

Figure 17. The electric scheme realized to measure the temperature by use of the PIC18F4550 with the LM35 temperature sensor

ACKNOWLEDGMENT This work is supported by a grant from the Ministry of Education, Science and Technological Development of Republic of Serbia, as a part of project No. TR33037 “Development and Application of Distributed System for Monitoring and Control of Electrical Energy Consumption for Large Consumers." REFERENCES [1] [2]

http://www.mesbor.rs/ (accessed 10 January 2013) V.Tasić, D.Brodić, D.Milivojević, M.Pavlov, “Practicing of Lab Exercises at the Laboratory of Applied Electronics and Computer Engineering”, Proceedings of 6th. International Scientific Conference Computer Science 2011, 01.-03.09.2011. Ohrid, FJR Macedonia, pp. 429-434, ISBN 978-954-438-914-7. [3] http://www.automation.siemens.com (accessed 10 January 2013) [4] W. Bolton, Programmable Logic Controllers, Fifth Edition, Newnes, 2009. [5] V.Tasić, D.Milivojević, V.Despotović, D. Brodić, M.Pavlov, V.Miljković, “Dladder - an Integrated Environment for Programming PIC Microcontrollers”, Proceedings of XLVII International Scientific Conference on Information, Communication and Energy Systems and Technologies ICEST 2012, 28.6.-30.6.2012, V.Trnovo, Bulgaria, vol. 2., pp. 577-580. [6] Microchip Inc., MPLAB ICD 2 In-Circuit Debugger User’s Guide, Microchip Technology Inc., 2005. http://ww1.microchip.com/ downloads/en/devicedoc/51331b.pdf (accessed 10 January 2013) [7] http://www.emu8086.com (accessed 10 January 2013) [8] http://www.ziplib.com/emu8086/virtual_devices.html (accessed 10 January 2013) [9] D.Milivojević, V.Despotović and V.Tasić: “Process Control Program as an Element of Distributed Control System”, Information Technology and Control, vol.39, pp. 152-158. No. 2, 2010 [10] www.ti.com/lit/ds/symlink/lm35.pdf (accessed 10 January 2013)