Go Down

Topic: Serial Communication and writing to TLC (Read 334 times) previous topic - next topic

amoeboar

Hello All,

My first time posting to this forum. I have a question about writing to the TLC from Processing via serial. I'm reading Kinect data on the Processing side and trying to send the output to my TLC chips. The problem is that it is a 3-dimensional array and I don't know how to signal the chip to push out bits. Here's what my code looks like:


//___________Processing

*** a bunch of depth data processing
*** handshaking methods
*** when Processing gets the signal that it can send bytes I do this:

Code: [Select]
// update the array, send it
    for (int y = 0; y < 8; y++) {
      for (int z = 0; z < 8; z++) {
        for (int x = 0; x < 8; x++) {
          // TODO: POPULATE ARRAY
          myPort.write(cube[y][z][x]);
          //print(cube[y][z][x]);
        }
      }
    }


When I print this output to the console I get a bunch of zeroes while my program loads (as expected), then around the 30th cycle or so I get stuff like this:

240000000240000000240000000882009732521167521654759102-975968280689-80-111155900059-121-12471-11740391060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006385000000106-1110000073-105-725800656-67-64-64-123007653-68-64-67-73800000000000000000000000000000000000000000000020000663000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
counter = 28


I think that's right, because if I understand correctly the numbers correspond to a location of the 3-dimensional array.

Then on the Arduino side I'm doing this:


//___________Arduino

Code: [Select]
if (Serial.available() >= 8) {

    //********** TLC STUFF **********
    for (int y = 0; y < 8; y++){
      for (int z = 0; z < 8; z++) {
        for (int x = 0; x < 8; x++) {
          bytes[y][z][x] = Serial.read();

          int LEDbrightness = map(y, 0, 8, 0, 4095);

          Tlc.clear();
          Tlc.set(x, LEDbrightness);
          Tlc.update();

          digitalWrite(analogPin[y], LOW);
          //delay(delayTime);
          digitalWrite(analogPin[y], HIGH);
        }
      }
    }
  }


And this is where I'm hitting a wall. How can I tell Tlc.set() which channel to send the information to, since it's coming in a different from from Processing?

To clarify, I've got 4 Tlc's daisy chained for 64 outputs. So in order to switch between the 64-pixel layers, I'm cycling through 8 Analog pins. The process is something like, "Hold layer LOW, shift out 64 bits, return layer HIGH to turn off LEDs. Switch to next layer, hold it LOW, shift out 64, and so on." I don't know how to translate the data coming into Arduino from Processing to talk to my chips in the way the function Tlc.set() is set up.

How can I do this? Help would be hugely appreciated!!!!

Go Up