Experimenting with PIC Microcontrollers

One of the most popular and easy to use microcontroller families available in the market today is the Microchip “PIC microcontroller”. The following experimental tutorials are intended to facilitate the learning of PIC microcontroller interfacing and programming. Each topic is started with the background theory followed by simple experiments to explain how the theory can be implemented into actual applications. I am emphasizing the use of high level language (C) for PIC programming. The C compiler used in writing the programs is mikroC Pro for PIC from MikroElektronika. You can download and install the demo version of this compiler that limits the size of the output HEX file to 2K. PIC16F688 and PIC16F628A microcontrollers are chosen for the most basic experiments whereas the advanced topics are discussed with PIC18F2550. I hope some of you will find these tutorials helpful for coming up to speed on PIC microcontrollers. If you have any suggestions or comments, you can email me at [admin (at) embedded-lab.com].

spacer


spacer

Pre-Lab Preparation

Hardware and Software requirements
Choosing a PIC Programmer
Regulated power supply for your breadboard
Getting ready for the first lab
Breadboard module for PIC16F688
Breadboard module for PIC16F628A

spacer

Lab 1: Flashing an LED

Start with the “Hello World” project to make sure that every set up you have made is correct and working well. You will use a PIC16F688 microcontroller to flash an LED on and off.

Required Theory : I/O ports in PIC16F688

spacer

Lab 2: Basic digital input and output

Learn how to read digital inputs from a push button switch. Every time the push button is pressed, the LED will be toggled on and off. You will also learn about the bouncing characteristic of a switch, and how to take care of that.

Required Theory : I/O ports in PIC16F688

spacer

Lab 3: Four bit binary counter

Four LEDs are connected to a PIC16F688 microcontroller to make a 4-bit binary counter. The counter counts the pressing of a push button. It starts from 0 and is incremented on every press. When it reaches 15, it overflows and the next output will be o again.

Required Theory : I/O ports in PIC16F688

spacer

Lab 4: Interfacing a character LCD

HD44780 based LCD displays are very popular among hobbyists because they are cheap and they can display characters. Besides they are very easy to interface with microcontrollers and most of the present day high-level compilers have in-built library routines for them. Learn how to include one in your microcontroller project.

Required Theory : Provided in the article

spacer

Lab 5: Analog-to-digital conversion (ADC)

Analog-to-digital conversion (ADC) is necessary because, while embedded systems deal with digital values, their surroundings typically involve many analog signals such as, temperature, speed, pressure, etc. Learn how to interface analog signals with a PIC microcontroller.

Required Theory : ADC channels in PIC16F688

spacer

Lab 6: Interfacing a seven segment display

Seven segment LEDs are mostly used to display decimal numbers. They are popular because they are visually attractive and easy to interface. This lab session discusses about the functioning of seven segment display modules and driving a single module with a PIC microcontroller to display numbers.

Required Theory : Provided in the article

spacer

Lab 7: Timers and Counters (Part 1)

Hardware timer modules are used in microcontroller based systems for accurate event timing and counting. This experimental tutorial describes the Timer0 module in PIC microcontrollers and it’s functionality. Two programs are written to demonstrate the timer and counter functions separately.

Required Theory : Provided in the article

spacer

Lab 8: Asynchronous serial communication

The PIC16F628A microcontroller has a built in USART hardware that allows to communicate with a wide range of serial devices such as memory chips, LCDs, personal computers, etc. This tutorial describes how to establish a full duplex asynchronous serial link between a PIC and a PC.

Required Theory : Provided in the article

spacer

Lab 9: Pulse Width Modulation (PWM) using CCP module

The Capture/Compare/PWM module in a PIC16F628A microcontroller is very versatile in function. This experiment describes the use of CCP module to generate a PWM signal to control the brightness of LED. The same principle can be extended to control the power delivered to an electronic load using the principle of PWM.

Required Theory : Provided in the article

spacer

Lab 10: DC motor control

DC motors provide mechanical power to microcontrollers. This experimental tutorial provides information on interfacing DC motors to PICMicro. You will learn about the classic H-bridge circuit that can control a motor in clockwise and counterclockwise direction.

Required Theory : Provided in the article

spacer

Lab 11: Multiplexing seven segment LED displays

Multiplexing is the most common technique for interfacing multiple seven segment LED displays to microcontrollers. Read this experimental tutorial to find out how this technique works.

Required Theory : Provided in the article

spacer

Lab 12: Basics of LED dot matrix display

LED dot matrices are very popular means of displaying information as it allows both static and animated text and images. This tutorial describes the basic structure of a monochrome LED dot matrix and its interface with a microcontroller to display static characters and symbols.

Required Theory : Provided in the article

spacer

Lab 13: Read and Write to internal EEPROM

EEPROMs are a type of non-volatile memory which can be programmed and erased electrically while within the circuit. PIC16F628A microcontroller comes with some built-in internal EEPROM. This tutorial describes how to perform the basic read/write operation to it.

Required Theory : Provided in the article

spacer

Lab 14: Inter-Integrated Circuit (I2C) communication

I2C is a very popular synchronous serial communication protocol that requires only two pins for data transfer. This tutorial describes the basics of I2C protocol and how to connect multiple I2C devices on a common bus.

Required Theory : Provided in the article

spacer

Lab 15: Scrolling text message on LED dot matrix display

This is the continuation of Lab 12 and you will learn how to display a scrolling text message on an LED dot matrix. The matrix used is of size 8×16 (128 LEDs in total).

Required Theory : Provided in the article

spacer

Lab 16: Understanding interrupts

Interrupts are powerful concept in embedded systems for controlling events in a time-critical environment. This tutorial first describes the interrupt system in general and then illustrates how it is handled in PIC micrcontrollers.

Required Theory : Provided in the article

spacer

Lab 17: Sleep and Wake PIC microcontrollers

PIC microcontrollers’ Sleep feature is an extremely useful mechanism to minimize power consumption in battery-powered applications. Read this tutorial to learn how to put a PICMicro into sleep and wake it up with an WDT time-out.

Required Theory : Provided in the article

spacer

Lab 18: Matrix keypad interfacing

Matrix keypads are very common input devices in embedded systems. They have simple architecture and are easy to interface. This tutorial describes two different approaches of reading input data from a 4×4 (16 keys) matrix keypad interfaced to a PIC microcontroller. The pressed key information is displayed on a character LCD. The microcontroller used in this experiment is PIC16F1827.

Required Theory : Provided in the article

spacer

Lab 19: Play musical notes

A PIC microcontroller can be programmed to play musical notes of a song tune by bit-banging one of its I/O pins high and low to generate square waves corresponding to the note frequencies. This experiment describes how to do it. The microcontroller used in this experiment is PIC16F1827, which plays the notes of the popular “Happy birthday to you” tune.

Required Theory : Provided in the article

spacer

Lab 20: Interfacing a Graphical LCD (GLCD)

The use of a graphical LCD (GLCD) drastically changes the look of your project. It provides more freedom for presenting data than the HD44870 based character LCDs. This tutorial will help you to get one in your next project.

Required Theory : Provided in the article

spacer

Lab 21: Servo motor control

A servo motor is a special geared DC motor equipped with an electronic circuit for controlling the direction of rotation, as well as the position, of the motor shaft. In this lab session, we will first explore what a servo motor consists of and how it works and then illustrate how to interface it with a PIC microcontroller.

Required Theory : Provided in the article


gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.