expansion of input / output plc omron cj1gcpu42h...
TRANSCRIPT
EXPANSION OF INPUT / OUTPUT PLC OMRON CJ1GCPU42H USING PIC
CHONG KOK HEE
This report is submitted in partial fulfillment of the requirements for the award
of Bachelor of Electronics Engineering (Computer Engineering) With Honours
Faculty of Electronic and Computer Engineering
University Technical Malaysia Malacca
April 2009
UNIVERSTI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER
BORANG PENGESAHAN STATUS LAPORAN
PROJEK SARJANA MUDA II
Tajuk Projek : EXPANSION OF INPUT / OUTPUT PLC OMRON CJ1GCPU42H USING PIC ………………………………………………………………………………
Sesi Pengajian :
2008 / 2009 ………………………………………………………………………………
Saya CHONG KOK HEE mengaku membenarkan Laporan Projek Sarjana Muda ini disimpan di Perpustakaan dengan syarat-syarat kegunaan seperti berikut: 1. Laporan adalah hakmilik Universiti Teknikal Malaysia Melaka.
2. Perpustakaan dibenarkan membuat salinan untuk tujuan pengajian sahaja.
3. Perpustakaan dibenarkan membuat salinan laporan ini sebagai bahan pertukaran antara institusi
pengajian tinggi.
4. Sila tandakan ( √ ) :
SULIT*
(Mengandungi maklumat yang berdarjah keselamatan atau kepentingan Malaysia seperti yang termaktub di dalam AKTA RAHSIA RASMI 1972)
TERHAD* (Mengandungi maklumat terhad yang telah ditentukan oleh
organisasi/badan di mana penyelidikan dijalankan)
TIDAK TERHAD
Disahkan oleh:
__________________________ ___________________________________ (TANDATANGAN PENULIS) (COP DAN TANDATANGAN PENYELIA)
Alamat Tetap: NO 22, JLN 2/1 BIDARA,
TMN BIDARA, 68100 BT CAVES,
SELANGOR DARUL EHSAN.
Tarikh : 23 – 4 - 2009 Tarikh: 23 – 4 - 2009
iii
“I hereby declare that this report is the result of my work except for quotes as cited in
the references.”
Signature :
…………………………………………
Author : CHONG KOK HEE
…………………………………………
Date : 23 APRIL 2009
…………………………………………
iv
“I hereby declare that I have read this report and in my opinion this report is
sufficient in terms of the scope and quality for the award of
Bachelor of Electronic Engineering (Computer Engineering) with Honors.”
Signature :
…………………………………………
Supervisor’s Name : EN FARID ARAFAT BIN AZIDIN
…………………………………………
Date : 23 APRIL 2009
…………………………………………
v
This book is dedicated to my parents, family members and friends.
Last but not least, to my supervisor and all the UTeM lecturers.
vi
Acknowledgement
This project would not have been possible without the support of many
people. Many thanks to my supervisor, Mr. Farid Arafat Bin Azidin, who read my
numerous revisions and helped make some sense of the confusion. He always
provides the excellent guidance, concern and informative discussions regarding to
my project. I would like to express my most sincere gratitude and appreciation to him
and everyone who give help to me during the process to accomplish this project. And
finally, thanks to my beloved family members for their unconditional love, support
and patience and at last to numerous friends.
vii
ABSTRACT
Programmable Logic Control (PLC) is the control hubs for a wide variety of
automated systems and processes. It contains multiple inputs and outputs that use
transistors and other circuitry to simulate switches and relays to control equipment.
This is microcontroller based project which is using a microcontroller to expand the
inputs / outputs of the PLC OMRON CJ1GCPU42H. This project was developed
with the main objective to expand the inputs / outputs for PLC inexpensively using
PIC while maintaining standard PLC input properties and functionality. The project
is useful for those UTeM students who will be use the PLC as a tool for them to do
their research in the future.
viii
ABSTRAK
Programmable Logik Kawalan ialah suatu pusat kawalan yang mempunyai
pelbagai fungsi dalam automatik system dan proses. Ia mengandungi banyak input
dan output yang menggunakan transistor dan lain litar yang simulasi suis dan relay
untuk kawalkan sesuatu alat. Projek ini mengunakan kawalan mikro sebagai asas
projek iaitu dengan menggunakan kawalan mikro untuk membanyakan input atau
ouput bagi PLC OMRON CJ1GCPU42H. Projek ini dihasilkan dengan tujuan untuk
membanyakan input atau output bagi PLC dengan mengunakan PIC secara kos
rendah tanpa mengubahkan asal unsur dan fungsi bagi input PLC yang sedia ada.
Projek ini dapat membantu pelajar UTeM di mana mereka yang akan mengguna PLC
sebagai alat untuk membuat kajian mereka pada masa hadapan.
ix
CONTENT
CHAPTER TITLE PAGE
PROJECT TITLE i
STATUS REPORT DECLARATION FORM ii
DECLARATION iii
SUPERVISOR APPROVAL iv
DEDICATION v
ACKNOWLEDGMENT vi
ABSTRACT vii
ABSTRAK viii
CONTENTS ix
LIST OF TABLE xii
LIST OF FIGURE xiii
LIST OF ABBREVIATION xvi
LIST OF APPENDIX xvii
I INTRODUCTION 1
1.1 Background Of Project 2
1.2 Project Objectives 2
1.3 Problem Statement 3
1.4 Scope Of Work 3
1.5 Short Brief On Methodology 4
1.6 Thesis Outline 5
x
II LITERATURE REVIEW 6
2.1 Introduction 6
2.2 Research And Study 6
2.3 Microcontroller 7
2.3.1 Comparison between PICs 7
2.3.2 Embedded design of microcontroller 8
2.3.3 PIC Microcontrollers 9
2.3.3.1 Selecting microcontroller 9
2.3.3.2 PIC16F877A 10
2.3.4 Types of memory 12
2.4 PIC C Compiler 12
2.4.1 PC based versus PIC based program development 13
2.4.2 Terminology 13
2.4.3 The structure of C programs 15
2.5 PROTEUS 6 Professional ISIS 16
2.6 PROTEUS 6 Professional ARES 16
2.7 WINPIC 17
2.8 PLC 17
2.9 CX – Programmer 19
III METHODOLOGY 20
3.1 Introduction 20
3.2 Process Flowchart 21
3.3 Program Development by Using CX – programmer 22
3.4 Program Development by Using PIC C compiler 26
3.5 Testing Program In PROTEUS 6 Professional 28
3.6 Design PCB Layout In PROTEUS 6 Professional ARES 31
xi
IV RESULT AND DISCUSSION 34
4.1 Introduction 34
4.2 Result of Simulation 34
4.2.1 CX – Programmer 34
4.2.2 PIC C compiler 37
4.2.3 PROTEUS 6.9 Professional ISIS 39
4.2.4 PROTEUS 6.9 Professional ARES 43
4.2.5 WinPIC 45
4.3 Hardware Creation 47
4.4 Discussion 48
4.4.1 C programming discussion 49
4.4.2 PROTEUS ISIS discussion 51
4.4.3 PROTEUS ARES and hardware discussion 51
V CONCLUSION AND SUGGESTION 53
5.1 Conclusion 53
5.2 Suggestion 54
REFERENCES 56
APPENDIX A 57
xii
LIST OF TABLE
NO TITLE PAGE
2.1 Comparison between PICs 8
2.2 Comparison between wired logic and programmable controllers 18
4.1 Relationship between inputs and outputs 51
xiii
LIST OF FIGURE
NO TITLE PAGE
2.1 PIC16F877A pinout 10
2.2 PIC16F877A usages and features 11
2.3 PLC OMRON CJ1GCPU42H 19
3.1 Process flowchart for whole project development 21
3.2 CX – Programmer Windows 22
3.3 The setting for the Change PLC window 22
3.4 Setting for the I / O table 23
3.5 I/O table configuration 23
3.6 Ladder symbol for CX - programmer 24
3.7 Setting for Work Online 24
3.8 Message box for confirmation 25
3.9 Setting for transfer the data to PLC from CX – programmer 25
3.10 Setting for Download options 25
3.11 PIC C Compiler interface 26
3.12 Create New File / Project 26
3.13 Select the File / Project location and name to save 27
3.14 Compile selected file / project 27
3.15 ‘Compile’ button at PIC C compiler interface 28
3.16 ISIS 6 Professional User Interface 28
3.17 Circuit diagram for project 29
3.18 Select components for the project 29
3.19 Pick Devices window to select component 30
3.20 Inter – sheet Terminal 30
3.21 Pick Terminals window 30
xiv
3.22 Overview for the ARES layout editor 31
3.23 Various views of the simple sample layout 31
3.24 Library Pick form ready for selection 32
3.25 Square pads placement for the DIL40 32
3.26 Example of placing the track on DIL40 33
4.1 Result for button 3 pressed in CX – programmer 35
4.2 Result for button 3 pressed in PLC’s output 35
4.3 Result for 3 buttons pressed in CX – programmer 36
4.4 Result for 3 buttons pressed in PLC’s output 36
4.5 Result for 2 buttons pressed in CX - programmer 36
4.6 Result for 2 buttons pressed in PLC’s output 37
4.7 The message box show the source file is debugging and compiling 37
4.8 No error during debugging and compiling the source file 38
4.9 Files created after debugging and compiling the source file 38
4.10 The initial state for the buttons 39
4.11 Result for Button 1 is pressed 39
4.12 Result for Button 2 is pressed 40
4.13 Result for Button 1 and 2 are pressed 40
4.14 Result for Button 3 is pressed 41
4.15 Result for Button 1 and 3 are pressed 41
4.16 Result for Button 2 and 3 are pressed 42
4.17 Result for Button 1, 2 and 3 are pressed 42
4.18 Overall layout in PROTEUS ARES (1) 43
4.19 Overall layout in PROTEUS ARES (2) 43
4.20 Top layout in PROTEUS ARES 44
4.21 Bottom layout in PROTEUS ARES 44
4.22 Program PIC without any error 45
4.23 Verified PIC without any error 46
4.24 Reading PIC without any error 46
4.25 Top view of the hardware with the components on PCB 47
4.26 Bottom view of the hardware 47
4.27 Side view of the hardware with component on PCB 48
4.28 Top view for the hardware with bulbs 48
4.29 Declarations for programming 49
xvi
LIST OF ABBREVIATIONS
ALU – Arithmetic Logic Unit
ASCII – American Standard Code for Information
Interchange
CCP – Capture, PWM
CCS C Compiler – Customer Computer Service C Compiler
CISC – Complex Instruction Set Computer
CPU – Center Processing Unit
EEPROM – Electrical Erasable Programming Read Only
Memory
IDE – Integrated Developement Environment
I/O – Input / Output
MSB – Most Significant Bit
NVM – non-volatile storage
PCB – Printed Circuit Board
PIC – Programmable Interface Controller or
Programmable Intelligent Computer
PID – Proportional – Integral – Derivation
PLC – Programmable Logic Controller
PWM – Pulse Width Modulation
RAM – Random Access Memory
RISC – Reduce Instruction Set Computer
RTOS – Real Time Operating System
LCD – Liquid Crystal Display
LED – Light Emitter Diode
LSB – Least Significant Bit
1
CHAPTER I
INTRODUCTION
Programmable Interface Controller or Programmable Intelligent Computer
(PIC) is made by Microchip Technology. It contains a processor core, memory, and
programmable input / output peripherals. Besides that, it is cheaper and consumes
less power compare to the microprocessor. PIC is very powerful and useful because
it can be use for many types of applications such as automobile engine control
systems, remote controls, office machines, appliances, expansion of ports and etc.
Programmable Logic Controller (PLC) is a digital computer used for
automation of industrial processes, such as control of machinery on factory assembly
lines. It is unlike general-purpose computers because it is designed for multiple
inputs and output arrangements, extended temperature ranges, immunity to electrical
noise, and resistance to vibration and impact. It is also an example of a real time
system since its output results must be produced in response to its input conditions
within a bounded time, otherwise unintended operation will result. The functionality
of the PLC has evolved over the years to include sequential relay control, motion
control, process control, distributed control systems and networking. The data
handling, storage, processing power and communication capabilities of some modern
PLCs are approximately equivalent to desktop computers. PLC-like programming
combined with remote I/O hardware, allow a general-purpose desktop computer to
overlap some PLCs in certain applications
2
1.1 Background Of Project
The PLC OMRON CJ1GCPU42H has 16 inputs and 16 outputs. This project
will expand the output from PLC while maintaining its standard input properties and
functionality. In this project, 3 inputs / outputs from the PLC will be use to expand
the PLC outputs and the total outputs for PLC will become 20 outputs after the
modification is done. The combination of PIC 16F877A and external relay are
needed in order to expand the input / output from PLC. Besides that, some of the
programming languages such as CX – programming and C language will be use in
the project, where CX – programming will be use in PLC and C language will be use
in PIC.
In this project, development process will be focus on the interface between
PLC and PIC because they will affect the entire cost of the project by choosing the
components.
1.2 Project Objectives
The following objectives are needed as a guide to achieve the goal of this
project:
i) To expands the PLC inputs / outputs using microcontroller while maintaining
standard PLC’s input properties and functionality.
ii) To allow interface between 2 control elements (PLC and PIC).
iii) To use as low as possible in the cost of components for the design.
iv) To use as small as possible in the space for the PCB board to expand the
PLC’s outputs / inputs.
v) To implement what had learnt in microcontroller and industrial control to the
project.
3
1.3 Problem Statement
The major problem faced by designer when the situation require a
microcontroller to control the system is spend too much time on program
development process. Based on common microcontroller in the market such as PIC
(Programmable Interrupt Controller), a complete and successful compiled source
code is necessary to operate the PIC. Normally, most of the time is spend on writing
the source code.
The important of this project is expanded the port of the PLC in the University
Technical Malaysia Malacca’s laboratory so that the PLC can become 4 times more
ports than the original ports. This is because the PLCs in the laboratory are not
enough for the students to do their research work.
Beside that, another problem often faced by programmer is lots of error
occurred during compiling the source code. Although the compiler program able to
debug and provide a reference for user to make correction, but sometime is too
complicated and wasting time to make correction for all the errors.
Based on research and study result, the interface between PIC and PLC is the
most headache problem for the designer. This is because there are 2 problems will be
encounter in this path. The first one is step down the voltage from PLC because the
voltage can be supported in PIC is about 5V only, whereas the voltage on PLC is
about 24V. The other one is step up the voltage from PIC in order to complete the
project. This will affect the cost of the entire project.
1.4 Scope Of Work
This final project basically is expanded the outputs for PLC OMRON
CJ1GCPU42H. Therefore there will be 2 main components, PLC OMRON
CJ1GCPU42H and PIC 16F877A, to be use in this project.
4
Design and simulation will be performed using CX program for PLC. Whereas
for the PIC, there will be using 3 software, PIC C compiler, PROTEUS 6.9 VSM and
WinPIC. The successful simulated program will be downloading to the PIC using
WinPIC. Testing on PCB board will also be carried out when all the designs and
simulations have done.
The design will then be transferred to PCB as prototyping using Proteus ARES.
Then proceed with etching and soldering process. Testing and troubleshooting on the
prototype model will be done to ensure the functionality of the prototype.
1.5 Short Brief On Methodology
To develop the project during PSM-I, CX – program had used for design the
ladder diagram for the PLC and CCS C compiler had used for design the program for
the PIC16F877A.
After that, the error free program will be converted to hex code through CCS C
compiler. This hex code will be tested in PROTEUS 6.7 to determine some error that
can not be trace by PIC C compiler.
When everything is done without any problem then the program will be tested
using 3 push buttons which will be connected to PIC16F877A to verify the program.
Then it will proceed to circuit layout design by using PROTEUS ARES. This layout
will be etched to the positive acting PCB and then solder the components to the PCB.
If everything is ok then the project is done.
1.6 Thesis Outline
This thesis consists of five chapters which are Chapter 1, Chapter 2, Chapter 3,
Chapter 4, and Chapter 5. In Chapter 1, it will discuss the introduction of the project
which includes the objective of the project, problem statement, scopes of work,
methodology, and the important of the project.
5
In Chapter 2, it will describe the literature review had been done for the
project. Every facts and information which is found through journals or other
references where later on it will be implement in the project.
The methodology of the project will be discussed in Chapter 3. The project
methodology will be covered the two main parts which is software development part
and hardware creation part. In software creation part, software like PIC C compiler
and CX – programmer will be to develop the software part and PROTEUS ISIS will
be used for testing the hex code generated by PIC C compiler, whereas in hardware
creation part will discussed the process of etching, drilling, and soldering.
In Chapter 4, it will display the results for the software development part and
hardware creation part discussed in Chapter 3. All of these results will be show in the
form of figures only. Besides that, there will be some discussion about the simulation,
C programming and hardware part that had done in the project.
Lastly, the Chapter 5 will summarize the project and it will also discuss the
conclusion of the project and suggestions or recommendations in the future work.
6
CHAPTER II
LITERATURE REVIEW
2.1 Introduction
This chapter reviews some references from previous projects, journals,
articles, books and datasheets. All these information were collected from the
different sources such as library, internet, product manual and etc. The useful data
will be discussed on this chapter.
2.2 Research And Study
Nowadays, there are many types of compilers to program the
microcontroller in PIC field. They are used to translate source code from a high-level
programming language such as C++ or C to a lower level programming languages
such as machine code or assembler language. For example, just take a common
microcontroller which is PIC16F877A. It has many program compilers supported
such as PIC C Compiler, PIC C Compiler, PIC Simulator IDE, PIC Basic or
SourceBoost IDE and etc. All of these compilers require the program instructions or
known as source codes to generate the Hex code. These source codes all are in C
language which is also know as high level programming language. With these
compilers and microcontrollers, many modifications for the hardware can be done
easily without changing the hardware part. In this report, there will be some
comparison for PICs.
7
2.3 Microcontroller
A microcontroller is all the components of the microcomputer system such
as Central Processing Unit (CPU), Arithmetic Logic Unit (ALU), input / output (I / O)
and peripherals devices combined together onto one integrated chip. It emphasizes
high integration, in contrast to a microprocessor which only contains a CPU. In
addition to the usual arithmetic and logic elements of a general purpose
microprocessor, the microcontroller integrates additional elements such as read-write
memory for data storage, read-only memory for program storage, Flash memory for
permanent data storage, peripherals, and input/output interfaces. At clock speeds of
as little as 32KHz, microcontrollers often operate at very low speed compared to
microprocessors, but this is adequate for typical applications. They consume
relatively little power (milliwatts or even microwatts), and will generally have the
ability to retain functionality while waiting for an event such as a button press or
interrupt. Power consumption while sleeping (CPU clock and peripherals disabled)
may be just nanowatts, making them ideal for low power and long lasting battery
applications.
2.3.1 Comparison between PICs
In this project, the PIC16F877A will be choosing for development of the
project. This PIC is chosen because of its total number of pins and cost. Besides that,
the consideration for future developments of the project also is one of the reasons
that this PIC is chosen.
The Table 2.1 is shows the comparison between PIC16F84 and
PIC16F877A in terms of their cost, number of pins, availability in market and etc.
Since the PLC has 16 inputs and 16 outputs, so the total number of pins and the cost
for the PIC will be the first priority to consider in choosing PIC for the project. After
that, other factors like the availability in market, performance, and etc will be take in
to consideration.