PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891

    Default PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2

    Hello,

    I'm building a IR remote control based on Bruce's information (http://www.rentron.com/Infrared_Communication.htm).

    The IR link (hardware) works fine but I can't get the communication between both PICs working since I'm not familiar with the SERIN2 command.

    To go on step-by-step, I don't use the IR system for the moment and "wired" both PICs together (via a 1k2 resistor).

    The "emitter" PIC sends continuously this "ABCD1234efgh5678" string and this works fine. The (shortened) code in the "emitter" PIC is:
    Code:
    MAIN:
        SEROUT2 D_Out, 49548, ["ABCD1234efgh5678", 13]
        GOTO MAIN
    END
    The "receiver" PIC is setup to receive () the string and send it out to a Serial Terminal (currently for testing purpose).

    Based on the PBP "SER2MOD" example, the "receiver" code looks like this and should make the program wait for the "A" character to be received and read the seven next characters:
    Code:
    ' Fuses  PIC12F675
    @ DEVICE XT_OSC ;Xtal 4MHz
    @ DEVICE WDT_OFF
    @ DEVICE PWRT_OFF
    @ DEVICE MCLR_OFF
    @ DEVICE BOD_OFF
    @ DEVICE PROTECT_OFF
    @ DEVICE CPD_OFF
    
    CMCON      = %00000111 'Comparator is OFF
    ANSEL      = %00000000 'Disable analog inputs
    OPTION_REG = %10000000 'GPIO Pull-Ups disabled
    INTCON     = %00000000 'All Interrupts disabled
    GPIO       = %00000000 'Ports Levels
    TRISIO     = %00001000 'Ports Directions
    
    D_Out  VAR GPIO.2 'Serial Data Out
    D_In   VAR GPIO.3 'Serial Data In
    D_Data VAR byte[8]'Serial Data
    
    MAIN:
        SERIN2 D_In, 49548, [WAIT("A"), STR D_Data\7]
        SEROUT2 D_Out, 49548,[STR D_Data\7, 13, 10]
        GOTO MAIN
    END
    Problem: it seems I don't get anything into the receiver PIC or at least, this is what I feel since the Serial Terminal stays blank.

    NB: 49548 is the data mode: 2400bauds, Open, Inverted, No Parity.
    Roger

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


    Did you find this post helpful? Yes | No

    Default

    Hi Roger,

    Do you have a Pull-Up resistor on the serial line?

    SEROUT2 mode 49548 is Open Collector output. It never drives the line high, so it requires a pull-up.
    From your description, it sounds like you just have a 1.2k in series.

    Alternatively, you can use mode 16780 which will drive it high.
    <br>
    DT

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Sounds right... not sure how and why SERIN2 deal with it... how on earth an input could be an open-collector type NO i haven't open the LIB(s)
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    As far as SERIN2 is concerned, it doesn't matter.
    49548 and 16780 are the same thing.

    But it will make a difference with the SEROUT2.
    49548 - open collector output.
    16780 - Driven output.
    <br.
    DT

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    ...Do you have a Pull-Up resistor on the serial line?
    <br>
    Yes, a 10k. The 1k2 resistor is connected between both PICs.

    I'll have a try with a driven output.
    Roger

  6. #6
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default another transmission protocol

    Looking around the Internet for some additional information about IR transmission, I found out that i.e. SONY uses a Pulse Width Modulation protocol that looks simple to implement with PICs (http://www.sbprojects.com/knowledge/ir/sirc.htm).

    So instead of trying to establish a "serial" communication, I'll have a go with PULSOUT/PULSIN.

    Might be easier since the IR (hardware) layer is already working well.
    Roger

Similar Threads

  1. 2 PIC, serial communication
    By lightgreen in forum Serial
    Replies: 6
    Last Post: - 21st November 2009, 15:20
  2. Replies: 11
    Last Post: - 12th July 2008, 02:36
  3. Replies: 5
    Last Post: - 20th March 2006, 01:34
  4. Pic To Pic Serial Communication?
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 5th February 2005, 00:59
  5. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45

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