8 digit 7 segment. LedControl() Help

hi, i'm new to arduino and programing in C in general, i have experience with web programing (php, html, css, sql.).

i have bought a 8 digit, 7 segment display from DX.com and am having some troubles getting it to work. it has 2x 74HC595D's and a 5 pin connector (VCC, GND, DIO, SCK, RCK).

i have hooked it up and able to send data to it as a pair of shift register with this code:

// Pin numbers
int rck = 30;
int sck = 50;
int dio = 40;

// Binary for 0 to 9
byte num[13]={B11000000, B11111001, B10100100, B10110000, B10011001, B10010010, B10000010, B11111000, B10000000, B10011000, B10001001, B10000110, B11000111};

// Positions
byte pos[8]={1, 2, 4, 8, 16, 32, 64, 128};

void setup() {
  pinMode(rck, OUTPUT);
  pinMode(sck, OUTPUT);
  pinMode(dio, OUTPUT);
}

void loop() {
    digitalWrite(rck, LOW);
    shiftOut(dio, sck, MSBFIRST, pos[0]);
    shiftOut(dio, sck, MSBFIRST, num[10]);
    digitalWrite(rck, HIGH); 
    digitalWrite(rck, LOW);
    shiftOut(dio, sck, MSBFIRST, pos[1]);
    shiftOut(dio, sck, MSBFIRST, num[11]);
    digitalWrite(rck, HIGH); 
    digitalWrite(rck, LOW);
    shiftOut(dio, sck, MSBFIRST, pos[2]);
    shiftOut(dio, sck, MSBFIRST, num[12]);
    digitalWrite(rck, HIGH); 
    digitalWrite(rck, LOW);
    shiftOut(dio, sck, MSBFIRST, pos[3]);
    shiftOut(dio, sck, MSBFIRST, num[12]);
    digitalWrite(rck, HIGH); 
    digitalWrite(rck, LOW);
    shiftOut(dio, sck, MSBFIRST, pos[4]);
    shiftOut(dio, sck, MSBFIRST, num[0]);
    digitalWrite(rck, HIGH);  
}

and it prints "HELLO".

the problem i am having is that i am trying to use the LedControl library to simplify writing numbers to the "screen" as i want to use it as a Tachometer/temp gauge/speedometer. for an off road buggy. and am getting confusing results with the demo sketch from the LedControl library (attached is an animated gif of what i get.)

//We always have to include the library
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(40,50,30,2);

/* we always wait a bit between updates of the display */
unsigned long delaytime=250;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
}


/*
 This method will display the characters for the
 word "Arduino" one after the other on digit 0. 
 */
void writeArduinoOn7Segment() {
  lc.setChar(0,0,'a',false);
  delay(delaytime);
  lc.setRow(0,0,0x05);
  delay(delaytime);
  lc.setChar(0,0,'d',false);
  delay(delaytime);
  lc.setRow(0,0,0x1c);
  delay(delaytime);
  lc.setRow(0,0,B00010000);
  delay(delaytime);
  lc.setRow(0,0,0x15);
  delay(delaytime);
  lc.setRow(0,0,0x1D);
  delay(delaytime);
  lc.clearDisplay(0);
  delay(delaytime);
} 

/*
  This method will scroll all the hexa-decimal
 numbers and letters on the display. You will need at least
 four 7-Segment digits. otherwise it won't really look that good.
 */
void scrollDigits() {
  for(int i=0;i<13;i++) {
    lc.setDigit(0,3,i,false);
    lc.setDigit(0,2,i+1,false);
    lc.setDigit(0,1,i+2,false);
    lc.setDigit(0,0,i+3,false);
    delay(delaytime);
  }
  lc.clearDisplay(0);
  delay(delaytime);
}

void loop() { 
  writeArduinoOn7Segment();
  scrollDigits();
}

any idea's what i'm doing wrong? as far as i can tell i am initializing LedControl correctly. LedControl(40,50,30,2);
i have tried all the combinations of the 3 pins but only this one gives anything at all. and i put the 2 as it's technically 2 shift registers instead of 1, but still only get the 1'st of the 2 4 segments to do anything.

btw, i am using a funduino mega 2560 if that is important at all.

7czit.gif

Hi mike16889,

You can't use that library with this display, they are incompatible. The library is for use with displays driven by max7219 chips. Your display is driven by 2 74hc595 chips.

Paul

That would explain it. Is there a library for the 74hc595? Or how diffrent are the 2 chips. Is it worth looking into modding the library to work?

A library to drive that particular display you bought? I doubt it.

The '595 is a basic, general purpose logic chip designed to turn serial data into parallel data. The '7219 is a special purpose chip designed to drive led displays. With almost all multi-digit led displays, multiplexing is used to reduce the complexity of the circuit. Multiplexing means lighting one digit at a time, in turn, but done so fast that the eye sees all the digits lit. The max7912 chip performs this multiplexing. The display you purchased relies on the Arduino to perform the multiplexing. The 595s simply reduce the number of outputs required to do this from 12 to 3.

I'm afraid you will probably have to do without a library. Not the end of the world for a reasonably experienced programmer. You will get lots of help here if you are willing to have a go at it yourself.

Paul

I am a little surprised and concerned about that display you purchased, after looking at the schematic. There are no series resistors to protect the segments, and no transistors to protect the 595 outputs that drive the digits. I would have expected it to be either very dim, unevenly lit, or just simply go pop as soon as switched on!

Perhaps someone more experienced can explain to us how/why it works.

Paul

no, it seems to run fine, the digits seem to be about as bright as i expect them to be, i have had the first 5 on continuously for about half hour. displaying "HELLO" and it seems to be fine. is it possible the 7 seg modules have the limiting resistors built in?

for now i have ordered a 4x20 char LCD from ebay that has plenty of documentation and i will be using that for my project, wish there was an lcd similar that was just a lot bigger so i could read it better when driving.

Hmm... is there some way you could mount one of the magnifier sheets in front of the lcd?

Paul

Its a posibility. I havent chosen a case or anything yet. And as its for a home built off road buggy its pritty flexible. Whats the image like threw one of them?

Ermmm... larger!

I did a library of sorts some time ago. You can download it from the library repository link in the signature block below. Hope it is useful for you as well.