Go Down

Topic: Control 8 x 7 Segment display. (Read 5071 times) previous topic - next topic

Nightwolf83

Hi Guys,

i want to control my  8x 7 Segment display
The display has 5 input pins VCC, GND, DIO, SCK, RCK.
What is the meaning of Pin SCK, RCK?
My Problem is I don't know how to control the 7 Segment Display.

For example:
I want to count the First Segment from 0-9.

I don't know how I can access the first 7 Segment Display

Enclosed a pic from my Segments.


Thanks!

Boffin1

You cant see the chip numbers, but they are likely to be 74HC595 shift registers.

Have a look at http://www.gammon.com.au/forum/?id=11518  from Nick Gammon

JoeN

I am going to take a wild guess here and say that is a 595 display just like the last guy.  So it is going to want 64 bits of data for the 64 segments.  Why not read up on ShiftOut and sent it FFFFFFFFFFFFFFFF (64 1 bits).  I bet it illuminates all the segments.  Then work it out which bit maps to what segment.

http://arduino.cc/en/Reference/shiftOut

See "For accompanying circuit, see the tutorial on controlling a 74HC595 shift register." about a page down.

Set latchPin to the Arduino pin you have RCK connected to.
Set clockPin to the Arduino pin you have SCK connected to.
Set dataPin to the Arduino pin you have DIO connected to.
I have only come here seeking knowledge. Things they would not teach me of in college.

Boffin1

If you use the ShiftOut circuit,  the capacitor on the latch line is wrong and should not be connected.

Nightwolf83


Thanks a lot for your help.

Now i can write "Hallo"  :)

But now i have the problem that only "o" will be displayed when i use the delay function.

My Code:
Code: [Select]

void loop()
{

digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,1);
  shiftOut(data,clock,MSBFIRST,B10001001);
  digitalWrite(latch,HIGH);
  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,2);
  shiftOut(data,clock,MSBFIRST,B10001000);
  digitalWrite(latch,HIGH);
  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,4);
  shiftOut(data,clock,MSBFIRST,B11000111);
  digitalWrite(latch,HIGH);
  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,8);
  shiftOut(data,clock,MSBFIRST,B11000111);
  digitalWrite(latch,HIGH);
  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,16);
  shiftOut(data,clock,MSBFIRST,B11000000);
  digitalWrite(latch,HIGH);
 
  delay(1000);

}


It works fine without delay function.




JoeN

#5
Jan 07, 2013, 06:45 pm Last Edit: Jan 07, 2013, 06:47 pm by JoeN Reason: 1
I am not sure why you are telling your shift register chain to latch before you have all the data out there.  I think by latching it every time with the delay you get the other letters displaying but only for an imperceptable amount of time and then O for a full second.  Without the delay you get all the letters showing for the same imperceptable amount of time but at  a 1/5 duty cycle which is why it works.  Try this, hopefully it works better:

Code: [Select]

void loop()
{
 digitalWrite(latch,LOW);
 shiftOut(data,clock,MSBFIRST,1);
 shiftOut(data,clock,MSBFIRST,B10001001);
 shiftOut(data,clock,MSBFIRST,2);
 shiftOut(data,clock,MSBFIRST,B10001000);
 shiftOut(data,clock,MSBFIRST,4);
 shiftOut(data,clock,MSBFIRST,B11000111);
 shiftOut(data,clock,MSBFIRST,8);
 shiftOut(data,clock,MSBFIRST,B11000111);
 shiftOut(data,clock,MSBFIRST,16);
 shiftOut(data,clock,MSBFIRST,B11000000);
 digitalWrite(latch,HIGH);
 
 delay(1000);
}

I have only come here seeking knowledge. Things they would not teach me of in college.

Nightwolf83

Hi JoeN,

thanks for the quick answer.

When i use your code only the last Segment is activ ("O" will be shown).


JoeN


Hi JoeN,

thanks for the quick answer.

When i use your code only the last Segment is activ ("O" will be shown).


Wow, sorry to lead you down the wrong path.  Gotta give that a think, not sure why it would behave that way.  Anyone else have a good idea here?
I have only come here seeking knowledge. Things they would not teach me of in college.

Boffin1

I dont get the

Code: [Select]
  shiftOut(data,clock,MSBFIRST,1);
  shiftOut(data,clock,MSBFIRST,B10001001);


I usually take the latch low, then pump through all the Bbytes and take the latch high again.

The bytes will be latched into the right registers...

Nightwolf83


Thanks for your help Boffin1.

when i use this code
Code: [Select]

  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,B10101010);
  shiftOut(data,clock,MSBFIRST,B11111001);
  digitalWrite(latch,HIGH);


every second Segment shows "1" this is correct but i want to control every single segment for example the first "1" the second "2" ....

I tried also this code

Code: [Select]

  digitalWrite(latch,LOW);
 
  shiftOut(data,clock,MSBFIRST,B10101010);
  shiftOut(data,clock,MSBFIRST,B11111001);
   shiftOut(data,clock,MSBFIRST,B01010101);
  shiftOut(data,clock,MSBFIRST,B10010000);
 
  digitalWrite(latch,HIGH);


Now i see the the other segments I think this is also correct, because i overwrite the first Bytes. I don't know how can i control every single Segment.




Boffin1

A segment refers to the one line of a 7 segment display ....   you are controlling every one of those individually with the 1s and 0s in the bitmap  B10000000  etc....

Quote
i want to control every single segment for example the first "1" the second "2" ....


If you mean you want the first digit to be "1"  and the second digit to be "2'" then depending on which way they have wired up the segments (  I will assume here a,b,c,d,e,f, dec.pt )

for a "1"  you would shiftout B01100000   ( only segments a and b on )

for a "2"   you would shiftout B110110100   ( only segments a, b d,e, and f on )

dcialdella


Sorry but could somebody show how connect the display?
(arduino? mega?)
I have the same.

thank you

dcialdella

#12
Nov 07, 2013, 09:25 am Last Edit: Nov 07, 2013, 09:32 am by dcialdella Reason: 1
I found I used the code




and the physical connection like this.
   http://arduino.cc/en/uploads/Reference/ICSPHeader.jpg


It work's in Arduino Mega R3.




#include <SPI.h>

const byte LATCH = 10;

const byte numberOfChips = 4;

byte LEDdata [numberOfChips];  // initial pattern

void refreshLEDs ()
  {
  digitalWrite (LATCH, LOW);
  for (byte i = 0; i < numberOfChips; i++)
    SPI.transfer (LEDdata );
    digitalWrite (LATCH, HIGH);
  } // end of refreshLEDs
 

void setup ()
{
  SPI.begin ();
}  // end of setup


void showPattern (const unsigned int p1, const unsigned int p2)
  {
  LEDdata
  • = highByte (p1);
      LEDdata [1] = lowByte  (p1);
      LEDdata [2] = highByte (p2);
      LEDdata [3] = lowByte  (p2);
      refreshLEDs ();
      delay (30);
      } // end of showPattern
     
    void loop ()
    {
    unsigned int pattern;

      pattern = 1;
      for (int i = 0; i < 16; i++)
        {
        showPattern (pattern, pattern);
        pattern <<= 1;
        }

      pattern = 0x8000;
      for (int i = 0; i < 16; i++)
        {
        showPattern (pattern, pattern);
        pattern >>= 1;
        }   

      pattern = 1;
      for (int i = 0; i < 16; i++)
        {
        showPattern (~pattern, ~pattern);
        pattern <<= 1;
        }

      pattern = 0x8000;
      for (int i = 0; i < 16; i++)
        {
        showPattern (~pattern, ~pattern);
        pattern >>= 1;
        }   
       
    }  // end of loop



arnakke

@Nightwolf83

From the code you post, I believe your display is a multiplexed common anode type with two latched shift registers.
The second shift register, the one you shift out to first, controls which digit is on. You can turn on multiple digits at the same time, but then they will all show the same digit. So for all practical purposes, it makes sense to activate just one at a time.
The first shift register, the one you shift out to second, controls which segments are on. Since this is the cathode part of the LED's, a zero means on, and a one means off. Your segments are organized as DP-G-F-E-D-C-B-A. Google seven segment display and look at the pictures if you don't know the naming of the segments. You could also change your shiftout to LSBFIRST and the segments would be ordered in the normal order.

Now, since you can only have one digit on at a time, you just need to change quickly between them. The memory of the cells in your eye means that you will perceive it as if they are all on, albeit a bit dimmer.
If you go over all the digits at frequency of 100 Hz or more you will get a nice flicker free display. You could use the timer1 or timer2 overflow interrupt to trigger the code that changes which digit is on. By default it runs at a frequency of 490 Hz. So with your 8 digits, the display will scan at a frequency of 490/8 = 61  Hz. It's a bit low, but it probably won't be too annoying to look at.

I'm working on a library to ease the use of seven segment displays. If you are interested I could write a driver for your display type and have you test it for me.

dcialdella


Sure.
Thank you.
I'm trying to understand how manage the display.

Go Up