Go Down

Topic: shiftOut issues (Read 125 times) previous topic - next topic

CupcakeSmasher

Hello, I am working on a project that uses a 4x4 grid of RGB LEDs. It is wired up with shift registers that will link to the LEDs. We have used 8 shift registers that each use only 6 of their outputs. (I know it is inefficient but I didn't have control of that) The issue I have come across is the code behind the project. I know that shiftOut can be stacked on each other so that one shift register can use the first data and pass on the second data to the next. I then tried it with all eight registers and that didn't work, so I split it so that every 2 shift registers are independent of the rest. What this means is that I have tried using separate outputs from the Arduino board so that the first three service the first 2 Shift registers and so on. I do not have access to the code right now, but tell me if that would be useful.

CrossRoads

Daisy chain them. Put a 0.1uF cap from the VCC pin of each device to Gnd.
I have daisy chained 10,20, 27 with no issues.
Code: [Select]

digitalWrite (latchPin, LOW);
for (x=0; x<8; x=x+1){
shiftOut (dataPin,clkPin, MSBFIRST, dataArray[x]);
}
digitalWrite (latchPin, HIGH);

Make sure SRCLR is connected to VCC, and OE (G/) is connected to GND or to a PWM pin for brightness control. analogWrite( 0 ) for full bright, analogWrite(255) for full off.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CupcakeSmasher

Thank you for the quick response.
Is it not possible the other way? I will rewire if it isn't. Here is the code:

This is the description of the code:

The function is so it will function similar to digital write, because I am making it as easy as possible for people to work on when I am no longer here (school setting) It is the very bottom that doesn't work, only the last two ics seem to function

CrossRoads

Sure, anything's possible.

Fix this part
Code: [Select]

void updateLEDs()  {
  digitalWrite(latchUno, LOW);
  digitalWrite(latchDua, LOW);
  digitalWrite(latchTre, LOW);
  digitalWrite(latchFor, LOW);
  shiftOut(dataUno, clockUno, MSBFIRST, valueEins);
  shiftOut(dataUno, clockUno, MSBFIRST, valueZwei);
  shiftOut(dataDua, clockDua, MSBFIRST, valueDrei);
  shiftOut(dataDua, clockDua, MSBFIRST, valueVier);
  shiftOut(dataTre, clockTre, MSBFIRST, valueFunf);
  shiftOut(dataTre, clockTre, MSBFIRST, valueSechts);
  shiftOut(dataFor, clockFor, MSBFIRST, valueSieben);
  shiftOut(dataFor, clockFor, MSBFIRST, valueAcht);
  digitalWrite(latchUno, HIGH);
  digitalWrite(latchDua, HIGH);
  digitalWrite(latchTre, HIGH);
  digitalWrite(latchFor, HIGH);
}

to
Code: [Select]

void updateLEDs()  {
  digitalWrite(latchUno, LOW);
  shiftOut(dataUno, clockUno, MSBFIRST, valueEins);
  shiftOut(dataUno, clockUno, MSBFIRST, valueZwei);
  digitalWrite(latchUno, HIGH);

  digitalWrite(latchDua, LOW);
  shiftOut(dataDua, clockDua, MSBFIRST, valueDrei);
  shiftOut(dataDua, clockDua, MSBFIRST, valueVier);
  digitalWrite(latchDua, HIGH);

  digitalWrite(latchTre, LOW);
  shiftOut(dataTre, clockTre, MSBFIRST, valueFunf);
  shiftOut(dataTre, clockTre, MSBFIRST, valueSechts);
  digitalWrite(latchTre, HIGH);

  digitalWrite(latchFor, LOW);
  shiftOut(dataFor, clockFor, MSBFIRST, valueSieben);
  shiftOut(dataFor, clockFor, MSBFIRST, valueAcht);
  digitalWrite(latchFor, HIGH);
}
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CupcakeSmasher

#4
May 04, 2015, 09:15 pm Last Edit: May 04, 2015, 09:21 pm by CupcakeSmasher
I have it so that the code works, but it seems to reuse the previously used bit instead of a unique bit passing to each register. Is that what is supposed to happen? I know I didn't say it, but is there a way to accomplish this?

What is happening is that only the first two registers work, in the code this is the one that uses ports 11, 12, 13. Then the one directly connected works as well. After this none of the other registers appear to output anything.

Go Up