How to make Fading LED's

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
DJ Kitty
Posts: 3
Joined: Thu Jun 02, 2011 1:25 am
Contact:

How to make Fading LED's

Post by DJ Kitty »

Hey Everyone.

I'm am Very New to Flowcode and Programming. What I know about it isn't even n patch to what you Guys know.
If got this Idee of n 32 LED circle I want to build that makes Patterns and Automation. but I don't know How to make the LED's Actualy fade smootly. I do know and understand that it must lower the Variable's? if I'm not mistaking?

I'f put my Project file for editing and helping. I know it looks like a block but here you must use imagenation cuz FLOWCODE 3 doesn't offer a Seprate LED Component like in V4, it is actually supposed to be a circle!. But i'm using Flowcode 3.
another thing that jumps 2 mind is How do I light up Several LED's at exactly the same time? cus when you take my projectand slow down the PIC clock speed to Example 5, you could actually see how it actually light up array at a time.... is there a why to Light it up at exactly the same time?

Please keep your reply as simple as possible, I haven't done ANY programming, so I don't know anything actually of programming, this is like my first project of programming.
but I really want to build this Thing.
so if there must be Program language code, could you also PLEASE explain step by step? Cus that is something I don't understand at all. I'm like lost cus I'm actully a Music Producer and a Sound Engineer. I know a lot about that... but not programming.
Sorry
My brother had done Programming in "Asamble" i think and I can lent his Serial Port Programmer to put the hex file on the PIC.

I would really Appreciate your help!!!
Thanx
Attachments
FlowCode 32 LED Sircle.fcf
(10 KiB) Downloaded 1138 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: How to make Fading LED's

Post by medelec35 »

Hi DJ Kitty,
If you have flowcode V4 Demo then I created a flowchart that not only has variable brightness, but it has variable speeds and displays different patterns.
See:
http://www.matrixmultimedia.com/mmforum ... 401#p24498
(Fade4.fcf only currently opens with V4)
What you could do, is load V4 demo, then copy all the component blocks to V3
You also need to copy all within the supplementary code window
View menu then select project options.

As for only one set lighting up at a time. if i remember correctly each function will be accessed at OSC/4 (not go time to confirm this yet I'm running late :p)
So If osc speed is 20MHz then all leds in each port will take 1/osc/4 to light = 1/20x10E6/4 = 0.2uS = 5MHz

Due to persistence of vision, any any frequency above about 80Hz and it will look solid. So in real life you will see ALL leds light at the same time!
The program will will running far to fast for you to see any bank of LED's lighting individually.

If you are struggling I will put something together a bit later with Flowcode V3

Martin
Martin

DJ Kitty
Posts: 3
Joined: Thu Jun 02, 2011 1:25 am
Contact:

Re: How to make Fading LED's

Post by DJ Kitty »

Hey Martin

Thank you very mutch for your reply.

I have download the demo but would really like to have a reg code for it cuz flowcode 4 just works mutch easier for me... But I dont :( . anyway...

I don't understand actually mutch what is going on in that File the one you had said to take a look at.
but as I'm figuring out this fading thing, I have done some edit to my project and want you to have a look and check if I am at leased on the right path with the fading?
At the begining and not at pattern one. Cuz there aren't fading in Pattern one.

Please take a look and tell me what you think for a noobie and a first try...
Attachments
FlowCode 32 LED Sircle.fcf
(20 KiB) Downloaded 875 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: How to make Fading LED's

Post by Benj »

Hello,

You can upgrade your v3 version to v4 for 50% of the v4 cost price.

Professional - http://www.matrixmultimedia.com/product ... PHPSESSID=
Student / Home - http://www.matrixmultimedia.com/product ... PHPSESSID=

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: How to make Fading LED's

Post by medelec35 »

Here is your Flowchart modified so the main pattern dims.
I have deleted the call to the 1st pattern.
I am unable to test on real hardware so don't know If it works well or not.
Because the timer interrupt is much slower at triggering on simulator than on hardware, You will not be able to use simulator to determine its effectiveness
(if effective at all)
I have also made flowchart more efficient by using calculation boxes to determine correct port values.
The Varying Brightness will work by PWM i.e rapidly switching the port on and off at a fixed frequency. The time which the port is on compared to time port is off is called the duty.
duty can vary from 0% = no brightness to 100% = full brightness.
For more detail, you could search for PWM
>> is just bit shift right.
<< is bit shift left.
E.g <<1 = bit shift all by left by 1 place this is the same as multiplying by 2^1 = 2. <<2 = 2^2 = 4. <<3 = 2^3 = 8 ect.

When you say fade, I'm not sure if you mean the LEDS get dimmer or you mean a chasing pattern, like lights on night riders KITT car?
This flowchart should do both.

As for the way you have set port values:
You only use masking if you don't want to use the non ticked ports. Only the ticked ports will be effected by the value. Since you are using the whole port, you do not need to use port masking.
Eg if port = 255 = all LED's wil be on.
To turn off LED connected to LSB, just change port to 254. (Binary = 11111110)
Or to turn off LED connected to MSB, change port Value to 127 (Binary = 01111111 = 1111111)

Take a look at Flowcode V3 tutorials here:
http://www.matrixmultimedia.com/mmforum ... =26&t=6528

Hope this helps

Martin
Attachments
FlowCode 32 LED Sircle Modifed1A.fcf
Created with Flowcode V3
(17.16 KiB) Downloaded 976 times
Martin

DJ Kitty
Posts: 3
Joined: Thu Jun 02, 2011 1:25 am
Contact:

Re: How to make Fading LED's

Post by DJ Kitty »

Hi Martin.

Thank you for the Reply and your modification.

Now i don't want to sound stupid and to be Honest. I don't have an idea what is going on here. I do understand what you are saying, but I don't have the slitest Idea what flowcode is doing and do you get there. To be honnest, maybe if I would know the program like the palm of my hand, I would have known. I have checked out Flowcode TUT but don't understand it either, cus they are not talking, I can see what they are doing, but i don't know why they are doing it and the purpose of it.

What I have meant by Fading is Like Dimming the led en turning it slowly back on. Like the Britness difference. not Chasing. I'm getting at chasing later on. So what I have did with the last project reply was to try brightness diff, in a way it make sense to me, But i may be wrong.

If I could ask you a faver and you have the time, could you maybe make an video of what you are doing and explain why you are doing that, so that I also could understand what you are doing? with a screen recorder or something.

I really apriciate your help and your work alot.

Blessings
Ebert

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: How to make Fading LED's

Post by medelec35 »

What I did with the Flowcode was to keep the same pattern as you created, but hopefully the brightness of the LEDS forming a circle should change from full brightens and fade to off.
Have a read of this thread:
http://www.matrixmultimedia.com/mmforum ... mr0#p24863

Since I have a timer0 interrupt on your flowchart.

To be honest I believe the only way to learn is mater the basics, by loading the tutorials and follow step by step what's going on.
It is best to lean about various functions and components. E.g after learning about timer and port interrupts, learn about PWM, pic maths etc. These forums are a gold mine of resources and information.
I can help you to work out what's happening within the last flowchart I posted, just by posting a flowchart tackling each part separately.
In order to do that I will need to know what components/eblocks do you have.
E.g have to got a variable resistor, so you can alter the voltage going to an analogue pin?
If so I will post a flowchart that just deals with dimming 1 LED only, and take you though it step by step.

Martin
Martin

JanB
Posts: 34
Joined: Thu Feb 23, 2012 7:33 pm
Contact:

Re: How to make Fading LED's

Post by JanB »

medelec35 wrote: If so I will post a flowchart that just deals with dimming 1 LED only, and take you though it step by step.
Martin
Martin, (or someone else)

I have almost the same question.
I have a 12f629 with a simple LED flash pattern, On and Off. (one LED)

Now I want to fade / dimming the same led in a new pattern from 0% to 100% and back to 0%.
I read all kinds of possibilities in this forum, but I think this is going to “far” for what I want to have. I want to make it as simple as possible.
Can you please give me a example because when I read the topic’s I really don’t know where to begin. If I know and understand it, than I can make a more complex flowchart.

Thanks,

Jan

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: How to make Fading LED's

Post by Enamul »

HI,
You can try the bit banged PWM examples in PWM component examples..
http://www.matrixmultimedia.com/lc_index.php?p=18
If you can't sort that please let us know..I will post something for you..The issue is PIC12f629 don't have any hardware PWM so you have to use soft pwm to control LED brightness..but if can move to PIC12f617...in that case you can easily use hardware pwm to control brightness.
Enamul
University of Nottingham
enamul4mm@gmail.com

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: How to make Fading LED's

Post by medelec35 »

Hi Jan,
Not sure if this is what your after?
I don't really recommend using Timer interrupt the way I did, but only had a few mins spare.
Sorry if it does not work, as not tested on hardware.

I can see if I can come up with a better solution as soon as I can

Martin
Attachments
Dim pwm.fcf
(6.5 KiB) Downloaded 928 times
Martin

JanB
Posts: 34
Joined: Thu Feb 23, 2012 7:33 pm
Contact:

Re: How to make Fading LED's

Post by JanB »

medelec35 wrote:
I can see if I can come up with a better solution as soon as I can

Martin
Hi Martin,

Thanks for posting this fcf. I will test it later this day, I have to go my job now.

I would really appreciate if you want to post this also. I like to see the difference and learn from this.

Jan.

JanB
Posts: 34
Joined: Thu Feb 23, 2012 7:33 pm
Contact:

Re: How to make Fading LED's

Post by JanB »


ErikRussell
Posts: 1
Joined: Mon Aug 26, 2013 8:22 am
Contact:

Re: How to make Fading LED's

Post by ErikRussell »

DJ Kitty wrote:Hey Everyone.

I'm am Very New to Flowcode and Programming. What I know about it isn't even n patch to what you Guys know.
If got this Idee of n 32 LED circle I want to build that makes Patterns and Automation. but I don't know How to make the LED's Actualy fade smootly. I do know and understand that it must lower the Variable's? if I'm not mistaking?

I'f put my Project file for editing and helping. I know it looks like a block but here you must use imagenation cuz FLOWCODE 3 doesn't offer led lights Component like in V4, it is actually supposed to be a circle!. But i'm using Flowcode 3.
another thing that jumps 2 mind is How do I light up Several LED's at exactly the same time? cus when you take my projectand slow down the PIC clock speed to Example 5, you could actually see how it actually light up array at a time.... is there a why to Light it up at exactly the same time?

Please keep your reply as simple as possible, I haven't done ANY programming, so I don't know anything actually of programming, this is like my first project of programming.
but I really want to build this Thing.
so if there must be Program language code, could you also PLEASE explain step by step? Cus that is something I don't understand at all. I'm like lost cus I'm actully a Music Producer and a Sound Engineer. I know a lot about that... but not programming.
Sorry
My brother had done Programming in "Asamble" i think and I can lent his Serial Port Programmer to put the hex file on the PIC.

I would really Appreciate your help!!!
Thanx
Thanks man for sharing detailed informative post.. I am looking to build similar led so I will surely make use of information

Post Reply