Pages: [1]   Go Down
Author Topic: TLC for LEDs not working with IR receiver library  (Read 496 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello!

My problem is that the TLC Lib (https://code.google.com/p/tlc5940arduino/downloads/detail?name=Tlc5940_r014_2.zip&can=2&q=) is not working with the IR lib (https://github.com/shirriff/Arduino-IRremote).
Weird flickering and then no light.
Works fine without the IR lib.
Im not using same pins.

Can somebody pls help?!
Logged

Offline Offline
Faraday Member
**
Karma: 95
Posts: 5660
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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/
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 19, 2014, 10:37:36 pm by mHo2 » Logged

Offline Offline
Faraday Member
**
Karma: 95
Posts: 5660
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Quote
 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"
 
Quote
 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
Code:
#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 (627.69 KB - downloaded 21 times.)
* tlc5940.pdf (1331.58 KB - downloaded 9 times.)
* IRrecvDemo.ino (0.53 KB - downloaded 9 times.)
* IRrecord.ino (4.48 KB - downloaded 9 times.)
« Last Edit: March 20, 2014, 12:42:34 am by raschemmel » Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Quote
 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).


Quote
 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
Code:
#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.

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.
Logged

Offline Offline
Faraday Member
**
Karma: 95
Posts: 5660
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 ?

Quote
Good work on solving it, though.

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

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 ?

Quote
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:
http://en.wikipedia.org/wiki/Bit-banging

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).
Logged

Pages: [1]   Go Up
Jump to: