Arduino: Individually Control Shift Register Pins

Discussions area for bildr's blog posts.
Hi, This is a great library that you have put together for this shift register and i will use it every time i use one of my shift registers. I only have one problem. Whenever I try to individually toggle on pin 8, it dosent work. I can do shifter.setAll(HIGH); to turn it on, but not shifter.setPin(8, HIGH); ( these both have the shifter.write(); after them. If anyone can help me with this problem, i will appreciate it very much

This is a rather long piece of test code i wrote so i can test this problem the Pin 8 problem is near the end-
Code: Select all
#include <Shifter.h>

#define SER_Pin 4 //SER_IN
#define RCLK_Pin 5 //L_CLOCK
#define SRCLK_Pin 6 //CLOCK

#define NUM_REGISTERS 1 //how many registers are in the chain


//initaize shifter using the Shifter library
Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);

void setup(){
shifter.clear();
shifter.write();
delay(100);
}

void loop(){

shifter.setPin(1, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(2, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(3, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(4, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(5, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(6, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(7, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(8, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setAll(HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

}
jreeve17
 
Posts: 3
Joined: Sat Dec 29, 2012 6:09 pm

My guess is that pin 7 (8 as you call it) works. But it is pin 0 that never turns on unless you call setAll because you never call it.
The pins like the arduino start at 0, not 1.

Shorter version of the same code
Code: Select all

#include <Shifter.h>

#define SER_Pin 4 //SER_IN
#define RCLK_Pin 5 //L_CLOCK
#define SRCLK_Pin 6 //CLOCK

#define NUM_REGISTERS 1 //how many registers are in the chain


//initaize shifter using the Shifter library
Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);

void setup(){
  shifter.clear();
  shifter.write();
  delay(100);
}

void loop(){


  for(int in = 0; i < 8; i ++){
    shifter.setPin(i, HIGH);
    shifter.write();
    delay(500);

    shifter.clear();
    shifter.write();
    delay(100);
  }

  shifter.setAll(HIGH);
  shifter.write();
  delay(500);

  shifter.clear();
  shifter.write();
  delay(100);

}








jreeve17 wrote:Hi, This is a great library that you have put together for this shift register and i will use it every time i use one of my shift registers. I only have one problem. Whenever I try to individually toggle on pin 8, it dosent work. I can do shifter.setAll(HIGH); to turn it on, but not shifter.setPin(8, HIGH); ( these both have the shifter.write(); after them. If anyone can help me with this problem, i will appreciate it very much

This is a rather long piece of test code i wrote so i can test this problem the Pin 8 problem is near the end-
Code: Select all
#include <Shifter.h>

#define SER_Pin 4 //SER_IN
#define RCLK_Pin 5 //L_CLOCK
#define SRCLK_Pin 6 //CLOCK

#define NUM_REGISTERS 1 //how many registers are in the chain


//initaize shifter using the Shifter library
Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);

void setup(){
shifter.clear();
shifter.write();
delay(100);
}

void loop(){

shifter.setPin(1, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(2, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(3, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(4, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(5, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(6, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(7, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setPin(8, HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

shifter.setAll(HIGH);
shifter.write();
delay(500);

shifter.clear();
shifter.write();
delay(100);

}
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

I'm looking to "read" multiple sensors, so I want to use the Shift-In register here https://www.sparkfun.com/products/11733. Your tutorial and library look like they would be a great help, but I was curious if you had any suggestions for using this material with a shift-in register.

Also, how are you using digital Pin 2 as the SCK?
jlzizmor
 
Posts: 1
Joined: Tue Jun 09, 2015 8:59 am

I don't think this code will help you with those parts. Check out http://playground.arduino.cc/Code/ShiftRegSN74HC165N

A clock (SCK) is just a pin that goes HIGH and LOW. I just tell the pin to go HIGH and LOW. Using the SCK from the SPI bus on the Arduino could make it faster since that pin can move HIGH/LOW a lot faster than other pins, but I liked being able to use it on any pin and the speed doesn't really matter too much for what I was doing.

jlzizmor wrote:I'm looking to "read" multiple sensors, so I want to use the Shift-In register here https://www.sparkfun.com/products/11733. Your tutorial and library look like they would be a great help, but I was curious if you had any suggestions for using this material with a shift-in register.

Also, how are you using digital Pin 2 as the SCK?
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Hello,

Bringing this post back to the top.

I'm currently working on a project which, at the end, I hope to have several clusters of LED lights cycle through patterns based on selected button presses.

Before I get there though, I'm trying to understand the basics of programming, thus splitting this project into smaller, more manageable portions.

Up do now, I have the following setup:
Arduino pro Mini (5V)
ULN2803 transistor
74HC595 shift register
8 LEDs
12V power supply.
L7805 Voltage regulator

Basically I have everything wired as shown http://labalec.fr/erwan/wp-content/uplo ... 03a_bb.png
Only difference is, the power source I'm using is 12v regulated by a L7805. Also, the pins to the shift register clock, latch, and serial are on different pins on my arduino.

Question: Where I'm stuck right now is, how do I implement the sample code (provided in the second post) for the "breathing" effect using millis() function?

Incorporating the blink without delay tutorial, I believe I have all of the elements and it compiles without error. However, the outcome I have is all 8 LEDs turned on.

My code is shown below. Your help is appreciated!

Code: Select all
#include <Shifter.h>

#define SER_Pin 10 //SER_IN

#define RCLK_Pin 11 //L_CLOCK

#define SRCLK_Pin 12 //CLOCK

#define NUM_REGISTERS 1 //how many registers are in the chain

long previousMillis = 0;
long interval = 500;

//initaize shifter using the Shifter library

Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);  

void setup() {

}

void loop() {

   shifter.clear(); //set all pins on the shift register chain to LOW

   shifter.write(); //send changes to the chain and display them
 
    unsigned long currentMillis = millis(); // start clock

    int middle = ((NUM_REGISTERS * 8) / 2); //center pin

    int randomNum = random (0, 4);

  if ((currentMillis - previousMillis) >= interval) {

    previousMillis = currentMillis; // reset clock

      for (int i = 0; i < randomNum; i++)

    {

          if ( i == LOW) {

            shifter.setPin(middle + i, HIGH);

            shifter.setPin(middle - i, HIGH);

            shifter.write(); //send changes to the chain and display them

      }

    }

  }
 else {

      for (int i = randomNum - 1; i >= 0; i--) {

          shifter.setPin(middle + i, LOW);

          shifter.setPin(middle - i, LOW);

          shifter.write(); //send changes to the chain and display them

    }
  }
}
louisdaboois
 
Posts: 2
Joined: Sun Aug 16, 2015 2:03 am

So using this code you can only turn them on or off. So you can't do an analog/breathing thing with it.

This person says you can do it using their code however: http://www.elcojacobs.com/shiftpwm/


louisdaboois wrote:Hello,

Bringing this post back to the top.

I'm currently working on a project which, at the end, I hope to have several clusters of LED lights cycle through patterns based on selected button presses.

Before I get there though, I'm trying to understand the basics of programming, thus splitting this project into smaller, more manageable portions.

Up do now, I have the following setup:
Arduino pro Mini (5V)
ULN2803 transistor
74HC595 shift register
8 LEDs
12V power supply.
L7805 Voltage regulator

Basically I have everything wired as shown http://labalec.fr/erwan/wp-content/uplo ... 03a_bb.png
Only difference is, the power source I'm using is 12v regulated by a L7805. Also, the pins to the shift register clock, latch, and serial are on different pins on my arduino.

Question: Where I'm stuck right now is, how do I implement the sample code (provided in the second post) for the "breathing" effect using millis() function?

Incorporating the blink without delay tutorial, I believe I have all of the elements and it compiles without error. However, the outcome I have is all 8 LEDs turned on.

My code is shown below. Your help is appreciated!

Code: Select all
#include <Shifter.h>

#define SER_Pin 10 //SER_IN

#define RCLK_Pin 11 //L_CLOCK

#define SRCLK_Pin 12 //CLOCK

#define NUM_REGISTERS 1 //how many registers are in the chain

long previousMillis = 0;
long interval = 500;

//initaize shifter using the Shifter library

Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);  

void setup() {

}

void loop() {

   shifter.clear(); //set all pins on the shift register chain to LOW

   shifter.write(); //send changes to the chain and display them
 
    unsigned long currentMillis = millis(); // start clock

    int middle = ((NUM_REGISTERS * 8) / 2); //center pin

    int randomNum = random (0, 4);

  if ((currentMillis - previousMillis) >= interval) {

    previousMillis = currentMillis; // reset clock

      for (int i = 0; i < randomNum; i++)

    {

          if ( i == LOW) {

            shifter.setPin(middle + i, HIGH);

            shifter.setPin(middle - i, HIGH);

            shifter.write(); //send changes to the chain and display them

      }

    }

  }
 else {

      for (int i = randomNum - 1; i >= 0; i--) {

          shifter.setPin(middle + i, LOW);

          shifter.setPin(middle - i, LOW);

          shifter.write(); //send changes to the chain and display them

    }
  }
}
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

ameyer wrote:So using this code you can only turn them on or off. So you can't do an analog/breathing thing with it.

This person says you can do it using their code however: http://www.elcojacobs.com/shiftpwm/


Thank you for the quick response ameyer.

I think I should phrase my question differently... "breathing" was not the right terminology

I'm not looking to use the code you provided with PWM having them fade in and out. What I'm trying to achieve is the exact same effect as your example, but without using the delay function.
louisdaboois
 
Posts: 2
Joined: Sun Aug 16, 2015 2:03 am

Ahh! Ok.

So I think you problem is most likely in this one line:
if ( i == LOW) {

LOW is just the same as 0.
So it will only trigger when i == 0, aka when the loop first starts.


louisdaboois wrote:
ameyer wrote:So using this code you can only turn them on or off. So you can't do an analog/breathing thing with it.

This person says you can do it using their code however: http://www.elcojacobs.com/shiftpwm/


Thank you for the quick response ameyer.

I think I should phrase my question differently... "breathing" was not the right terminology

I'm not looking to use the code you provided with PWM having them fade in and out. What I'm trying to achieve is the exact same effect as your example, but without using the delay function.
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Hi, am I right in thinking that as they share the same power line, you couldn't output individual analog values to each LED? Also, is there a way that you could use shift registers to read multiple analog inputs (from potentiometers for arguments sakes) ?
I have been using multiplexers in my project to expand the I/O ports of an uno to read/write analog values from sensors/to LEDs. The only drawback being that the mux I/Os can't receive power simultaneously (only the one which is selected), which means I have to very quickly cycle through all the pins, reading/writing one value at a time, which causes some minor timing issues when outputting pwm values.
Thanks - and great tutorial!
alexRowntree
 
Posts: 1
Joined: Fri Aug 28, 2015 9:31 am

Yes, the shift register uses a single power source. You can PWM the shift register pins and get an analog like value with this: http://www.elcojacobs.com/shiftpwm/

This shift register can no read values, but others can (like the 74HC165N) . HOWEVER... You still can not read multiple at the same time with them. They work very much like a mux in that way but worse. They will only read a digital value, so you just get back HIGH or LOW.


alexRowntree wrote:Hi, am I right in thinking that as they share the same power line, you couldn't output individual analog values to each LED? Also, is there a way that you could use shift registers to read multiple analog inputs (from potentiometers for arguments sakes) ?
I have been using multiplexers in my project to expand the I/O ports of an uno to read/write analog values from sensors/to LEDs. The only drawback being that the mux I/Os can't receive power simultaneously (only the one which is selected), which means I have to very quickly cycle through all the pins, reading/writing one value at a time, which causes some minor timing issues when outputting pwm values.
Thanks - and great tutorial!
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

I was curious if this program will work just fine with the TLC5916 shift register? I'd imagine so since the mechanics of that register are the same besides the ability to sink current.
psiewert
 
Posts: 1
Joined: Fri Apr 15, 2016 4:09 pm

:oops: Hello Builder Forum,

Connected 160 LEDS using the setup in the article titled
Arduino: Individually Control Shift Register Pins
using the code copied below and this setup
Imag

Working on using a PIR sensor (motion detector) to activate
the LED display. Getting flicker in the tenth thru twentieth
registers when the PIR sensor is introduced. The tech
at SparkFun said that one should not try to run more than
five or so LEDs using the 5volt Arduino power supply.
So a nine volt 650mA wall wart was connected using this setup

Imag

This caused all 160 LEDS to blink about twice a second. Using a nine volt
battery causes all the lights to come on and stay on.

Is it true that controlling one hundred LEDs overloads the Arduino voltage
regulator? If so how is the statement " That means if you have 1000 of
these chained together, you will be able to say “setPin 7,432 HIGH”,
and BAM! Just like that pin 7,432 goes HIGH." to be reconciled
with the idea that more five LEDs is an overload?

If this true how can power be supplied to 160 LEDs (the ultimate goal is 320
LEDs) and still be controlled by the Arduino?

Thanks.

Allen Pitts, Dallas Texas



Code: Select all

#include <Shifter.h>

#define SER_Pin 4 //SER_IN
#define RCLK_Pin 3 //L_CLOCK
#define SRCLK_Pin 2 //CLOCK

#define NUM_REGISTERS 20 //how many registers are in the chain
//initaize shifter using the Shifter library
Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);
unsigned long delaytime=100;
void setup(){
}
void loop(){
 shifter.clear(); //set all pins on the shift register chain to LOW
 shifter.write(); //send changes to the chain and display them
   delay(delaytime);

 for (int n = 0; n < 159 ; n++)
 {
 shifter.setPin(n, HIGH); //set pin 1 in the chain(second pin) HIGH
 shifter.write(); //send changes to the chain and display them
 //notice how you only call write after you make all the changes you want to make
  delay(delaytime);
  }
  shifter.setAll(HIGH); //Set all pins on the chain high
 shifter.write(); //send changes to the chain and display them
  delay(delaytime);
 }
allenpitts
 
Posts: 5
Joined: Sun Jan 11, 2015 7:44 pm

It should, yeah

psiewert wrote:I was curious if this program will work just fine with the TLC5916 shift register? I'd imagine so since the mechanics of that register are the same besides the ability to sink current.
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

The Arduino can source about 500ma from the 5V pin. So depending on your LEDs, that could be one, or a lot.

The registers should not be powered by anything above 7V according to the docs. You may kill them if you do.

But if you use a large power supply that is 7 (or less) volts, you should be able to power a whole lot of LEDs.

Iv'e personally used these to power a lot of 12V hights before before like this:

Screen Shot 2016-04-17 at 7.50.44 PM.png
Screen Shot 2016-04-17 at 7.50.44 PM.png (417.93 KiB) Viewed 4330 times





allenpitts wrote::oops: Hello Builder Forum,

Connected 160 LEDS using the setup in the article titled
Arduino: Individually Control Shift Register Pins
using the code copied below and this setup
Imag

Working on using a PIR sensor (motion detector) to activate
the LED display. Getting flicker in the tenth thru twentieth
registers when the PIR sensor is introduced. The tech
at SparkFun said that one should not try to run more than
five or so LEDs using the 5volt Arduino power supply.
So a nine volt 650mA wall wart was connected using this setup

Imag

This caused all 160 LEDS to blink about twice a second. Using a nine volt
battery causes all the lights to come on and stay on.

Is it true that controlling one hundred LEDs overloads the Arduino voltage
regulator? If so how is the statement " That means if you have 1000 of
these chained together, you will be able to say “setPin 7,432 HIGH”,
and BAM! Just like that pin 7,432 goes HIGH." to be reconciled
with the idea that more five LEDs is an overload?

If this true how can power be supplied to 160 LEDs (the ultimate goal is 320
LEDs) and still be controlled by the Arduino?

Thanks.

Allen Pitts, Dallas Texas



Code: Select all

#include <Shifter.h>

#define SER_Pin 4 //SER_IN
#define RCLK_Pin 3 //L_CLOCK
#define SRCLK_Pin 2 //CLOCK

#define NUM_REGISTERS 20 //how many registers are in the chain
//initaize shifter using the Shifter library
Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);
unsigned long delaytime=100;
void setup(){
}
void loop(){
 shifter.clear(); //set all pins on the shift register chain to LOW
 shifter.write(); //send changes to the chain and display them
   delay(delaytime);

 for (int n = 0; n < 159 ; n++)
 {
 shifter.setPin(n, HIGH); //set pin 1 in the chain(second pin) HIGH
 shifter.write(); //send changes to the chain and display them
 //notice how you only call write after you make all the changes you want to make
  delay(delaytime);
  }
  shifter.setAll(HIGH); //Set all pins on the chain high
 shifter.write(); //send changes to the chain and display them
  delay(delaytime);
 }
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Would the Shifter library work with a TPIC6B595. I would rather use these because I can directly control a relay and I already have boards made for them.
jeremiah.putnam
 
Posts: 2
Joined: Sun Apr 24, 2016 1:52 am

I'm guessing it would but I haven't tried it

jeremiah.putnam wrote:Would the Shifter library work with a TPIC6B595. I would rather use these because I can directly control a relay and I already have boards made for them.
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

So, I could use this to control individual inputs?

And example would be controlling relays in a vehicle. Let's say I have 4 relays set up. I have the code to turn on 3 of them, lets say on pins 2,4 and 5. Now I want to turn on the relay on pin 3, could I just turn that one on or would I also have to reissue the command to keep 2,4, and 5 up?
jeremiah.putnam
 
Posts: 2
Joined: Sun Apr 24, 2016 1:52 am

You can just turn on 3 without reissuing the command for 2,4,5

The code has all the states of every pin loaded in memory so when you change pin 3, it knows to keep 2,4,5 on for you


jeremiah.putnam wrote:So, I could use this to control individual inputs?

And example would be controlling relays in a vehicle. Let's say I have 4 relays set up. I have the code to turn on 3 of them, lets say on pins 2,4 and 5. Now I want to turn on the relay on pin 3, could I just turn that one on or would I also have to reissue the command to keep 2,4, and 5 up?
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Hello Bildr forum,

Working on an LED display to sequence 320 LEDs using the approach
outlined in article 'Arduino: Individually Control Shift Register Pins'
using Arduino Uno and SparkFun BOB-10860.

Pictorial of setup
Imag

Was hoping turn on all 320 LEDs at once but found
out only 30 could be turned on at a time. So have limited the
LEDS on simultaneously by turning off the first LED
when the 31st is set HIGH.

Have daisy chained 25 of the Sparkfun BOB-10860 and
it works perfectly. But when the 26th is added the LEDs on the
26th BOB (74HC595 break out board) immediately
begins blinking erratically.

You Tube of 26th IC
https://youtu.be/xAc26amrLzI

Tried substituting the 25th BOB for the 26th.
No joy. Tried turning on fewer LEDS and several
other troubleshooting approaches with no luck.

Any idea why the daisy chain won't extend?
The article says "you have 1000 of these chained together".
Just trying to do 40.

Thanks.

Allen Pitts, Dallas Texas

PS Animated gif of half of the desired display.
Http://www.allenpitts.com/electronics/Matt_22_37/Matt_22_37_anim_150626.gif
allenpitts
 
Posts: 5
Joined: Sun Jan 11, 2015 7:44 pm

This is actually a super easy fix. I limited it to 25 because I didn't think anyone would ever go higher. But it's not a real limit... I just did it to save ram.

In the file “Shifter.h” - change
Code: Select all
 byte _shiftRegisters[25];

to
Code: Select all
 byte _shiftRegisters[40];

Or however many you need.

You may be able to turn on more LEDs at once if you use a bigger power supply. I think.

I love this think by the way!!!!! The back is so cool!



allenpitts wrote:Hello Bildr forum,

Working on an LED display to sequence 320 LEDs using the approach
outlined in article 'Arduino: Individually Control Shift Register Pins'
using Arduino Uno and SparkFun BOB-10860.

Pictorial of setup
Imag

Was hoping turn on all 320 LEDs at once but found
out only 30 could be turned on at a time. So have limited the
LEDS on simultaneously by turning off the first LED
when the 31st is set HIGH.

Have daisy chained 25 of the Sparkfun BOB-10860 and
it works perfectly. But when the 26th is added the LEDs on the
26th BOB (74HC595 break out board) immediately
begins blinking erratically.

You Tube of 26th IC
https://youtu.be/xAc26amrLzI

Tried substituting the 25th BOB for the 26th.
No joy. Tried turning on fewer LEDS and several
other troubleshooting approaches with no luck.

Any idea why the daisy chain won't extend?
The article says "you have 1000 of these chained together".
Just trying to do 40.

Thanks.

Allen Pitts, Dallas Texas

PS Animated gif of half of the desired display.
Http://www.allenpitts.com/electronics/Matt_22_37/Matt_22_37_anim_150626.gif
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Hello Bldr forum Shift Register post'

Thanks to Ameyer and every one who has contributed info to this
post thread. I have learned a lot and continue to find
new ways to experiment with these ICs.

I got thrown a curve ball by the post that said
"if you have 1000 of these chained together, you will be
able to say “setPin 7,432 HIGH”, and BAM! Just like that pin 7,432 goes HIGH"
So I thought I could turn on hundreds of LEDs. But
what the author meant was one could control hundreds of LEDs
but only a dozen or so lights could be turned on at the same
time. The plan was to turn on 320 LEDs in sequence and have
all 320 turned on at the end of the sequence.

So I researched and learned about MOSFETs and put together
a design using field effect transistors to controls a larger
voltage and amperage than the Arduino could supply.

But I would be plunking down 320 individual transistors
and thought there might be an array that could be used in an IC.
That's when I found the ULN2803a in this same post thread.

I have seen some designs that have resistors between the 74HC595
outputs and the ULN2803 inputs and other that did not.
viewtopic.php?p=4830#p4830

The question is this. Can the BOB 10680
outputs be used to drive the ULN2803 inputs
without the 2.7k ohm resistors as shown the design
posted herewith below?

And a second question if I may. I know resistors are needed
between the 20 volt source and the LEDs but is
840 ohms enough?

At
https://www.sparkfun.com/tutorials/219
the idea offered is
VSource - VForward / ILed
In the case at hand a 20 volt source less
LED voltage forward, 3.3 v is 16.7 volts.
16.7 volts divided .002 amps results
in a resistor of 840 ohms.

Is this reasonable?

Thanks

Allen Pitts, Dallas Texas

Imag
allenpitts
 
Posts: 5
Joined: Sun Jan 11, 2015 7:44 pm

First off, you can get high power shift registers that have the transistors built into them. Like this: https://www.sparkfun.com/products/734


It all comes down to the current draw of the LED.
I'll assume the LEDs draw 20ma at 3.3v (the data sheet should tell you what it is). In this case you would want to use a 1k resistor with a 20v source. You can calculate the needed resistor here: http://led.linear1.org/1led.wiz

If you had a power supply that was 3.3v you could, in theory, not use any resistor. BUT... You will never find a power supply that is exactly 3.3v without fluctuating.

The problem with LEDs is that they have non-linear current draw with voltage change. Basically if you double the voltage you normally think that you then double the current (as is with a resistor). But LEDs are exponential, so a small change in voltage will cause a large change in current on the LED.

Long story short: If you need a 1K resistor, you can use something slightly larger than that (the LED will just be a little dim), but do not use anything under that because you will blow up the LED.


allenpitts wrote:Hello Bldr forum Shift Register post'

Thanks to Ameyer and every one who has contributed info to this
post thread. I have learned a lot and continue to find
new ways to experiment with these ICs.

I got thrown a curve ball by the post that said
"if you have 1000 of these chained together, you will be
able to say “setPin 7,432 HIGH”, and BAM! Just like that pin 7,432 goes HIGH"
So I thought I could turn on hundreds of LEDs. But
what the author meant was one could control hundreds of LEDs
but only a dozen or so lights could be turned on at the same
time. The plan was to turn on 320 LEDs in sequence and have
all 320 turned on at the end of the sequence.

So I researched and learned about MOSFETs and put together
a design using field effect transistors to controls a larger
voltage and amperage than the Arduino could supply.

But I would be plunking down 320 individual transistors
and thought there might be an array that could be used in an IC.
That's when I found the ULN2803a in this same post thread.

I have seen some designs that have resistors between the 74HC595
outputs and the ULN2803 inputs and other that did not.
viewtopic.php?p=4830#p4830

The question is this. Can the BOB 10680
outputs be used to drive the ULN2803 inputs
without the 2.7k ohm resistors as shown the design
posted herewith below?

And a second question if I may. I know resistors are needed
between the 20 volt source and the LEDs but is
840 ohms enough?

At
https://www.sparkfun.com/tutorials/219
the idea offered is
VSource - VForward / ILed
In the case at hand a 20 volt source less
LED voltage forward, 3.3 v is 16.7 volts.
16.7 volts divided .002 amps results
in a resistor of 840 ohms.

Is this reasonable?

Thanks

Allen Pitts, Dallas Texas

Imag
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Hello Bldr forum Shift Register post,

Working on a design for a display to light 320 LEDS
using Arduino, and shift register 74HC595. Immediately
ran into problems with the 5v 500mA supplied by the
Arduino. First cut back the number of LEDS that can be
on simultaneously to 48 although if there was some way
of increasing that number it would improve the design.

Have looked at several designs using ULN2803.
But ULN2803 uses current to control the IC and won't
take long to bump the max.

Found some articles on MOSFETS explaining that
they use voltage instead of current to open the gate to
higher voltage/amperage combination.
It my understanding that because the resistance
at the MOSFET gate is high that the voltage will be constant
across the 74HC595 outputs although the resistance from
the connections, and shift registers will probably limit the number
of 74HC595s that can be controlled with predictable result.

Based on research have drafted a design using the Arduino,
74HC595 (SparkFun BOB 10680) and MOSFET 2N7000.
Imag

The other concern is the size of the limiting resistors.
Every limiting resistor calculator seen says the upper limit
http://www.quickar.com/noqbestledcalc.htm
is 30-40 LEDs. But the circuit I am using now, which is powered
by the 5v 500mA from the Arduino, lights 48 LEDs at once in parallel
and is reliable until the number of LEDs in the circuit
get past 200 LEDs. Would not almost triple the voltage and
nine times the amps power more LEDs that what the Arduino
does now?

PS. While prepping to set this post a design was found at
http://bildr.org/2011/08/74hc595-breakout-arduino/
posted by ameyer Fri Mar 09, 2012 8:00 am
Imag
This design suggests using a separate power supply for
the 74HC595 ICs. So then there would be three power
supplies: 1. Wall wart supplied by Arduino. 2. A 7volt
supply for the 75HC595s. 3. A 19 volt running thru the
2n7000s for the LEDs

Sorry for the long post but I have been working on this for
over a year and this the third complete redesign.

So this actually three questions.
1. Will a separate 7 volt Vcc scale up run 40 74HC595s?
2. Will 150 ohms work to limit the current to the LEDs?
3. Does the overall design look viable particularly the
three power supply aspect?

Thanks

Allen
allenpitts
 
Posts: 5
Joined: Sun Jan 11, 2015 7:44 pm

I must not be reading this right. This seems like an incredibly simply design, but the text is so long and complicated so please forgive me if I am not seeing something.

Do not pay attention to that image you found, that is to control 3 separate register chains.

You just need a chain of the shift registers connected to transistor arrays to be 100% safe. You don't need a MOSFETs unless these are some MASSIVE LEDs you are driving. It really doesn't matter that the MOSTFET is triggered by voltage - That's true, but it doesn't matter. I also don't understand the 19v for the MOSFETs, you would need some major resistors if you used that high of a voltage. I don't know what that buys you either. I'm guessing that you thing the 19V allows you to power more LEDs at a time, but it won't. No matter what it looks like you are not chaining any LEDs. Each LED is being powered individually.

You can use a single power line, but I often use 2 - One fore the arduino over USB or whatever, and one for the shift registers. 5V is what the registers want, so 5v they get. The LEDs with a simple resistor can also be powered via 5v.



I think it should just work like this. (you could probably even get away with not using the transistors (the ULN2003a chips) but it will be a little safer this way in case you want to turn on all the LEDs at the same time.)

Screen Shot 2017-04-20 at 11.15.13 PM.png
Screen Shot 2017-04-20 at 11.15.13 PM.png (284.85 KiB) Viewed 199 times





allenpitts wrote:Hello Bldr forum Shift Register post,

Working on a design for a display to light 320 LEDS
using Arduino, and shift register 74HC595. Immediately
ran into problems with the 5v 500mA supplied by the
Arduino. First cut back the number of LEDS that can be
on simultaneously to 48 although if there was some way
of increasing that number it would improve the design.

Have looked at several designs using ULN2803.
But ULN2803 uses current to control the IC and won't
take long to bump the max.

Found some articles on MOSFETS explaining that
they use voltage instead of current to open the gate to
higher voltage/amperage combination.
It my understanding that because the resistance
at the MOSFET gate is high that the voltage will be constant
across the 74HC595 outputs although the resistance from
the connections, and shift registers will probably limit the number
of 74HC595s that can be controlled with predictable result.

Based on research have drafted a design using the Arduino,
74HC595 (SparkFun BOB 10680) and MOSFET 2N7000.
Imag

The other concern is the size of the limiting resistors.
Every limiting resistor calculator seen says the upper limit
http://www.quickar.com/noqbestledcalc.htm
is 30-40 LEDs. But the circuit I am using now, which is powered
by the 5v 500mA from the Arduino, lights 48 LEDs at once in parallel
and is reliable until the number of LEDs in the circuit
get past 200 LEDs. Would not almost triple the voltage and
nine times the amps power more LEDs that what the Arduino
does now?

PS. While prepping to set this post a design was found at
http://bildr.org/2011/08/74hc595-breakout-arduino/
posted by ameyer Fri Mar 09, 2012 8:00 am
Imag
This design suggests using a separate power supply for
the 74HC595 ICs. So then there would be three power
supplies: 1. Wall wart supplied by Arduino. 2. A 7volt
supply for the 75HC595s. 3. A 19 volt running thru the
f for the LEDs

Sorry for the long post but I have been working on this for
over a year and this the third complete redesign.

So this actually three questions.
1. Will a separate 7 volt Vcc scale up run 40 74HC595s?
2. Will 150 ohms work to limit the current to the LEDs?
3. Does the overall design look viable particularly the
three power supply aspect?

Thanks

Allen
ameyer
Founder
 
Posts: 3327
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Previous

Return to Blog Posts

Who is online

Users browsing this forum: No registered users and 1 guest

cron