Slave/Master communication problems


Closed Thread
Results 1 to 3 of 3
  1. #1
    jmescajadillo's Avatar
    jmescajadillo Guest

    Exclamation Slave/Master communication problems

    I'm using a program of master/slave structure using serial communications.

    This is the slave program (The comments were made on its original language, Spanish):

    include "modedefs.bas"
    trs var PORTC.6 'Variable que identifica PORTA.0
    F var BYTE
    T var BYTE 'Numero de traje
    A var BYTE 'Variables de Botones
    T=0
    trisa = 255 'Configura PORTA pata todas las entradas
    ADCON1 = 0 'PORTA es analógica
    DEFINE ADC_BITS 8

    loop:
    Low PORTB.5
    Low PORTB.6
    Low PORTB.7

    Low PORTB.0
    Low PORTB.1
    Low PORTB.2 'boton1
    ADCIN 0,A
    F=A-50

    IF (A<50) THEN
    T=11
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    High PORTB.5
    Low PORTB.6
    Low PORTB.7

    Low PORTB.0
    Low PORTB.1
    Low PORTB.2 'boton2
    ADCIN 0,A
    F=A-50

    IF (A<50) THEN
    T=12
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    Low PORTB.5
    High PORTB.6
    Low PORTB.7

    Low PORTB.0
    Low PORTB.1
    Low PORTB.2 'boton3
    ADCIN 0,A
    F=A-50

    IF (A<50) THEN
    T=13
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    Low PORTB.5
    Low PORTB.6
    Low PORTB.7

    High PORTB.0
    Low PORTB.1
    Low PORTB.2 'boton4
    ADCIN 0,A
    F=A-50

    IF (A<50) THEN
    T=14
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    High PORTB.5
    Low PORTB.6
    Low PORTB.7

    High PORTB.0
    Low PORTB.1
    Low PORTB.2 'boton5
    ADCIN 0,A
    F=A-50

    IF (A<50) THEN
    T=15
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    Low PORTB.5
    High PORTB.6
    Low PORTB.7

    High PORTB.0
    Low PORTB.1
    Low PORTB.2 'boton6
    ADCIN 0,A
    F=A-50

    IF (A<50) THEN
    T=16
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    Low PORTB.5
    Low PORTB.6
    Low PORTB.7

    Low PORTB.0
    High PORTB.1
    Low PORTB.2 'boton7
    ADCIN 0,A
    F=A-50

    IF (A<50) THEN
    T=17
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    High PORTB.5
    Low PORTB.6
    Low PORTB.7

    Low PORTB.0
    High PORTB.1
    Low PORTB.2 'boton8
    ADCIN 0,A
    F=A-50
    IF (A<50) THEN
    T=18
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    Low PORTB.5
    High PORTB.6
    Low PORTB.7

    Low PORTB.0
    High PORTB.1
    Low PORTB.2 'boton9
    ADCIN 0,A
    F=A-50

    IF (A<50) THEN
    T=19
    Serout trs,n9600,[#T] 'trs var PORTC.6 pin 17
    Pause(50)
    Serout trs,n9600,[#F] 'trs var PORTC.6 pin 17
    Pause(50)
    Endif

    Goto loop

    End

    The transmission results are shown on the file "Recepcion 3.jpg", attached in this post.

    This is the Master program that pretends to grab these results and send it to the computer:

    include "modedefs.bas"

    NT Var BYTE
    FT Var BYTE
    TX Var PORTC.6
    RX Var PORTC.7

    seguir:
    serin rx,n9600,NT
    serin rx,n9600,FT
    serout tx,n9600,[#NT,"-"]
    serout tx,n9600,[#FT,10,13]
    goto seguir
    END

    The results are shown on the file "Transmision 3.jpg", also attached in this post.

    Once you saw the files and programs, you can see the magnitude of the problem. The results of the master program does not match the ones on the slave. While the slave send the correct parameters and results, the master sends another that are incorrect. I think it's a matter with the serin and serout commands, something that I just missed. Please help me with this and I'll be grateful, because this is part of my universitary thesis!

    Regards and thanks for your attention...

    Juan Escajadillo
    Attached Images Attached Images   
    Last edited by jmescajadillo; - 12th September 2006 at 16:22.

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

    Default

    Try..
    Code:
    serin rx,n9600,#NT
    serin rx,n9600,#FT
    Steve

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

  3. #3
    jmescajadillo's Avatar
    jmescajadillo Guest

    Unhappy Already tried

    Quote Originally Posted by mister_e
    Try..
    Code:
    serin rx,n9600,#NT
    serin rx,n9600,#FT
    I've already tried this way due to a little knowledge of the serin command, but it got worse: it doesn't transmit anything on the hyperterminal program! Please suggest me something else to solve my problem.

    Thank you anyway

    Juan Escajadillo

    P.S: I'm using two pics: the PIC16F873A for the slave, and the PIC16F876A for the master. They have similar pin structure... and they work! How do I know when one of my PICs is deffective?
    Last edited by jmescajadillo; - 13th September 2006 at 19:59.

Similar Threads

  1. Serial communication problems
    By amindzo in forum Serial
    Replies: 0
    Last Post: - 28th August 2006, 17:48
  2. Serial communication problems
    By amindzo in forum General
    Replies: 0
    Last Post: - 28th August 2006, 17:47
  3. Serial Communication Problems (Strange!!)
    By Armando Herjim in forum Serial
    Replies: 1
    Last Post: - 20th June 2006, 22:46
  4. serial communication problems
    By bronorisp in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 20th January 2005, 23:50
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

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