INTRODUCTION TO PIC
In this blog we are going to see the introduction of PIC microcontroller, what are its application and why it is so much popular in wide areas of Embedded system.
Hello people, today we are going to see about the PIC microcontroller, what is it, and why we do use it. PIC is a microcontroller, before going to the introduction to PIC we will see a basic definition of a microcontroller.
What is a Microcontroller?
A PIC stands for Peripheral interface controller may be a microcontroller which is intended by Microchip Technology. Initially, it was brought up as a Peripheral interface controller but over time, it's currently mentioned as Programmable Intelligent Computer. The large reason of PIC of holding a market is it's compatible with both hobbyists and industrial developers.
It has been used in wide applications like smartphones, medical devices, telecommunication devices. The strong features of PIC are it can be programmed for storing and running data through it.
Every PIC has some major and common units like:
- Processor
- Memory (RAM, ROM, EPROM)
- Input/ Output ports
- Serial and Parallel ports
- Timer
- counter
- A-D converter or D-A converter
- Flash memory (program memory)
- SRAM memory (Data memory)
- various crystal oscillators
Architecture
While learning a new microcontroller it is a good practice to learn its architecture first to understand the technicalities in a better way. PIC microcontroller supports RISC architecture, So let's look at some characteristics of RISC architecture:
- Only 35 commands in an instruction set
- Most of the instructions are single-cycle (2 clock cycles, or 4 clock cycles in 8-bit models)
- you can calculate the execution time of the command on the basis of its clock frequency.
The above diagram shows the basic architecture of PIC. let's have a basic understanding of subunits/ blocks
CPU
The CPU is subdivided into Accumulator, ALU, control unit. It supports normally RISC architecture.
What is RISC Architecture?
RISC, or Reduced Instruction Set Computer. is a type of microprocessor architecture that utilizes a small, highly-optimized set of instructions, rather than a more specialized set of instructions often found in other types of architectures.
Memory
Like any other microcontroller PIC also has a certain amount of RAM, ROM, EEPROM, SRAM, flash memory. Where ROM is used for storing data permanently, EEPROM and EPROM are the same as ROM only the difference is its memory can be erased optically or electrically when we want on necessary condition. RAM is the complex memory in PIC, as it is associated with various types of registers and bank modules. As its name suggests RAM (Random Access Memory) is used to store temporary data, which means when the power is gone data will be erased. Flash memory is a special type of memory used to Read, Write, store the data or a command multiple times, A PIC has a certain amount of Flash memory.
ADC & DAC
As the name says ADC converts analog voltage to digital voltage values. In PIC the ADC has a 10-bit resolution and 8 channels, Suppose you have to convert the analog voltage from 0 to 5v then you can convert it into 210 = 1024 different DC levels. The operating voltage of ADC is generally 5v. The converter stores the lower 8 bits in the ADRESL register and the upper bits in the ADRESH register. The operation of ADC is controlled by special function registers ADCON0 and ADCON1.
Input/Output Ports
For a reference, let's take an example of the PIC16 family, which mainly has 5 ports, Port A, B, C, D, E. The working of all the ports is almost the same like they all can be used as GPIO.
Port A: It is a 16-bit port, which can be used as an input or output port based on the status of the TRISA register.
Port B: It is an 8-bit port, which can be used as both an input and output port. 4 of its bits can be used as an interrupt when needed
Port C: It is an 8-bit port whose operation (input or output) is determined by the status of the TRISC register.
Port D: It is an 8-bit port, Apart from being an I/O port it can also act as a slave port for connection to the microcontroller bus.
Port E: It is a 3-bit port that serves the additional function of the control signals to the A/D converter.
Oscillators
In a mid-scale MCU family, the device is used for generating a clock frequency signal called oscillators, which is required for executing the instruction and peripherals of the function, PIC microcontroller consists of two types of oscillators, one is crystal and the other is RC oscillators. In RC oscillators the value of frequency depends upon the value of resistor and capacitor selected in the circuit. while in Crystal oscillator the crystal is connected between two oscillator pins and the value of the capacitor connected to each pin determines the mode of operation of the oscillator.
Timer & Counter
PIC microcontroller has a built-in Timer module that can be used for many applications like generating precise delay, Pulse counting, Pulse measurement. It 3 timers, out of which 2 are 8-bit times and 3rd is a 16-bit timer, it can also be used as a counter.
CCP module
CCP MODULE: CCP stands for Capture, Compare, and PWM. These are inbuilt modules in the pic microcontroller. It's a special module in the pic microcontroller designed for modulation and waveform generation applications. it's also wont to generate specific time delay. This module OF pic microcontroller contains a 16-bit register which might operate as:
16-bit Capture register
16-bit Compare register
10-bit PWM Master/Slave Duty Cycle register
CAPTURE MODE:
If a register constantly changes its value, this mode provides access to this state of that register. during this case, it's the timer TMR1 register.
COMPARE MODE:
This mode continually compares the values of two registers. One amongst that register is that the timer TMR1 register. When a predetermined amount of your time expires, this circuit also allows the user to trigger an external event.
PWM (PULSE WIDTH MODULATION)
This mode can generate signals of varying frequency and duty cycle one or more output pins.
Advantages
- They are reliable and therefore the malfunctioning of PIC percentage is incredibly less. and therefore the performance of the PIC is extremely fast thanks to using RISC architecture.
- Power conception is additionally very less in comparison to other microcontrollers.
- After we see within the programmer's point of view interfacing is incredibly easy, also we can connect analog devices directly with no extra circuitry and use them. Programming is additionally very easy when to put next to other microcontrollers.
Disadvantages
- The length of the program is big due to using RISC (35 instructions).
- Program memory isn't accessible and only 1 single accumulator is present.
Application
The PIC microcontrollers have wide applications within the education likewise as industrial sectors. Almost in any industrial unit, a particular process is distributed, the microcontroller is employed. the benefits of using this microcontroller include low power consumption, high performance, supports hardware and software tools like simulators, compilers, and debuggers. Following are some general applications of PIC microcontrollers:
- Automatic light intensity controller of street light
- Object counter: displaying and monitoring (for the industry purpose)
- Automatic Hand sanitizer
- Color object sorting machine
- RFID card and password-based Door lock system
- Smart irrigation system
- The smart ration card system
- Finger-print based locker system
- Face detection based Attendance system
These are some examples of an automatic system that you can easily achieve by PIC microcontroller.
Final Words
These are the overall summary of the microcontroller which included introduction architecture, its peripherals, and some applications. It is a versatile tool for making small scale embedded systems. Hope you will get basic information about PIC. If you have any doubt regarding something feel free to ask in the comment section.