WinPicProg PIC Tutorial


This is an ongoing series of beginners PIC tutorials, started in June 2002, they will describe the construction of simple modular hardware and give examples of code to make use of it. The boards are connected together by leads with Molex 10 pin connectors, and it's designed so that more than one extension board will be used as the tutorials develop. There's a great deal of free source code you can download from the Internet, a superb resource is the PicList - and I will probably be using many snippets of code from there.

PIC's are extremely versatile devices, they are basically an entire computer on a chip, the device used in this tutorial is particularly easy to use as it's a 'FLASH' based chip, which allows easy reprogramming, and it requires hardly any support components (not even a clock crystal). For a suitable programmer, please refer to my WinPicProg site. Although any programmer and software capable of programming a 16F628 will be suitable, obviously I'm using my own WinPicProg software, in conjunction with the P16PRO40 hardware.

Support for this tutorial series will be available on my PicProg BBS, I'll be adding an extra forum just for tutorial questions, by asking questions in the forum other users will be able to take advantage of any answers given, and provide answers themselves.


I've decided to base this tutorial on the PIC16F628 rather than the 16F84, there are a number of reasons for this!.

  1. The 16F628 is now often cheaper.
  2. It contains more program memory and registers.
  3. It has more hardware facilities.
  4. It has a built-in 4MHz oscillator, making it easier (and cheaper) to construct.
  5. It has more I/O pins, 16 as opposed to 13 for the 16F84, the extra 3 I/O pins take the place of the oscillator in and out connections, and the MCLR (reset) pin - to use these extra 3 pins you must set the oscillator to internal, and disable the MCLR pin. The examples given will include this in the configuration fuse settings.

The 16F628 has it's I/O pins split across two ports, PortA and PortB, these have quite different properties, and it's important to understand these differences or things don't always work as you expect!. Firstly PortB, this is pretty straightforward, although some of the pins can be used by various of the built-in hardware, as a normal port all pins can be inputs or outputs. PortA is a little less straightforward, all pins can be used as inputs, but RA5 can only be used as an input, and RA4 has an 'open-collector' output stage, this means it requires a 'pull up' resistor to function as a 'normal' output - it can 'sink' current, but can't 'source' it. RA4 in the 16F84 has the same properties - this is often a cause of problems.

I've now introduced a second alternative processor board, based on the larger PIC16F876, running at 20MHz, I'll be introducing specific tutorials using this board, and also giving details of the slight changes necessary for using the existing tutorials on the new board.

The first part of the Tutorial 1 will simply pulse all the output pins repeatedly, and will demonstrate how to setup the PIC before use. Most of the Tutorials will include a number of examples (1.1, 1.2 etc), starting with a very simple example and working towards slightly harder ones. Although 'Tutorial 1' specifies it needs the LED Board, the first couple of parts of the tutorial can be used without it, by selecting Jumper J1 to connect the on-board LED to pin RB7. To build the boards see the hardware page.

Tutorial Number Boards required. What do we learn?.
Hardware Hardware for the tutorials.  
Hardware Extras Extra little circuits that will be useful.  
Tutorial 0 Programmer board and software. How to actually program a chip.
Tutorial 1 Main Board, (LED Board). How to flash LED's. 
Tutorial 2 Main Board, Switch Board, (LED Board). How to read switches.
Tutorial 3 Main Board, LCD Board, (Switch Board). How to use an LCD text module.
Tutorial 4 Main Board, Joystick Board, LCD Board. How to read a PC Joystick.
Tutorial 5 2 x Main Board, 2 x IR Board, LCD Board, Switch Board. How to do IR communications.
Tutorial 6 Main Board, LCD Board, various I2C Boards. How to use I2C.
Tutorial 7 Main Board, LCD Board, RS232 Board. How to do RS232.
Tutorial 8 Main Board 2. How to do hardware PWM.
Tutorial 9 Main Board, Keypad Board, LCD Board, IR Board, RS232 Board. How to use a HEX keypad.
Tutorial 10 Main Board, 7 Segment LED Board. How to use dual 7 segment LED's.
Tutorial 11 Main Board 2 or 3, Analogue Board, LCD Board, RS232 Board. How to use analogue inputs.
Tutorial 12 Two Main Boards, One 876 Main Board, TX Board, RX Board,
LCD Board, RS232 Board, Switch Board, LED Board, Analogue Board.
How to use licence free
wireless modules.
Tutorial 13 876/877 Main Board, Multiplex LED Board. How to multiplex a matrix of LED's.
Tutorial 14 To be decided. To be decided.