TLC for LEDs not working with IR receiver library

Hello!

My problem is that the TLC Lib (Google Code Archive - Long-term storage for Google Code Project Hosting.) is not working with the IR lib (GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols).
Weird flickering and then no light.
Works fine without the IR lib.
Im not using same pins.

Can somebody pls help?!

The TLC5940 requires the TLC5940 Library. You can't use the IR library with the TLC5940 unless you write your own library.
Here's a tutorial on using the IR REMOTE library. The TLC5940 uses SPI protocol.

raschemmel:
The TLC5940 requires the TLC5940 Library. You can't use the IR library with the TLC5940 unless you write your own library.
Here's a tutorial on using the IR REMOTE library. The TLC5940 uses SPI protocol.
http://www.instructables.com/id/Arduino-Control-LEDs-with-a-Remote-Control/

I'm sorry, but that seems like you're misinterpreting his issue. It's clear that he is using the two libraries in conjunction. Did you even read his post?

@OP

You'll need to understand the libraries more in detail to start messing around and playing with these. It's clear that using the two libraries are interfering, possibly with low level interrupts and timers, or high level code timing.
Maybe someone else has used these two, but at the moment I don't have the time to explore your IR library.

Yeah, maybe I missed the part about him using the IR REMOTE library WITH the TLC LIBRARY , but have you ever used the TLC
library ? Did you look at the tutorial on that (instructable) ? Did you even look at the wiring diagram for the IR REMOTE tutorial ?
Look closely , do you see any wires going to arduino pins 11, 12, &13 ? Those are SPI pins. The TLC5940 is a SPI protocol device. There is no possible way these two libraries can WORK TOGETHER , PERIOD. One is SPI , the other is not. They can work concurrently, in the sense that if you keep the chip select pins separate so there is no conflict the two libraries MIGHT work within the same program because the commands for each, are calling routines in different libraries and there is no reason why one should interfere with the other if the hardware does not conflict.

It's clear that using the two libraries are interfering, possibly with low level interrupts and timers, or high level code timing.

This is nonsense. (because it has nothing to do with low level interrupts, timers or high level code. It is a HW CONFLICT)
This is a quote from the attached pdf "Demystifying the TLC5940"

There are a multitude of ways you can interface with a piece of hardware. The datasheet
for your device should specify the communication protocol(s) it supports. The TLC5940
uses SPI (Serial Peripheral Interface) to communicate with a microcontroller.

SPECIFICALLY, , PINS 10 11 &13.
Why not pin-12 ? Because pin-12 is MISO (Master IN , Slave OUT). The arduino is not reading from the chip so it doesn't need that.
Pin -10 is SS (chip select ) is the chip's BLANK signal, when it goes LOW, OUTn are controlled by PWM signal.
pin-9: Level triggered latch signal. When XLAT = high, the TLC5940 writes data from the input shift register to either GS register (VPRG = low) or DC register (VPRG = high). When XLAT = low, the data in GS or DC register is held constant.
Pin-3 is the chip's GSCLK (Reference clock for grayscale PWM control)
pin-11: is the chip's SIN signal (Serial data input)

BUT WAIT ! NO ! THAT CAN'T BE POSSIBLE, BECAUSE PIN -11 IS USED BY IR REMOTE (SEE ATTACHED IR REMOTE EXAMPLE)

CODE FROM IR REMOTE example

 #include <IRremote.h> 
[b]int RECV_PIN = 11;[/b]

In fact THE FIRST 4 of the 8 example programs in the IR REMOTE library use pin 11 or 11 , 12 & 13. (see attached examples)
If the OP is running two libraries that are using the SAME pins, do you think that is going to work ?
@OP,
Try redefining the pins mentioned above in the IR REMOTE examples. See if it works with other pins not used by SPI.

Demystifying-the-TLC5940.pdf (628 KB)

tlc5940.pdf (1.3 MB)

IRrecvDemo.ino (545 Bytes)

IRrecord.ino (4.48 KB)

raschemmel:
Yeah, maybe I missed the part about him using the IR REMOTE library WITH the TLC LIBRARY , but have you ever used the TLC
library ? Did you look at the tutorial on that (instructable) ? Did you even look at the wiring diagram for the IR REMOTE tutorial ?
Look closely , do you see any wires going to arduino pins 11, 12, &13 ? Those are SPI pins. The TLC5940 is a SPI protocol device. There is no possible way these two libraries can WORK TOGETHER , PERIOD. One is SPI , the other is not. They can work concurrently, in the sense that if you keep the chip select pins separate so there is no conflict the two libraries MIGHT work within the same program because the commands for each, are calling routines in different libraries and there is no reason why one should interfere with the other if the hardware does not conflict.

It's clear that using the two libraries are interfering, possibly with low level interrupts and timers, or high level code timing.

This is nonsense. (because it has nothing to do with low level interrupts, timers or high level code. It is a HW CONFLICT)
This is a quote from the attached pdf "Demystifying the TLC5940"

Is that first comment directed toward me? I haven't actually looked at any of his library stuff, FYI. So I was throwing out possible causes.

That being said I'm pretty damn sure I know how that TLC library works, seeing as i've re-written it for an ARM chip (teensy 3.1).

raschemmel:

There are a multitude of ways you can interface with a piece of hardware. The datasheet
for your device should specify the communication protocol(s) it supports. The TLC5940
uses SPI (Serial Peripheral Interface) to communicate with a microcontroller.

SPECIFICALLY, , PINS 10 11 &13.
Why not pin-12 ? Because pin-12 is MISO (Master IN , Slave OUT). The arduino is not reading from the chip so it doesn't need that.
Pin -10 is SS (chip select ) is the chip's BLANK signal, when it goes LOW, OUTn are controlled by PWM signal.
pin-9: Level triggered latch signal. When XLAT = high, the TLC5940 writes data from the input shift register to either GS register (VPRG = low) or DC register (VPRG = high). When XLAT = low, the data in GS or DC register is held constant.
Pin-3 is the chip's GSCLK (Reference clock for grayscale PWM control)
pin-11: is the chip's SIN signal (Serial data input)

BUT WAIT ! NO ! THAT CAN'T BE POSSIBLE, BECAUSE PIN -11 IS USED BY IR REMOTE (SEE ATTACHED IR REMOTE EXAMPLE)

CODE FROM IR REMOTE example

 #include <IRremote.h> 

int RECV_PIN = 11;



In fact THE FIRST 4 of the 8 example programs in the IR REMOTE library use pin 11 or 11 , 12 & 13. (see attached examples)
If the OP is running two libraries that are using the SAME pins, do you think that is going to work ?
@OP,
Try redefining the pins mentioned above in the IR REMOTE examples. See if it works with other pins not used by SPI.

Again, haven't looked at the libraries. I was not suggesting I have either, but your original post was completely out of context. Good work on solving it, though.

That being said I'm pretty damn sure I know how that TLC library works, seeing as i've re-written it for an ARM chip (teensy 3.1).

Then you know the SPI pins can't be changed for the TLC library. So the question is, do you know if they can be redefined for the IR REMOTE library because I couldn't find any reason hardware or software why the IR REMOTE library needs to use the same pins (or some of them) as the TLC library. Can the OP just redefine them ? (to solve the hardware conflict that is obvious from my last post ?

Good work on solving it, though.

We know where the conflict is (pins) . We don't know the solution yet.

raschemmel:

That being said I'm pretty damn sure I know how that TLC library works, seeing as i've re-written it for an ARM chip (teensy 3.1).

Then you know the SPI pins can't be changed for the TLC library. So the question is, do you know if they can be redefined for the IR REMOTE library because I couldn't find any reason hardware or software why the IR REMOTE library needs to use the same pins (or some of them) as the TLC library. Can the OP just redefine them ? (to solve the hardware conflict that is obvious from my last post ?

Good work on solving it, though.

We know where the conflict is (pins) . We don't know the solution yet.

If that is indeed the problem (hardware pins), OP can get around it with using a different set of SPI pins if his/her board supports it (e.g. teensy or others?). That being said, bit-banging is a possible solution instead of SPI, and works with the TLC library with minor modifications:

That being said, after a quick glance over of that library for the IR, it only leverages PWM pins, so yes that is changeable. The only issue I would have is looking at what that interrupt does and seeing if it's special to OC2A (pin 11).