multiplexing tpic6b595's

Hi All,
Please forgive if this is a really stupid question. I’m sure its been answered before but perhaps in a way I don’t understand? I have wired up two tpic6b595’s to an arduino uno I think they are properly wired according to instructions. The problem is that if I turn on (led #3 for example) it turns on #3 led from both chips. I would like to be able to turn on leds 1-16 and have number 1-8 only turn on from the first shift register while 9-16 turn on led’s from the second shift register. I did this using TLC5940nt chips a few weeks ago and all I had to do was go into the tlc_config.h file and set the number of chips I was daisychaining there (#define NUM_TLCS 2.)

So my question is, assuming I have everything wired correctly, what do I need to do to tell this when I turn on pin#9 it will know to turn on pin#1 on the second shift register? I’ve attached the code. I see nothing in this code that would let the system know how many chips are in play so maybe I’m missing some needed code?

Thanks in advance for any insight.

JC

595_test.txt (1.96 KB)

jcmusix:
I have wired up two tpic6b595's to an Arduino UNO I think they are properly wired according to instructions.

But we don't know, because we don't have a picture or schematic of it.

jcmusix:
The problem is that if I turn on (led #3 for example) it turns on #3 led from both chips. I would like to be able to turn on leds 1-16 and have number 1-8 only turn on from the first shift register while 9-16 turn on led's from the second shift register.

OK, so you attached the code. That is very inconvenient. Let's look at it here (the way the instructions tell you to):

/*
Shift Register Example
for TPIC6B595 shift register by Jens C Brynildsen

This sketch turns reads serial input and uses it to set the pins
of a TPIC6B595 shift register.

Hardware:
* TPIC6B595 shift register attached to pins 7, 8, 11 and 12 of the Arduino,
as detailed below.
* LEDs attached to each of the outputs of the shift register

Based on the example created 23 Mar 2010 by Tom Igoe

*/

//Pin to clear the register
const int clearPin = 7;
//Pin connected to latch pin (RCK) of TPIC6B595
const int latchPin = 8;
//Pin connected to clock pin (SRCK) of TPIC6B595
const int clockPin = 12;
////Pin connected to Data in (SER IN) of TPIC6B595
const int dataPin = 11;

int counter = 0;
int numLedsInUse = 8;

void setup() {
 //set pins to output because they are addressed in the main loop
 pinMode(clearPin, OUTPUT);
 pinMode(latchPin, OUTPUT);
 pinMode(dataPin, OUTPUT);  
 pinMode(clockPin, OUTPUT);
 Serial.begin(9600);
 Serial.println("*");
 
 // Always start by setting SRCLR high
 digitalWrite( clearPin, HIGH);

 // delay a little and then set 
 delay(10);
}

void loop() {
 // Display LED's running
  digitalWrite( clearPin, HIGH);
 if( counter >= (numLedsInUse-1) ){
   counter = 0;
 } else {
   counter++;
 }
 
 // write to the shift register with the correct bit set high:
 registerWrite(counter, HIGH);
 delay( 1000);
}

// This method sends bits to the shift register:

void registerWrite(int whichPin, int whichState) {
// Serial.println(whichPin);
   
 // the bits you want to send
 byte bitsToSend = 0;
 // write number as bits
 bitWrite(bitsToSend, whichPin, whichState);

 // turn off the output so the pins don't light up
 // while you're shifting bits:
 digitalWrite(latchPin, LOW);
// Serial.println(bitsToSend);
// Serial.println("_");
 
 // shift the bits out
 shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend);

 // turn on the output so the LEDs can light up:
 digitalWrite(latchPin, HIGH);
}

Hmmm. Well, it is very confused code, but you are sending 8 bits and latching them. When you do it a second time, the 8 bits from the first register - if you have chained them correctly - go to the second and it displays what was previously on the first.

If you want to display 16 bits, you have to send (the correct) two lots of 8 bits so they ripple through the two registers, before the latch puts them to the output. You do not (need to) turn off the outputs because the outputs correspond to what is in the latches, not the ripple registers.

I know, I didn’t get a lot of responses because I didn’t ask a good question. I was thinking that this could be so common that there might be a simple answer. I think that multiplexing tlc5940 chips was much easier but someone told me that I should be using the power sinking tpic6b595 chips and I’m really struggling with them.

Here is a picture of the schematic I am using for the two tpic6b595 chips. Does everything seem ok with it? Have I missed something?

I wired two of these chips on a breadboard and the leds wired to the first chip are turning on and off just fine but I am getting no leds from the second chip to turn on using the code I provided. Oddly, yesterday both sets of leds seemed to light consecutively but perhaps that was a wiring error.

I appreciate your information where you said, “If you want to display 16 bits, you have to send (the correct) two lots of 8 bits so they ripple through the two registers, before the latch puts them to the output,” but I don’t understand that. Could you or anyone point me to a sketch that would work that I can study and play with to try to understand all this?
Thanks,
JC

jcmusix:
I appreciate your information where you said, "If you want to display 16 bits, you have to send (the correct) two lots of 8 bits so they ripple through the two registers, before the latch puts them to the output," but I don't understand that.

From the Arduino shiftOut() reference pages (Help>Reference>shiftOut in the IDE)

int data = 500; // an int is two bytes, or 16 bits
shiftOut(dataPin, clock, MSBFIRST, (data >> 8)); // shift out highbyte
shiftOut(dataPin, clock, MSBFIRST, data); // shift out lowbyte

Leo..

OH! ok, I think I'm starting to get the hang of it. :o One step at a time. At least with some experimentation I'm able to work lights off and on with two multiplexed tpic6b595's, but I may be back to ask more when I add the third chip. I have 12 chips total daisychained. I will be driving 90 something solenoids using the timing based off the data in a midi file to drive a player piano if I ever reach the conclusion of this project.
Thanks so much for your help!
JC

Are you doing this for the solenoids of your previous posts?
You can also use binary numbers, so you can see which solenoid you're activating, e.g. number four only.
Leo..

digitalWrite(latchPin, LOW); // disable transfer to outputs
shiftOut(dataPin, clock, MSBFIRST, B00010000); // shift out first byte
shiftOut(dataPin, clock, MSBFIRST, B00000000); // shift out second byte
digitalWrite(clockPin, HIGH); // transfer to outputs

Yes, I'm doing this to drive racks of solenoids to open air vents to activate player piano valves. I already have the software that will extract the note, time, and duration values from midi files. I'm not sure at this point if I'm going to try to serial read the midi data files to activate the solenoids or if I'm going to use some sort of include statement to read all the notes and durations as an array. I'm not so worried about that, I can try different approaches there, but my focus right now is to get my solenoid switching worked out.
Thanks for the tip of using B00000000, B00001000 etc. I tried it and it makes it SO much easier to work with that way.

Thanks Very Much!
JC

If you have multiple TPIC6x595s daisychained, then you can keep the data to send to them in an array and just send the array contents out after you have made a change to some byte. I prefer to use SPI to send the data out.

//time for an update?
digitalWrite (latchPin, LOW);
for(x=0; x<numberOfBytes; x=x+1){
SPI.transfer(dataArray[x]);
}
digitalWrite (latchPin,  HIGH); // outputs update on this rising edge

I have done this for 45 daisy chained shift registers, at SPI clock at 8 MHz for a 20 KHz update rate.

I also offer a board with up to 12 TPIC6B595 shift registers, and a 328P processor. Plug on an FTDI Basic for programming it.
http://www.crossroadsfencing.com/BobuinoRev17/

If I had it to do over again, if I had known at the start, I would buy your pre-assembled board. If I have any difficulty completing or working with this board I will buy also buy one. It looks SO much neater than the mess of spaghetti wire I have. :o Thanks for the tip on using SPI as well. Edit: looking at the work I have left to do maybe I will just go ahead and order one of your boards. I really dont want to solder a few hundred more wires and end up with a big mess in the end.

e1c1d628c0e9e76adb312726078bd5aaa3683223.jpg

OK, that matches the datasheet but I think you should always connect all three ground pins - to ground.

CrossRoads:
I also offer a board with up to 12 TPIC6B595 shift registers, and a 328P processor. Plug on an FTDI Basic for programming it.
BobuinoRev17/

Recommendation - just buy it!