Friday, 27 January 2012

FYP Week 1 - Introduction on microcontroller selection

Hi,
How are you doing? Hope everyone is fine… Today I am going to start on the introduction of the most important component in my Final Year Project (FYP), which is the microcontroller. I am using a PIC16F887A by Microchip.

So let’s learn more about PIC microcontrollers.

Introduction
A PIC microcontroller is a processor with built in memory and RAM, and you can use it to control your projects.  So it saves you building a circuit that has separate external RAM, ROM and peripheral chips. It is a very powerful device that has many useful built in modules. For example:
  •  EEPROM
  •  Timers
  • Analogue comparators
  • UART
The PIC is one of the most popular microcontrollers and in case you were wondering the difference between a microprocessor and a microcontroller is that a microcontroller has an internal bus with in built memory and peripherals. Click here for the PIC16F877A datasheet

Features
A PIC microcontroller is an amazingly powerful fully featured processor with internal RAM, EEROM FLASH memory and peripherals.  One of the smallest ones occupies the space of a 555 timer but has a 10bit ADC, 1k of memory, 2 timers, high current I/O ports a comparator, a watch dog timer and etc.

Programming
One of the most useful features of a PIC microcontroller is that you can re-program them as they use flash memory (if you choose a part with an F in the part number e.g. PIC12F675 not PIC12C509). You can also use the ICSP serial interface built into each PIC Microcontroller for programming and even do programming while it's still plugged into the circuit. That’s so cool right…hehe
You can either program a PIC microcontroller using assembler or a high level language. I recommend using a high level language such as C as it is much easier to use.

Input / Output (I/O)
A PIC Microcontroller can control outputs and react to inputs. For example, you could drive a relay at the output or read input buttons. Many now have a built in ADC so you can read analogue signal levels so you don't need to add an external device.

Peripherals
The best way to start is to learn about the main features of a chip and then begin to use each peripheral in a project.  I think learning by doing is the best way…..hehe <3

PIC microcontroller
Feature
PIC microcontroller
feature description
Flash memory
Re-programmable program storage.
Memory storage for variables.
Long term stable memory: Electrically Erasable Programmable Read Only Memory.
High current Input/Output ports (with pin direction change).
Typically 3.
Built in RS232 protocol (only needs level translator chip).
Capture/Compare/PWM module.
I2C and SPI Interfaces.
An analogue comparator and internal voltage reference.
Analogue to digital converter.
Parallel Slave Port (for 8 bit microprocessor systems).
LCD interface.
ICSP,WDT,BOR,POR,PWRT,OST,SLEEP
Simple programming using In Circuit Serial Programming.

Note: these are some of the main features (some chips have all of these and some don't).

Flash memory
This is the program storage area and gives you the most important benefit for using a PIC microcontroller. It allows you to program the device many times. It can be re-programmed up to 100,000 times (probably more) as they use Flash memory

ICSP
In Circuit Serial Programming (ICSP) is the next most important benefit. You can re-program the device while it's still in the circuit so once your programmer is setup you can leave it on the bench and test your programs without moving the chip around and it makes the whole process much easier. J

I/O Ports
Input / Output ports let you communicate with the outside world so you can control leds, LCDs or just about anything with the right interface.  You can also set them as inputs to gather information.

Pin direction
Most PIC microcontroller pins can be set as an input or an output. This allows you to use a pin for multiple operations. For example, the Real Time clock project uses RA0, the first pin of PORTA, to output data to a seven segment display and at a later point in the program read the analogue value as an input.

Current
The PIC I/O ports are high current ports capable of directly driving LEDs (up to 25ma output current) - the total current allowed usually ~200mA this is often for the whole chip.

Timer / Counters
Each PIC microcontroller has up to three timers that you can either use as a timer or a counter (Timer 1 & 2) or a baud clock (Timer 2).  

USART
The USART is a useful module and saves having to code up a software version so it saves valuable program memory. All you need to interface it to a PC serial port is a MAX232 chip (or equivalent).

Baud Rates
You have to be careful using the baud rates as they depend on the main clock in use and normal oscillator values in general do not fit very well with 'real' baud rates.  

CCP 
The Capture/Compare/PWM module has three modes of operation:
  • Capture - Capture the time of an event.
  • Compare - Generate an output when Timer 1 reaches a value.
  • PWM - Pulse Width Modulation.

Comparator and comparator voltage reference 
The comparator is module that has two analogue comparators which can be set up in one of 8 different ways. Either digital or analogue inputs can be compared to reference voltages.

In one mode an internally generated voltage reference is used as an input to both comparators and in the same mode multiplexing lets you monitor up to four different input pins.

ADC 
The single 10 bit Analogue to Digital Converter can have up to 8 inputs for a device multiplexed from input pins.
The ADC can be used during sleep but you have to use the RC clock mode. One benefit of this is that there will be no digital switching noise so you will get better conversion accuracy.

PSP
The Parallel Slave Port lets you to connect the PIC microcontroller directly into a microprocessor system. It provides an 8 bit read/write data bus and RD (read) WR (write) and CS (chip select) inputs - all active low.
This will let you add a PIC microcontroller to a system so that the PIC microcontroller can be treated as a memory mapped peripheral.  It will let the microcontroller behave just as though it was another microprocessor building block e.g. some memory or ram but in this case you have full control over exactly what the building block is i.e. you can re-program the PIC microcontroller to do just about anything..

Special Features
ICSP
In Circuit Serial Programming
Refer ICSP above
WDT
Watch dog timer
This is a software error protector. 
BOR
Brown Out reset
This detects if the power supply dips slightly and resets the device if so.
POR
Power on reset
This starts microcontroller initialization.
PWRT
PoWeR up Time
A time delay to let Vdd rise.
OST
Oscillator start up timer
Wait for 1024 cycles after PWRT.
SLEEP
PIC microcontroller sleep mode
Enter low power mode.

Differences between all three PIC microcontroller
All three devices are extremely powerful and the main difference is that they have different numbers of pins and memory size. 
PIC microcontroller Device
PIC microcontroller No. Pins
PIC microcontroller Flash memory WORDS
PIC12F675
8
1k
PIC16F88
18
4k
PIC16F877A
40
8k

(Note: that all of them have the letter F in - this means it is a Flash re-programmable part - don't go and buy a part with O in as its OTP - programmable only once!)

 So, that's it for now I guess... Next I will discuss on the PIC main board PCB designing and its etching procedures. Hope you enjoy this entry. Tata for now....!  :)




###################################################################

QUOTE of the day...!!!

Life is like riding a bicycle - in order to keep your balance, you must keep moving.  ~Albert Einstein

###################################################################




Regards,


Idriah Safriza :)
/* CUTE CURSOR */ Waving Onion Kun /* ticker */