Pages: [1]   Go Down
Author Topic: [SOLVED] 74hc595 and TLC5940 together: not working?  (Read 982 times)
0 Members and 1 Guest are viewing this topic.
Milano, Italy
Offline Offline
Faraday Member
**
Karma: 11
Posts: 3091
Sideralis Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I am working on a project and I have planned to use a 74hc595 for multiplexing part of my work and a TLC5940 for rgb led driving. I have just added on my breadboard the TLC, wrote some basic lines of code -using the acLeone library- AND nothing works anymore.

Trying to exclude part of the code I see that the 595 alone works and that the 5940 alone works, but they don't work together in the same sketch.

Is this a known issue!?
« Last Edit: March 07, 2011, 02:40:32 pm by Federico » Logged

Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

The Netherlands
Offline Offline
Full Member
***
Karma: 2
Posts: 178
Beep!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do you want to connect the two?
Do you have them chained together? Or do you use them for different components? Tlc5940 for the negatives and the 595 for the positives?

A bit more information would be nice to see if this can work or not.

If you have them linked together I don't think it'll work. Both chips are completely different.
And then again, you can just as easily daisy chain a couple of 5940 or 595's together to have more connections.
Logged

Milano, Italy
Offline Offline
Faraday Member
**
Karma: 11
Posts: 3091
Sideralis Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for helping smiley-kitty
I use the two ICs for different component, I am going to use the 5940 ust for driving some RGB led and I am going to use the 595 for multiplexing another part of my circuit. Basically I am not using just 5940 and multiplexing with them because I already spent lot of nights and many posts on this forum without being able to succeed.

Anyway...

So they are not linked together, they just should work on the same arduino. I have also a piece of (bad) code, when I set the Tlc.init() the shiftOut funcion stop working, but the Tlc works. If I don't set the part of the code for the 5940, the shiftOut works...

Code:
#include "Tlc5940.h"

int aPin = 2; int bPin = 6; int cPin = 4; int dPin = 7; //sn74141 pin
int latchPin = 8; int clockPin = 12; int dataPin = 5;  //74hc595 pin
//TLC5940 pins are auto defined into the library

int gray=0;

void setup()   {               
  Tlc.init();
 
  pinMode(aPin, OUTPUT);
  pinMode(bPin, OUTPUT);
  pinMode(cPin, OUTPUT);
  pinMode(dPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
 
}

long tempo=millis();
boolean toggle=0;

void loop(){
 
  if (millis()-tempo >= 1000) {
    tempo=millis();
    toggle=!toggle;
  }
 
  gray+=50;
 
  delay(10);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, B00000010);
  sn74141pilot(toggle);
  digitalWrite(latchPin, HIGH);
 
  Tlc.clear();
  Tlc.set(0, gray);
  Tlc.update();
 
  delay(10);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, B00000100); 
  sn74141pilot(!toggle);
  digitalWrite(latchPin, HIGH);
 
  if (gray==4095) gray==0;
}

void blank(){
  sn74141pilot(15); //1111
  delay(5);
}

void sn74141pilot(int num){
  digitalWrite(aPin, B0001&num);
  digitalWrite(bPin, B0010&num);
  digitalWrite(cPin, B0100&num);
  digitalWrite(dPin, B1000&num);
}

Thanks, Fede
Logged

Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8600
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
 sn74141pilot(15); //1111
  delay(5);
}

void sn74141pilot(int num){
  digitalWrite(aPin, B0001&num);
  digitalWrite(bPin, B0010&num);
  digitalWrite(cPin, B0100&num);
  digitalWrite(dPin, B1000&num);


What is the 15 supposed to do, all these will simply set the pin HIGH.

B0001 & 15 = B0001, so there's no point, and IIRC any number <> 0 will set the pin HIGH.

I don't see any writing to the 5490, or is that what Tlc.update(); does?

Also

Code:
int clockPin = 12
That's one of the SPI pins, it will affect the SPI I think.


______
Rob
« Last Edit: March 03, 2011, 08:45:25 pm by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Milano, Italy
Offline Offline
Faraday Member
**
Karma: 11
Posts: 3091
Sideralis Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The sn74141pilot is a function for sending data to another IC, a 74141 chip, and the blank function is a wrapper for human being to send an HIGH signal to this 74141ic.
This is a part of the code that doesn't change the response that I have from the 74hc595 and the TLC5940

After more test I notice that simply having the 595 and the TLC wired as described by my pinout, creates problems. When I call Tlc.init() the shiftOut function stops responding. I don't know about the pin 12, it is the one used in the shiftOut tutorial: http://www.arduino.cc/en/Tutorial/ShiftOut
I'd like to test a different pin as soon as possible...

Federico
Logged

Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

Milano, Italy
Offline Offline
Faraday Member
**
Karma: 11
Posts: 3091
Sideralis Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Unconnecting the pin 12, and using another pin, everything works.
How does this pin 12 works? Why it is not working as expected while using a timer?
Where can I find a bit of documentation about this?

Thanks a lot for helping me solve this!

Fede
Logged

Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Where can I find a bit of documentation about this?

http://arduino.cc/en/Reference/SPI

"On the Arduino Duemilanove and other ATmega168 / 328-based boards, the SPI bus uses pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK)."

Since you didn't need to read data in from your SPI device, you didn't need to connect the "master in" pin, and it looked like a free pin you could use.  But alas, using it seems like to confuse the SPI infrastructure.
Logged


Milano, Italy
Offline Offline
Faraday Member
**
Karma: 11
Posts: 3091
Sideralis Arduino!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks  smiley-cool
Logged

Federico - Sideralis
Arduino &C: http://www.sideralis.org
Foto: http://blackman.amicofigo.com

Pages: [1]   Go Up
Jump to: