Hi Everybody,
Im with fun doing all kind of simple programming and I may say I do get my programs running one way or the other.
but now im stuck in something maybe not so important seeing all the harder questions here, but there must be a way. and something simple now and then makes it fun...
I made a loop running 255 times in a programmable led and added each loop a variable is added to the PWM of the led, and a delay so it appears it fades in in brightness.
it does work in the simulation here in flowcode but of coarse our eye is seeing much more difference in say a value 1-10 for the PWM or even 1-100 on the scale of 255 max.
I tried to add in a kind of logarithmic variable or even a second variable in the delay but im not succeeding...
is there a mathematic genius here who can tell me how to add small numbers in the start and larger steps in the end? I have found a log calculation in fc but don't know how to add it and try.
Thanks, Angelo.
fading in and out led
Moderator: Benj
- Steve001
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
- Contact:
Re: fading in and out led
Hi Dutch
There was a project some time ago (V4) if you do a search "mood light" the article zone gives a 404 error for some reason hopefully matrix staff will see this and try and fix the broken link.
viewtopic.php?f=36&t=7021&hilit=mood+light
this post may be of some use also
viewtopic.php?f=54&t=14888
Steve
There was a project some time ago (V4) if you do a search "mood light" the article zone gives a 404 error for some reason hopefully matrix staff will see this and try and fix the broken link.
viewtopic.php?f=36&t=7021&hilit=mood+light
this post may be of some use also
viewtopic.php?f=54&t=14888
Steve
Success always occurs in private and failure in full view.
-
- Posts: 102
- Joined: Mon Aug 19, 2013 8:38 am
- Location: Netherlands
- Has thanked: 24 times
- Been thanked: 5 times
- Contact:
Re: fading in and out led
I get the same error on that first link. but maybe the posted code I can open.
the second I have to see if parts work in my project. I see real pwm used while I create it with variable timings for led on and a fixed off.
Thanks for your response!
the second I have to see if parts work in my project. I see real pwm used while I create it with variable timings for led on and a fixed off.
Thanks for your response!
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: fading in and out led
Hi Dutch!
I dont know if I understand you correct, I I think you mean when the led has to ligth up, you want it more linear.
I made some changes in your program. The led will ligth up fastere in the beginning and slower in the end.
Hope you can see the idea in the program. You can add some more desicions IF and split it more up.
Br Jorgen
I dont know if I understand you correct, I I think you mean when the led has to ligth up, you want it more linear.
I made some changes in your program. The led will ligth up fastere in the beginning and slower in the end.
Hope you can see the idea in the program. You can add some more desicions IF and split it more up.
Br Jorgen
- Attachments
-
- fade in led1.fcfx
- (10 KiB) Downloaded 243 times
- 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: fading in and out led
I'm not sure how well this would work but you could maybe try the Fibonacci sequence. Store the values for the sequence in a look up table component and reference the values with an incrementing or decrementing index variable. I can provide a demo of needed
I'm not sure if you would use the value for the pwm duty or the delay between values or both. Maybe start with just the duty and see how you get on.
I'm not sure if you would use the value for the pwm duty or the delay between values or both. Maybe start with just the duty and see how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 102
- Joined: Mon Aug 19, 2013 8:38 am
- Location: Netherlands
- Has thanked: 24 times
- Been thanked: 5 times
- Contact:
Re: fading in and out led
Hmm more linear to our eye but that is indeed less larger incements in the start and faster in the end.jgu1 wrote:Hi Dutch!
I dont know if I understand you correct, I I think you mean when the led has to ligth up, you want it more linear.
I made some changes in your program. The led will ligth up fastere in the beginning and slower in the end.
Hope you can see the idea in the program. You can add some more desicions IF and split it more up.
Br Jorgen
What you made is a possibility. didn't think of that because its a little rough jumps but maybe good enough for a visual effect! going to play with that idea a bit! thanks.
-
- Posts: 102
- Joined: Mon Aug 19, 2013 8:38 am
- Location: Netherlands
- Has thanked: 24 times
- Been thanked: 5 times
- Contact:
Re: fading in and out led
If you could make a simple example how to get a value out of a lookup table that would be great. learning on the jobBenj wrote:I'm not sure how well this would work but you could maybe try the Fibonacci sequence. Store the values for the sequence in a look up table component and reference the values with an incrementing or decrementing index variable. I can provide a demo of needed
I'm not sure if you would use the value for the pwm duty or the delay between values or both. Maybe start with just the duty and see how you get on.
il try to extrapolate values for red for the human eye then.. it might look like a logarithmic scale..
- 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: fading in and out led
Here's a quick example.
Fibonacci is otherwise known as natural log I believe. We could use the log function instead of the LUT but this adds a lot of processing overhead dealing with the floating point maths.
Fibonacci is otherwise known as natural log I believe. We could use the log function instead of the LUT but this adds a lot of processing overhead dealing with the floating point maths.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- DavidA
- Matrix Staff
- Posts: 1076
- Joined: Fri Apr 23, 2010 2:18 pm
- Location: Matrix Multimedia Ltd
- Has thanked: 58 times
- Been thanked: 258 times
- Contact:
Re: fading in and out led
I found issue causing the articles not to shown.
https://www.matrixtsl.com/article.php?a=365
'Should' work now.
https://www.matrixtsl.com/article.php?a=365
'Should' work now.