Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Newbie: Super simple project for PIC ICD w/PICKit 2

Status
Not open for further replies.

Pavius

New Member
Hello!

I'm a seasoned embedded programmer looking into getting his hands dirty in board design with a slight chance of getting horribly electrocuted.

Since i have much experience with PICs (in the software aspect) I decided to use them as a starting point (though i must admit their cuteness was also a factor in my decision). Anyways, i've read TONS of tutorials and have cross referenced many schematics. Unfortunately the majority of "getting started" guides ignore the in circuit debugging facilities completely - i understand that this adds complexity and might frighten a newbie, but i can't see myself working without a source level debugger, even as a first step.

Also, since i am going to develop code and build boards, there is a 100% chance i will fry MCUs or incorrectly wire up a peripheral. To help me isolate issues, i want a pre-built test bed to test discrete MCUs in the form of a board i will order from microchip that allows plugging in MCUs and running code on them (for example, i will use this to check that the PICkit2 + MPLab + compiler environment work well as a first step). The expensive route is to get a PICDEM2 + ICD2 (250$ - this was what i worked on when i developed for PIC) but since i don't want to dip into the crack fund, i am opting for a cheap(er) PICkit 2 + 18 pin demo board + PIC16F819 which should cost about 65$ total. Reading some forums showed that there no difference between the ICD2 and PICKit2 debugging facilities for PIC16F/18F. This is good.

Anyways, a few threads back Nigel Goodwin posted a schematic for ICSP connectivity. Reading the PICKit2 user guide i see there is no mention of extra wiring between ICSP and ICD. Therefore i assume that with the same schematic i will be able to download and debug code via PICkit2 and MPLAB.

As my first project i want to build a simple LED light flasher thingie with a regulated power supply.

Therefore, my to-buy list is:
[for testing code]
- PICkit 2
- 18 pin demo board
- PIC16F819

[for my board]
- Breadboard
- Jumper wires (Which guage is recommended?)
- PIC16F819
- Some LEDs and resistors for current limiting
- All components in Nigel's schematic
-- I see most people buy a crystal and two capacitors instead of a ceramic resonator which has this in one easy to swallow package. Why is this?
-- What do i need to know about the capacitors/resistors in terms of voltage specification, wattage, etc. I'm sure there are a million types of 10k resistors. If someone could give exact model numbers that i can reference - that would be best
- An ICSP header to connect the PICKit 2 to the breadboard. Any suggestions?
- Are my points in bold correct?

Thanks!
 
Therefore i assume that with the same schematic i will be able to download and debug code via PICkit2 and MPLAB.
The pinout of the PICkit 2 is as follows:
1. VPP - Goes to MCLR pin of target PIC
2. 5V/3.3V - Can power your target board if it doesn't draw too much current
3. Ground - Connect to target ground
4. PGD - To PGD pin of PIC
5. PGC - To PGC pin of PIC
6. NC (Not Connected)

What I do is build an **broken link removed** for the PICkit 2 to adapt to 2x5 IDC. Then I build a simple 10-conductor ribbon cable with 2x5 IDC female on both ends. At the breadboard end I build an adapter by soldering a 2x5 piece of pin header to a 2x5 shrouded male IDC connector. The cable can be ripped from an old floppy cable or old (40-conductor - not 80!) IDE hard drive cable. If you don't have one a computer store will sell you one for about $3.

The breadboard end looks like this (all photos are clickable):

**broken link removed** **broken link removed**

**broken link removed** **broken link removed**

**broken link removed**

I would drop the 18-pin demo board and just use the breadboard. You can order the PICkit 2 without it. The breadboard is much more flexible and useable for a wide range of projects (the board only does one thing). Like this:

**broken link removed**

- Jumper wires (Which guage is recommended?)
I use mostly 22AWG

-- What do i need to know about the capacitors/resistors in terms of voltage specification, wattage, etc. I'm sure there are a million types of 10k resistors. If someone could give exact model numbers that i can reference - that would be best
Here's a list I posted a long time ago. 1/4 watt carbon film resistors are fine:
futz said:
Pin 1 - VPP - To the MCLR pin on the chip. Don't forget to put a 33K or so pullup resistor on MCLR too (not critical - anything from 10K to 33K is ok).
Pin 2 - 5V - To VDD on your target circuit.
Pin 3 - Ground - To Ground on your target circuit
Pin 4 - PGD - To the PGD pin on the PIC
Pin 5 - PGC - To the PGC pin on the PIC

Get a 12F683, 16F88, 18F1320, 18F2550, 18F4550 or 4620. That gives you a bit of a range of different chips in different sizes with different peripherals. Other people will suggest some others probably. Whatever. Once you learn one, the rest are very similar. The PIC product line is very standardized. They mostly just have more or fewer onboard peripheral modules.

Get a 4MHz and a 20MHz crystal and a few 22pF ceramic disc capacitors.

Get a dozen or so 0.1uF ceramic caps and the same number of 100uF electrolytics (and maybe a few 10uF).

Some 33K (dozen), 10K (dozen), 4.7K (dozen), 1.2K (dozen), 1K (25), 330 (50) and 180 (25) ohm resistors is good to start with. If you buy these in 200-quantity or better you'll get a big price break.

Get some 5mm LEDs - red, green, yellow, blue, whatever you want.

A couple 10K trimpots and some switches with leads suitable for plugging into a breadboard.

Some pin header. Some IDC connectors and an old 40-conductor IDE cable or a floppy cable to rip up and make programming cables out of.

Some 2-row header pins and some IDC male headers to make breadboard ICSP adapters out of.

A solderless breadboard or two (or more) and **broken link removed** (or make your own).

A roll of 30ga wire-wrap wire is useful for projects, but get a roll of something more like 22ga for breadboard wires (30ga is too thin).

A decent soldering iron and some small-guage rosin-core solder and a can of rosin paste flux too.

That's a good start. What have I forgotten? Probably a few things...
 
Last edited:
Ahh!! Fantastically detailed post, futz. I am in your debt.

In regards to dropping the 18 pin board - i have yet to create a single board so i don't trust myself. I want something sturdy and 100% reliable for the first few weeks of experimentation. After that i will probably drop it as you suggest.

Do you know of any limitations, in your experience, of the PICKit2 vs. the ICD2? Source level debugging, watchpoints, breakpoints, whatever? Why are ICD2s selling if the PICKit2 does the same thing?

Thanks again!
 
Do you know of any limitations, in your experience, of the PICKit2 vs. the ICD2? Source level debugging, watchpoints, breakpoints, whatever? Why are ICD2s selling if the PICKit2 does the same thing?
I have a genuine PICkit 2 and a Junebug (PICkit 2 clone) as well as a couple ICD2 clones. I think the original ICD2 was serial. If that's what they're selling, serial ICD2 is SLOW for both programming and debugging. The slow programming you can live with, but slow debugging is painful. The PICkit 2 is very fast.

I have a Blueroom Electronics Inchworm+ (ICD2 clone) with the Unicorn addon board that adds USB connectivity. It's just as fast as the PICkit 2.

Which would I buy now that I know what I know now? (Huh?) PICkit 2 or a good clone, like the . The ICD2 is pretty much obsolete.

Both the PICkit 2 and ICD2 are being replaced by the PICkit 3 and the ICD3 (is that right?). They're much more expensive at present though. You don't need either for now, unless your budget can do it.
 
Last edited:
Of the few PIC boards that I have, I must say that the 18pin one is used the least. Don't get me wrong, the 16f88 and the like are great. For the most part, its the lack of pins for "development" of software routines which might include an LCD (think debug). So instead of having a 4 bit LCD (with 6-7 pin requirement) a serial LCD backpack was required with its sluggish response time. Lots of switching Port,Pins in code to accommodate lack of I/O. Of course if you have a 28-40 pin board, then that problem goes away.

Its really too bad that Microchip doesn't make a cost effective 40 pin dip board. If it weren't for the Olimex PIC-40 then the Olimex PIC-28 would be next up for me. On the Microchip side, the LPC board is great for the small devices. My 0.02 cents.

In the picture of a Olimex PIC-40 board a Samtec board standoff header was used to clear the PicKit 2 from the db9 and power plug receptacle.
 
Look no further...

Hi.
Consider the easyPIC5 development board from Mikroelectronica:
EasyPIC5 Development Board | mikroElektronika

It's all there on one board, for $130, not including S&H. Has so many features I'd risk Carpal Tunnel Syndrome listing them all. They have a raft of plug-in adapter boards, for cheap, that let you experiment with just about every peripheral of interest to the hobbyist, student and technician. I have their EasyPIC 3 and 4 and can highly recommend them.

Later!
kenjj
 
Both the PICkit 2 and ICD2 are being replaced by the PICkit 3 and the ICD3
Yes, i know. However, working with the ICD2/MPLAB back in the day left me extremely unimpressed. I'd rather wash my face with acid than have to suffer through the agony of working with premature debugging products.

Of the few PIC boards that I have, I must say that the 18pin one is used the least.
No doubt i will jump to the 18Fs in a few weeks, once i get the quirks of working with a breadboard, soldering, etc. Just need something to jumpstart.

Consider the easyPIC5 development board from Mikroelectronica
I saw it from reading the forum FAQ. It seems extremely impressive for someone who wants to fiddle around with peripherals - perhaps i will get one down the line for reference/testing code. I have tons of code i wrote a few years ago that operates near all the PIC peripherals... right now the focus is on getting a stable power supply without being flung across the room :D
 
right now the focus is on getting a stable power supply without being flung across the room :D
**broken link removed** Just plug a 9-12VDC wall wart into it and your breadboard is powered.

You'll see them in use all over my web-site.

Other companies have similar products too. Sparkfun, for instance.
 
Last edited:
After talking to the local microchip distributor, he pointed my attention to the fact that the 6 pin connector on the 18 pin demo board is for PICKit Serial Analyzer. I could not find any schematics for the 18 pin board but i assume that i won't be able to connect a PICKit 2 to these pins and debug. Is this true?

I see that the 28 pin board has 2 6 pin connectors. Will one accomodate a PICKit as an ICD? Are there any schematics for these boards?
 
If you really want a demo board to play with I suggest Bill's Junebug. It is an ICD2 clone with a onboard 18F1320 target with switches, LEDs, pots for ADC, and an IR reciever. Like the original PICkit2 it can also be used as an ICSP programmer/debugger, serial IO tool, and 4 channel logic analyzer. It comes as a kit or assembled. I use Junebug's in my high school microcontroler programming class.

Back in the days of the Z80 a demo board made a lot of sense because it took quite a few chips to make a system.

Modern microcontolers have put the entire board on a chip. To get a PIC chip with an internal osc up an running (hooked to the programer/debugger) you only need 5 wires and add a .1uf bypass cap.
The wires are
VDD power
VSS ground
MCLR reset and program voltage
PGCLK program clock
PGDATA program data​
To attach you only need the LED and a current limiting resistor.
To attach a switch you need the switch and a pullup resistor. Futz's wonder pictures show much of this.

It still makes sense to buy a board when the chip is not in a DIP package only happens over 40 pins.

Get a few solderless breadboards $3 Solderless bread boards at MPJA.
 
I can't find any schematics for the 18 pin demo board either (Probably too new), but for debug, it states that an ICD debug header (Product Search - microchipDIRECT) is required.

I see that the 28 pin board has 2 6 pin connectors. Will one accomodate a PICKit as an ICD? Are there any schematics for these boards?

Schematics for the 28 pin board can be found here:
https://www.electro-tech-online.com/custompdfs/2009/01/41301A.pdf

One 6 pin connector is for ICSP with PICkit2/ICD2 etc. and the other purely for PKSA. If the target supports debugging (supported 28 pin devices listed in section 1.3) there shouldn't be any problems, provided you remember to use the debugger option in MPLAB, then remember to reprogram with the programmer option afterwards. :eek:

HTH.
 
... right now the focus is on getting a stable power supply without being flung across the room :D

This is what I use for most of my boards that draw under .1 amp.

LM2931AZ50R
Desc.: Low Drop Voltage Regulators/Drivers 5.0V 0.1A Very Low drop out.

It is suprising what you can do with 100mA and this is a great regulator for doing so. Two caps and a 6-12V DC wall wart is all you need for a power supply. The schematic is in the data sheet.

They even have the sort of internal portection for use in a car. It is the only 5V regulator I know that will still provide usable output with a 5V input.

About 30 cents.

3v0
 
If you really want a demo board to play with I suggest Bill's Junebug

Thanks, 3v0. I am aware of the junebug but it does not suite my needs (since i have worked intensely with the PIC before at the software level). I will, however, probably get a Mikroelectronica EasyPIC5 somewhere down the line because it has TONS of peripherals that i haven't worked with in the past.

provided you remember to use the debugger option in MPLAB, then remember to reprogram with the programmer option afterwards. :eek:

Thanks for the schematics and tips. I changed my order to a 28 pin + PIC16F886-I/P. Once i have the kit in hand i will probably be able to make more sense of your tip here. Do you mean i will always have to switch between debug/program modes to use the PICKit? I don't recall this with the ICD2.

LM2931AZ50R

I understand that this linear regulator is more efficient than the LM7805 - why don't all the tutorials use it then?
 
Thanks, 3v0. I am aware of the junebug but it does not suite my needs (since i have worked intensely with the PIC before at the software level). I will, however, probably get a Mikroelectronica EasyPIC5 somewhere down the line because it has TONS of peripherals that i haven't worked with in the past.

Good enough. It has some interesting stuff.​


... Do you mean i will always have to switch between debug/program modes to use the PICKit? I don't recall this with the ICD2.

The PICkit works the same as the ICD2 in that regard. You select debugger or programmer from the MPLAB menu. The debug mode can program so there is no reason to switch back and forth.​


I understand that this linear regulator is more efficient than the LM7805 - why don't all the tutorials use it then?
Some people do not know about them. Others uses what they are used to using.

Also it is only 100ma. You are not going to be running a lot of LEDs or most any motors But it works fine for many applications.

I first ran into it on Luhan Monat's Mondo Superprobe. It has 17 functions in one easy to build probe. The frequency counter is the one I use most.
 
Last edited:
Do you mean i will always have to switch between debug/program modes to use the PICKit? I don't recall this with the ICD2.

3v0 said:
The PICkit works the same as the ICD2 in that regard. You select debugger or programmer from the MPLAB menu. The debug mode can program so there is no reason to switch back and forth.

You're both familiar with debugging so this is preaching to the choir, however for others following this thread, a little clarification is needed.

During a debugging operation, the device is programmed using the debugger menu in MPLAB IDE. This option loads the debug executive code into the device in addition to the application code, to allow debugging to take place.

Once the application is debugged the device needs to be reprogrammed, using the programmer option, to remove the debug executive code and return the device to stand-alone operation.
 
For anyone following this thread with interest, especially regarding the 18 pin demo board, Pavius has a similar discussion going on over at the Microchip Forum:
**broken link removed**

Within that thread, "PICkit2Dev" (Moderator) corrects mis-information provided by another member and more importantly, the Microchip Sales Rep.

As you would expect from a demo board designed to be used with PICkit2, the 6 pin connector on the 18 pin board is indeed an ICSP header, and not a PKSA header. However, without a physical demo board to inspect, or a schematic to refer to, any speculation would have been just that.

Anyway, the schematic is now available from within PICkit2Dev's post and can be found here:

**broken link removed**
 
Pavius do you live in the us if do I'll send you a board that you can use with a pickit2 just tell me what chip you plan to use.
 
For anyone following this thread with interest, especially regarding the 18 pin demo board, Pavius has a similar discussion going on over at the Microchip Forum:
Microchip Technology User Forums

Within that thread, "PICkit2Dev" (Moderator) corrects mis-information provided by another member and more importantly, the Microchip Sales Rep.

As you would expect from a demo board designed to be used with PICkit2, the 6 pin connector on the 18 pin board is indeed an ICSP header, and not a PKSA header. However, without a physical demo board to inspect, or a schematic to refer to, any speculation would have been just that.

Anyway, the schematic is now available from within PICkit2Dev's post and can be found here:

**broken link removed**

If Osc in pin decoupled to ground by 0.1uF how does the oscillator to work? Or, is it that either crystal or external RC oscillator ? Even the 44pin demo board has the same schematic around RA7.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top