More output pins on UNO?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
tlhIngan
 
Posts: 11
Joined: Thu Nov 24, 2011 2:18 pm

Re: More output pins on UNO?

Post by tlhIngan »

philba wrote:Sigh. You went to some effort to post the video but didn't post the code or some sort of schematic diagram. The video doesn't tell us much at all. If the SRs are wired up correctly, then it's your code. You should post that. (use the code tag)
Here are the 4 code samples I've been trying. They are not my own creation, I've found them here and there for 74HC595 Arduino applications.

1st one.

Code: Select all

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

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

//do not touch
#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

void setup(){
  pinMode(SER_Pin, OUTPUT);
  pinMode(RCLK_Pin, OUTPUT);
  pinMode(SRCLK_Pin, OUTPUT);

  //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(SRCLK_Pin, LOW);

    int val = registers[i];

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

  }
  digitalWrite(RCLK_Pin, HIGH);

}

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

void loop(){

  setRegisterPin(2, LOW);
  setRegisterPin(3, LOW);
  setRegisterPin(4, LOW);
  setRegisterPin(5, LOW);
  setRegisterPin(6, HIGH);
  setRegisterPin(7, LOW);

  writeRegisters();  //MUST BE CALLED TO DISPLAY CHANGES
  //Only call once after the values are set how you need.
}
2nd one.

Code: Select all

int latchPin = 9;             //595 pin 12
int clockPin = 10;          //595 pin 11
int dataPin = 8;           //595 pin 14
//595 pin 16 connected to 5VDC
//595 pin 8 connected to GND

void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
  digitalWrite(latchPin, LOW);      //When the latchPin goes from low to high, the data gets moved from the shift registers to the output pins
  shiftOut(dataPin, clockPin, MSBFIRST, B10101010);     //Using the shiftOut function to send binary 11111111 to light all LEDs.  You can change from 1 to 0 to turn off.
  digitalWrite(latchPin, HIGH);   // Move the data from shift registers to output pins
/*  delay(5000); // wait 5 seconds, then go back to the top of loop */
}
3rd one.

Code: Select all

// This pin gets sets low when I want the 595 to listen
const int  pinCommLatch = 9;

// This pin is used by ShiftOut to toggle to say there's another bit to shift
const int  pinClock     = 10;

// This pin is used to pass the next bit
const int  pinData    = 8;

void setup()
{
  pinMode (pinCommLatch, OUTPUT);
  pinMode (pinClock, OUTPUT);
  pinMode (pinData, OUTPUT);
  
  //Serial.begin (56600);
} // setup

void sendSerialData2 (
  byte  value)
{
  // Signal to the 595 to listen for data
  digitalWrite (pinCommLatch, LOW);
  digitalWrite (pinClock, LOW);
  digitalWrite (pinData, LOW);
  digitalWrite (pinData, HIGH);
  digitalWrite (pinClock, HIGH);
  // Signal to the 595 that I'm done sending
  digitalWrite (pinCommLatch, HIGH);
}  // sendSerialData2
  
void loop()
{
  byte counter;
  sendSerialData2 (counter);
} // loop
4th one.

Code: Select all

// This pin gets sets low when I want the 595s to listen
const int  g_pinCommLatch = 9;

// This pin is used by ShiftOut to toggle to say there's another bit to shift
const int  g_pinClock     = 10;

// This pin is used to pass the next bit
const int  g_pinData    = 8;

// Number of shift registers in use
const int g_registers = 3;

// Array of numbers to pass to shift registers
byte g_registerArray [g_registers];

void setup()
{
  pinMode (g_pinCommLatch, OUTPUT);
  pinMode (g_pinClock, OUTPUT);
  pinMode (g_pinData, OUTPUT);
  
  Serial.begin (56600);
  
} // setup

// Simple function to send serial data to one or more shift registers by iterating backwards through an array.
// Although g_registers exists, they may not all be being used, hence the input parameter.
void sendSerialData (
  byte registerCount,  // How many shift registers?
  byte *pValueArray)   // Array of bytes with LSByte in array [0]
{
  // Signal to the 595s to listen for data
  digitalWrite (g_pinCommLatch, LOW);
  
  for (byte reg = registerCount; reg > 0; reg--)
  {
    byte value = pValueArray [reg - 1];
    
    for (byte bitMask = 128; bitMask > 0; bitMask >>= 1)
    {
      digitalWrite (g_pinClock, LOW);
    
      digitalWrite (g_pinData, value & bitMask ? HIGH : LOW);
        
      digitalWrite (g_pinClock, HIGH);
    }
  }
  // Signal to the 595s that I'm done sending
  digitalWrite (g_pinCommLatch, HIGH);
}  // sendSerialData

void loop()
{
  g_registerArray[0]=255;
  g_registerArray[1]=128;
  g_registerArray[2]=4;
  sendSerialData (g_registers, g_registerArray);
  delay(1000);
} // loop

Magician
 
Posts: 19
Joined: Fri May 06, 2011 10:48 pm

Re: More output pins on UNO?

Post by Magician »

Do you have a 1 uF cap? If yes, remove it.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: More output pins on UNO?

Post by adafruit_support_rick »

3rd code sample is obviously wrong. sendSerialData2 ignores the input value, and only sends 1 bit.

Also, looking at some of your loops, it's conceivable that you're not holding the data clock high long enough. See if a brief delay after setting serial clock HIGH helps any.

User avatar
floresta
 
Posts: 223
Joined: Thu Jul 31, 2008 10:27 am

Re: More output pins on UNO?

Post by floresta »

And you are correct, the pins on my drawing are not in standard position: I moved them around (on the drawing only) to make the drawing simpler. I had this printout in front of me while soldering.
And that is precisely the difference between a schematic diagram and a wiring diagram.

On a schematic diagram the connections are rearranged to make it easy to follow the signal flow. Ideally you want the input on the left and the output on the right. The devices are represented by generic shapes, circles for transistors (and tubes) and rectangles for most other devices. Bridge circuits are squares rotated 45 degrees, etc. The locations where the wires connect to these shapes bears no relation to their actual location on the device. Usually all or most of the signal wires are shown and few or none of the power connections are shown.

On a wiring diagram the devices are represented by shapes that are similar to the actual devices. The locations where the wires connect to these shapes are the same as on the real devices. Usually all of the signal wires are shown although they may be grouped together and shown as a thick 'bus'. These diagrams, which used to be used primarily in the power segment, are now quite common as they are helpful in designing printed circuit boards.

From this description you should be recognize the the so called 'schematic' diagrams produced by Eagle are much more closely related to 'wiring' diagrams and the use of the word schematic to describe them makes anyone who studied or taught Technical Drafting cringe.

Don

tlhIngan
 
Posts: 11
Joined: Thu Nov 24, 2011 2:18 pm

Re: More output pins on UNO?

Post by tlhIngan »

Magician wrote:Do you have a 1 uF cap? If yes, remove it.
I do have that capacitor in there and I can definitely remove it.
What is it doing anyway? Noise filtering?

tlhIngan
 
Posts: 11
Joined: Thu Nov 24, 2011 2:18 pm

Re: More output pins on UNO?

Post by tlhIngan »

driverblock wrote:3rd code sample is obviously wrong. sendSerialData2 ignores the input value, and only sends 1 bit.
Yeah, the original code was doing some weird bit-logic thing, and I couldn't tell which LEDs were supposed to come on, so I made those changes.
driverblock wrote:Also, looking at some of your loops, it's conceivable that you're not holding the data clock high long enough. See if a brief delay after setting serial clock HIGH helps any.
That is a great idea, I'll try that.

tlhIngan
 
Posts: 11
Joined: Thu Nov 24, 2011 2:18 pm

Re: More output pins on UNO?

Post by tlhIngan »

How do I tell if my 595's have been blown by the Arduino on power-up as has been suggested?
Is there a continuity test I can do on the chip?

Magician
 
Posts: 19
Joined: Fri May 06, 2011 10:48 pm

Re: More output pins on UNO?

Post by Magician »

And that is precisely the difference between a schematic diagram and a wiring diagram.
Yes, I was aware there is some simplification acceptable on the drawings, but video clip what confused me, I couldn't get why resistor coming directly to pin 8. Probably, just for aesthetic outlook -);
Anyway, I'm working myself on the display with 74HC595 right now, so far I was able to run chain of 3 registers (will be more), and they all buffered with ULN2803 at the outputs to operate with +12V RGB strip. Board arduino Uno. Code taken from here:
http://www.arduino.cc/cgi-bin/yabb2/YaB ... 251011/all I'll modify it later for my needs, but for now I run it "out of the box" and it works perfectly. No resistors on pin 10 or 13, no capacitor, hardware set-up same as you posted above (except buffers), or on this link: http://bildr.org/2011/02/74hc595/

tlhIngan
 
Posts: 11
Joined: Thu Nov 24, 2011 2:18 pm

Re: More output pins on UNO?

Post by tlhIngan »

I've removed the capacitor and I've added delays in the output phase, still no change in behavior.

Code: Select all

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

#define number_of_74hc595s 3 
#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

void setup(){
  pinMode(SER_Pin, OUTPUT);
  digitalWrite(SER_Pin, LOW);
  pinMode(RCLK_Pin, OUTPUT);
  digitalWrite(RCLK_Pin, LOW);
  pinMode(SRCLK_Pin, OUTPUT);
  digitalWrite(SRCLK_Pin, LOW);
  clearRegisters();
  writeRegisters();
}               

void clearRegisters(){
  for(int i = numOfRegisterPins - 1; i >=  0; i--){
     registers[i] = LOW;
  }
} 

void setRegisters(){
  for(int i = numOfRegisterPins - 1; i >=  0; i--){
     registers[i] = HIGH;
  }
} 

void writeRegisters(){

  digitalWrite(RCLK_Pin, LOW);
  delay(50);

  for(int i = numOfRegisterPins - 1; i >=  0; i--){
    digitalWrite(SRCLK_Pin, LOW);
    delay(50);
    int val = registers[i];
    digitalWrite(SER_Pin, val);
    delay(50);
    digitalWrite(SRCLK_Pin, HIGH);
    delay(50);
  }
  digitalWrite(SRCLK_Pin, LOW);
  delay(50);
  digitalWrite(RCLK_Pin, HIGH);
  delay(50);
  digitalWrite(RCLK_Pin, LOW);
  delay(50);

}

void setRegisterPin(int index, int value){
  registers[index] = value;
}

void loop(){

/*  setRegisterPin(1, HIGH);
  setRegisterPin(2, LOW);
  setRegisterPin(3, HIGH);
  setRegisterPin(4, LOW);
  setRegisterPin(5, HIGH);
  setRegisterPin(6, LOW);
  setRegisterPin(7, HIGH);*/
  clearRegisters();
  writeRegisters();
  delay(1000);
  setRegisters();
  writeRegisters();
  delay(1000);
  
}
Are my 595s fried?
How can I test them?

tlhIngan
 
Posts: 11
Joined: Thu Nov 24, 2011 2:18 pm

Re: More output pins on UNO?

Post by tlhIngan »

I've tested the following with a multimeter.

Arduino: +5V pin to GND pin, I get ~5V
All 3 595s: both power pins to both grounded pins, I get ~5V for all 4 possible combinations

595 output pins to common ground: 1st chip in the chain, I get ~0.3V for each of the 8 output pins, the 2nd and 3rd chips I get 0.00V for each of the 8 output pins.

595 grounded pins to common ground: All 0.00V, except the GND pin of the 1st chip, which reads ~0.3V. How can this happen?

595s Clock pins to common ground: reading fluctuates between 1 and 2 V in the current program.

595s Latch pins to common ground: I get a "pulse" at regular intervals in the current program.

595s Data pins to common ground: 1st and 3rd chips read 0.00V, 2nd chip reads ~0.3V in the current program.

595s Serial out to common ground: 1st chip reads ~0.3V, 2nd and 3rd chips read 0.00V in the current program.

Is my 1st chip burnt out?

tlhIngan
 
Posts: 11
Joined: Thu Nov 24, 2011 2:18 pm

Re: More output pins on UNO?

Post by tlhIngan »

Found it!
I had a discontinuity between the data pin of the 1st 595 and the wire going to it.
I redid that soldering joint, now the LEDs light on command.
I removed all the delays and it still works.

Thanks for all the replies!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”