Top Banner
Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th , 2011
18

Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

Dec 16, 2015

Download

Documents

Tony Osler
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

Getting Started with PIC Microcontrollers

Kelly Flowers – NN8EApril 18th, 2011

Page 2: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

My Background

• Licensed in 1979• Education – BSEE 1981• Licensed Professional Engineer (Ohio)• Former NOARS member (80’s and 90’s)• Worked for Allen-Bradley/Rockwell for 25yrs• Worked with computers and microprocessors

since 1979• Began working with PICs in late 90’s

Page 3: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

What am I going to cover tonight?

• PIC background, purpose, value proposition• PIC architecture (what’s it look like inside one)• How can you use one?• PIC system overview(dev s/w, programmer, target or

protoboard)• Programming language choices(Assy, Basic, C)• Simple examples / hands on• Recommended resources

Just want to whet your appetite tonight!

Page 4: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

The 411 on PICs

• Peripheral Interface Controllers came along in the 90’s from Microchip

• Small pin count microcontrollers intended to be ‘smart’ and ‘fast’ I/O front ends for more traditional microprocessors

• Not intended to have big number-crunching ability

• Hundreds of PIC’s and dsPIC’s

Page 5: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

Why are they so popular?• Cost!

– Per piece cost is low, typically under $5– Software development environment needed to program the

devices is FREE (MPLAB IDE)– Programmers are low cost

• Learning curve is fast(low # of instructions)• Proliferation of hardware, software, books• Backward compatibility• Higher level language compilers(Basic, C)• ‘Canned’ serial comms (RS232, SPI, I2C)• Flash memory based, quickly re-programmable• Minimal support parts needed

Page 6: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

The simplest of PIC’s

This even has analog input capability!!!

Page 7: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.
Page 8: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

General PIC project overview

INPUTS

DigitalAnalog

PICOUTPUTS

Digital

SERIAL DEVICES(displays, EEPROM, RTC, smart sensors)

Page 9: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

What do you need to get started?

• PC to load development software(MPLAB) on to• Programmer which connects between PC and your

PIC• Target or protoboard or your actual project board to

test your program!

Page 10: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

The simplest of PIC projects

Even the 12F675 supports ICSP!

Page 11: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

What is MPLAB IDE?• This is the program you download to your PC to

get started with writing your first program• Integrated Development Environment– Free integrated software tool set for developing and

troubleshooting programs for embedded applications using PIC’s

– Easily integrates with 3rd party software such as high level language compilers

– Really high quality, professional grade software• The bad news is Microchip upgrades it a lot and

every few generations changes the look and feel!

Page 12: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

Programming Language Choices

• Assembly language is the lowest level– No extra cost to use– Fastest– Manipulating things at the ‘bit level’– Not easy to do higher level tasks like serial comm

and math

Page 13: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

35 Assembly instructions (mid-range)

Page 14: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

Two Higher Level Choices• BASIC

– Micro Engineering Labs• C

– Multiple vendors (I use CCS)– Free ‘light’ versions– Popular with scientists and engineers

• High level languages are used to simplify more complicated tasks like math and serial communications

• Microchip made using these with MPLAB a breeze!• Typically execute more slowly than Assembly programs

doing the same thing, but this is not usually a problem• The full versions cost $100 to $300

Page 15: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

You’re gonna need a Programmer…

Page 16: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

Putting it all together• Picture your final project(I like to do the hardware

design first)• Download MPLAB or install it off supplied disc• Connect programmer with blank PIC installed• Launch MPLAB and set up for proper PIC and the

type of programmer you are using• Write your program(or use an example) and ‘build’

till you have no errors! (the hard part)• Try it out! Do this as many times as needed since

you can keep erasing and reprogramming in seconds!

I recommend the PICkit 2 + ARRL Book

Page 17: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

Project Thoughts….• Keyer• Test equipment– Freq counter– Signal gen (DC to Daylight with DDS board!!!)– SWR / power meter

• Repeater control• Automatic control of anything!• Hobby servo control• Any timing and/or counting applications• Holiday lights• Home automation

Page 18: Getting Started with PIC Microcontrollers Kelly Flowers – NN8E April 18 th, 2011.

Resources• Microchip website

– MPLAB, PICkit 2&3, ICD 2&3, datasheets, app notes• ARRL “PIC Programming for Beginners”• Hellebuyck “Beginner’s Guide to Embedded C Programming”• Square 1 website(www.sq-1.com)• Wilmshurst “Designing Embedded Systems with PIC Microcontrollers• Nuts and Volts magazine• www.sparkfun.com

– Programmers, proto boards, parts• www.best-microcontroller-projects.com

– Tutorials, projects• www.olimex.com

– Excellent cheap proto boards(available at sparkfun)• www.kangaus.com PIC-EL II proto board, docs• www.digikey.com, www.mouser.com, www.jameco.com, www.newark.com PICs and

parts• GOOGLE!!! EBAY!!!