Benutzer Diskussion:Paul

aus Metalab Wiki, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Version vom 11. November 2008, 13:25 Uhr von MariusKintel (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springenZur Suche springen

Hallo Zusammen,

ich bin ein Neuer und hab gleich mal eine frage an euch. Ich habe von dem LED Projekt auf dieser Seite gelesen und habe nun die Hoffnung das einer von euch mir vielleicht bei einem Problem weiterhelfen könnt.

Ich benutze die Software VVVV (www.vvvv.org) um serielle Daten an das Arduino Board zu senden das wiederum 16 LED`S (PWM) mittels des TL5940 steuert. ich habe folgende Libary benutzt die alle wichtigen befehle schon beinhaltet. http://www.arduino.cc/playground/Learning/TLC5940 --> (For driving LEDs:)

Eigentlich funktioniert alles doch manchmal geht ein kurzes flickern über alle LED`s. Ich habe schon wirklich sehr viel probiert um das zu verhindern, konnte bis dato den Fehler aber leider nicht finde. Auch die Seriellen Daten werden fehlerfrei eingelesen.

Ich hoffe nun einer von euch kann mir weiterhelfen!!!


Viel dank schon mal für die Mühe.

--> Hier kommt der von mir benutzte Code

  1. include <TLC5940LED.h>
  1. define NUM_TLCS 1
  1. define MAX_LINE_LENGTH 20
  2. define SET_COMMAND 's'
  3. define COMMAND_ARG_DELIMITER ','

char serialBuffer[MAX_LINE_LENGTH]; uint8_t serialBufferSize = 0;

bool isNumber(char c) { return c >= '0' && c <= '9'; }

uint16_t parseDec(char *cpStart, char *cpEnd) { uint16_t result = 0; uint16_t ten = 1; for (char *cp = cpEnd - 1; cp >= cpStart; cp--) { char c = *cp; if (isNumber(c)) { result += ((*cp) - '0') * ten; ten *= 10; } } return result; }

void doSet() { char *cp = serialBuffer; if (*cp == SET_COMMAND)

 {
  cp++;
  char *cpEnd = cp;
  while (cpEnd < serialBuffer + serialBufferSize && *cpEnd != COMMAND_ARG_DELIMITER) 
       {

cpEnd++;

       }
       //Channels Read

uint8_t channel_0 = parseDec(cp, cp + 2); //Channel --> 1 - 16

       uint8_t channel_1 = parseDec(cp + 2, cp + 4);      
       //Stop Values Read

uint16_t Evalue_0 = parseDec(cpEnd + 1, cpEnd + 2); //E_0

       Evalue_0 = Evalue_0 * 1000;
       uint16_t Evalue_1 = parseDec(cpEnd + 2, cpEnd + 3);       //E_1
       Evalue_1 = Evalue_1 * 1000;
       uint16_t Evalue_2 = parseDec(cpEnd + 3, cpEnd + 4);       //E_2
       Evalue_2 = Evalue_2 * 1000;
       uint16_t Evalue_3 = parseDec(cpEnd + 4, cpEnd + 5);       //E_3
       Evalue_3 = Evalue_3 * 1000;
       //Start Values Read
       uint16_t Svalue_0 = parseDec(cpEnd + 5, cpEnd + 6);       //A_0
       Svalue_0 = Svalue_0 * 1000;
       uint16_t Svalue_1 = parseDec(cpEnd + 6, cpEnd + 7);       //A_1
       Svalue_1 = Svalue_1 * 1000;
       uint16_t Svalue_2 = parseDec(cpEnd + 7, cpEnd + 8);       //A_2
       Svalue_2 = Svalue_2 * 1000;
       uint16_t Svalue_3 = parseDec(cpEnd + 8, cpEnd + 9);       //A_3
       Svalue_3 = Svalue_3 * 1000;   
       //Set Fades

Tlc.newFade(channel_0, 100, Svalue_0, Evalue_0);

       channel_0 ++;
       Tlc.newFade(channel_0, 100, Svalue_1, Evalue_1);  
       Tlc.newFade(channel_1, 100, Svalue_2, Evalue_2); 
       channel_1++;
       Tlc.newFade(channel_1, 100, Svalue_3, Evalue_3);
      
       while (Tlc.updateFades()); // this will run until all the fades are done
       Tlc.update();
   } 
   else if (*cp == 'c') 
   {
   Tlc.clear();
   Tlc.update();	
   } 
   else 
   {
   Serial.println("Set syntax= s1,4095{space}");
   }

}

void setup() { Serial.begin(2400); Serial.println("Set syntax= s1,4095{space}"); Tlc.init(NUM_TLCS, 32); // --> more than about 40 and the ram run out of space Tlc.resetTimers(); }

void loop() { if (Serial.available()) { if (serialBufferSize < MAX_LINE_LENGTH) { char c = Serial.read(); Serial.print(c); if (c == ' ') { Serial.println(); doSet(); serialBufferSize = 0; } else { serialBuffer[serialBufferSize++] = c; } } else { serialBufferSize = 0; } } }



Come by the lab one day and present your project. It should be within our expertise to help your progress on this. MariusKintel 14:25, 11. Nov. 2008 (CET)