Page 1 of 1
led pwm
Posted: Wed Aug 29, 2012 3:16 pm
by donald
Hello all,
We have made a flowchart to light the progressive led and operated.
We have done and the second flowchart for the illumination of two led
light and does not work, please help me if it can me to correct an flowchart.
Thank you in advance!
Re: led pwm
Posted: Wed Aug 29, 2012 3:47 pm
by medelec35
Hi donald,
Not had time to check on hardware, but one mistake is
You have got:
If LED_Count_1 > MAX_LED_COUNT_1
LED_Count = 0
Should it be LED_Count_1 = 0 instead?
Also have got in the inputs_1 branch at the bottom:
LED_Brightness= 0
Should it be LED_Brightness_1 = 0
Martin
Re: led pwm
Posted: Wed Aug 29, 2012 4:19 pm
by donald
Hi Martin,
Yes that's right, I would check again.
Re: led pwm
Posted: Wed Aug 29, 2012 5:29 pm
by donald
Hello all,
We repaired mistakes referred to, but does not come on gradually, shed light on chaotic,
the two keys are not operable, however led to port A0 give signs.
Re: led pwm
Posted: Wed Aug 29, 2012 11:16 pm
by medelec35
Hi donald,
Had more time to sort flowchart out.
There were several issues.
So have corrected them.
Also the interrupt frequency has to be higher or you will observe too much flickering.
Trouble is with 4MHz (you really want a higher frequency xtal than 4 (the higher the better) for a duty of 0 to 100% the frequency of pwm only works out at 38.64Hz
In order to get this frequency, timer0 interrupt is set at 3906.250Hz
I have also removed all the seconds delay as this would increase due to servicing of interrupt time.
Using interrupt timer0 for seconds as well.
Another difference is the two pwm channels now work independent, simultaneously to each other.
Whereas before one channel would have to finish then 10 seconds later the other channel was allowed to work.
Let me know if you want to go back to that way and I can change flowchart accordingly.
Can you Let me know how you get on with flowchart please.
Martin
Re: led pwm
Posted: Thu Aug 30, 2012 3:38 am
by donald
Hi Martin,
Thank you very, very much, it is now clear and I understand the logic,
other wise many good teachers, but you are exceptional.
Thanks once again!
Re: led pwm
Posted: Fri Aug 31, 2012 3:05 pm
by donald
Hello all,
I have a problem, a led does not light up always from 0 to 100 and shed light
on continuously from minimum to maximum. I want to be ignited at 0 each time it is pressed
the button and extinguish after reaching the maximum, to be ignited only when it is acted out the button.
Re: led pwm
Posted: Wed Sep 05, 2012 4:09 pm
by donald
Hello all,
I want to light up progressively when I touch the button and is not ignited
when it has reached maximum and use at least two ports.
I can't do that, any idea or flowchart is welcome.
Thank you in advance!
Re: led pwm
Posted: Wed Sep 05, 2012 7:45 pm
by medelec35
Hi donald,
This will work as your original flowchart
E.g if both switches are on then LED connected A1 will start at 10% and keep getting brighter every second then will go off.
Then LED connected A3 will start at 10% and keep getting brighter every second then will go off.
Both will keep taking turns in changing brightness.
If switch is off the corresponding LED will stay off.
Since both switches are monetary then if LED connected to A1 is on then operating switch connected to port A2 will have no effect until LED on A1 has fully extinguished.
But that might be what your after?
Re: led pwm
Posted: Thu Sep 06, 2012 3:48 am
by donald
Hi Martin,
Thank you very much, it seems that it works, run some more tests,thank you once more.
Re: led pwm
Posted: Thu Sep 06, 2012 7:44 am
by medelec35
Hi donald,
Your welcome,
I understand what your trying to achieve.
E.g press ans release a momentary switch, and LED corresponding to the switch will start at 10% work it's way up to 100% brightness (while press any switches will have no effect until led is off)
That's how this flowchart will work
Martin
Re: led pwm
Posted: Thu Sep 06, 2012 5:03 pm
by donald
Hi Martin,
It works great, with all my consideration and respect.
Thank you very much !
Re: led pwm
Posted: Thu Sep 06, 2012 9:36 pm
by medelec35
No problem,
Glad it's working for you.
Thanks for the update.
Martin
Re: led pwm
Posted: Sat Sep 08, 2012 11:16 pm
by Werner
Hi Guys, Just looking at the program I am having a hard time figuring out why the program goes to Timer_Int macro the sixth time through (Stepping though)?

I should have said when no switch is pushed?
Thanks