Darrel's interrupts in a 7 segment display


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Wow, worked the first time, Darrel.
    Great! I guess my internal simulator is still working.

    Quote Originally Posted by ardhuru View Post
    a couple of parameter values over the serial port
    If it's only a couple values every now and then, just turn off the interrupts before using the SEROUT? statement.
    Depending on the baudrate and amount of data, it may cause a small blink in the display.
    <br>
    DT

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    If you set your interrupt time to 1.5mSec or so, you can send one character at 9600 baud between interrupts. Just don't try to do too much else in that period!
    Charles Linquist

  3. #3
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: Darrel's interrupts in a 7 segment display

    Hi all,
    I'm having trouble understanding something in this example code. Maybe someone can explain.
    Code:
    Main:
      FOR Value = 0 TO 999
        GOSUB SetDisp
        PAUSE 500
      NEXT Value
    GOTO Main
    
    '---[Set 7-seg patterns to WORD value]--------------------------------------
    SetDisp:
      FOR Idx = 2 to 0 STEP -1
        Temp = Value DIG Idx
        LookUp Temp,[132,175,193,137,170,152,144,143,128,136,210,251],Temp
        SEGDEF(Idx) = Temp
      NEXT Idx
    RETURN
    The biggest question is why is there 12 data points in the table? I am assuming that the actual numbers are because of the wiring of the digits with this specific LED as I can not figure out a segment pattern. After that, I fall down on why 12 instead of 8 unless it involves positioning the decimal point somehow. I wonder, if with the original wiring, this would be clearer to me. I would think that you would line up the segments in order with the port pins in order.

    Thanks
    Mark

  4. #4
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: Darrel's interrupts in a 7 segment display

    Another observation that this is a specific solution to the OP's issue is that can't be just cut-n-pasted without thinking it through:
    Code:
    PORTE = %111                 ; turn off all digits to prevent ghosting
      PORTC = SEGDEF(digitloop)    ; put segment pattern to pin
      PORTE = ~(DCD digitloop)     ; turn on the digit
    my application is common cathode and it uses a ULN2803 as a driver for the cathodes of the digits. If I hadn't looked at it and tried to understand it, I could have easily have turned on ALL BUT ONE of the displays instead of ONE AT A TIME. Mine is also, 8 digits, so it matters a bit more for the PIC pin. Not a complaint in any way, more of a way to close the loop for anyone looking at it later. BTW: very slick way to step through the digits. Learned something new today.
    Mark

  5. #5
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Darrel's interrupts in a 7 segment display

    Quote Originally Posted by boroko View Post
    Hi all,
    I'm having trouble understanding something in this example code. Maybe someone can explain.
    Code:
    Main:
      FOR Value = 0 TO 999
        GOSUB SetDisp
        PAUSE 500
      NEXT Value
    GOTO Main
    
    '---[Set 7-seg patterns to WORD value]--------------------------------------
    SetDisp:
      FOR Idx = 2 to 0 STEP -1
        Temp = Value DIG Idx
        LookUp Temp,[132,175,193,137,170,152,144,143,128,136,210,251],Temp
        SEGDEF(Idx) = Temp
      NEXT Idx
    RETURN
    The biggest question is why is there 12 data points in the table? I am assuming that the actual numbers are because of the wiring of the digits with this specific LED as I can not figure out a segment pattern. After that, I fall down on why 12 instead of 8 unless it involves positioning the decimal point somehow. I wonder, if with the original wiring, this would be clearer to me. I would think that you would line up the segments in order with the port pins in order.

    Thanks
    Mark
    As I can not resist a challenge even if it is only an academic exercise to me.

    ------- GFEDCBA

    0 132 10000100
    1 175 10101111
    2 193 11000001
    3 137 10001001
    4 170 10101010
    5 152 10011000
    6 144 10010000
    7 143 10001111
    8 128 10000000
    9 136 10001000
    F 210 11010010
    - 251 11111011


    Looking at the bit pattern for :-

    0 the active segments are 0 and inactive 1 in a 0 the central cross bar is inactive therefore this is C
    6 the only inactive segment is top right therefore this is E
    5 the inactive segments are top right and bottom left so bottom left is D
    9 confirms bottom left is D
    3 top left and bottom left inactive so top left is A
    2 top left and bottom right inactive so bottom right is G
    7 top left centre bottom left and bottom inactive so bottom is B

    which leaves F is the top segment giving this pattern

    -F-
    A E
    -C-
    D G
    -B-


    251 is the centre bar obviously used for - (minus)
    210 converting the bit pattern gives F

    Having decoded this pattern it makes no sense to me as the normal segment pattern is

    Name:  Capture1.PNG
Views: 1523
Size:  9.7 KB

    Leaving the question why connect a 7 segment display in this no standard way?

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Darrel's interrupts in a 7 segment display

    Well Actually Steve, The display's may have been wired that way in the schematic originally. Makes no difference. As far as the table is concerned, to generate all 16 hexidecimal characters the table would be 16 entries wide. in the past I have generated tables with all 16 entries as well as lower case "c,n o r". Thats 20. Ther is no standard way if you get my drift. It's completely up to the circuit designer.
    Dave Purola,
    N8NTA
    EN82fn

  7. #7
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Darrel's interrupts in a 7 segment display

    Quote Originally Posted by Dave View Post
    Well Actually Steve, The display's may have been wired that way in the schematic originally. Makes no difference. As far as the table is concerned, to generate all 16 hexidecimal characters the table would be 16 entries wide. in the past I have generated tables with all 16 entries as well as lower case "c,n o r". Thats 20. Ther is no standard way if you get my drift. It's completely up to the circuit designer.
    In my post I decoded the lookup table to work out the display pattern and the wiring. I intuitively did not like the resultant pattern and wondered why choose that pattern. Internet searches revealed a commonly followed trend of port.0-port.7 connected to a-g respectively.

    From Wikipedia
    Name:  Capture.PNG
Views: 3026
Size:  41.9 KB


    LED-based 7-segment display which cycles through the common glyphs of the ten decimal numerals and the six hexadecimal "letter digits" (A–F)
    Hexadecimal digits can be displayed on seven-segment displays. A combination of uppercase and lowercase letters is used for A–F;[6] this is done to obtain a unique, unambiguous shape for each hexadecimal digit (otherwise, a capital D would look identical to an 0 and a capital B would look identical to an 8). Also the digit 6 must be displayed with the top bar lit to avoid ambiguity with the letter b.
    Which implies that there are two ways to wire up a seven segment display one for g-a encoding and one for a-g encoding. But as you say no one has to follow these commonly used encodings, which do dictate the circuit to be used.

    The inclusion of "-" and "F" in the encoding makes me think that the original code was probably for displaying temperatures. Also the codes are eight digits which includes the DP reinforcing the idea of a temperature display. I wonder if the original project was wired in the same way, that is assuming this is recycled code.

    Can anyone see any advantage in this scheme?

    -F-
    A E
    -C-
    D G
    -B-

    I can not and surely the wiring will be like spaghetti.

Similar Threads

  1. 7 Segment Displays and MAX7219
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st October 2010, 18:30
  2. LED Machine Tach For Tired Eyes
    By Archangel in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 27th January 2010, 14:55
  3. Weird compile issue 7 segment LED display
    By George in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st June 2006, 02:12
  4. 7 segment digit problem (using Mister E's code)
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2005, 20:25
  5. WRITE not working
    By servo260 in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 29th December 2004, 02:02

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts