Design and Implementation of Electronic Control Trainer with PIC Microcontroller ()
1. Introduction
Modern microcontroller chips can store hundreds of thousands of transistors each. The first microprocessors had external peripherals such as memory, input-output lines, and timers (Matic, 2003). In time came a new device called integrated circuit (IC), which contains both processor and peripherals. Also called a microcontroller, this was the first chip with a microcomputer [1,2].
Peripheral Interface Controller (PIC) is new to electronics control. Providing complete control in a single chip, a PIC microcontroller has special function registers, power on reset, interrupts, user RAM for storing of program data, EPROM program memory, timer circuits, instruction set, low power consumption, and on-board Ato-D converters. It replaces conventional control of industrial machinery (e.g., motor-speed control) [2,3].
Microcontroller and microprocessor differ in many ways. In functionality, a microprocessor needs external components for receiving/sending data, and memory. A microcontroller does not need external components because all the necessary peripherals are built-in, saving time and space (see Figure 1 for microcontroller set [4- 7]).
The EasyPIC-6 by MikroElektronika (see Figure 2) is an extraordinary development tool for programming and experimenting with PIC® microcontrollers. It supports over 160 MCUs in PIC10, PIC12, PIC16, and PIC18 families, in DIP packages from 8 to 40 pins. The board comes installed with PIC16F887. An impressive array of peripherals and expansion connectors are available onboard, as are optional LCD displays and temperature sensor [8,9].
An on-board programmer and mikroICD debugger allow direct connection to PC via USB cable. Fully functional demo versions of MikroElektronika’s C, Pascal, and BASIC compilers are included (hex output limited to 2K program words), complete with documentation and dozens of sample programs. The EasyPIC-6 also includes an external ICD connector compatible with MPLAB ICD2 and ICD3, allowing full compatibility with MPLAB Integrated Development Environment (IDE) [10,11].
Its main problem is lack of facility for external experiments to be implemented in many undergraduate laboratory applications; it is also daunting to beginner designers. This paper presents a practical implementation of EasyPIC-6-based electronic control trainer able to execute about 36 experiments, and rearrangement of the EasyPIC-6 power supply to extend the trainer’s capability to AC-DC-current applications.
1.1. Integrated Development Environment (IDE)
The core development tool set operates under the IDE umbrella called MPLAB. The tools look and feel the same,
Figure 2. EasyPIC-6 cart by MikroElektronika [11].
so learning of new tool interface is minimized. These are the development capabilities of the MPLAB IDE:
Ø Source-code editing;
Ø Project management;
Ø Machine-code generation (from assembly or “C”);
Ø Device simulation;
Ø Device emulation;
Ø Device programming.
The comprehensive tool suite allows complete project development without leaving the MPLAB environment [12]. The MPLAB IDE software eases software development as never before in 8-bit microcontroller. MPLAB is a Windows application that contains:
o A full-features editor;
o Three operating modes:
■ Editor
■ Emulator
■ Simulator o A project manager;
o Extensive online help;
MPLAB allows o Editing of source files (ASM and C files);
o One-touch assembly (or compiling) and download to PIC16/17 tools;
o Debugging via:
■ Source files
■ Absolute listing file
■ Program memory o Run-up to four emulators on the same PC;
o Run or single-step;
■ Program memory
■ Source file
■ Absolute listing The microchip simulator, MPLAB-SIM, operates under the same platform as the PICMASTER emulator, so the user need only learn a single tool set that functions equally in both the simulator and the full-features emulator [13].
1.2. MPLAB-SIM Simulator Software
The software simulator is a no-cost tool for evaluating Microchip’s products and designs. Its use greatly helps debug software, particularly algorithms. Depending on a project’s design complexity, a time/cost benefit comparing simulator with emulator should be looked into. Projects with multiple development engineers can keep costs down by using both simulator and emulator, allowing speedy debugging of tough problems. MPLAB-SIM Simulator simulates PICmicro series microcontrollers at instruction level. With any given instruction, the user may examine or modify any of the data or provide external stimulus to any of the pins. The input/output radix can be set by the user, the execution performed as either single step, execute until break, or trace. MPLAB-SIM supports symbolic debugging via MPLAB-C and MPASM. The software simulator’s low-cost flexibility in developing and debugging code outside laboratory environment makes it excellent multi-project development tool [14,15].
PIC ranges very broadly, from tiny 6-pin 8-bit devices with just 16 bytes of data memory performing only basic digital I/O, to 100-pin 32-bit devices with 512 kilobytes of memory and many integrated peripherals for communications, data acquisition, and control. Newcomers may be confused by an aspect of PIC programming: the lowend devices have entirely separate addresses and data buses for data and program instructions. 8-bit or 16-bit refers to the amount of data that can be processed at once, i.e., the width of the data memory (in microchip terminology, “registers”) and the ALU (Arithmetic and Logic Unit). Low-end PICs, operating 8-bit data at any one time, have three architectural families [16,17].
1.2.1. Baseline (12-Bit Instructions)
These PICs are based on the original PIC architecture, going back to the 1970’s and General Instrument’s “Peripheral Interface Controller”. They are rather limited, but within their limits (such as no interrupts) are simple to work with (particularly in modern assemblers such as 6-pin 10F series, 8-pin 12F509, and 14-pin 16F506).
1.2.2. Midrange (14-Bit Instructions)
An extension of the baseline architecture, it supports interrupts, has more memory and on-chip timers and peripherals, includes PWM (pulse width modulation) for motor control, supports serial, I2C, and SPI interfaces, and has LCD controllers. Modern examples include 8-pin 12F629, 20-pin 16F690, and 40-pin 16F887.
1.2.3. High-End (16-Bit Instructions)
Otherwise known as 18F series, this architecture overcomes some limits of the midrange devices. It has more memory (up to 128k program memory and almost 4k data memory) and advanced peripherals (including USB, Ethernet, and CAN or controller area network) connectivity. The 18F architecture supports C programming and is, among 8-bit PIC families, the only one with C compiler. Examples include 18-pin 18F1220, 28-pin 18F2455, and 80-pin 18F8520. Maybe a little confusing is that PIC18F series has 16-bit program instructions operating on 8-bits of data at a time, and is considered an 8-bit chip [12,18].
BASIC programming language is known to users as the easiest and is the most used. The reputation is increasingly transferred onto microcontrollers. PIC BASIC enables quicker and relatively easier program writing for PIC microcontrollers, as compared with Microchip’s assembly language MPASM. During program writing, the programmer encounters the same problems always: serial sending of messages, writing of variable on LCD display, generating of six PWM signals, etc. [16].
Facilitating programming are PIC BASIC’s built-in commands, which are intended to solve problems typically found in praxis. Where execution speed and program size are concerned, MPASM is less advantaged than PIC BASIC (therefore giving rise to the possibility of combining PIC BASIC and assembler). The part of the program where the same commands are executed many times or the execution time is critical is usually written in assembler. Modern microcontrollers such as PIC execute the instructions in a single cycle lasting 4 tacts of the oscillator. If the microcontroller oscillator is 4 MHz (one tact lasts 250 nS), then one assembler instruction requires 250 nS × 4 = 1 uS for the execution. Each BASIC command is actually a sequence of assembler instructions; the exact time necessary for execution of a BASIC command is simply the sum of the times necessary for execution of assembler instructions within one BASIC command [17,19].
2. Hardware Design of the PIC Trainer Model
Figure 3 is a laboratory model of the trainer design hardware. The model has three main parts: board for applied experiments, PIC microcontroller simulator, and interfacing board with PC computer. There is also a built-in power supply.