led pwm

Moderator: Benj

Post Reply
donald
Posts: 74
Joined: Tue Feb 14, 2012 5:17 pm
Been thanked: 3 times
Contact:

led pwm

Post 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!
Attachments
led pwm 2.fcf
(20.29 KiB) Downloaded 301 times
led pwm 1.fcf
(13.96 KiB) Downloaded 273 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: led pwm

Post 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
Martin

donald
Posts: 74
Joined: Tue Feb 14, 2012 5:17 pm
Been thanked: 3 times
Contact:

Re: led pwm

Post by donald »

Hi Martin,
Yes that's right, I would check again.

donald
Posts: 74
Joined: Tue Feb 14, 2012 5:17 pm
Been thanked: 3 times
Contact:

Re: led pwm

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: led pwm

Post 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
Attachments
led pwm 3.fcf
(17.97 KiB) Downloaded 304 times
Martin

donald
Posts: 74
Joined: Tue Feb 14, 2012 5:17 pm
Been thanked: 3 times
Contact:

Re: led pwm

Post 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!

donald
Posts: 74
Joined: Tue Feb 14, 2012 5:17 pm
Been thanked: 3 times
Contact:

Re: led pwm

Post 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.
Attachments
led pwm 4.fcf
(18.85 KiB) Downloaded 262 times

donald
Posts: 74
Joined: Tue Feb 14, 2012 5:17 pm
Been thanked: 3 times
Contact:

Re: led pwm

Post 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!
Attachments
led pwm 5.fcf
(21.63 KiB) Downloaded 285 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: led pwm

Post 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?
Attachments
led pwm 6.fcf
(19.18 KiB) Downloaded 286 times
Martin

donald
Posts: 74
Joined: Tue Feb 14, 2012 5:17 pm
Been thanked: 3 times
Contact:

Re: led pwm

Post by donald »

Hi Martin,
Thank you very much, it seems that it works, run some more tests,thank you once more.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: led pwm

Post 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
Martin

donald
Posts: 74
Joined: Tue Feb 14, 2012 5:17 pm
Been thanked: 3 times
Contact:

Re: led pwm

Post by donald »

Hi Martin,
It works great, with all my consideration and respect.
Thank you very much !

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: led pwm

Post by medelec35 »

No problem,
Glad it's working for you.
Thanks for the update.

Martin
Martin

Werner
Posts: 95
Joined: Sat Jun 11, 2011 4:12 am
Has thanked: 87 times
Been thanked: 31 times
Contact:

Re: led pwm

Post 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)? :D
I should have said when no switch is pushed?

Thanks
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"

Post Reply