3 digit 7-Seg serial Display


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2005
    Location
    The Netherlands
    Posts
    39

    Default 3 digit 7-Seg serial Display

    This serial display receives every seconds data, 1200 baud of an other PIC

    I'm trying to convert this seconds (0 to 9999) into Minutes, Seconds... on the LED display.

    But, i'm missing the minutes ?!

    Thanks for any help!

    Name:  dsp_01.jpg
Views: 958
Size:  598.0 KB


    @ device pic16f687,intrc_osc_noclkout,bod_off,pwrt_on,wdt_o ff,mclr_on,protect_on

    DEFINE OSC 4 ' Set Speed (INT OSC)
    DEFINE HSER_RCSTA 90h ' Enable USART receive
    DEFINE HSER_TXSTA 24h ' TXSTA=%00100100 TX enable, BRGH=1 for high-speed
    ' DEFINE HSER_TXSTA 20h ' TXSTA=%00100000 TX enable, BRGH=0 for low-speed
    ' DEFINE HSER_SPBRG 207 ' 1200 Baud @ 4MHz, 0.17%
    DEFINE HSER_BAUD 1200 ' Set Baudrate to 1200
    DEFINE HSER_CLROERR 1 ' Auto clear over-run errors


    ' setting for PIC '687
    OSCCON = %01100111 ' Internal Clock set to 4 MHZ ?!?
    INTCON = 0 ' Disable interrupts
    ADCON1 = 7
    ANSEL = 0 ' Analog to Digital
    ANSELH = 0 ' Analog to Digital
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %00000000
    PORTA = 0
    PORTB = 0
    PORTC = 0

    B0 var byte ' Segment counter
    W1 var word ' VAR for received bytes
    W2 var word
    D1 var word
    RCIF var PIR1.5 ' USART received character

    w1 = 0 ' Start Val

    pause 250 ' Wait for Power_Up


    ' ----- [ Main ] --------------------------------------------------------------

    Main:

    IF RCIF = 1 THEN ' If RCIF = 1 there's new char in RCREG

    hserin [WAIT("@"),W1.HIGHBYTE,W1.LOWBYTE] ' Get char from UART


    ' *** convert received seconds 0-999 into Minutes & Seconds ***

    W2 = W1 / 60 ' Minutes = W1 / 60
    W1 = W1 // 60 ' seconds = W1 // 60

    gosub Display
    Else
    gosub Display

    endif


    goto Main


    display:

    D1 = W1 ' Put W1 entry value in D1
    B0 = D1 / 100 ' Find number of hundreds
    D1 = D1 // 100 ' Remove hundreds from W1

    Gosub bin2seg ' Convert number to segments


    poke PortC,%10000000 ' DP on first LED
    high PortA.2 ' Minutes LED
    Pause 3 ' Leave it on 3 ms
    low PortA.2 ' Turn off to prevent ghosting

    B0 = D1 / 10 ' Find number of tens
    D1 = D1 // 10 ' Remove tens from W1

    Gosub bin2seg ' Convert number to segments

    Poke PortC,B0 ' Send segments to LED
    high PortA.1
    Pause 3 ' Leave it on 3 ms
    low PortA.1 ' Turn off to prevent ghosting

    B0 = D1 ' Get number of ones

    Gosub bin2seg ' Convert number to segments

    Poke PortC,B0 ' Send segments to LED
    High PortA.0
    Pause 3 ' Leave it on 3 ms
    Low PortA.0 ' Turn off to prevent ghosting


    Return ' Go back to caller


    bin2seg:

    ' Convert binary number in B0 (0 t/m 9) to segments for LED
    Lookup B0,[$3F,$6,$5B,$4F,$66,$6D,$7D,$7,$7F,$6F],B0


    Return


    ' ----- [ E N D ] -------------------------------------------------------------

    END

  2. #2
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 3 digit 7-Seg serial Display

    Nice display, where did you get it?

  3. #3
    Join Date
    Jul 2005
    Location
    The Netherlands
    Posts
    39


    Did you find this post helpful? Yes | No

    Default Re: 3 digit 7-Seg serial Display

    I have make this !

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: 3 digit 7-Seg serial Display

    Not clear what you mean.

    Ioannis

  5. #5
    Join Date
    Oct 2005
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 3 digit 7-Seg serial Display

    I think you forget to put minutes in the minutes LED although you do remember it for the rest digits .So try this..
    ........
    ........
    poke PortC,%10000000 ' DP on first LED
    Poke PortC,B0 ' Send segments to LED
    Poke PortC.7,1
    high PortA.2 ' Minutes LED
    Pause 3 ' Leave it on 3 ms
    low PortA.2 ' Turn off to prevent ghosting
    ........
    ........

  6. #6
    Join Date
    Jul 2005
    Location
    The Netherlands
    Posts
    39


    Did you find this post helpful? Yes | No

    Default Re: 3 digit 7-Seg serial Display

    [QUOTE=Ioannis;144615]Not clear what you mean.

    Ioannis,

    I'm missing the minutes on the first LED dsp...

  7. #7
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: 3 digit 7-Seg serial Display

    Perhaps I am not following your idea clearly, but it seems the problem is bigger than you state...

    Up until 599 seconds the display may read minutes and seconds like: M.SS with no problem, but with 10 minutes, then seconds (or minutes) must be only one digit. You may choose to change the display so that at low times, - less the 599 seconds you display M.SS but at 600 seconds the display becomes MM.S. This will require two display routines. Or, you may display minutes as hexadecimal and use A, B, C, D, E, F for values greater than 10. Then you may display M.SS for all values up to 999 seconds with only 1 minutes digit.

    Once you have determined how to display your time consistently, then recheck the datasheet of your display, it seems strange to me that a serial display will require more than some string data to display numbers. I would imagine some SEROUT Pin, Mode, (Item{,Item}) statement would work - at least try this through the built in serial function (DEBUG) in PicBasic to be sure all that you intend to send to the display is correct.

    HTH

Similar Threads

  1. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 09:42
  2. Replies: 2
    Last Post: - 14th July 2008, 23:11
  3. Replies: 2
    Last Post: - 22nd January 2008, 15:25
  4. How to display dot on 7-seg , 4 digit
    By chai98a in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 19th January 2007, 19:17
  5. SMART Serial 4 Digit LCD Display (SMARD4)
    By paul borgmeier in forum Adverts
    Replies: 0
    Last Post: - 5th January 2005, 06:50

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