PIC to PIC (3 digit LED display)
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Location
    The Netherlands
    Posts
    42

    Default PIC to PIC (3 digit LED display)

    Hello,

    I'm sending a Word VAR (0-999) from PIC to PIC with 1200baud.

    But, the communications is not stable all the time. Like start_Up problems. The multiplexing of 3 digit LEDs works very well.

    Maybe I need some tricks in the communication ?!?


    This (PIC '883) is the sender:

    W2 VAR WORD

    Loop:
    W2 = W2 + 1
    Serout PortA.7,T1200,[W2.highbYTE,W2.lowBYTE] ' Send two byte
    Pause 1000
    Goto Loop



    And this is the 3 digit LED Display (PIC '687) receiver:

    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_BAUD 1200 ' Set Baudrate to 1200
    DEFINE HSER_CLROERR 1 ' Auto clear over-run errors

    Main:

    ' ******************** Main Program ********************

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

    hserin [W1.HIGHBYTE,W1.LOWBYTE] ' Get char from serial port (UART)

    gosub Display
    Else
    gosub Display

    endif

    goto Main

    ' Sub to send the number (0-999) in W1 to 7-seg

    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,B0 ' Send segments to LED
    high PortA.2
    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

  2. #2
    Join Date
    Sep 2009
    Posts
    733

    Default Re: PIC to PIC (3 digit LED display)

    Try
    Serout PortA.7,T1200,["No:",W2.highbYTE,W2.lowBYTE] ' Send two byte

    hserin [WAIT("No:"),W1.HIGHBYTE,W1.LOWBYTE] ' Get char from serial port (UART)

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

    Default Re: PIC to PIC (3 digit LED display)

    Hi Pedja089,

    Thanks for your replay.

    I give some flickering on the Display now but it works. The communications is stable now.

    I will try to send one character like "@" and play some with the On/Off time of the LEDs (gosting)

  4. #4
    Join Date
    Sep 2009
    Posts
    733

    Default Re: PIC to PIC (3 digit LED display)

    Speed up comm speed. Also add Timeout to hserin. Look in manual for details.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,854

    Default Re: PIC to PIC (3 digit LED display)

    Also in your processing routines you use Pause and a subroutine bin2seg.

    Maybe all together add a delay more than the time to scan serial port? Just a though.

    You overall way of thinking is prone to communication errors.

    What you should do is a tight main loop that passes new data to your display part of the program and have new data received in an interrupt ISR.

    That way you will never miss new data because they arrive asynchronously in regard with the program state.

    A flag will report to main routine that ISR has new data. So main will send them for processing. If in the mean time new data arrive, ISR will grab them for later processing.

    Ioannis

Similar Threads

  1. 6 digit - 7 segment display code
    By lerameur in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th June 2014, 06:36
  2. LED Bargraph chip (guitar LED bling-age) ..do with a PIC?
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 12th July 2009, 23:15
  3. Replies: 2
    Last Post: - 14th July 2008, 22:11
  4. Replies: 2
    Last Post: - 22nd January 2008, 14:25
  5. How to display dot on 7-seg , 4 digit
    By chai98a in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 19th January 2007, 18:17

Members who have read this thread : 19

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