LED circuit using 16F628A microcontroller assistance

bertus

Joined Apr 5, 2008
22,278
Hello,

I have misread the transistor type.
If it was a TIP120 (a 5 A Darlington transistor) the 1K or greater would work.

Greetings,
Bertus
 

SgtWookie

Joined Jul 17, 2007
22,230
Ryan,
Are you planning on using this circuit in a motor vehicle?

If so, you need to be aware that the actual voltage in the system can vary considerably; from a low of around 11.4v when the battery is heavily discharged and the engine is off, to 14.5v or even higher when the engine is running, charging a heavily discharged battery.

If you're planning on such use, you should tell us so that we can make suggestions.
 

eblc1388

Joined Nov 28, 2008
1,542
With so many LEDs you'll need to use either a NPN darlington or a logic level MOSFET to do the LED switching because of the limited 15~20mA output drive current of the PIC. At best the TIP50 has a current gain of 20 only and no way you can saturate it with 20mA base current as SgtWookie have told you earlier.

A logic level MOSFET is preferred because its saturation voltage is lower than the darlington(about 0.1V vs 1~2V) so will be cooler and even let you place more LEDs in series in one branch than using a darlington.
 

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
SgtWookie said:
If you're planning on such use, you should tell us so that we can make suggestions.
Short answer is yes, plan to use these in motor vehicles. There are voltage regulators for that aren't there? Or (I'm opening the door for newb criticism here probably) isn't that typically what the function of a capacitor is? To smooth out voltages? Ugh, sorry for being so new...lol

eblc1388 said:
A logic level MOSFET is preferred because its saturation voltage is lower than the darlington(about 0.1V vs 1~2V) so will be cooler and even let you place more LEDs in series in one branch than using a darlington.
Can you suggest one? How do you decide which is best over the others? (I imagine there's probably text on LL MOSFETs somewhere).

Best,
 

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
SgtWookie said:
If so, you need to be aware that the actual voltage in the system can vary considerably; from a low of around 11.4v when the battery is heavily discharged and the engine is off, to 14.5v or even higher when the engine is running, charging a heavily discharged battery.
Will THIS work for that purpose?
 

bertus

Joined Apr 5, 2008
22,278
Hello,

The 78T12 will not work all the time.
There has to bee a voltage difference of 2.5 Volts between in and output to let the regulator work properly.
You might want to look at a buck-boost converter like the LM5118.
This can regulate 4 - 70 volts input to 12 volts output.
See page 23 of the datasheet (it is not as simple as the 78T12).

Greetings,
Bertus
 

Attachments

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
I'll be honest bertus, this confuses the heck out of me. Would integrating this into my circuit require all the additional components shown in the schematic on page 23? Seems like an awful lot of stuff for something like keeping a DC power source that varies +/- 4 volts regulated to a near constant 12V output.
 

eblc1388

Joined Nov 28, 2008
1,542
My suggestion is to try it without the regulator first. Design your circuit with around 13V battery voltage in mind. The series current limiting resistor will absorb some of the voltage fluctuation. There would be some slight brightness changes when in use. But as the LEDs are flashing, I doubt it would be noticeable.

You can actually look at the effect if you have a variable DC power supply.

If the LED brightness changes of the final result is bothering you, then consider adding a voltage regulator.

Logic level MOSFET is designed to be driven by microcontroller that has 0~5V(or even 0~3.3V) output drive capacity. Non logic level MOSFET would require some 10V gate voltage in order to saturate which microprocessor output pin cannot provide.

Any logic level MOSFET of a few amperes and over 100V would be good in your case. If you have located one but not entirely sure, you can ask for a confirmation of the part number here.
 

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
And why must it be over 100 Volts? Isn't that a lot for this application? I'm only asking these questions by the way to understand the reasons behind these decisions. Not to be a pain in everyone's rear.

Part I had in mind for that is HERE
 

SgtWookie

Joined Jul 17, 2007
22,230
And why must it be over 100 Volts? Isn't that a lot for this application? I'm only asking these questions by the way to understand the reasons behind these decisions. Not to be a pain in everyone's rear.
Well, you could likely get by with a lower Vdss rating, but automotive environments can be pretty brutal. The higher voltage rating won't hurt you, as long as the total gate charge doesn't skyrocket with a plummeting current capacity .

As far as what voltage to design it for; my opinion is that eblc1388's 13v suggestion is a bit low. I suggest that you design it for 14v, and leave at least 2.5v "headroom" for the current limiting resistors. The more headroom you have, the less effect changes in voltage will have on the current flowing through the LEDs.

Let's just look at the blue LEDs for the moment.
14v - 2.5v = 11.5v (this will be the voltage we'll use to determine how many LEDs you can use in series)
11.5v / 3.5v = 3.2857... (3.5v = the Vf of your blue LEDs @ 30mA)
The integer value of the result is 3, which is the most that you can have in series with a supply of 11.5v.
Now to calculate the current limiting resistors:
Rlimit >= (Vsupply - VfLEDtotal) / DesiredCurrent
Rlimit >= (14v - (3 * 3.5v)) / 30mA = (14 - 10.5) / 0.03A = 3.5 / 0.03 = 116.666... Ohms
The closest standard value is 120 Ohms.
Calculating the resistor wattage requirement:
RWatts >= (Vsupply - VfLEDtotal) * DesiredCurrent * 2 (we double the wattage for reliability)
RWatts >= (14 - (3 * 3.5v)) * 0.03 * 2 = (14 - 10.5) * .06 = 3.5 * .06 = 0.21 Watts. You can use 1/4 Watt resistors for the three blue LEDs in series.

Part I had in mind for that is HERE
That's a good choice; they should work fine.
To limit the maximum current from the I/O pins when charging/discharging the MOSFET's gate, use a 200 Ohm resistor between the I/O pin and the gate.

To ensure that the MOSFET remains turned OFF if the uC is removed or a fault occurs, also use a 4.7k to 10k resistor from the MOSFET's gate to ground.
 
Last edited:

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
Ok, assuming I design for 14V input, do I need to put a resistor immediately following the voltage input to bring it down to "12" volts? Or will 14V be ok (up to 15V possibly since its an automotive application) so long as I plan the current limiting resistors for the LED arrays for 14 volts instead of 12? I know that the 7805 output is 5 volts, so everything after the 7805 is ok. According to the datasheet for the 7805 I have, input can be up to 35V @ 3A.

Sound right?
 

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
Hello,

The 78T12 will not work all the time.
There has to bee a voltage difference of 2.5 Volts between in and output to let the regulator work properly.
You might want to look at a buck-boost converter like the LM5118.
This can regulate 4 - 70 volts input to 12 volts output.
See page 23 of the datasheet (it is not as simple as the 78T12).

Greetings,
Bertus
I have one other quesiton about this, what is the purpose of 0Ω resistors? There appears to be several of them on the schematic on page 23 of this document.
 

thatoneguy

Joined Feb 19, 2009
6,359
"Zero Ω resistors" are used as jumpers and placeholders. Autoplacing robotic equipment can add them easier than being reconfigured for a piece of wire. Sometimes they are used to route around empty parts of a circuit board that doesn't have all options installed.

Visually, they look just like a resistor, but have one black band in the middle.

There are other strange things as well. Have a look at the LG 7x Zero Element Vacuum Tubes, or "Nullodes", they have no electrodes.
http://www.nrhf.no/wehrm-ror/wehrm-spesial.html
 

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
NPN transistors have Base, Emitter, and Collector.

MOSFET has Gate, Drain, and Source.

How do they compare as far as my connections? With the NPNs I had Emitters to ground, Collectors connected to the Cathode of the leds, and Base connected to my V+. In other words, I recently got familiar with the leads on the NPN transistors, but MOSFETs at this point are new to me...lol.
 

eblc1388

Joined Nov 28, 2008
1,542
I recently got familiar with the leads on the NPN transistors, but MOSFETs at this point are new to me...lol.
They also have three pins. The control is done via the Gate pin as you have already guessed. You need to follow the good practice mention in last sentence of post#31 by SgtWookie regarding gate connection to the MCU.

Confusion arises from pin Source and Drain. The Drain is not connected to ground like the emitter of a NPN.

Instead, connect the Source to ground or 0V and the Drain to LEDs.
 
Top