This guide will show you what a PIC microcontroller is and what you can do
A microcontroller is a self contained fully functional computer with built
The idea of a microcontroller is that it can stand alone and does not require any other circuitry to do a useful task. Normal processors such as those found in desktop PCs require a multitude of circuitry before you can get anywhere near a useful system.
Another important point about a microcontroller is that it is not intended to be a super-duper all singing all dancing mega MIP device it is intended for doing fairly simple tasks that do not require huge amounts of processing power.
Note : You can now get DSP microcontrollers which do allow very complex operation at high speed - but these require advanced knowledge of signal processing mathematics.
Having said that a microcontroller is actually extremely efficient for doing
fairly simple tasks for the simple reason that it has built in peripherals.
These include such as timers, ADCs, analogue comparators, pulse width modulators, USARTs...and more.
Ths is one I find amazing the 12f675 is has only 8 pins (the same as a 555).
It has :
*One analogue comparator.
*10 bit 4 input ADC.
*Six usable I/O pins (you need one for power and and one for Ground)
*1024 program memory words (program space).
*64 Bytes Ram
*128 bytes EEPROM
*External clock capable to 20MHz
Phew - just compare that to a 555 = 1 comparator!
A 12F675 tutorial is available on the site.
However I would not recomment that you use it, as a beginner, since although it is a powerful device it only has 8 pins (two of which are power and ground). So pins are multiplexed for programming and for use. This makes it more difficult to use since you have to program the device then set it up for use.
If you use a larger pinned device such as a 16F628 (18pins), 16F88 (18 pins) or a 16F877 (40 pins) or even 18F2550 (28 pins) or 18F4550 (40pins) then you are going to find it a lot easier to allocate pins to different functions - and you can leave the programmng port connected to only the ICSP programmer while experimenting with the other pins of the device..
Low pin count devices are really for a finalized "minimized" project - e.g. if you are building a small footpring PCB then the smaller devices will save money. Go for larger ones for experimentation (they also have more RAM and Flash program memory (EEPROM) making it easier to create programs..
The other point is that most internal peripherals work in more-or-less the same way even between different families i.e. 12F, 16F, 18F - of course there are enhancements but the basic functionality is the same e.g.. for timers and comparators etc.
Actually the 'simple tasks' are only simple in comparison to the computing
power of a PC. In reality the microcontroller is ideal for tasks that require
low level hardware control.
These ready-to-use peripherals save you from having to wire up extra circuitry all you have to do is program the internal peripheral to configure the microcontroller for your application.
Examples of what you can make using a microcontroller are:
*Ultrasonic range finder.
*Universal Infrared controller.
*X10 home automation controller.
*Home security alarm.
*Dot matrix led controller.
*Seven segment Digital clock.
...and many more...
... In fact the list is endless because
you can make up virtually any electronic
project you can think of and...
...a microcontroller makes it easy.
The website and this guide focus on only a few microcontrollers in the PIC range since all PIC devices share common internal peripherals (so learning about a peripheral means you have learned the peripheral for all PIC devices):
12F675 - 8 pin.
16F88 - 18 pin.
16F877 - 40 pin.
Note: Sometimes there are small differences - so check the data sheet - but in general the peripherals are identical across the same range of devices.
All microcontrollers have a Central Processing Unit (or CPU) and this is
responsible for taking the data, processing it and spitting out a result.
For the PIC microcontroller mid range devices (16F) the processing block is 8 bits wide so the microcontroller works only with data having 8 bits in it.
PIC Microcontrollers have three types of memory:
PIC devices use a Harvard
architecture which simply means that Data memory and Program memory are
The idea is that you can get a speed improvement by storing the program and the data in separate memory sections because you can retrieve data from both sections at the same time.
For a von-neumann architecture (where the same memory is used to store program and data) the processor has to fetch the program instruction and then fetch the data so it works more slowly.
For this reason you will see references to the PIC saying it has 12bit or 14bit architecture etc. - this refers only to the program memory - all you really need to know is the data memory size as this is the fundamental unit that the microcontroller operates on - it's usually 8 bit.
Program memory is based on Flash technology (this is the 12bit or 14bit
spec.). This is non volatile memory
which stores your program instructions.
Note: non-volatile means that it keeps its contents even when the power is turned off so it's ready to go as soon as power is applied.
This is also the memory that you program using an external programmer (using the PIC ICSP port) and programmed from a PC using the programming software e.g. ICPROG.
Data memory is simply memory based on
SRAM technology. This type of memory retains its values only while the power is on.
Unlike Flash memory you can easily change the values stored in data memory while the program is running.
So you can create counters to store the number of events detected or temporarily store the intermediate result of a computation. This is memory that stores changing data i.e. you store variables in Data Memory.
EEPROM memory is another data store - it's a cross between the program
memory and data memory. You can store any data in it and retrieve any data
from it - but it takes more effort to store and retrieve data.
This is because it is also non-volatile just like the flash memory but under program control you can change the stored values just like data memory but when the power goes off it keeps the stored values.
It is Electrically Erasable PROM : Non volatile Data Memory.
Note: Newer devices let you alter the program memory itself - which is why bootloading is possible.
For a normal program you would use EEPROM to store program settings that you
need to keep between power cycling of the device.
For example if you had designed a programmable power supply you would want the microcontroller to remember the last voltage so the unit powers up to the same voltage at the next session.
... Ports - Using microcontrollers to communicate with the 'real' world.
How to use the TCS230 (/TCS3200) Color detector chip and easily add it to any of your projects.
With the ADXL345 acellerometer you can detect up to 16g! You can also find out how to use it for tap detection and more.
HMC5883L - How make a digital compass, Find out the differences between the HMC5883L and the QMC5883L and whether they are compatible.
Easily use an ESP8266 with the Arduino IDE and program your first sketch into the ESP8266
The MCP4725 chip is a 12 bit DAC with memory that outputs voltage that you can use for many dfferent purposes. Find out what they are in this page.
PCF8591: A four input ADC with single DAC. How good is this 8 bit ADC, and should you use it in your next project?