PLC With PIC16F648A Microcontroller (Part 1) : ELECTRONICS WORLD November 2008
PLC With PIC16F648A Microcontroller (Part 1) : ELECTRONICS WORLD November 2008
PLC With PIC16F648A Microcontroller (Part 1) : ELECTRONICS WORLD November 2008
net/publication/291773586
CITATION READS
1 7,456
1 author:
Murat Uzam
Yozgat Bozok University
150 PUBLICATIONS 2,053 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
An Image Interpreter for Vision-Based Logic Control of Manufacturing Plant View project
Analog Input / Analog Output Modules for a 5V Microcontroller Based PLC View project
All content following this page was uploaded by Murat Uzam on 20 August 2017.
9 770959 833110 11
Special Issue –
Microcontrollers:
• BUILD YOUR OWN DATA LOGGER
• BUILD YOUR OWN MCU-BASED PLC
• CHOOSING BETWEEN ARM7 AND CORTEX-M3
PURCHASING
NEW OSCILLOSCOPES?
CONSIDER THE UPDATE
RATES!
ALSO IN THIS ISSUE: THE TROUBLE WITH RF: SO MANY TRANSMITTERS, SO SMALL A BAND
Electronics World CONTENTS
05 EDITOR’S COMMENT
Issue 1871
Volume 114,
11
9 770959 833110
2008 £4.60
NOVEMBER world.co.uk
www.electronics
RATES!
PRODUC TS
11 FOCUS
SYSTEM S,
UKDL COMMS TEST
POSTERS AND
TECHNO LOGY RIGHT LASER ANALYS ERS
LEARNING FOR THE
FROM RIGHT JOB
NATURE A BAND
SO SMALL
TRANSMITTERS,
SO MANY
TROUBL E WITH RF:
ISSUE: THE
ALSO IN THIS
21
Dogan Ibrahim describes the design of a
microcontroller-based multichannel data
logger device with SD card and real-time clock
interface
39 UKDL
Dr Ric Allott reviews some of the fundamental
properties of lasers and how these properties influence
the choice of laser for a particular manufacturing
operation
45 PRODUCTS 26 32
www.electronicsworld.co.uk Electronics World - November 08 ❙ 3
UZAM 16/9/08 10:25 Page 36
Feature PLC/MCU
PLC/MCU Feature
rogrammable Logic Controllers UZAM_PLC with PIC16F648A. First in the macros. In addition, many new features
Feature PLC/MCU
board is shown in Figure 1. The main Electronics World for details). PIC16F648A microcontroller. Although it
board contains mainly five sections: power, For other types of USB or parallel port can run up to 20MHz, in UZAM_PLC it is
programming, CPU (Central Processor PIC programmers the reader is expected to fixed to run at 4MHz with its internal
Unit), inputs and outputs. make necessary arrangements. ICSP oscillator. This frequency is fixed because
The power section accepts 12V AC input connector takes the lines VPP(MCLR), VDD, time-delays are calculated based on this
and produces as outputs 12V DC to be VSS(GND), DATA (RB7), CLOCK (RB6) from speed. However, by means of two
used as the operating voltage of relays, the PIC programmer hardware through a switches, namely SW1 and SW2, it is also
and 5 V DC to be used for ICs, inputs, etc. properly prepared cable and it serves them possible to use an external oscillator with
The programming section deals with the to a 4PDT (four pole double throw) switch. different crystal frequencies. When doing
programming of PIC16F648A There are two positions of the 4PDT so, time-delay functions must be calculated
microcontroller. For programming the switch. As seen in Figure 1, in one position accordingly. SW3 directs the RA5 pin either
PIC16F648A in circuit, it is necessary to use of 4PDT switch, PIC16F648A is ready to be to one pole of 4PDT switch or to the future
a PIC programmer hardware and software programmed and in the other position the extension connector.
with ICSP (In Circuit Serial Programming) loaded program is run. For properly
capability. For those who have a PC with programming the PIC16F648A by means of PROGRAMMING PICS
serial port, PCB files for a PIC programmer a PIC programmer and the 4PDT switch, it When programming PIC16F648A, RA5
hardware, called JDM programmer, and is also a necessity to switch off the power should be connected to 4PDT switch. RB0,
related software can be downloaded switch. RB6 and RB7 pins are all reserved to be
(please contact the editorial office of The CPU section consists of the used for an 8-bit parallel to serial converter
PLC/MCU Feature
register 74HC/LS165. Through these three PIC16F648A provides the following: DC signals. These external input signals are
pins and with added 74HC/LS165 registers 4096 words of Flash program memory; 256 isolated from the other parts of the
we can describe as many inputs as we bytes of RAM data memory and 256 bytes hardware by using NPN type opto-couplers
wish. RB0, RB6, and RB7 are the “data in”, of EEPROM data memory. The UZAM_PLC (e.g. 4N25). For simulating input signals,
the “clock in” and the “shift/load” pins, macros make use of registers defined in one can use on board push-buttons as
respectively. RAM data memory. Note that it may be temporary inputs and slide switches as
Similarly, RB3, RB4 and RB5 pins are all possible to use PIC16F628A as the CPU, permanent inputs.
reserved to be used for 8-bit serial to but one has to bear in mind that In the beginning of each PLC scan cycle
parallel converter register/driver TPIC6B595. PIC16F628A provides the following: 2048 (get_inputs) 74HC/LS165 is loaded (RB7
Through these three pins and with added words of Flash program memory; 224 bytes (shift/load) = 0) with the level of 8 inputs
TPIC6B595 registers we can describe as of RAM data memory and 128 bytes of and then this data is serially clocked in
many outputs as we wish. RB3, RB4 and EEPROM data memory. (when RB7 = 1; through RB0 “data in” and
RB5 are the “clock out”, the “data out” In this case it is necessary to take care of RB6 “clock in” pins). If there is no I/O
and the “latch out” pins, respectively. The the usage of RAM data memory. The extension board used, then 8 clock_in
remaining unused pins of the PIC16F648A inputs section introduces 8 discrete inputs signals are enough to get the 8 input
are connected to the “future extension for the UZAM_PLC, called I0.0, I0.1, ..., signals. For each I/O extension board, 8
connector”. I0.7. Each input can accept 5V DC or 24V more clock_in signals are necessary.
A B C
D E
Figure 3: Photographs of (a) the UZAM_PLC main board, (b) UZAM_PLC I/O extension board, (c) UZAM_PLC main board with a PIC
programmer, (d) UZAM_PLC main board plus an I/O extension board and a USB PIC programmer, (e) UZAM_PLC main board plus two
I/O extension boards and a USB PIC programmer
UZAM 17/9/08 14:48 Page 40
Feature PLC/MCU
DATA INPUT As shown in Figure 2, the “I/O extension board” contains mainly
The serial data coming from the I/O extension board is taken from two sections: discrete inputs (8 of them) and discrete outputs (also
the “SI” input of 74HC/LS165. The outputs section introduces 8 8 of them). They are similar to the ones as described for the main
discrete relay outputs for the UZAM_PLC, called Q0.0, Q0.1, ..., board.
Q0.7. Each relay operates with 12V DC and is driven by an 8-bit The I/O extension connector “DB9M” seen on the left connects
serial to parallel converter register/driver TPIC6B595. the I/O extension board to the main board or to a previous I/O
Relays have SPDT (single pole double throw) contacts with C extension board. Similarly, the I/O extension connector “DB9F”
(common), NC (normally closed) and NO (normally open) terminals. seen on the right connects the I/O extension board to an adjacent
At the end of each PLC scan cycle (send_outputs) the output data I/O extension board. In this way we can connect as many I/O
is serially clocked out (through RB3 “clock out” and RB4 “data extension boards as necessary. The 12V DC power is taken from
out” pins) and finally latched within TPIC6B595. If there is no I/O the main board or from a previous I/O extension board and it is
extension board used, then 8 clock_out signals are enough to send passed to the next I/O extension boards.
the 8 output signals. For each I/O extension board, 8 more The 5V DC voltage is taken from the main board or from a
clock_out signals are necessary. previous I/O extension board through the “DB9M” connector and it
The serial data going to the I/O extension board is sent out from is passed on to the next I/O extension boards through the “DB9F”
the “SER OUT” (pin 18) of TPIC6B595. In addition, there is also an connector. The PCB design files of the I/O extension board can be
I/O extension connector “DB9F” for conveying the I/O data to and had from the editorial offices of the magazine. Note that in the
from all the connected extension I/O boards. The PCB design files PCB design of the I/O extension board, some lines of I/O extension
of the main board can be received from the editorial offices of connectors “DB9M” and “DB9F” are different from the ones
Electronics World. Note that in the PCB design of the main board, shown in Figure 2. Figure 3 is a selection of photos of the
some lines of I/O extension connector are different from the ones UZAM_PLC main board and I/O extension board with and without a
shown in Figure 1. PIC programmer. ■