Shop OBEX P1 Docs P2 Docs Learn Events
Program Problem? — Parallax Forums

Program Problem?

jknightandkarrjknightandkarr Posts: 234
edited 2010-01-29 06:40 in Propeller 1
I got my Propeller wired up to numeric LED displays & tried it using Seven-segment Test.spin found here on the object exchange.
obex.parallax.com/objects/142/
and all I get is odd ball displays. Looks to me they are jarbled up. So I tried a simple test program to run through all my digits one at a time, displaying 0 to 9, & ending with the Decimal Points flashing back & forth before restarting to test my wiring job. The program displayed exactly what I wanted, so I assume it's problem with the seven segment program i downloaded. What part I don't know I've tried a few things & so far nothing fixes it. I got my segment/digit information, namely
DAT
     'Common cathode 7-segment displays are activated by bringing the cathode to ground
        DigSel          byte    %1110
                        byte    %1101
                        byte    %1011
                        byte    %0111
        
        Digit0          byte    %00111111
        Digit1          byte    %00000110
        Digit2          byte    %01011011
        Digit3          byte    %01001111
        Digit4          byte    %01100110
        Digit5          byte    %01101101
        Digit6          byte    %01111101
        Digit7          byte    %00000111
        Digit8          byte    %01111111
        Digit9          byte    %01100111


directly from the SevenSegment.spin file, modified the DigSel to take it to 4 digits in my test program, so I know that's not the problem with the Seven-segment Test.spin I tried to use only the SevenSegment.spin & added my I/O pin usage information, a value to display, adjust config values as needed & get nothing but a blank display, so neither program is working correctly for me. If someone can help me figure this out, I'd be greatfulll, because I'm confused.

Joe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-27 13:10
    You should rather attach your code. From an object in the ObjectExchange that's already there for 3 years, I'd expect that it works.
  • jknightandkarrjknightandkarr Posts: 234
    edited 2010-01-27 15:14
    MagIO2 said...
    You should rather attach your code. From an object in the ObjectExchange that's already there for 3 years, I'd expect that it works.

    Well the code is the same as in the object actually, it remains basically unchanged but I'll add it.

    {Demo program for SevenSegment object.}
    
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      lowDigit =8                   'Low digit cathode
      digits = 4                    'Number of digits to display
      Segment0 = 0                  'Segment start pin
    
    VAR
      long  counter
    
    OBJ
      sevenseg : "SevenSegment"
      
    PUB Start
      sevenseg.start(lowDigit, digits, Segment0, true)
      
      counter := 0
      repeat
        sevenseg.SetValue(counter++)
        if (counter / 10 // 10) == 0
          sevenseg.disable                                  'disable the display when the second digit is 0
        else
          sevenseg.enable
        waitcnt(clkfreq/10 + cnt)
      sevenseg.SetValue(99)
    



    {{General purpose Seven-segment display object. Can control from one to eight digits.
    
       Author: Steve Nicholson
       Version: 1.0 (4 Jan 2007)
       Email: ssteve@mac.com
       Copyright: none
    
    }}
    
    VAR
      long LowDigitPin, HighDigitPin                        'The pins for specifying digits.
                                                            ' Must be contiguous
                                                            ' HighDigitPin can be from 0 to 7 more than LowDigitPin
      long Seg0Pin, Seg8Pin                                 'The pins for the segments.
                                                            ' Must be contiguous
                                                            ' Segment 8 is the decimal point
      long flags
      long myStack[noparse][[/noparse]10]
      long runningCogID
      long myValue
    
    CON
      isEnabled = %0001  
    
    PUB Start(dLow, digits, s0, enabled)
    '' Start the display
    '' Parameters:
    ''   dLow - the pin number of the least significant digit
    ''   digits - the number of digits to display  (up to 8)
    ''   s0 - the pin number of segment 0
    ''   enabled - the initial enabled state
      myValue := 0
      LowDigitPin := dLow
      HighDigitPin := dLow + ((digits - 1) <# 7)            'Limit to eight digits
      Seg0Pin := s0
      Seg8Pin := s0 + 7
      dira[noparse][[/noparse]Seg0Pin..Seg8Pin]~~                              'Set segment pins to outputs
      dira[noparse][[/noparse]LowDigitPin..HighDigitPin]~~                     'Set digit pins to outputs
      outa[noparse][[/noparse]Seg0Pin..Seg8Pin]~                               'Turn off all segments
      dira[noparse][[/noparse]LowDigitPin..HighDigitPin]~~                     'Turn off all digits
      if enabled                                            'Set initial enabled state
        flags |= isEnabled
      else
        flags~
      stop
      runningCogID := cognew(ShowValue, @myStack) + 1
    
    PUB Stop
    '' Stop the display
      if runningCogID
        cogstop(runningCogID~ - 1)
    
    PUB Enable
    '' Enable the display
      flags |= isEnabled
    
    PUB Disable
    '' Disable the display
      flags &= !isEnabled
      
    PUB SetValue(theValue)
    '' Set the value to display
      myValue := theValue
    
    PRI ShowValue | digPos, divisor, displayValue
    ' ShowValue runs in its own cog and continually updates the display
      dira[noparse][[/noparse]Seg0Pin..Seg8Pin]~~                              'Set segment pins to outputs
      dira[noparse][[/noparse]LowDigitPin..HighDigitPin]~~                     'Set digit pins to outputs
      repeat
        if flags & isEnabled
          displayValue := myValue                           'take snapshot of myValue so it can't be changed
                                                            ' while it is being displayed
          divisor := 1                                      'divisor is used to isolate a digit to display
          repeat digPos from 0 to HighDigitPin - LowDigitPin 'only display as many digits as there are pins
            outa[noparse][[/noparse]Seg8Pin..Seg0Pin]~                         'clear the segments to avoid flicker
            outa[noparse][[/noparse]HighDigitPin..LowDigitPin] := byte[noparse][[/noparse]@DigSel + digPos] 'enable the next digit
            outa[noparse][[/noparse]Seg8Pin..Seg0Pin] := byte[noparse][[/noparse]@Digit0 + displayValue / divisor // 10] 'display the digit
            waitcnt (clkfreq / 10_000 + cnt)                'the delay value can be tweaked to adjust
                                                            ' display brightness
            divisor *= 10
        else
          outa[noparse][[/noparse]HighDigitPin..LowDigitPin]~~                 'disable all digits
          waitcnt (clkfreq / 10 + cnt)                      'wait 1/10 second before checking again
         
    DAT
            'Common cathode 7-segment displays are activated by bringing the cathode to ground
            DigSel          byte    %11111110
                            byte    %11111101
                            byte    %11111011
                            byte    %11110111
                            byte    %11101111
                            byte    %11011111
                            byte    %10111111
                            byte    %01111111
            
            Digit0          byte    %00111111
            Digit1          byte    %00000110
            Digit2          byte    %01011011
            Digit3          byte    %01001111
            Digit4          byte    %01100110
            Digit5          byte    %01101101
            Digit6          byte    %01111101
            Digit7          byte    %00000111
            Digit8          byte    %01111111
            Digit9          byte    %01100111
    



    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-27 19:43
    Sorry ... thought you did some more changes.
    Did you wire it up by yourself (breadboard or prototyping PCB) or is it this big propeller board?

    In the first case you maybe wired it differently than expected by the program? The digit pins should switch a transistor to ground when pin is low. The segment pins are high when the segment shoult light up. If the digit part is wrong then two things can happen:
    The digit is usually "on" and only one of the 4 digits is off (if the transistor switches in the wrong case - output = 1) or you have a reversed display (the segments which are off show the number) in case your transistor is connected to supply voltage instead.
  • jknightandkarrjknightandkarr Posts: 234
    edited 2010-01-27 20:00
    I have the PropRPM modual. I wired my displays up like this %DpGFEDCBA I got the Digit patterns from the SevenSegment program & tested them in my display, thinking that could be the issue, but that don't seam to be the case so far. The odd thing is the program doesn't have the Dp used, but my jarbled mess I get includes the decimal points. Some place there's a goof up. I don't know if this has anything to do with it, the prop seams fine, but last nite while playing around I got an error message saying the Prop wasn't connected to COM1, but it was, after a reset the program found it again, and occasionally some of the LED's on P16-P15 light up for no reason. There's no instructions using them in my programs, No DIRA or OUTA set on those pins. So I don't know if this is part of my problem or not.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-01-28 15:10
    How about posting your COMPLETE code as an attachment?

    Without seeing the complete code it is guessing in the fog

    best regards

    Stefan
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-28 17:37
    Aren't there 7 segment displays that have a common annode and some having a common cathode? Maybe that's the problem?
  • jknightandkarrjknightandkarr Posts: 234
    edited 2010-01-29 05:10
    StefanL38 said...
    How about posting your COMPLETE code as an attachment?

    Without seeing the complete code it is guessing in the fog

    best regards

    Stefan

    My codes i used are on the object exchange.
    obex.parallax.com/objects/142/
    

    I really didn't modify it, other then dabble with come things & nothing worked, so non of that was saved.
    MagIO2 said...
    Aren't there 7 segment displays that have a common annode and some having a common cathode? Maybe that's the problem?

    I think its one or the other. I don't think there's both on the same chip. My leds are all Common Cathode.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • jknightandkarrjknightandkarr Posts: 234
    edited 2010-01-29 05:53
    PRI ShowValue | digPos, divisor, displayValue
    ' ShowValue runs in its own cog and continually updates the display
      dira[noparse][[/noparse]Seg0Pin..Seg8Pin]~~                              'Set segment pins to outputs
      dira[noparse][[/noparse]LowDigitPin..HighDigitPin]~~                     'Set digit pins to outputs
      repeat
        if flags & isEnabled
          displayValue := myValue                           'take snapshot of myValue so it can't be changed
                                                            ' while it is being displayed
          divisor := 1                                      'divisor is used to isolate a digit to display
          repeat digPos from 0 to HighDigitPin - LowDigitPin 'only display as many digits as there are pins
            outa[noparse][[/noparse]Seg8Pin..Seg0Pin]~                         'clear the segments to avoid flicker
            outa[noparse][[/noparse]HighDigitPin..LowDigitPin] := byte[noparse][[/noparse]@DigSel + digPos] 'enable the next digit
            outa[noparse][[/noparse]Seg8Pin..Seg0Pin] := byte[noparse][[/noparse]@Digit0 + displayValue / divisor // 10] 'display the digit
            waitcnt (clkfreq / 10_000 + cnt)                'the delay value can be tweaked to adjust
                                                            ' display brightness
            divisor *= 10
        else
          outa[noparse][[/noparse]HighDigitPin..LowDigitPin]~~                 'disable all digits
          waitcnt (clkfreq / 10 + cnt)                      'wait 1/10 second before checking again
    



    I think I found the issue. The highdigitpin & lowdigitpin along with Seg0Pin & Seg8Pin are reversed. After swaping places in the Seg0Pin & Seg8Pin, my display is now un jarbled. Now I just have to adjust the high & lowdigitpins to get the order fixed.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • jknightandkarrjknightandkarr Posts: 234
    edited 2010-01-29 06:40
    And now after several trial & error problem, my display is working exactly as it's suppose to.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
Sign In or Register to comment.