PIC micro Projects

These Projects use the 8 bit PIC microcontroller. Mostly 16F and 18F series, though 10 and 12 series possible. For most 18pin or larger projects the 18F family is recommended.

Which PIC and Language?

The 10F, 12F, 16F and 18F are the PIC microcontroller families from Microchip. Microchip also call the dspPIC, PIC24, PIC32 and PIC33 "PIC", but these are quite different CPUs.

There are C compilers for the 10F, 12F, 16F and 18F, but the tiny stack with lack of Program access, Harvard Architecture and apart from the 18F series, the back switching make C quite unsuitable so many people program them in Assembler. The 18F has much expanded instruction set, addressing modes and Hardware Multiply. Also available is BASIC and Forth. But the best language for the 10F, 12F, 16F and 18F families is JAL V2 by Kyle. There is an earlier JAL by Wouter. It's not been updated or maintained for some years, JAL V2 (usually just called JAL) has replaced Wouter's JAL. JAL stands for "Just Another Language". It has the ease of getting started of BASIC with some similarities to syntax of Modern Basic and C. But also many ideas and features from Pascal and Modula-2 to make the embedded programming easier and reading & editing programs easier. JAL was especially designed for the 16F, but takes advantage of 18F features too. Another advantage of JAL is a large selection of library material in Open Source JAL (unlike some C compilers for PIC) with functions and drivers for many devices commonly used with Microcontroller. There is even USB, IDE, SD card, Graphics LCD and TCP/IP libraries as well as the SPI and I2C. Also there are HW and SW implementations of SPI and I2C and UART so that there is more flexibility or multiple ports on devices with only one, or the I2C or UART pins needed for a different function.  So Jal is the best solution.

Many projects on the Internet and in books use the PIC16F84. This is completely obsolete. Even the 16F627, 16F628, 16F876 and 16F877 are pretty obsoleted. It's not hard to use existing published assembler on the newer PIC 16F and 18F.   

The 18F family has 18 pins to 100 pins and up to 1M byte Flash for program. The 10F, 12F are 6 pin to 40 pin devices. The 16F is mostly 18 pins to 64 pins.

Unlike ARM SoC, many PIC are available in DIL (through hole) and SMT (Surface Mount technology).

But I really want to use C

Then don't use these 10F, 12F, 16F or 18F PICs. Use dspPIC, PIC24, PIC33, PIC32 or ideally an ARM with enough Flash and RAM for Linux. It's pretty easy to "port" C code to JAL and since JAL is very readable, it's easy to port JAL applications and libraries to larger more C capable CPUs. 

Microchip  PIC Selection Guide   10F, 12F, 16F and 18F series

Baseline Architecture Mid-Range Architecture Enhanced Mid-Range Architecture PIC18 Architecture
Pin Count 6-40 8-64 8-64 18-100
Interrupts No Single interrupt capability Single interrupt capability with hardware context save Multiple interrupt capability with hardware context save
Performance 5 MIPS 5 MIPS 8 MIPS Up to 16 MIPS
Instructions 33, 12-bit 35, 14-bit 49, 14-bit 83, 16-bit
Program Memory Up to 3 KB Up to 14 KB Up to 28 KB Up to 128 KB
Data Memory Up to 138 Bytes Up to 368 Bytes Up to 1,5 KB Up to 4 KB
Hardware Stack 2 level 8 level 16 level 32 level
Features
  • Comparator
  • 8-bit ADC
  • Data Memory
  • Internal Oscillator

In addition to Baseline:

  • SPI/I²C™
  • UART
  • PWMs
  • LCD
  • 10-bit ADC
  • Op Amp

In addition to
Mid-Range:

  • Multiple Communication Peripherals
  • Linear Programming Space
  • PWMs with Independent Time Base

In addition to
Enhanced Mid-Range:

  • 8x8 Hardware Multiplier
  • CAN
  • CTMU
  • USB
  • Ethernet
  • 12-bit ADC
Highlights Lowest cost in the smallest form factor Optimal cost to performance ratio Cost effective with more performance and memory High performance, optimized for C programming, advanced peripherals
Total Number of Devices 16 58 29 193
Families PIC10, PIC12, PIC16 PIC12, PIC16 PIC12FXXX, PIC16F1XX PIC18

For Initial Learning and Hobby use the 18F series is recommended. The 16F84, 16827, 16F628, 16F877 and 16F876 are obsolete more expensive parts

Replacements

Cheaper, faster, More RAM and More Flash. 18F parts preferable to 10F, 12F, 16F. except in high volume

Obsolete 16F 18F
16F84 16F648A 18F1220
16F627 16F648A 18F1220
16F628 16F648A 18F1220
16F745 ---- 18F2550
16F876 16F886 18F2550
16F877 16F887 18F4550

The 16F648A can use up to 20MHz crystal or up to 4MHz internal precision clock to give 2 more I/O pins, so up to 5 x faster than 16F84.

PIC16F648A

 Program Memory Type  Flash
 Program Memory (KB)  7
 CPU Speed (MIPS)  5
 RAM Bytes  256
 Data EEPROM (bytes)  256
 Digital Communication Peripherals  1-A/E/USART,
 Capture/Compare/PWM Peripherals  1 CCP
 Timers  2 x 8-bit, 1 x 16-bit
 Comparators  2
 Temperature Range (C)  -40 to 125
 Operating Voltage Range (V)  2 to 5.5
 Pin Count  18

16F series vs 18Fseries

However in most cases migrating or using from the start the 18F1220 is a better choice, it's lower power and up to twice as fast, minimum. All 18F have HW multiply (not on 16F). The Flash is 16bits on 18F rather than 14bit, so two bytes of data can be stored at each location rather than one on the 16F series. The 18F1320 is identical to 18F1220 except 8K bytes (4 K instructions) rather than 4k Bytes (2K instructions).

Unless Volume Cost or binary compatibility, only use the Enhanced Mid-Range Architecture 12F and 16F series (8 pin to 64 pins)

The advantage of the 18F1220, 18F2550 and 18F4550 is that they can run at a wide range of Internal clock from a different external Crystal (16F84 4MHz or 16F877A 20MHz) up to 48MHz. USB is optional and they work as 3.3V or 5V systems. They also really only differ in pin count. The 18F2550 and 18F4550 are "drop in" replacement for 16F876 and 16F877 if USB is not used. Assembler is easily adapted and JAL can simply be recompiled. The 10F, 12F and 16F only needed if DIL pin count must be less  than 18 or volume cost is an  issue. For production the smaller surface mount versions are recommended.

Another advantage of the 18F vs 16F is simpler assembler (if you insist on Assembler) as there are extended addressing modes to avoid the horrid "bank switching" of the 16F

PIC18F1220 

 18F1220 Parameter  Value
 Program Memory Type  Flash
 Program Memory (KB)  4
 CPU Speed (MIPS)  10
 RAM Bytes  256
 Data EEPROM (bytes)  256
 Digital Communication Peripherals  1-A/E/USART,
 Capture/Compare/PWM Peripherals  1 ECCP
 Timers  1 x 8-bit, 3 x 16-bit
 ADC  7 ch, 10-bit
 Temperature Range (C)  -40 to 150
 Operating Voltage Range (V)  2 to 5.5
 Pin Count  18
 Max speed  40MHz

 The18F1220 has no USB option

PIC18F2550

 18F2550 Parameter  Value
 Program Memory Type  Flash
 Program Memory (KB)  32
 CPU Speed (MIPS)  12
 RAM Bytes  2,048
 Data EEPROM (bytes)  256
 Digital Communication Peripherals  1-A/E/USART, 1-MSSP(SPI/I2C)
 Capture/Compare/PWM Peripherals  2 CCP
 Timers  1 x 8-bit, 3 x 16-bit
 ADC  10 ch, 10-bit
 Comparators  2
 USB (ch, speed, compliance)  1, Full Speed, USB 2.0
 Temperature Range (C)  -40 to 85
 Operating Voltage Range (V)  2 to 5.5
 Pin Count  28

PIC18F4550

 18F4550 Parameter  Value
 Program Memory Type  Flash
 Program Memory (KB)  32
 CPU Speed (MIPS)  12
 RAM Bytes  2,048
 Data EEPROM (bytes)  256
 Digital Communication Peripherals  1-A/E/USART, 1-MSSP(SPI/I2C)
 Capture/Compare/PWM Peripherals  1 CCP, 1 ECCP
 Timers  1 x 8-bit, 3 x 16-bit
 ADC  13 ch, 10-bit
 Comparators  2
 USB (ch, speed, compliance)  1, Full Speed, USB 2.0
 Temperature Range (C)  -40 to 85
 Operating Voltage Range (V)  2 to 5.5
 Pin Count  40
 

Do download the datasheets!

Additional Features 18F2550, 18F2550

  • Full Speed USB 2.0 (12Mbit/s) interface
  • 1K byte Dual Port RAM + 1K byte GP RAM
  • Full Speed Transceiver
  • 16 Endpoints (IN/OUT)
  • Internal Pull Up resistors (D+/D-)
  • 48 MHz performance (12 MIPS)
  • Pin-to-pin compatible with PIC16C7X5

Parametrized Search tree and  Search Chart

Programming

For the beginner the practice used to be to make "no-parts" or "JDM" programmer for Serial Port or Parallel port on DOS or Windows 98. Or buy a more expensive 3rd party programmer. But now the best choice is for the Beginner or low volume user is a Pickit2 or Pickit2 clone (Microchip published the design) from €15 to €30 depending on source.

pickit2-clone
Pickit2 or 
Pickit2 Clone from €15

All the software is freely downloaded from Microchip for Linux or Windows. The JAL programming language are  at JAL Resources for Compiler and Library and also an  optional IDE. for Windows (Jal Edit). See also "JustAnotherLanguage" Blog/Support site

Prototyping

The Magenta Electronics Pic Ice was my first "Prototyping" PIC board, but I only once found the Debugging feature useful, That must have been 7 to 10 years ago (2001 to 2003?). It has a 2 line Text LCD, a small plug-in breadboard area, small solder breadboard space and PC serial port. Actually just regular veroboard (stripboard) or plain plug-in Breadboard will do. But you can also buy ready made "prototyping" PCBs especially for PIC cpu. See the gallery. Generally complete kits are a waste of money.  

Velleman

The Velleman products are well made, but many carried by companies like Maplin are Obsolete and overpriced. I tested and evaluated the following:

K8048 PIC evaluation and Programmer. Includes obsolete 16F627, very slow serial Port Programming and may be erratic on XP, Vista and  Windows7. Velleman now resell a PicKit2 programmer.

K8055 USB data acquisition

  • Obsolete slow preprogrammed16C745  (one time version of 16F745)
  • Only about 50 samples per second
  • Only 8 bit analogue resolution

The 18F2550 is in same size package, is cheaper chip and can do easily 10,000 Samples per second using JAL libraries. 10Bit ADC vs 8bit (other 18F are 12bit)

Updated Drivers and applications on Velleman Download site

PIC related Books

Waste of money unless you don't have an Internet connection. Bert van Dam and Wouter van Ooijen are probably best authors.

PIC related sites

C Resources for PIC micro

JAL Resources for Compiler and Library and here is optional IDE

JAL Blog/Support

JALV2 Compiler author (Kyle)

Bert van Dam excellent Book upgrade/Starter pack (doesn't need his books). The included libraries are a bit different from the "official" JAL.

Wouter van Ooijen's Start with PICs (written some while ago but still good advice) and his shop (click on flag). He invented the original JAL.

Vasile Surducan's Electronics pages. A top contributor to JAL. (Wouter's pages are out of date so Link to Vasile is broken!)

PIC Hardware is at Microchip

See Pickit2 programmer. About €25 on eBay.

Good support on the "Official PIC List" the web site of the PIC mailing list.

Also Good support on Yahoo Groups Piclist and Yahoo Groups JalList

Please report broken links using the form (Select Broken Link).