Show Posts
Pages: [1] 2
1  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: March 09, 2013, 06:46:12 am
Thanks a bunch Grympy!
2  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: March 07, 2013, 07:48:41 pm
Thank you again Grumpy. Very nice of you to give me the basics put into context...

I got one question though. There´s two lines for each channel in the code, and you just explained the second one.

This line: if(tlc_addFade(1, 400, 0, millis()+ duration, millis()+ duration + duration)

What about the first one, can you explain that one too?

This line: if( tlc_addFade(1, 0, 400, millis(), millis()+ duration )



When I play around with it I can´t seem to make it work proper. Guess I´m just putting values in the wrong parameters.

3  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: March 06, 2013, 10:25:09 am
Well I haven't played with this library but looking at the tlc_fades.h file it says the parameters are:-
Quote
/** Adds a fade to the fade buffer.
    \param channel the ouput channel this fade is on
    \param startValue the value at the start of the fade
    \param endValue the value at the end of the fade
    \param startMillis the millis() when to start the fade
    \param endMillis the millis() when to end the fade
    \returns 0 if the fade buffer is full, fadeBufferSize if added successfully
*/
So I would expect the last parameter, when to end the fade will determine the length of the fade. I think you are passing the the end time by the time the fade starts plus the duration.


You must call tlc_updateFades(millis()) regularly as well.



Sorry, but I have no idea how to play with these parameters you´re talking about. I´ve tried to learn, but I don´t know where to put all that stuff. I know it´s probably basics, but I can learn better if someone put it in context, leaning from a code that is.

This is a 2-LED code I have now example:

Code:
#include "Tlc5940.h"
#include "tlc_fades.h"

TLC_CHANNEL_TYPE channel;
int analogValue;
int duration;
int maxValue = 400;

void setup()
{
  Tlc.init();
  Serial.begin(9600);
  Serial.println("Starting the code");
}

void loop() {
 analogValue = analogRead(0);

  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
   
   
       
     if (!tlc_isFading(1)){
      duration = 3000 - (analogValue * 2);
      if( tlc_addFade(1, 0, maxValue, millis(), millis()+ duration ) == 0) ;
      if(tlc_addFade(1, 400, 0, millis()+ duration, millis()+ duration + duration) ==0 ) ;
      }
     
      if (!tlc_isFading(2)){
      duration = 3000 - (analogValue * 2);
      if( tlc_addFade(2, 0, maxValue, millis(), millis()+ duration ) == 0) ;
      if(tlc_addFade(2, 400, 0, millis()+ duration, millis()+ duration + duration) ==0 ) ;
      }
     
     
   
     
     
     
     
     
 if (channel++ == NUM_TLCS * 16) {
      channel = 0;
    }
  }
  tlc_updateFades();
}

How would you write the code to make the fading slower?

And if I would like to have the 2nd LED to start fading in when the 1st is fading out? Sort of the "Knight rider chain effect, but more smoother.
4  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: March 05, 2013, 11:15:36 am
Thanx. I'll look into it when i find the time.
5  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: March 02, 2013, 07:44:52 pm
Thanks again Grumpy... I just wish the fade-in/out could be a bit slower. The duration values in my code is just for how long they´ll stay at max I guess. I would like them to fade up so that it takes about 2 seconds to reach full brightness. Is that a simple task?
6  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: March 01, 2013, 01:41:58 pm
I have a question. All 30 LEDs start up at the same time, and then start with their individual duration. I would like them to start up one and one, with different delay. How would I control that, using this 3-LED code for example?


Code:
#include "Tlc5940.h"
#include "tlc_fades.h"

TLC_CHANNEL_TYPE channel;
int analogValue;
int duration;
int maxValue = 400;

void setup()
{
  Tlc.init();
}

void loop() {
 analogValue = analogRead(0);

  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
       
     if (!tlc_isFading(1)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(1, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(1, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(2)){
      duration = 2500 - (analogValue * 2);
      tlc_addFade(2, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(2, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(3)){
      duration = 3400 - (analogValue * 2);
      tlc_addFade(3, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(3, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
     
     
    if (channel++ == NUM_TLCS * 16) {
      channel = 0;
    }
  }
7  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 26, 2013, 06:27:43 pm
Thank you so much Mike! Finally got it to work... Can´t tell you how much I appreciate this help!!

/ Quizz
8  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 25, 2013, 12:02:35 pm
Well that actually worked... Now I´ve got 15 LEDs without flickering. Thanks!!
When I add one more LED to the code it starts to flicker again though.

Starting the code
error in buffer 15
error in buffer 15

Should I edit the tlc_fades.h again, if I want more than 15 LEDs that is?
9  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 25, 2013, 04:53:43 am
Yeah, sorry about that. I should know the basics before coming here of course...

Anyway, I run a 15 LED example expanded to cope with the error messages, and this is what I´ll have after about 2 minutes. It keeps on going of course. For every new error message, there´s a flicker in that specific LED. It all seem very random.

Code:
Starting the code
error in buffer 13
error in buffer 13
error in buffer 14
error in buffer 14
error in buffer 15
error in buffer 15
error in buffer 14
error in buffer 15
error in buffer 15
error in buffer 11
error in buffer 11
error in buffer 12
error in buffer 12
error in buffer 12
error in buffer 14
error in buffer 14
error in buffer 14
error in buffer 8
error in buffer 9
error in buffer 10
error in buffer 10
error in buffer 11
error in buffer 7
error in buffer 7
error in buffer 14
error in buffer 6
error in buffer 6
error in buffer 7
error in buffer 15
error in buffer 13
error in buffer 12
error in buffer 14
error in buffer 8
error in buffer 3
error in buffer 12
error in buffer 8
error in buffer 11
error in buffer 4
error in buffer 12
error in buffer 15
error in buffer 10
error in buffer 14
error in buffer 6
error in buffer 10
error in buffer 5
error in buffer 15
error in buffer 3
error in buffer 4
error in buffer 9
error in buffer 8
error in buffer 13
error in buffer 14
error in buffer 10
error in buffer 7
error in buffer 8
error in buffer 11
error in buffer 15
error in buffer 14
error in buffer 9
error in buffer 12
error in buffer 15
error in buffer 10
error in buffer 7
error in buffer 6
error in buffer 4
error in buffer 11
error in buffer 11
error in buffer 11
error in buffer 13
error in buffer 13
error in buffer 12
error in buffer 9
error in buffer 8
error in buffer 11
error in buffer 7
error in buffer 15
error in buffer 10
error in buffer 8
error in buffer 3
error in buffer 4
error in buffer 4
error in buffer 5
error in buffer 2
error in buffer 9
error in buffer 12
error in buffer 4
error in buffer 15
error in buffer 2
error in buffer 5
error in buffer 5
error in buffer 7
error in buffer 13
error in buffer 12
error in buffer 15
error in buffer 10
error in buffer 9
error in buffer 12
error in buffer 5
error in buffer 11
error in buffer 15
error in buffer 9
error in buffer 12
error in buffer 7
error in buffer 8
error in buffer 8
error in buffer 8
error in buffer 9
error in buffer 14
error in buffer 3
error in buffer 11
error in buffer 13
error in buffer 15
error in buffer 15
error in buffer 15
error in buffer 12
error in buffer 7
error in buffer 8
error in buffer 8
error in buffer 4
error in buffer 14
error in buffer 2
error in buffer 15
error in buffer 13
error in buffer 4
error in buffer 3
error in buffer 4
10  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 24, 2013, 12:16:22 pm
so in place of doing simply the tlc_addFade
every time you should do:-
Code:
if( tlc_addFade( ........ ) == 0 ) Serial.print("error no room");
You need a Serial.begin(9600) in the setup function.
Then run the code and see if you get any error print outs.


I think you´ll have to guide me again =)

Where do I put the if( tlc_addFade( ........ ) == 0 ) Serial.print("error no room"); ?

And what´s the setup function?

Sorry once again for my lack of knowledge
11  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 24, 2013, 11:40:38 am
Ok, the cleaned up code have the same issues. No changes

Code:
#include "Tlc5940.h"
#include "tlc_fades.h"

TLC_CHANNEL_TYPE channel;
int analogValue;
int duration;
int maxValue = 400;

void setup()
{
  Tlc.init();
}

void loop() {
 analogValue = analogRead(0);

  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
       
     if (!tlc_isFading(1)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(1, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(1, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(2)){
      duration = 2500 - (analogValue * 2);
      tlc_addFade(2, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(2, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(3)){
      duration = 3400 - (analogValue * 2);
      tlc_addFade(3, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(3, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(4)){
      duration = 3000 - (analogValue * 2);
      tlc_addFade(4, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(4, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(5)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(5, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(5, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(6)){
      duration = 2500 - (analogValue * 2);
      tlc_addFade(6, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(6, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(7)){
      duration = 3400 - (analogValue * 2);
      tlc_addFade(7, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(7, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(8)){
      duration = 3000 - (analogValue * 2);
      tlc_addFade(8, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(8, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(9)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(9, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(9, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(10)){
      duration = 2500 - (analogValue * 2);
      tlc_addFade(10, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(10, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(11)){
      duration = 3400 - (analogValue * 2);
      tlc_addFade(11, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(11, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(12)){
      duration = 3000 - (analogValue * 2);
      tlc_addFade(12, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(12, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(13)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(13, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(13, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
      if (!tlc_isFading(14)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(14, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(14, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
       if (!tlc_isFading(15)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(15, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(15, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
       if (!tlc_isFading(16)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(16, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(16, 400, 28, millis()+ duration, millis()+ duration + duration);}
     
     
     
    if (channel++ == NUM_TLCS * 16) {
      channel = 0;
    }
  }
  tlc_updateFades();
}
12  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 24, 2013, 11:32:45 am
Oh, and here´s the library I used:

http://code.google.com/p/tlc5940arduino/downloads/detail?name=Tlc5940_r014_2.zip
13  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 24, 2013, 11:19:24 am
could be rewritten:-
Code:
if (!tlc_isFading(13)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(13, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(13, 400, 28, endMillis, endMillis + duration);}
with
Code:
analogValue = analogRead(0);
done at the start of the loop and analogValue defined outside of any function to make it a global variable.

I get some error messages, so where exactly do I put the analogValue = analogRead(0); into the 4-LED code below for example?

Code:
#include "Tlc5940.h"
#include "tlc_fades.h"

TLC_CHANNEL_TYPE channel;



void setup()
{
  Tlc.init();
}

void loop()
{
  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
   

   
     if (!tlc_isFading(1)){
      duration = 3750 - (analogValue * 2);
      tlc_addFade(1, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(1, 400, 28, endMillis, endMillis + duration);}
     
      if (!tlc_isFading(2)){
      duration = 2500 - (analogValue * 2);
      tlc_addFade(2, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(2, 400, 28, endMillis, endMillis + duration);}
     
      if (!tlc_isFading(3)){
      duration = 3400 - (analogValue * 2);
      tlc_addFade(3, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(3, 400, 28, endMillis, endMillis + duration);}
     
      if (!tlc_isFading(4)){
      duration = 3000 - (analogValue * 2);
      tlc_addFade(4, 28, maxValue, millis(), millis()+ duration );
      tlc_addFade(4, 400, 28, endMillis, endMillis + duration);}
     
     
       
   
   
    if (channel++ == NUM_TLCS * 16) {
      channel = 0;
    }
  }
  tlc_updateFades();
}



Hippynerd, I´m going to look into that, thanks
14  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 23, 2013, 04:25:45 am
Yes, it´s all very frustrating indeed. It´s nice to hear I´m getting closer though, because I can´t really see any improvements here, exept the exclusions so far.

The idea is to have 30 LEDs "breathing"(fading) smoothly in different durations. Kind of like the organic diode pulse effect you´ll get when you turn on you Macbook. I´m going to use it for some different projects later, that´s IF I can get to work of course.

But I´m up for trying other alternatives, and I´ve got another set of LEDs for experimenting. Never done any multiplexing though, so I´d need some help there I guess.

Thanks for helping me out here, also good luck with your own frustrating project.
15  Using Arduino / LEDs and Multiplexing / Re: Problem with multiple tlc5940 on: February 22, 2013, 07:22:15 pm
Grumpy, here is when they start to flicker some, with 14 LEDs:
Code:
#include "Tlc5940.h"
#include "tlc_fades.h"

TLC_CHANNEL_TYPE channel;

void setup()
{
  Tlc.init();
}

void loop()
{
  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {
    
     if (!tlc_isFading(0)){
      uint16_t duration = 4000 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(0, 28, maxValue, startMillis, endMillis );
      tlc_addFade(0, maxValue, 28, endMillis, endMillis + duration);}
    
     if (!tlc_isFading(1)){
      uint16_t duration = 4200 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(1, 28, maxValue, startMillis, endMillis );
      tlc_addFade(1, maxValue, 28, endMillis, endMillis + duration);}
    
     if (!tlc_isFading(2)){
      uint16_t duration = 4400 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(2, 28, maxValue, startMillis, endMillis );
      tlc_addFade(2, maxValue, 28, endMillis, endMillis + duration);}
      
     if (!tlc_isFading(3)){
      uint16_t duration = 4600 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(3, 28, maxValue, startMillis, endMillis );
      tlc_addFade(3, maxValue, 28, endMillis, endMillis + duration);}
      
     if (!tlc_isFading(4)){
      uint16_t duration = 4800 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(4, 28, maxValue, startMillis, endMillis );
      tlc_addFade(4, maxValue, 28, endMillis, endMillis + duration);}
  
     if (!tlc_isFading(5)){
      uint16_t duration = 5000 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(5, 28, maxValue, startMillis, endMillis );
      tlc_addFade(5, maxValue, 28, endMillis, endMillis + duration);}
      
     if (!tlc_isFading(6)){
      uint16_t duration = 3000 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(6, 28, maxValue, startMillis, endMillis );
      tlc_addFade(6, maxValue, 28, endMillis, endMillis + duration);}
      
     if (!tlc_isFading(7)){
      uint16_t duration = 3200 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(7, 28, maxValue, startMillis, endMillis );
      tlc_addFade(7, maxValue, 28, endMillis, endMillis + duration);}
      
     if (!tlc_isFading(8)){
      uint16_t duration = 3400 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(8, 28, maxValue, startMillis, endMillis );
      tlc_addFade(8, maxValue, 28, endMillis, endMillis + duration);}
    
     if (!tlc_isFading(9)){
      uint16_t duration = 3600 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(9, 28, maxValue, startMillis, endMillis );
      tlc_addFade(9, maxValue, 28, endMillis, endMillis + duration);}
    
     if (!tlc_isFading(10)){
      uint16_t duration = 3800 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(10, 28, maxValue, startMillis, endMillis );
      tlc_addFade(10, maxValue, 28, endMillis, endMillis + duration);}
      
     if (!tlc_isFading(11)){
      uint16_t duration = 5200 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(11, 28, maxValue, startMillis, endMillis );
      tlc_addFade(11, maxValue, 28, endMillis, endMillis + duration);}
      
       if (!tlc_isFading(12)){
      uint16_t duration = 3350 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(12, 28, maxValue, startMillis, endMillis );
      tlc_addFade(12, maxValue, 28, endMillis, endMillis + duration);}
      
       if (!tlc_isFading(13)){
      uint16_t duration = 3750 - (analogRead(0) * 2);
      int maxValue = 400;
      uint32_t startMillis = millis();
      uint32_t endMillis = startMillis + duration;
      tlc_addFade(13, 28, maxValue, startMillis, endMillis );
      tlc_addFade(13, maxValue, 28, endMillis, endMillis + duration);}
      
        
    
    
    if (channel++ == NUM_TLCS * 16) {
      channel = 0;
    }
  }
  tlc_updateFades();
}

Hippynerd:

Yeah, but quick and easy doesn´t seem to be the right words in this situation smiley-cry
Pages: [1] 2