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.

software PWM

Status
Not open for further replies.
Assuming all the LEDs will be the same brightness, I would setup an ISR to turn them on/off by just using the tris register (in = off, out = on). You can then (in your background program) turn individual LEDs on/off by just setting the port bit.

Mike.
 
I received the boards for the Christmas Star with 70 white and blue leds. Now to work on how to do multitasking.
The blue leds on the perimeter just twinkle but the inner leds (white) to fade in and out).
Will post a schematic after I locate schematic on other computer.
This is the same star I was working on last year using EASEYEDA.
 
Here is the schematic for the Christmas star.
The white LEDs I want to fade in and out while the blue LEDs twinkle.
for the twinkle just toggle the LEDS but the fade in and out??
 

Attachments

  • Schematic_copy4_2022-03-20.pdf
    166.2 KB · Views: 218
Hmmmm. Your "schematic" says the LED resistors are 100 ohms. Your various comments say they are 150 ohms. Or 330 ohms. Or maybe 680-715 ohms. But whatever value the resistors are, all the power calculations are off, because your 70 LEDs are actually 35 pairs in parallel, which isn't good form (and also wasn't mentioned, at least in this thread).

Does this schematic really match this particular board? Or is it kinda, sorta close? Maybe?
 
oups I forgot to update the schematic. I used a different computer to do project.
The resistor arrays are 330 ohm 1202 smd
Yes the board was assembled using the gerber from this schematic.
I only had the top layer assembled. Yes 2 LED's in parallel and one 330 ohm resistor. If I have the calculations? correct it should only be 8-10ma per port pin.
Data sheet says a max of 25ma per pin/185ma max per chip (18f43K22)
hopefully it will work. I had to order some additional resistor arrays as I only had 805 smd arrays on hand.
Should be receiving this week so I can assemble and test. Hopefully no magic smoke.
 
...But whatever value the resistors are, all the power calculations are off, because your 70 LEDs are actually 35 pairs in parallel, which isn't good form (and also wasn't mentioned, at least in this thread)....
... Yes 2 LED's in parallel and one 330 ohm resistor. If I have the calculations? correct it should only be 8-10ma per port pin.
They're not.

For the blue LEDs, Vf ~ 3 volts. If the supply voltage is 5v and R = 330 ohms, the current through the resistor[ will be about 6mA. This current will be shared between the parallel LEDs, meaning each LED will pass about 3mA.

For the white LEDs, with Vf ~ 3.7v, the current through the resistor will be about 4mA, resulting in an LED current of about 2mA.

18 port pins drive blue LEDs, for a total current of 108mA. 16 port pins drive white LEDs, for a total current of 64mA. Total output current to drive all of the LEDs will be about 172mA.

You're pretty close to the maximums for normal temperature ranges.

18f45k22 current.jpg


[Edited to show screen shot]

By your (incorrect) calculations of 8-10mA per port pin x 34 port pins, the current would be 340mA. So much for the magic smoke.

You've lucked out by not understanding how current flow works out for parallel LEDs. The current of 2 - 3 mA through each LED should be plenty bright, and saves you from blowing a hole in the micro.

Are the LEDs you used diffussed? If not, they will be blindingly bright and leave spots in your eyes.
 
Last edited:
Paralleled LEDs are very unlikely to share the current evenly.

Mike.
Very true, which is why I said it was bad form above. I didn't want to get bogged down in the minutia that would likely be ignored anyway. The key point is that with parallel LEDs, the lowest Vf of any member of the group and the series resistance determine what current will flow. No matter if there are two LEDs or a hundred in parallel, the resistor determines the current that will flow, and that current is spread across some or all of the LEDs. More LEDs in parallel don't change the total current available.

It's fortunate that MrDEB put two LEDs of the same color in each group - if the group had a blue and a white LED in parallel, the white LED would illuminate dimly, if at all. Why would this happen?
 
I doubt very much if any matching of LEDs has been done. And, why three?

Mike.
You don't need to match the LED's, just use identical ones - from the same batch would be nice, but the same exact part is fine. A minimum of three is the number recommended by the manufacturers in order to sufficiently average out the current between them - it's widely done commercially with no ill effects.

I suspect with LED's out of the same batch/packet that two may well be 'OK', but a minimum of three is what's recommended.
 
I realize LEDs should be in series. My schematic has 2 LEDs in parallel which is really not the best method. but would not work without an additional output driver. Thus I have 2 LEDs in parallel.
As for brightness, I plan to toggle the blue LEDs very fast so it shouldn't matter too much.
I want to attempt to multitask the software PWM (white LEDs) with toggling the blue LEDs.
I recall the old digital diy site had a tutorial on multitasking but?





i realize
 
I edited my above post to show a screen shot of maximum allowed currents on the 18F4522. The text copy in the code tags didn't work quite as I had planned.

MrDEB, you are extremely resistant to catching the take-away points:
  • How you should have calculated the LED current (current from each port pin, and the current through each LED)
  • That your (incorrect) calculations showed you exceeded maximum current draw for the 18F but didn't give that a second thought
  • That the current through EACH LED will be LESS than you thought, but that should be about right depending on the LEDs used.
....A minimum of three is the number recommended by the manufacturers in order to sufficiently average out the current between them....
Nigel, do you have any reference that states this? The only references I can find by Osram and Maxim don't recommend parallel LEDs using a single resistor, and emphasize using LEDs binned by Vf.
 
I edited my above post to show a screen shot of maximum allowed currents on the 18F4522. The text copy in the code tags didn't work quite as I had planned.

MrDEB, you are extremely resistant to catching the take-away points:
  • How you should have calculated the LED current (current from each port pin, and the current through each LED)
  • That your (incorrect) calculations showed you exceeded maximum current draw for the 18F but didn't give that a second thought
  • That the current through EACH LED will be LESS than you thought, but that should be about right depending on the LEDs used.

Nigel, do you have any reference that states this? The only references I can find by Osram and Maxim don't recommend parallel LEDs using a single resistor, and emphasize using LEDs binned by Vf.
I read it a number of years back, I can't remember who's datasheet it was in?.
 
Who are you asking?

Mike.
Those who might benefit from giving the question some thought.

A totally ridiculous idea I know.
 
I read it a number of years back, I can't remember who's datasheet it was in?.
A pity, as I'd love to see the rational behind this. I don't see how it would work.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top