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.

BoostC Charlieplexed PWM 32

Status
Not open for further replies.
Duty cycle is the amount of time in a period that an LED is lighted. In that 5 column display each column is updated one at a time and so each LED in that matrix can be lighted for 20% or 1/5th of the time.

Refresh rate is how often you light each LED in the display over time. It's usually expressed in Hertz (cycles per second). In that 5 column display each column is lighted for 3.2 msecs and so it will take 16 msecs to update the entire 5 column display. The refresh rate is therefor 1 / 0.016 seconds = 62.5 Hertz.

Hi Mike I totally understood thanks for the well explanation.

In the above example I totally understood the refresh rate.But I like to know what is the duty cycle driving an LED?If I need a duty cycle of 50% what do I have to adjust in the software?

If I adjust the 3.2 msecs time it will change only refresh rate isn't it?How do I adjust the Duty cycle?
 
The duty cycle is determined by your hardware design. If you're driving one column at a time in your 5 column 8 row matrix then you're not going to get more than a 20% duty cycle. A 50% duty cycle would require 20 LEDs on for half the time and the other 20 LEDs on for half the time.

Probably easier to increase 'peak' current to the display (or use high brightness low current LEDs?).

If 10 ma 'average' LED current provides good brightness then you would need 50 ma 'peak' current to get the same brightness when the LED is lighted 1/5th of the time.

You can increase 'peak' current by reducing the value of current limiting resistors on the rows or by using column and/or row driver transistors or driver ICs.

If you need help or recommendations from Forum members please post your schematic.

Regards, Mike
 
Last edited:
Oh I see that's what I wondering the Duty Cycle is adjusting by the hardware.So the software side I need to concern only about refresh rate.

My circuit is like Nigels tutorial. Rows driving directly via a resistor.& the columns driving via transistors.

If I adjust the peak current by adjusting the resistor will it still 20% duty cycle for 5 columns even if I increase that refresh rate delay 3.2 msecs?Wont this delay acting like on time of the duty cycle period?

That is the place I got stucked.

"A 50% duty cycle would require 20 LEDs on for half the time and the other 20 LEDs on for half the time." How do you get 20 LEDs. A bit doubt here how did you get 20?

Sorry for asking questions
 
Last edited:
You can understand what is my point.

In that 5 column display each column is lighted for 3.2 msecs that's the delay cause to vary the refresh rate.

My problem is won't this delay acts like a duty cycles on time of an LED?
 
Last edited:
You can understand what is my point.

In that 5 column display each column is lighted for 3.2 msecs that's the delay cause to vary the refresh rate.

My problem is won't this delay acts like a duty cycles on time of an LED?

You're thinking too hard - it's really simple, you have five rows of LED's, each is on for 1/5th of the time - so in order to keep the same brightness you need to drive the LED's with 5 times the current. So if you're wanting the brightness of a single LED at 20mA, each row of LED's needs to be driven by 100mA - each LED gets an average of 1/5th of that, which is the same 20mA.

Refresh rate just needs to be high enough so you can't see them flickering - you don't want it too high though, or you're wasting cycles that your main program could be using.

My 7 segment LED tutorial included an example where it refreshed far too low, so you could see how it worked, with each digital being displayed in turn, slow enough to see. I would suggest you try doing the same, decrease the refresh rate until you can clearly see each row displayed individually - then gradually increase the refresh rate, you will reach a point where you can no longer see individual rows, but the display flickers, keep increasing until the flickering disappears, this is the minimum refreash rate for YOU - other people will be different, so increase it a fair bit further, to allow for different eyes.
 
....... My circuit is like Nigels tutorial. Rows driving directly via a resistor.& the columns driving via transistors. ....
If you have 5 rows with current limiting resistors and 8 columns with driver transistors then you must be scanning columns and have a 1/8th or 12.5% duty cycle. This is a big misunderstanding.

So is this a multiplexed 5 digit 7 segment display or a 5x8 matrix of 40 LEDs?

Post a schematic?

Mike
 
Last edited:
You can understand what is my point.

In that 5 column display each column is lighted for 3.2 msecs that's the delay cause to vary the refresh rate.

My problem is won't this delay acts like a duty cycles on time of an LED?
Here's an exercise. How much time each second is an LED 'on' when each column is lighted for 3.2 msecs? ...for 2 msecs? ...for 1 msec?

(1) 1 second / 5 columns / 3.2 msecs per column = 62.5 Hertz
(1) 62.5 Hz * 3.2 msecs column time = 200 msecs column time per second

(2) 1 second / 5 columns / 2 msecs per column = 100 Hertz
(2) 100 Hz * 2 msecs column time = 200 msecs column time per second

(3) 1 second / 5 columns / 1 msec per column = 200 Hertz
(3) 200 Hz * 1 msec column time = 200 msecs column time per second

Column "on time" effects refresh rate. Refresh rate does not effect duty cycle...
 
Last edited:
Hi for both of you Mike & Nigel now I understood well.

Column "on time" effects refresh rate. Refresh rate does not effect duty cycle...

That is what I want to know thanks for that Mike.

Here's an exercise. How much time each second is an LED 'on' when each column is lighted for 3.2 msecs? ...for 2 msecs? ...for 1 msec?

(1) 1 second / 5 columns / 3.2 msecs per column = 62.5 Hertz
(1) 62.5 Hz * 3.2 msecs column time = 200 msecs column time per second

(2) 1 second / 5 columns / 2 msecs per column = 100 Hertz
(2) 100 Hz * 2 msecs column time = 200 msecs column time per second

(3) 1 second / 5 columns / 1 msec per column = 200 Hertz
(3) 200 Hz * 1 msec column time = 200 msecs column time per second

Who knows?

Duty cycle time is adjusting by the hardware.There is no way to find the LED on time through software.Sorry about that.:( If you know a way to calculate the LED on time for each second let me know:)
 
But I can see one thing from your examples

The column time per second is same on all three examples.That is 200 msecs even if I change the update interval.
 
Found this tread and think this project is really cool.<strike> But i cant seem to compile any of the code. I have tried SourceBoost IDE 6.87 as the compiler.
Is there another compiler i can use or is it a setting thing.
</strike>

Thank You,
 
Last edited:
Found this tread and think this project is really cool.<strike> But i cant seem to compile any of the code. I have tried SourceBoost IDE 6.87 as the compiler.
Is there another compiler i can use or is it a setting thing.
</strike>

Thank You,
Are you getting an error message? Are you using MPLAB as the IDE or the SourceBoost IDE?

Mike
 
Are you getting an error message? Are you using MPLAB as the IDE or the SourceBoost IDE?

Mike

I had the wrong Clock/mHz setting for the chip that was failing to compile.

Also in futz code that has "void reset(void);" was failing, But i changed the name for all the reset(); functions to resetled();/void resetled(void); and works now. It was saying that reset had a body at the line where the rest function was setting all the led's to 0 duty cycle.
it seems that void reset(void ) is "Declared in boostc.h" as "(inline function)“Soft ”resets the CPU.Please note that “soft ”reset may differ
from hardware reset in the way how SFRs get initialised."
and as I read more about system.h its also includes boostc.h so
#include <boostc.h>
is not needed. witch was also in futz's code.

I still need to build this and find a programmer for the chip, est......

But its really cool how u use mostly all the pin and what i see that is different then another one like this is yours has duty cycle
Heres the other 1 like this Look for LED Chaser
 
Sorry you experienced problems. I wonder if you're using the code on something other than a 12F683?

That program on Futz' site includes portions of my program and seems to be missing a lot of the important comments. I'm not sure what that void reset(void) is. It's not in my program.

Anyway, I've attached the last version of my program below which has 64 PWM levels. Please let me know if you have problems.

Mike
 

Attachments

  • 12F683_LED_PWM.c
    7.6 KB · Views: 317
Last edited:
Also in futz code that has "void reset(void);" was failing, But i changed the name for all the reset(); functions to resetled();/void resetled(void); and works now. It was saying that reset had a body at the line where the rest function was setting all the led's to 0 duty cycle.
it seems that void reset(void ) is "Declared in boostc.h" as "(inline function)“Soft ”resets the CPU.Please note that “soft ”reset may differ
from hardware reset in the way how SFRs get initialised."
and as I read more about system.h its also includes boostc.h so
#include <boostc.h>
is not needed. witch was also in futz's code.
That's actually pretty much Mike's code, not mine. The line at the top (void reset(void); ) is just an unused function prototype that I accidently left in there when I changed something. Delete the line. It's not doing anything except generate confusion.

I'll edit the page right now and fix that. EDIT: Done. Removed a couple other unnecessary lines as well.
 
Last edited:
Hi,

Just joined this group so pardon not being upto date on latest things here.

I've been working with Mike over at instructables where there's been quite a lively thread on charliplexing.

https://www.instructables.com/id/Charlieplexing-LEDs--The-theory/

Anyway, the cylon eye code with trailing Leds is attached, it's Mikes older 16 level code I think. Just replace do_random with do_cylon (or any other patterns in the pattern.c file. Sorry it's not well commented.

Phil
 

Attachments

  • HPCharlie.zip
    4.2 KB · Views: 214
fantastic, seriously. almost the perfect solution for a project i just started. 8 pairs of red/yellow smt leds embedded in a tiny resin block which is poured and dried into a mold as a flame. you should already guess that i intend to make the flames flicker. the red and yellow leds are laid anti-parallel so only one will be on at a given time. with a high enough refresh rate i should be able to more accurately simulate a flame with the mixture of dual colors.

where my project will differ a little is ramping up/down the leds in a quasi-random order.

but first i must receive the tiny13s i ordered and learn how to 'avr' =0
 
Yes, i know i am very NEW to this! but i have been using google alot lately for these kind of things, but have one question of how to get C code (never used this type before) to assembly to hex? (think thats right) i have a programmer and everything i have been making other little projects!
THX,
Nick
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top