help for serial communication pic to pic


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Posts
    12

    Default help for serial communication pic to pic

    hello my friend

    please who can help me for sample code to create serial communication between 16f84A to 16f84A when using SEROUT/SERIN
    I want to send a decimal number (0000 to 9999) from one PIC to the other where it's display it on 7 segment display 4 digit as shown in pictur attached

    you can email my [email protected]
    and thankyou very much
    Attached Images Attached Images  

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251

    Default

    Try serout for the first pic and serin for the second pic.
    How to use serout and serin is in the manual that came with the compiler.

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

    Default

    Do you have the rest of the program set up? I mean the display is working?

    For the data just use something like:

    Serout portpin,speed,["#",word_variable]

    Serin portpin,speed,["#"],word_variable

    For the parameters, have a look at the manual. I'd recommend a low speed of T2400.

    Ioannis

  4. #4
    Join Date
    Dec 2008
    Posts
    12

    Default

    thanks all my friends

    I have this subroutine for display decimal number on 7 segement 4 digit
    for examlpe when I try to display 1230 in proteuse simulation is not work properly
    I have tow problem:
    1-correct subroutine for displaying decimal number
    2-and how I can include this subroutine with commands Serout serin in tow pic when first pic (transemetre) send decimal number the second pic (receiver) must receive it and display it on 7 segment 4 digit
    and thank you very much for your help


    subroutine to display decimal number
    w1 var word
    b0 var byte
    TRISA=%00000000
    TRISB=%00000000

    loop:
    w1=1230
    gosub disp
    goto loop
    disp:

    B0 = W1 / 1000 ' Find number of thousands
    W1 = W1 // 1000 ' Remove thousands from W1
    Gosub bin2seg ' Convert number to segments
    Poke PortB, B0 ' Send segments to LED
    Poke PortA, $17 ' Turn on fourth digit
    Pause 1 ' Leave it on 1 ms
    Poke PortA, $1F ' Turn off digit to prevent ghosting
    B0 = W1 / 100 ' Find number of hundreds
    W1 = W1 // 100 ' Remove hundreds from W1
    Gosub bin2seg ' Convert number to segments
    Poke PortB, B0 ' Send segments to LED
    Poke PortA, $1B ' Turn on third digit
    Pause 1 ' Leave it on 1 ms
    Poke PortA, $1F ' Turn off digit to prevent ghosting
    B0 = W1 / 10 ' Find number of tens
    W1 = W1 // 10 ' Remove tens from W1
    Gosub bin2seg ' Convert number to segments
    Poke PortB, B0 ' Send segments to LED
    Poke PortA, $1D ' Turn on second digit
    Pause 1 ' Leave it on 1 ms
    Poke PortA, $1F ' Turn off digit to prevent ghosting
    B0 = W1 ' Get number of ones
    Gosub bin2seg ' Convert number to segments
    Poke PortB, B0 ' Send segments to LED
    Poke PortA, $1E ' Turn on first digit
    Pause 1 ' Leave it on 1 ms
    Poke PortA, $1F ' Turn off digit to prevent ghosting
    Return ' Go back to caller

    ' Convert binary number in B0 to segments for LED
    bin2seg: Lookup B0,[$40,$79,$24,$30,$19,$12,$02,$78,$00,$18],B0
    Return

  5. #5
    Join Date
    Dec 2008
    Posts
    12

    Default

    I wait for your help ........

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default

    Hello jasm700,
    You want to look at the manual sect 4.17.7 it explains how to use the DIG command to get your digit.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. 2 PIC, serial communication
    By lightgreen in forum Serial
    Replies: 6
    Last Post: - 21st November 2009, 15:20
  2. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  3. PIC 2 PIC communication
    By Mario in forum Forum Requests
    Replies: 16
    Last Post: - 28th April 2006, 01:56
  4. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45
  5. Pic to Pic communication?
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th April 2004, 19:41

Members who have read this thread : 0

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