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

7 Segement DisplayHelp Needed

2»

Comments

  • 72sonett72sonett Posts: 82
    edited 2014-08-26 23:26
    NWCCTV wrote: »
    ... I have tried using both 3.3V and 5V
    In the AVI the displays seem very bright to me... :cool:
    There are no current limiting resistors on the board or in the schematic. 5 V should not be a problem once the program is OK as then each digit should only on for max 1/8 of the time, a segment even less, but while you are testing the program it would probably be safer to use 3.3 V and even then make sure that a display is not on for too long or it might burn out.

    I do not speak Spin, but in a BS2 my trial program would look like this;
    ' 2x4 7 segment display using 74HC595 shift register
    '
    ' http://forums.parallax.com/showthread.php/157074-7-Segement-DisplayHelp-Needed
    '
    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}
    '
    DIOpin   PIN 0     ' DS   (Data Serial)
    CLKpin   PIN 1     ' SHCP (Shift Clock Pulse)
    LATCHpin PIN 2     ' STCP (Storage Clock Pulse)
    '
    ' digits:     12345678   2x4 digits Common Anode 7 segment display
    digit1   CON %10000000 ' digit 1 high = on, others low = off
    digit2   CON %01000000 ' digit 2 on
    digit3   CON %00100000 ' digit 3 on
    digit4   CON %00010000 ' digit 4 on
    digit5   CON %00001000 ' digit 5 on
    digit6   CON %00000100 ' digit 6 on
    digit7   CON %00000010 ' digit 7 on
    digit8   CON %00000001 ' digit 8 on
    '
    ' segments:
    '    --a--
    '    |   |
    '    f   b
    '    |   |
    '    --g--
    '    |   |
    '    e   c
    '    |   |
    '    --d--  .dp
    '
    '             abcdefgp
    zero     CON %00000011  ' segments abcdef low = '0'
    one      CON %10011111  ' segments bc     low = '1'
    two      CON %00100101  ' segments abged  low = '2'
    three    CON %01100001  ' segments afged  low = '3'
    four     CON %10011001  ' segments fbgc   low = '4'
    five     CON %01001001  ' segments afgcd  low = '5'
    six      CON %01000001  ' segments afgcde low = '6' (with flag)
    seven    CON %00011111  ' segments abc    low = '7'
    eight    CON %00000011  ' segments abcdef low = '8'
    nine     CON %00001001  ' segments abcdfg low = '9' (with flag)
    dp       CON %11111110  ' segment  dp     low = '.'
    
    digitdata     VAR Byte
    segmentdata   VAR Byte
    '
    ' =========================[ main ]================================
    LOW LATCHpin                  ' initialise latch
    DO
      digitdata   = digit1        ' set digit to light up
      segmentdata = one           ' set segments to light up
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [segmentdata, digitdata] ' shift out data, show '1' on digit 1
      PULSOUT LATCHpin, 1         ' make data visible
    
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [two, digit2]   ' shift out data directly, show '2' on digit 2
      PULSOUT LATCHpin, 1         ' make data visible
    
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [three, digit3] ' continue for all 8 digits, show '3' on digit 3
      PULSOUT LATCHpin, 1
    
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [four, digit4]  ' show '4' on digit 4
      PULSOUT LATCHpin, 1
    
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [five, digit5]  ' etc.
      PULSOUT LATCHpin, 1
    
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [six, digit6]
      PULSOUT LATCHpin, 1
    
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [seven, digit7]
      PULSOUT LATCHpin, 1
    
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [eight, digit8]
      PULSOUT LATCHpin, 1
    
      SHIFTOUT DIOpin, CLKpin, LSBFIRST, [dp, digit8]    ' show decimal point on digit 8
      PULSOUT LATCHpin, 1
    LOOP                      'forever
    
    ' ==================================================================================
    
  • kwinnkwinn Posts: 8,697
    edited 2014-08-27 06:22
    NWCCTV wrote: »
    @kwinn, code does nothing. Nothing lights up.

    I will test it when I get home Thursday night. In the meantime I would suggest an ohmmeter or continuity tester to determine what pins are connected together. The '595 and display pinouts are known so it should only take 10 minutes or so to do that. Probably a lot easier than mucking around with untested programs.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-27 09:31
    NWCCTV wrote: »
    Results of Duane's code. I will try kwinn's on Wednesday.

    I don't suppose you tried adding the "!activeBits" line?

    Here's essentially the same thing as the earlier code but with the anodes and cathodes reversed.
    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
    
    
      COMMON_ANODE = true  '' set to false if digits are common cathode
                           
    VAR
    
    
      long shiftStack[64]
      long fourDigitNumber
      long shortInterval, longInterval
    
    
      byte digitBits[DIGITS]
      
    PUB Setup 
    '' This method starts in cog #0
    '' This method starts one additional cog.
    '' Presently there are six unused cogs.
    
    
      shortInterval := clkfreq / 2
      longInterval := clkfreq * 4
      cognew(MaintainDigits, @shiftStack)
      
      MainLoop
      
    PUB MainLoop | digit, activeBits
    
    
      repeat
        repeat fourDigitNumber from 0 to MAX_DISPLAYABLE
          waitcnt(longInterval + 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 ' check to see if it's a new number
          previousFourDigitNumber := fourDigitNumber
          BustDigits(fourDigitNumber)
               
        repeat result from 0 to MAX_DIGIT_INDEX  ' result is used as a temporary variable
          ShiftOutDigits(result, digitBits[result])
          waitcnt(shortInterval + cnt) ' This line should be commented out or delay made very short
                                       ' once the program is working.
          
    PUB BustDigits(numberToDisplay) | divisor
    '' Convert a number to bits representing the segments
    '' to light in a 7-segment display.
     
      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)
    '' This methos moves the digit bit to the correct location and
    '' combines the digit and segments bit together.
    '' The combined bits are shifted out.
    '' This method only displays a single digit at a time.
    '' All 8 digits need to be cycled quickly to make them
    '' all appear to be on.
    
    
      case digit ' convert digit to bit position
        0..3:    ' according to schematic what we call 0 - 3, they call 4 - 7
          digit := 11 - digit ' range 11 - 8   
        4..7:
          digit := 19 - digit ' range 15 - 12
        other:
          return
          
      '' our numbering system 0 1 2 3 4 5 6 7
      '' the displays system  4 5 6 7 0 1 2 3
        
      digit := 1 << digit  ' set the digit bit high
      !digit ' invert the bits (only the digit bit will be low) 
      digit &= $FF00 ' only keep top 8 bits
      activeBits &= $FF ' only keep bottom 8 bits
      
      activeBits |= digit  ' "Or" the bits controlling the digits together with the
                           ' bits controlling the segments.
                           ' The top 8 bits control the digits and the bottom 8 bits
                           ' control the segments.
    
    
      if COMMON_ANODE '' set this to false in CON section if it's a common cathode display
        !activeBits   ' invert 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 added a quarter of a second delay while each digit is displayed. You'll want to take this delay out (or shorten it) once you get a working program but the delay will help diagnose what's going on.

    I also added a constant "COMMON_ANODE" which can be set to true or false.
      COMMON_ANODE = true  '' set to false if digits are common cathode
    
    
    
    

    According to the datasheet, these are common anode displays so you should leave it set to true.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-27 09:56
    I was trying to find some of these 7-segment displays for a better price but so far, I've only found displays using a MAX7219 chips.

    The MAX7219 displays are very common on ebay. Here's one for $3.56 shipped.

    Edit: I found some of the '595 displays. I had to search for "LED 74HC595".

    I made an offer to purchase two of these for a total of $7.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-27 17:33
    I don't suppose you tried adding the "!activeBits" line?
    I did with no meaningful results.
    Here's essentially the same thing as the earlier code but with the anodes and cathodes reversed.
    Well. Not 100% but getting there!!!!
    I made an offer to purchase two of these for a total of $7.
    Those are the ones. Mine did not come with the wires though. What a rip!!! I also only paid $2.00 for the one I bought with free shipping. They really jacked up the price on it.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-27 19:19
    How do I convert C code to Spin? There is sample code here but it is looking for header files U do not have so if I can convert maybe it will help.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-27 20:15
    There's a C to Spin converter somewhere. The schematic shown in the RobotShop is different than the schematic Jordan posted.

    I changed the program to (hopefully) reflect the new schematic.
    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[64]
      long fourDigitNumber
      long shortInterval, longInterval
    
    
      byte digitBits[DIGITS]
      
    PUB Setup 
    '' This method starts in cog #0
    '' This method starts one additional cog.
    '' Presently there are six unused cogs.
    
    
      shortInterval := clkfreq / 2 ' change "2" to 200 once program is working
      longInterval := clkfreq * 4 ' comment out the "* 4" part to increase the speed
      cognew(MaintainDigits, @shiftStack)
      
      MainLoop
      
    PUB MainLoop | digit, activeBits
    
    
      repeat
        repeat fourDigitNumber from 0 to MAX_DISPLAYABLE
          waitcnt(longInterval + 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 ' check to see if it's a new number
          previousFourDigitNumber := fourDigitNumber
          BustDigits(fourDigitNumber)
               
        repeat result from 0 to MAX_DIGIT_INDEX  ' result is used as a temporary variable
          ShiftOutDigits(result, digitBits[result])
          waitcnt(shortInterval + cnt) ' This line should be commented out or delay made very short
                                       ' once the program is working.
          
    PUB BustDigits(numberToDisplay) | divisor
    '' Convert a number to bits representing the segments
    '' to light in a 7-segment display.
     
      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)
    '' This methos moves the digit bit to the correct location and
    '' combines the digit and segments bit together.
    '' The combined bits are shifted out.
    '' This method only displays a single digit at a time.
    '' All 8 digits need to be cycled quickly to make them
    '' all appear to be on.
    
    
          
      '' our numbering system 0 1 2 3 4 5 6 7
        
      digit := 1 << digit  ' set the digit bit high
     
      digit &= $FF ' only keep 8 bits (this shouldn't really be needed)
      !activeBits ' invert segment bits, segments are cathodes
      activeBits &= $FF ' only keep 8 bits (this shouldn't really be needed) 
      activeBits <<= 8  ' move segment bits to high bits (last to be clocked out)
      activeBits |= digit  ' "Or" the bits controlling the digits together with the
                           ' bits controlling the segments.
                           ' The top 8 bits control the digits and the bottom 8 bits
                           ' control the segments.
    
    
      
      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
    
    
    

    Only one digit will display at a time (for 1/2 second). To make all the digit light at once, you need to shorten the delay between updates. If the display appears to work correctly, then change the Setup method from:
    PUB Setup '' This method starts in cog #0
    '' This method starts one additional cog.
    '' Presently there are six unused cogs.
    
    
      shortInterval := clkfreq / 2 ' change "2" to 200 once program is working
      longInterval := clkfreq * 4 ' comment out the "* 4" part to increase the speed
      cognew(MaintainDigits, @shiftStack)
      
      MainLoop
      
    
    
    

    to:
    PUB Setup '' This method starts in cog #0
    '' This method starts one additional cog.
    '' Presently there are six unused cogs.
    
    
      [B]shortInterval := clkfreq / 200 [/B]
    [B]  longInterval := clkfreq [/B]
      cognew(MaintainDigits, @shiftStack)
      
      MainLoop
    

    The changed code should start counting up my one each second (approximately). You can make "longInterval" shorter to increase the count speed.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-27 20:47
    Duane Degn wrote: »
    Edit: I found some of the '595 displays. I had to search for "LED 74HC595".

    I made an offer to purchase two of these for a total of $7.

    My offer was turned down. I received a counteroffer of $7.90 for two which is only $0.08 less than the original price. It seems odd the seller has a "Make Offer" option when they'll only reduce the amount for multiple items by 1%.

    I ended up only buying one. The odd thing is if the selling didn't have a "Make Offer" button, I probably would have purchased two units but since I went to the bother of submitting an offer, I didn't want to accept the insulting 1% discount. I think the seller would be better off removing the "Make Offer" button from their sale page.

    I'm very curious to know how much shipping is on something like this. I would have thought shipping two items would have saved them more than eight cents?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-27 21:04
    Yea, I get frustrated some times wit the make offer option also. About 95% of the time it seems a reasonable offer is rejected. I will test the new code tomorrow. I am having vehicle issues right now and need to get that resolved.
  • kwinnkwinn Posts: 8,697
    edited 2014-08-28 06:46
    I can't believe the amount of programming effort going into this. There are 16 outputs from the 2 '595's going to 16 inputs on the 2 led displays.

    1- List the output pin numbers of the 2 '595's on a spreadsheet or piece of paper
    2- get an ohmmeter, put it on the lowest ohms range
    3- flip the display board over
    4- put one lead of the ohmmeter on the first '595 pin
    5- put the other ohmmeter lead on each of the display pins and write the pin# of the display pin with the lowest resistance next to the '595 pin#
    6- repeat 5 for each of the output pins of the two '595's

    Less than 10 minutes and you have all the information needed.
  • 72sonett72sonett Posts: 82
    edited 2014-08-28 08:21
    Duane Degn wrote: »
    ... Here's one for $3.56 shipped.
    But it also says:
    Shipping to: Worldwide
    Excludes: Alaska/Hawaii, US Protectorates, APO/FPO, Africa, Asia, Central America and Caribbean, Europe, Middle East, North America, Oceania, Southeast Asia, South America
    If you are in Antarctica or Australia you´re OK.

    The display with the MAX7219 chip would be easier to program as it does the multiplexing for you, just ´shift & forget´.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-28 14:23
    @Duane, The last code you posted displays the number 8 with about a one second delay on each segment. It does the two times and then stops.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-08-28 16:56
    I liked the videos showing the various results of these examples/tests. :cool:
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-28 19:48
    Example video to go with post# 43. Sorry, for some reason my phone recorded it upside down!!!!
  • 72sonett72sonett Posts: 82
    edited 2014-09-03 13:20
    It´s been quiet here for a few days... problem solved?

    Now can you make it display e.g. "12345678" continuously?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-03 13:35
    Not yet. Since I am not real great at writing drivers I am waiting on @Duane Degn to receive his to see what he comes up with.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-09-03 13:50
    NWCCTV wrote: »
    Not yet. Since I am not real great at writing drivers I am waiting on @Duane Degn to receive his to see what he comes up with.

    I probably will write a driver once I receive my display. I have a couple other 7-segment displays I want to control with '595 chips but I figure I'll wait until I receive the ebay display and just wire my other displays the same way as the ebay display so whatever driver I write will work with both displays.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-09-05 15:51
    NWCCTV wrote: »
    Example video to go with post# 43. Sorry, for some reason my phone recorded it upside down!!!!

    This was using code attached to post #38?

    My display arrived today so I tried the code attached to post #38 and it almost behaved as expected except I had the digits reversed. So instead of 00000001 counting up it displayed 10000000 counting up with the least significant digit on the left instead of the right.

    By changing line 131 from:
    digit := 1 << digit  ' set the digit bit high
    

    to:
    digit := 1 << (7 - digit)  ' set the digit bit high
    

    The order of the digits was fixed.

    I then commented out line # 105
    'waitcnt(shortInterval + cnt) ' This line should be commented out or delay made very short
                                       ' once the program is working.
    

    and instead of only one digit being visible at a time, all the digits were lit.

    I then changed line #77 from:
    longInterval := clkfreq * 4 ' comment out the "* 4" part to increase the speed
    

    to:
    longInterval := clkfreq / 4
    

    and now the displays counts up four units per second.

    I don't understand why you had all "8"s?

    I've attached the code with the above mentioned changes.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-05 17:41
    I wonder if I had something connected wrong. How is yours connected exactly?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-09-05 19:57
    NWCCTV wrote: »
    I wonder if I had something connected wrong. How is yours connected exactly?

    I think you need to swap the clock and latch lines. I was able reproduce what you saw when I switched these lines.

    This is how the pins should be connected:

    SHIFT_REGISTER_DATA to pin labeled "DIO"
    SHIFT_REGISTER_CLOCK to pin labeled "SCK"
    SHIFT_REGISTER_LATCH to pin labeled "RCK"

    I've noticed a lot of datasheets don't use the word "latch" when naming pins even though that's what everyone seems to call it.

    I think the latch pin is called the "storage register clock" in many 74HC595 datasheets and the pin commonly called the "clock" pin is called the "shift register clock" in many datasheets.

    I'm working on a better version of the code to make it easier to use with other programs.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-09-05 21:26
    The program attached to this post has the code to drive the shift registers in a child object.

    The number to be displayed is set with the method "Set".

    Instead of always having leading zeros, the leading character can now be set with the "SetPadBits" method. The demo program alternates between padding the display with zeros and leaving the extra digits blank.

    The demo program just increments a counter 100 times a second and displays the count. The lowest digit is kind of a blur.

    I don't have any support for decimal points yet. I'll probably add this tomorrow.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-05 21:42
    Great. Thanks Duane. I am currently working on my Wild Thumper Project so it may be a day or two before I can test it out.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-09-06 14:42
    This latest version adds decimal point support (but not well).

    You can either use "SetDp" which will place a single decimal point where told (and remove any previous decimal points) or you can use "AddDp" which doesn't delete previously set decimal points.

    The "AddDp" method could be used to set decimal points between hours minutes and seconds on a clock or for some other application where one would want more than one decimal point.

    Here's the display in action.

    To be really useful, I should add a better way of adding the decimal point. If you wanted to display "0.0024" there isn't presently a way to do so unless you displayed "0000.0024".

    I'm sure I'll improve the decimal point control sometime in the near future but if anyone needs this sort of control, let me know. I bet I could be talked into adding the feature sooner rather than later if someone needs it.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-08 18:14
    I bet I could be talked into adding the feature sooner rather than later if someone needs it.
    Only if you have the time, Duane. Thanks for what you have done thus far.

    EDIT: I think I have a bad unit. It pretty much does nothing now. It shows a few almost sevens but that is it.
  • kwinnkwinn Posts: 8,697
    edited 2014-09-08 20:05
    My suggestions are:

    Use a byte that has bits set for each of the eight decimal points that should be on.

    Use 5 bits per digit and set the dp bit based on bit 5.

    Use ascii text, test to be sure the characters are in the range of 2E to 39 hex, mask off the 4 lsb's so the digits 0 to 9 become hex 0 to 9, and the decimal point and slash become E and F hex. When the E is detected the dp bit is set for that digit.

    The first method is the simplest and has the added advantage of allowing for simplified leading zero suppression.
Sign In or Register to comment.