Pages: [1]   Go Down
Author Topic: Arduino + Shift register + 4 digit 7 seg. display and only can get 8 to display?  (Read 834 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried wiring it up using essentially this:
http://arduino.cc/en/tutorial/ShiftOut

I'm using this display:
https://www.sparkfun.com/products/9482
and a 74HC595 shift register.
The output pins of the register go to a 220 Ohm resistor and from there to the individual segments on the display.I only have one of the digit pins powered up(I plan on running  all four of them through a transistor in the future), through another 220 ohm resistor. So the whole digit get's 5V, through resistor, and the individual segments are put to ground from the shift register.Set LOW that is, if I set HIGH nothing happens. Sparkfun says it's common anode display and the code says set HIGH for common anode, but again nothing happens. I'm using the pineapple library from sparkfun's page and the example code.
https://github.com/Qtechknow/Arduino-Libraries/tree/master/Pineapple

I've tried a few different examples, the demo and the serial one and both only give me the number 8 up solid the whole time. So what's the deal here? What am I doing that's making only 8 display. Here is the demo one:
Code:
/* Pineapple Demo

Demonstrates the use of the Pineapple library with a 74HC595 shift register and
a 7-Segment display.  Credits for the library go to Quin, or Qtechknow, Adam
Meyer of Bildr, and Arduino forum member lloyddean.

created on 18 Apr 2012
made by Qtechknow (Quin)
*/

#include "Pineapple.h"

int serial = 4;  // shifte register, serial pin
int registerClock = 3;  // shift register, register clock
int serialClock = 2;  // shift register, clock

int numberofRegisters = 1;    // how many registers?

Pineapple pineapple;     // initialize the library

void setup() {
  pineapple.segmentPins(0, 1, 2, 3, 4, 5, 6, 7,LOW);  // set high for common anode, and low for common cathode
  pineapple.registerPins(serial, registerClock, serialClock, numberofRegisters);
}

void loop() {
  for(int i=0; i<10; i++) {
  pineapple.write(i);
  delay(500);
  }
}
Logged

Offline Offline
Sr. Member
****
Karma: 11
Posts: 467
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
pineapple.segmentPins(int a, int b, int c, int d, int e, int f, int g, int dp, boolean common)
      Declares the segment pins and the common anode or the common cathode.  Set the boolean common HIGH for a common anode display and LOW for a common cathode display.  For the segment pin numbers, set to 0 - 7 for the first shift register, 8-15 for the next, and so on.
Other than that, I've never used the Pineapple library, so I can't help you. I tend to avoid libraries for something as simple as a shift register anyway and write my own driver.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8842
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should not have current limiting resistors on the common (digit) pin, only on the individual (segment) pins.

If my understanding is correct, you have the common anode for one digit connected to +5V (through an unnecessary resistor).  The cathodes for the segments go through a current limiting resistor to the outputs of the 74HC595 shift register.  Taking the pins LOW should turn on the connected segment.  Perhaps the shift register isn't getting power and all of the segments are being grounded through the chip.  That would cause all the segments to light up.

Are you sure you have MR (Master Reset) pulled HIGH and OE (Output Enable) pulled low?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
pineapple.segmentPins(int a, int b, int c, int d, int e, int f, int g, int dp, boolean common)
      Declares the segment pins and the common anode or the common cathode.  Set the boolean common HIGH for a common anode display and LOW for a common cathode display.  For the segment pin numbers, set to 0 - 7 for the first shift register, 8-15 for the next, and so on.
Other than that, I've never used the Pineapple library, so I can't help you. I tend to avoid libraries for something as simple as a shift register anyway and write my own driver.

I've tried to figure out how to write my own code for a shift register and it's very confusing to me. I'm not sure where to start. I'm still pretty new to coding in general. :/

Also, it turns on (all segments only) with low and stays off with high...neither of which are what i'm looking for.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should not have current limiting resistors on the common (digit) pin, only on the individual (segment) pins.

If my understanding is correct, you have the common anode for one digit connected to +5V (through an unnecessary resistor).  The cathodes for the segments go through a current limiting resistor to the outputs of the 74HC595 shift register.  Taking the pins LOW should turn on the connected segment.  Perhaps the shift register isn't getting power and all of the segments are being grounded through the chip.  That would cause all the segments to light up.

Are you sure you have MR (Master Reset) pulled HIGH and OE (Output Enable) pulled low?

I took out the resistors, thank you for that. I wasn't too sure about that. I verified everything you said and it's all wired up right. I check the SER, RCLK, and SRCLK pins all are getting constant 5V from the Arduino...do you think it's only perceived 5V because it's flashing so fast or does that indicate the code isn't working right?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8842
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would expect the register clock to be pulsed low every half second and the serial clock to be pulsed low eight times every half second.  The pulses may be too short to detect with a multimeter.  Do you know anyone with an oscilloscope?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would expect the register clock to be pulsed low every half second and the serial clock to be pulsed low eight times every half second.  The pulses may be too short to detect with a multimeter.  Do you know anyone with an oscilloscope?

No, and...ah, ha! At last, a reason to buy an oscilloscope. lol I think we have some just laying around at my school...perhaps I could persuade them to put them on indefinite loan to me. I'm going to see if I can't change the code to just pulse slower so that I can see it.  Also, an analog multimeter should be able to detect that, right?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8842
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm going to see if I can't change the code to just pulse slower so that I can see it.  Also, an analog multimeter should be able to detect that, right?

As long as the pulses are longer than a couple hundred milliseconds the multimeter should show a dip.  I'm guessing that currently the pulses are closer to 10 microseconds (1/100th of a millisecond).

For about $15 you can get an 24 MHz 8-bit USB logic analyzer.  For example:
http://www.ebay.com/itm/Compatible-with-Saleae-USB-Logic-24MHz-8Ch-Logic-Analyzer-Supports-1-1-15-USA-/261496674835?pt=LH_DefaultDomain_0&hash=item3ce26a9a13
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: