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.

Using PWM on a 18F13K22

Status
Not open for further replies.
so i was thinking sticking it in one array, but have 64 bits
There aren't too many compilers I know of that would support a 64-bit data type on a PIC18, C or otherwise.
 
I looked at about 10 different LED CANDLE circuits and they all basically have several things in common.
They use two LEDs = red and yellow some have more than 2 but two seems a common number of leds. Besides with two I have less current drain.
most use either a mosfet or transistor to power the LEDs so the schematics are basically all the same except pin connections which can be changed to suit the PIC selected so in my case ports C2 - C5
Was using RGB leds but the blue was not that important and Red / Yellow obtains the desired colors. Over the last few days I have watched candles on tv and here at home and blue does appear but for simplicity the RED / YELLOW bi color will do the deed. Should get the LEDs on Monday as per usps tracking.
Ghostman posted the wire 2 wire link in post #156
I realize drawing a schematic before having the code and desired components is not the proper coarse of action for some people but all or most all the candle schematics are the same. Connect LED to port pin with resistor and either Vcc or grd. Very basic. I found drawing a schematic to be helpful in selecting components (data sheet specs) and visually following the code flow using the schematic. This method has solved many a problem.
Vcc > resistor > port pin goes low = LED lights up. Of coarse a breadboard is utilized first for each section of the circuit. That section works then on to the next section. If the breadboard fails to work then one can look over the schematic and maybe find the error. All the while adding to your schematic the working sections of the circuit. This method also helps eliminate errors when it comes time to design a PCboard. If you utilize a visual drawing of ones circuit as you progress, the errors of a wrong connection are minimized. I recall EEweb pointed this out once or twice. Correct schematic as you go, not later as you can miss something in the jumble of lines on a schematic.
As for data bits, The most I have seen is 16 bits in one array. see the Tetris project at DDIY. Graham uses 16 bits in his project but 64 sounds kinda way out there
 
What is a bi-polar led?
Yes I know it was a mistype lol



image.jpg

 
Last edited:
I don't recall anyone saying bi-color was incorrect.

If this data sheet is for the LEDs you ordered, they will be very dim. The rating on the flickering LEDs is 8000 – 12000 mcd. The data sheet above is for 120/200 mcd, quite a difference.


But speaking of incorrect, you should maybe check

"Connect LED to port pin with resistor and either Vcc or grd. Very basic."

against the data sheet for the 18F13K22. You have an extremely wrong assumption in this statement.
 
Sigh. If this is from the part you ordered, Kingbright Part Number: WP59EYC apparently, this is not going to work (without additional parts).

These LEDs have a common cathode. That means you supply V+ to the red element through a suitable resistor and to the yellow element through a suitable resistor. The common cathode is commented to ground. This means the PIC is sourcing current.

If you're planning to have one of these LEDs per candle, and you're planning on a maximum of 20 mA per LED element, that's a total of 6 LED elements at 20 mA = 120 mA worst case maximum that the PIC must source.

As stated in my post #147, the 18F13K22 can only source 70 mA total. Yes, an individual pin may supply 25 mA, but the total must be less than 70 mA.

image.jpg
 
The LED data sheet I posted was not the LED I ordered, I only used that data sheet to indicate that bipolar and bicolor are both correct. Sorry for the misunderstanding as I don't think I stated that this is the part I am going to use.
Here are the two different sized LEDs I ordered

https://www.mouser.com/ds/2/216/WP59EYW-45838.pdf

https://www.mouser.com/ds/2/423/VAOB-10GACE2-C-8173.pdf
Both common Anode.
The flickering led your referring to is not a diffused lens. That is why the mcd is so high but reading through most of the candle projects, a diffused lens is preferred.
not sure what your refeering to? wrong statement??
But speaking of incorrect, you should maybe check

"Connect LED to port pin with resistor and either Vcc or grd. Very basic."

against the data sheet for the 18F13K22. You have an extremely wrong assumption in this statement.
 
Lets try this for schematic readability. Set at 800 x 600 pixels with 675dpi. Not sure its any better but it looks ok on this end but then all the other schematics did to. Maybe I have the size to large?
candle schematic.jpg
 
I don't seem to have the ability to explain things in a way you can understand. I apologize for my inability to do so. Let me try one last time.

Referring to the picture below which shows my last two posts, in the underlined part A, you say it doesn't matter whether you connect an LED between V+ and a port pin, which means the PIC is sourcing current, or you connect an LED between a port pin and ground, which means the PIC is sinking current. This is based on the fact that a PIC18F-series port pin can source or sink 25 mA.

But this does not take into account the maximum current the 18F13K-whatever can source or sink. As I again explain at B, this particular chip can SINK 200 mA, but only SOURCE 70 mA. Any port pin can handle 25 mA, but the TOTAL LOAD can't exceed these limits (200 mA sink, 70 mA source). So the point to take away is that it makes a very big difference how you connect a bunch of LEDs to a PIC.

The above is general information based on what you have stated you want to do here many times – each LED on a separate port pin, no transistor drivers, 20 mA current each. If you do it this way, it's important to understand the different capabilities between sourcing current and sinking current.

In the schematic you have shown, this doesn't matter because you have transistor drivers. But in as much as the plan chances with every post, you should be aware of this consideration.

The schematic you have posted is not legible. Please put on your glasses or take off your glasses and notice the pin labels are an indecipherable blur.

And finally, the first LED you have ordered is common cathode. It is exactly the part I indicted in my post above.

image.jpg
 
Last edited:
The transistors were added due to the fact it was mentioned somewhere in this thread and the project Welcome to wire2wire LED candle has similar setup. Using the transistors will enable me to connect more LEDs to the main board.
As for the schematic, I will try a higher resolution or try changing the fonts from vector to true type seeing how the pin descriptions are hard to decipher. In addition using the transistors avoids any or almost any possibility of abusing the pic and allowing the magic within to escape.
On using separate LEDs, I considered this option as it would perhaps produce more light. Am going to apply hot melt glue to the LEDs anyway. I have lots of red leds so I plan to breadboard using one bi-colored led vers several red and several yellow leds for comparison.
In my design explanation, "Connect LED to port pin with resistor and either Vcc or grd. Very basic."perhaps I simplified it to much. I usually get my code working in sections then draw out schematic and making corrections as needed. taking into account the limitations of the pic as per data sheet. Another reason why I decided to go with the transistors then I should have no worries about exceeding the limitations of the pic.
 
Lets try this schematic. I changed from vector to true type and chnged the resolution to 1024 x 768 with 1000-dpi
candle schematic2.jpg
 
The problem with the images is this candle-schematic2-jpg.82935 see that JPG that means it was saved as a picture like any picture when you change the scale it distorts.
You need to use PNG witch don't distort and are scaleable. That's why there are such a thing LOL
 
Will give that a try Burt. I am frustrated that the schematic post, following the suggestions still don't produce a readable schematic.
Will try using png. THANKS in advance.
 
Went back to the file I posted and it is a pNG.
Diptrace, using the PRINT / PREVIEW option as suggested, only has jpeg or bit map. Will try the bit map then using I.
The schematic Jon posted a link to and he mentioned it was done using DIPTRACE but posted on a different website. I wonder idf that might have something to do with it. I would be interested to see Jon post a schematic done with DIPTRACE on Electro tech. I have posted schematics on other sites using Diptrace with no problems.
 
Here is same file but saved as a bit map in Diptrace PRINT PRIVIEW then increased resolution 1024 x 768 with 860dpi and saved as png it is a bigger file for sure
 

Attachments

  • candle 3.bmp
    1,018 KB · Views: 244
test.png
Zip up your Diptrace file and post it
test.png
Dang you can read it LOL
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top