# Developmentboard for PIC 16F628

Discussion in 'The Projects Forum' started by nerdegutta, Feb 27, 2011.

1. ### nerdegutta Thread Starter Moderator

Dec 15, 2009
2,629
851
I'm currently working on a developmentboard for the 16F628 PIC. I've made the schematic, placed components on the board, and etch the PCB. And as far as I know, its working. Schematic is here.

Criteria:

• Should have ISCP, so I don't have to move the chip back and forth.
• LEDs on all the PIC pins, to indicate activity
• Row of pins to be able to get input
• Row of pins to extend with cable to hook up on breadboard
• Provide breadboard with 9-12v dc
I supply the board with either a 9v battery or 12v. So I have a LM7812 regulator on the Power in. A LM78L05 is also connected to power in, to provide the PIC with 5v. The collector of the transistors are connected to 12v, and the bases are directly connected to the PIC pins.

But:

I'm learning a bit about transistors and resistors. And when I think of it, we used transistors and resistors here:

So my question is:

Should I have resistors connected to the transistors base like in the 25 Open end LED chaser?

And how would I calculate the resistance?

2. ### SgtWookie Expert

Jul 17, 2007
22,194
1,761
You're using NPN transistors as voltage followers (common collector current amplifiers).

As Bill mentions in one of the threads, the current on the base is multiplied by the beta (hFE) of the transistor, so the base current is relatively small. However, you wind up with a Vbe drop of ~0.63v to ~0.8v depending on how much current is going through the BE junction, as the transistor isn't saturated. So, if your uC's Vcc/Vdd is 5v, about the most you'd see at the emitter is around 5v-0.63v = 4.37v down to 5v-0.8v 4.2v, depending on your collector current. So, you'd have to calculate your LED limiting resistors as:
(Vdd - (Vbe+Vf_LED)) / Desired_LED_Current
meaning, if your Vdd = 5v, Vbe=0.7v, Vf_LED = 3v and Desired_LED_Current = 10mA, then:
(5v - (0.7v + 3v)) / 0.01 = 1.3/0.01 = 130 Ohms.

But, you also need to keep in mind the power dissipation in the transistor. You're supplying the collector with 12v, but about the highest you'll go on the emitter with that load is Vdd-0.7v, or 4.3v - so, 12v-4.3v = 7.7v, multiply that by 10mA and you get 77mW. In this case you're OK. If you were trying to get 100mA current from the emitter, that would be ~770mW, which exceeds the 625mW package limit for the plastic TO-92 cases.

If the Vbe loss doesn't bother you, then voltage followers like that one work fine, and you can save a resistor (the emitter resistor serves to limit both base current and load current).

However, if you want low power dissipation in the transistor, you'll need to use a common emitter configuration and a base current limiting resistor. PICs have an absolute maximum rating of +/-20mA current source/sink from the I/O pins, and when calculating base limiting resistors for using transistors as saturated switches, you want to use Ic/10 (desired collector current / 10)

Besides the individual pin I/O current limit (which is almost always the +/-20mA), you also have a package source/sink limit, which varies - you need to ensure that you don't exceed either the individual or the package limit.

Using 1k for a base current limit resistor is fairly safe; not too likely you'll stress the uC, and with Vdd = 5v, you'll get (Vdd-0.7v)/1k = 4.3mA base current, which is good for up to ~43mA collector current. With that same Vcc, you could actually go as low as ~220 Ohms (Vbe of 0.8v) to give you up to 200mA collector current, as long as you don't exceed package limits - but your uC will be sourcing its' maximum current. 470 Ohms to 1k Ohms gives a better margin for error.

3. ### nerdegutta Thread Starter Moderator

Dec 15, 2009
2,629
851
Thank you.

This was just the kind of answer I was looking for.

When you put it in those words, it's understandable. That's nice.

Thanks again.

4. ### jpanhalt AAC Fanatic!

Jan 18, 2008
5,699
912
Hi Jens,

Microchip recommends a capacitor and diode on MCLR. I have always included the capacitor to protect from momentary glitches causing a reset. The diode is because the pin is raised to about 13V (?) during programming and is to protect the 5V supply. I have not used the diode, but maybe I have just been lucky. See Figure 1, p.21 of the ICSP manual (Sorry, I don't have the actual link handy; search for "ICSP Guide").

You probably also want to add a decoupling capacitor across the chip.

John

5. ### nerdegutta Thread Starter Moderator

Dec 15, 2009
2,629
851
Thanks John.

I've never used either a diode or a capacitor. I will include it in my work from now on. I've never experienced un-planned resets to my chips, due to the lack of those components. But I see, and understand, the point of having them.

Jul 7, 2009
1,585
141
The output pins for the 16F690 can sink or source 25 mA max. There's also a maximum current source/sink limit of 200 mA from ports A, B, and C together and the whole package is limited to a maximum of 800 mW total power dissipation.

I had a friend from NYC fly across the country for a week's visit and we spent many happy hours together learning to program the 16F690 chip this week. Thus, I have some temporary erudition.

7. ### SgtWookie Expert

Jul 17, 2007
22,194
1,761
Yep, various uC's are going to have varied I/O source/sink limits. I usually like to err on the cautious side of things; I haven't found a PIC uC yet that has less than 20mA source/sink capability for a port I/O pin, but I suppose they do exist. Many support +/-25mA. I neglected to mention the ports limit though, which is also quite important. They vary considerably, so there is not really a decent "rule of thumb" for port limits.