Go Down

Topic: Shifting 200 Leds (Read 2766 times) previous topic - next topic

RazorFly

I have daisy chained 25 74hc5 95 each has its own 5 volt Power Supply. I would like some help with the shift out commands. I have been having some undesired results. Ie the last 3 or 4 registers stay latched and lit...so that's happening.


Thanks

raschemmel

This is a H/W & S/W issue. Post your schematic , or a short version of it. If you don't have a CAD schematic you can post as a PDF file then take a photo of the schematic with your cell phone and post that. Also  post your code and identify the source of the code.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

RazorFly

I am using this as a template as it "CLAIMS" that this will run 40+ ShiftRegisters

http://bildr.org/2011/02/74hc595/

CrossRoads

So you are wired up like this, with a decoupling cap on Each device, and sending data out thusly:
Code: [Select]

digitalWrite (ssPin, LOW); // use D10
for (x=0; x<24; x=x+1){
SPI.transfer(dataArray[x]);
}
digitalWrite (ssPin, HIGH);

#include <SPI.h>  at the top of your sketch
SPI.begin(); in setup, commits D13 to SCK, and D11 to MOSI
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.

raschemmel

Decoupling cap ? (maybe you better explain what  that is to him.and why he needs it...and what value to use.( I'm thinking at least 0.1uF on EACH chip and 1uF every 5th chip.)
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

RazorFly

I see where you have in the schematic controlling the ground side. I currently have it reversed. If that changes anything. I am a novice,  so where in my code should I place your code?

Thanks guys!

raschemmel

Quote
I see where you have in the schematic controlling the ground side. I currently have it reversed.

What does this mean ?
Can you rephase it using pin names to describe what you are talking about ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

RazorFly

In the schematic provided by crossroads the Leds in the top right corner are reversed from how I have mine wired up. Ie the shift register provides power not ground.

raschemmel

Which way matches the datasheet and arduino tutorial?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

CrossRoads

Either LED configuration works. I drew them that way because I use TPIC6B595 instead to sink full 20mA from each LED, while 74HC595  is limited to 8mA to meet the 70mA total current limit on the VCC & GND pin.

Put it in your code when you decide you want the outputs updated.
Or make it a function and call it when needed.
Or ...
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.

RazorFly

#10
Mar 28, 2014, 12:55 am Last Edit: Mar 28, 2014, 02:59 am by CrossRoads Reason: 1
Ok...Rewritten code like this:
(code tags added by moderator)
Code: [Select]

#include <SPI.h>

int SER_Pin = 8;   //pin 14 on the 75HC595
int RCLK_Pin = 9;  //pin 12 on the 75HC595
int ssPin = 10; //pin 11 on the 75HC595

//How many of the shift registers - change this
#define number_of_74hc595s 1

//do not touch
#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

void setup() {
 pinMode(SER_Pin, OUTPUT);
 pinMode(RCLK_Pin, OUTPUT);
 pinMode(ssPin, OUTPUT);
 SPI.begin();


 //reset all register pins
 clearRegisters();
 writeRegisters();
}


//set all register pins to LOW
void clearRegisters() {
 for (int i = numOfRegisterPins - 1; i >=  0; i--) {
   registers[i] = LOW;
 }
}


//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters() {

 digitalWrite(RCLK_Pin, LOW);

 for (int i = numOfRegisterPins - 1; i >=  0; i--) {
   digitalWrite(ssPin, LOW);

   int val = registers[i];

   digitalWrite(SER_Pin, val);
   digitalWrite(ssPin, HIGH);

 }
 digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value) {
 registers[index] = value;
}


void loop() {
 digitalWrite (ssPin, LOW); // use D10
 for (int x = 0; x < 24; x = x + 1) {
   SPI.transfer(dataArray[x]);
 }
 digitalWrite (ssPin, HIGH);


}


but have a brain ache How should i define the dataArray?

CrossRoads

Code: [Select]
byte dataArray[0] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
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.

Go Up