Shop OBEX P1 Docs P2 Docs Learn Events
7 Segement DisplayHelp Needed — Parallax Forums

7 Segement DisplayHelp Needed

NWCCTVNWCCTV Posts: 3,629
edited 2014-09-08 20:05 in General Discussion
So I apparently purchased one of these at some point last year and I have no clue as to how to get it working. Can anyone point me in the right direction as to how to connect to a Prop BOE board and which driver I should use from the OBEX? Thanks for the help.
«1

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2014-08-22 23:37
    Search 595 in the obex. Is there a schematic?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-23 04:55
    I will contact seller about a schematic but chances are low,
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-23 10:59
    Andy, with a little trial and error, you could figure out how your board is wired.

    Try this program and let me know what it looks like on your display.
    CON                                          
      _clkmode = xtal1 + pll16x 
      _xinfreq = 5_000_000
    
    
      '' Pin Assignments
      
      SHIFT_REGISTER_DATA = 16
      SHIFT_REGISTER_CLOCK = 17
      SHIFT_REGISTER_LATCH = 18 
    
    
      DIGITS = 8
      MAX_DIGIT_INDEX = DIGITS - 1
      
      SEGMENTS = 8
      MAX_SEGMENT_INDEX = SEGMENTS - 1
      
      BITS_TO_SHIFT = SEGMENTS + DIGITS
      MAX_BIT_INDEX = BITS_TO_SHIFT - 1
      
    PUB Setup 
    '' This method starts in cog #0
    '' This method starts one additional cogs (serial driver).
    '' Presently there are six unused cogs.
    
    
      dira[SHIFT_REGISTER_DATA] := 1  
      dira[SHIFT_REGISTER_CLOCK] := 1
      dira[SHIFT_REGISTER_LATCH] := 1
    
    
      MainLoop
      
    PUB MainLoop | digit, activeBits
    
    
      repeat
        repeat digit from 0 to MAX_DIGIT_INDEX
          repeat result from 0 to MAX_SEGMENT_INDEX
            activeBits := 1 << result
            ShiftOutDigits(digit, activeBits)
            waitcnt(clkfreq / 4 + cnt)
            
    PUB ShiftOutDigits(digit, activeBits)
    
    
      digit := 1 << digit  ' set the digit bit high
      !digit ' invert the bits (only the digit bit will be low) comment this line out if all but one digit lights
      digit &= $FF ' only keep lowest 8 bits
      
      activeBits |= digit << SEGMENTS ' assuming the digits are the high bits
     
      repeat BITS_TO_SHIFT
        outa[SHIFT_REGISTER_DATA] := activeBits     
        outa[SHIFT_REGISTER_CLOCK] := 1
        outa[SHIFT_REGISTER_CLOCK] := 0
        activeBits >>= 1
      outa[SHIFT_REGISTER_LATCH] := 1
      outa[SHIFT_REGISTER_LATCH] := 0
    
    
    

    We're hoping only one segment lights up at a time but it will probably take a couple attempts to get the display to look the way we want.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-23 20:52
    Thanks Duane. I will give this a try. I would have done it today but as usual I got side tracked on another project.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-24 21:23
    @Duane, I did as you said. I was able to figure out the pin assignments pretty easily as you mentioned. However, I am not sure if the outcome is suppose to be this way or not.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-08-24 22:01
    Actually you might do better with calling it a 7-segment display for searches.. An LCD is a Liquid Crystal Display and completely different.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-24 22:09
    If my assumption of how the display was wired had been correct, you should have only seen a single segment at a time. Obviously I guessed wrong.

    Try change the line:
    ShiftOutDigits(digit, activeBits)
    

    to
    ShiftOutDigits(activeBits, digit)
    

    Don't change anything else and let me know what the display does.

    BTW, Loopy is correct about your display not being a LCD.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-24 22:36
    Now it does nothing at all.

    Edit: Title changed but posts staying the same!!!
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-25 07:56
    Try commenting out the line.
    !digit
    

    in both versions.
  • 72sonett72sonett Posts: 82
    edited 2014-08-25 14:05
    NWCCTV wrote: »
    ...no clue as to how to get it working.
    The (74HC)595 is an 8 bit shift register. Since there are 2x 595s and 8 displays it seems to me that one 595 is driving 4 multiplexed displays, so you'll have to send 4 bytes (1 byte for each display, 1 bit for each segment) to the 595 and power the right display on its common anode so it lights up... and keep doing that very rapidly. Same for the second 595 and its 4 displays.

    E.g see http://forum.arduino.cc/index.php/topic,16922.0.html
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-25 14:22
    72sonett wrote: »
    The (74HC)595 is an 8 bit shift register. Since there are 2x 595s and 8 displays it seems to me that one 595 is driving 4 multiplexed displays, so you'll have to send 4 bytes (1 byte for each display, 1 bit for each segment) to the 595 and power the right display on its common anode so it lights up... and keep doing that very rapidly. Same for the second 595 and its 4 displays.

    E.g see http://forum.arduino.cc/index.php/topic,16922.0.html

    What's not clear is which shift register controls the segments and which controls the digits.

    I initially guessed the display was a common cathode display but the video Andy made makes me think it's a common anode.
  • kwinnkwinn Posts: 8,697
    edited 2014-08-25 14:34
    With there being only two '595's on the board one is probably connected to the anodes and one to the cathodes of the leds.

    Shift out 8 zeros followed by 8 ones and record what happens. Do the same with 8 ones followed by 8 zeros. Post the results. One of the two should light one or more segments on some (probably all) of the digits.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-25 14:41
    Shift out 8 zeros followed by 8 ones and record what happens. Do the same with 8 ones followed by 8 zeros
    How do I do this?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-25 15:05
    NWCCTV wrote: »
    How do I do this?

    This is the part of the code that shifts out the bits.
      repeat BITS_TO_SHIFT
        outa[SHIFT_REGISTER_DATA] := activeBits     
        outa[SHIFT_REGISTER_CLOCK] := 1
        outa[SHIFT_REGISTER_CLOCK] := 0
        activeBits >>= 1
      outa[SHIFT_REGISTER_LATCH] := 1
      outa[SHIFT_REGISTER_LATCH] := 0
    

    To shift out 8 zeros followed by 8 ones you'd set activeBits to $FF00. To shift 8 ones followed by 8 zeros you'd set activeBits to $00FF (aka 256)
  • kwinnkwinn Posts: 8,697
    edited 2014-08-25 15:11
    Sorry, thought you had already worked out the connections from the uC to the display board pins. First use an ohmmeter to determine what pins on the '595's the input pins go to. The clock and clear should go to both, but the data to only one of them.

    ****** NEVER MIND. I see Dwayne has already answered the software part, and the board has the pins labelled.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-25 18:43
    OK Shifting the bits to 8 ones followed by 8 zeroes did nothing. 8 zeroes followed by 8 ones produce the attached video. Commenting out !digit did nothing.

    The clock and clear should go to both,
    What do you mean by this? Here is how I have it connected, DIO Pin 0, SCK Pin 1 and RCK Pin 2. I have tried using both 3.3V and 5V on a Boe Board with the same results. Duane had program running on 16,17 and 18 but I changed that.
  • JordanCClarkJordanCClark Posts: 198
    edited 2014-08-26 03:56
    Think I found a schematic for you.
    595 Driver LED Module.jpg
    1024 x 465 - 42K
  • 72sonett72sonett Posts: 82
    edited 2014-08-26 04:02
    Duane Degn wrote: »
    ...I initially guessed the display was a common cathode display but the video Andy made makes me think it's a common anode.
    On the display I think I can see CAI3461BH, the CA... to me suggests Common Anode, otherwise not much info googles up... :frown:
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-08-26 05:48
    72sonett wrote: »
    On the display I think I can see CAI3461BH, the CA... to me suggests Common Anode, otherwise not much info googles up... :frown:

    Google just the 3461 along with LED comes up the jackpot
  • 72sonett72sonett Posts: 82
    edited 2014-08-26 08:27
    kwinn wrote: »
    ... one is probably connected to the anodes and one to the cathodes...
    Think I found a schematic for you.
    ... jackpot

    Then the whole thing could look like this;
    2x4-7-SegmentDisplay.jpg
    1024 x 708 - 47K
  • JordanCClarkJordanCClark Posts: 198
    edited 2014-08-26 08:52
    Yep, I'm guessing my previous post was a bit subtle...:lol:
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-26 11:19
    I changed the program to correspond (I think) to the schematic Jordan posted in post #18.
    CON                                          
      _clkmode = xtal1 + pll16x 
      _xinfreq = 5_000_000
    
    
      '' Pin Assignments
      
      SHIFT_REGISTER_DATA = 0
      SHIFT_REGISTER_CLOCK = 1
      SHIFT_REGISTER_LATCH = 2
    
    
      DIGITS = 8
      MAX_DIGIT_INDEX = DIGITS - 1
    
    
      MAX_DISPLAYABLE = 99_999_999
      HIGH_DIGIT_DIVIDER = 10_000_000
      
      SEGMENTS = 8
      MAX_SEGMENT_INDEX = SEGMENTS - 1
      
      BITS_TO_SHIFT = SEGMENTS + DIGITS
      MAX_BIT_INDEX = BITS_TO_SHIFT - 1
    
    
      SEGMENT_A = 1 << 7
      SEGMENT_B = 1 << 6
      SEGMENT_C = 1 << 5
      SEGMENT_D = 1 << 4
      SEGMENT_E = 1 << 3
      SEGMENT_F = 1 << 2
      SEGMENT_G = 1 << 1
      SEGMENT_DP = 1 << 0
      
    VAR
    
    
      long shiftStack[32]
      long fourDigitNumber
    
    
      byte digitBits[DIGITS]
      
    PUB Setup 
    '' This method starts in cog #0
    '' This method starts one additional cogs (serial driver).
    '' Presently there are six unused cogs.
    
    
      
      cognew(MaintainDigits, @shiftStack)
      
      MainLoop
      
    PUB MainLoop | digit, activeBits
    
    
      repeat
        repeat fourDigitNumber from 0 to MAX_DISPLAYABLE
          waitcnt(clkfreq / 4 + cnt)
    
    
    PUB MaintainDigits | previousFourDigitNumber
    '' This method runs in its own cog. It will continuously
    '' display the value of "fourDigitNumber" on the 7-segment display.
    
    
      dira[SHIFT_REGISTER_DATA] := 1  ' direction settings need to be done within cog using the pins
      dira[SHIFT_REGISTER_CLOCK] := 1
      dira[SHIFT_REGISTER_LATCH] := 1
      
      previousFourDigitNumber := $7FFFFFFF ' some impossible number
      
      repeat
        if fourDigitNumber <> previousFourDigitNumber
          previousFourDigitNumber := fourDigitNumber
          BustDigits(fourDigitNumber)
               
        repeat result from 0 to MAX_DIGIT_INDEX
          ShiftOutDigits(result, digitBits[result])
      
    PUB BustDigits(numberToDisplay) | divisor
    
    
      numberToDisplay <#= MAX_DISPLAYABLE
      divisor := HIGH_DIGIT_DIVIDER
      
      repeat result from 0 to MAX_DIGIT_INDEX 
        digitBits[result] := bitsInNumber[numberToDisplay / divisor]
        numberToDisplay //= divisor
        divisor /= 10
        
    PUB ShiftOutDigits(digit, activeBits)
    
    
      case digit ' convert digit to bit position
        0..3:
          digit := 11 - digit    
        4..7:
          digit := 19 - digit 
        
      digit := 1 << digit  ' set the digit bit high
      !digit ' invert the bits (only the digit bit will be low) comment this line out if all but one digit lights
      digit &= $FF00 ' only keep top 8 bits
      activeBits &= $FF ' only keep bottom 8 bits
      
      activeBits |= digit  ' assuming the digits are the high bits
     
      repeat BITS_TO_SHIFT
        outa[SHIFT_REGISTER_DATA] := activeBits     
        outa[SHIFT_REGISTER_CLOCK] := 1
        outa[SHIFT_REGISTER_CLOCK] := 0
        activeBits >>= 1
      outa[SHIFT_REGISTER_LATCH] := 1
      outa[SHIFT_REGISTER_LATCH] := 0
    
    
    DAT
    
    
    bitsInNumber            byte SEGMENT_A | SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_E | SEGMENT_F  '0
                            byte SEGMENT_B | SEGMENT_C  '1
                            byte SEGMENT_A | SEGMENT_B | SEGMENT_D | SEGMENT_E | SEGMENT_G '2
                            byte SEGMENT_A | SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_G '3
                            byte SEGMENT_B | SEGMENT_C | SEGMENT_F | SEGMENT_G '4
                            byte SEGMENT_A | SEGMENT_C | SEGMENT_D | SEGMENT_F | SEGMENT_G '5
                            byte SEGMENT_A | SEGMENT_C | SEGMENT_D | SEGMENT_E | SEGMENT_F | SEGMENT_G '6
                            byte SEGMENT_A | SEGMENT_B | SEGMENT_C '7
                            byte SEGMENT_A | SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_E | SEGMENT_F | SEGMENT_G '8
                            byte SEGMENT_A | SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_F | SEGMENT_G '9
    
    
    

    I have not tested it. It's very unlikely it will work since there are so many things I could have gotten wrong.

    In theory, the program will show numbers starting at zero and count up to 99,999,999.

    The method "MaintainDigits" should keep the display updated. Any of the other cogs can change the value displayed by changing the value of the global variable "fourDigitNumber".

    There isn't any provision for the decimal point.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-26 11:24
    72sonett wrote: »
    Then the whole thing could look like this;
    2x4-7-SegmentDisplay.jpg

    Your schematic doesn't agree with the one Jordan posted. You assume they would number the displays in a logical order. According to the other schematic, digit #0 is the left most digit of the display on the right. So the digits are numbered 4, 5, 6, 7, 0, 1, 2, 3.
  • kwinnkwinn Posts: 8,697
    edited 2014-08-26 11:57
    72sonett wrote: »
    Then the whole thing could look like this;
    2x4-7-SegmentDisplay.jpg

    Yes it could, but since Peter seems to have found the data sheet for the display it is simpler to use an ohmmeter to see what output pins on the '595's go to what pins on the displays. That video of the display output was not what I expected to see.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-26 12:09
    kwinn wrote: »
    Yes it could, but since Peter seems to have found the data sheet for the display it is simpler to use an ohmmeter to see what output pins on the '595's go to what pins on the displays. That video of the display output was not what I expected to see.

    I just went by the schematic Jodan posted. I assumed the anodes were at the top and cathodes at the bottom, but if the datasheet Peter found is correct, then the anodes and cathodes are reversed.

    This is an easy fix to the program. In the "ShiftOutDigits" method, add a "not" opperator.

    Change:
      activeBits |= digit  ' assuming the digits are the high bits
     
      repeat BITS_TO_SHIFT
    

    to
      activeBits |= digit  ' assuming the digits are the high bits
     
     [B] !activeBits[/B]
    
      repeat BITS_TO_SHIFT
    

    This will reverse the bits and swap the anodes with cathodes.
  • kwinnkwinn Posts: 8,697
    edited 2014-08-26 13:02
    I expected that when shifting out 8 ones followed by 8 zeroes and then 8 zeroes followed by 8 ones would result in all segments and DP being lit by one of them and a blank display by the other. Obviously it is not connected as I thought.

    I did not expect what the video shows. Perhaps try shifting out 16 bits at a time with only two bits high, toggle the load output, pause for one second, then shift the high bits one position and repeat. This might tell us more.

    That is, start with a word variable set to 3 and rotate one position each time.
  • 72sonett72sonett Posts: 82
    edited 2014-08-26 13:12
    Duane Degn wrote: »
    Your schematic doesn't agree with the one Jordan posted.
    I've changed the numbering and, although I did not see them on the original eBay picture, added the second connector and 'power on' LED.

    2x4-7-SegmentDisplay1,1.jpg
    1024 x 708 - 51K
  • kwinnkwinn Posts: 8,697
    edited 2014-08-26 15:28
    72sonett wrote: »
    I've changed the numbering and, although I did not see them on the original eBay picture, added the second connector and 'power on' LED.

    2x4-7-SegmentDisplay1,1.jpg

    If that doesn't work you can try the attached program. Away from my bench so it is not tested but it should shift 2 consecutive bits through the 16 '595 outputs.

    BTW

    The program Duane posted in post #4 (video in post #6) turned on all 7 segments and DP sequentially which should tell us something.

    Shifting out 8 zeros followed by 8 ones in post #17 turned on 6 of 7 segments starting with segment a off followed by b, c, d, e, f, g, and DP going off. Another clue.

    Cannot seem to upload or even see the file as a .spin, .txt, or .zip file so I will post it here.

    CON                     
                         
      _clkmode = xtal1 + pll16x 
      _xinfreq = 5_000_000
    
    ' Pin Assignments
    Data = 0
    Clock = 1
    Latch = 2
    
    ' Data to shift out
    DataBits = 3 
    
    
    VAR
    
    word    DataOut
      
    PUB Main
    
    ' Setup I/O pins for output
    
      dira [Data] := 1  
      dira [Clock] := 1
      dira [Latch] := 1
    
    ' Main routine
    
        DataOut := DataBits         
    
      repeat
          ShiftBits                 ' Output 16 bits to the 2 '595's and display them
          DataOut <-= 1             ' Shift the data 
          waitcnt(clkfreq / 4 + cnt)' Pause so pattern is visible
            
    PUB ShiftBits
    
      
        repeat 16                   ' Shift out 16 bits
          outa [Data] := DataOut     
          outa [Clock] := 1
          outa [Clock] := 0
          DataOut >>= 1
          
        outa [Latch] := 1             ' Transfer data to the '595 output registers
        outa [Latch] := 0
    
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-26 21:21
    Results of Duane's code. I will try kwinn's on Wednesday.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-26 21:29
    @kwinn, code does nothing. Nothing lights up.
Sign In or Register to comment.