help with SERIN & SEROUT


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Posts
    7

    Question help with SERIN & SEROUT

    hello my name is Max I`m from Mexico

    I have a problem; Im building a remote control using RF with modulation ASK, at the beginning I try to turn on and turn off a led. and Iam using the pic 16f84a. To turn on the led i used a switch and the command serout example:

    if sw1=1 then
    serout datout,N2400,{5}
    end

    to turn off i used another switch an the command serout

    if sw2=1 then
    serout datout, N2400,{8}
    endif

    the first test works very good even a 50mts of distance.
    But my problem is here: I try to turn on and turn off with the same switch but i cant do this, why? i have some theory about.
    when i use a one SW only have 2 (obvius)on/off, when is off the serout send the data again and again and when the SW do the same. the RX recieve the data time and time again with this the program behaves very rare.


    how i can to do the tx send only one time the code, even the sw still on or off during anytime?

    the rx: code is like this

    rx:
    serin datin, N2400,dato
    if dato =5 then
    high led
    endif

    if dato=8 then
    low led
    endif


    I was reading the command serin is able to compare the entrance variables, but i dont know how

    please any have an idea??? help me


    P.S. my english is too bad sorry i hope you understand my problem

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


    Did you find this post helpful? Yes | No

    Default

    Even it could be much than what you think, can you try that one and post resukt
    Code:
    Oldata  var byte
    Dato    var byte
    
    dato=0
    oldata=1
    
    rx: 
        serin datin, N2400,[dato]
        if dato != Oldata then
            if dato =5 then
                high led
                oldata-dato
                endif
            
            if dato=8 then
                low led
                oldata=dato
                endif
            
            endif
    But you may/must need a synchro data, then receive the function you want to do. Lookj for the WAIT modifier.

    A common protocol is Manchester, do a search within this forum you'll find the theory. But as you want to receive only 1 or few bytes, send some preamble data (like $aa, $55), then send a Synchro by, then your data). The receiver must wait the synchro, then get the data.
    Steve

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

  3. #3
    Join Date
    Sep 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Thumbs up Danke

    thank you.
    I will test with your code or similar, but i dont understand the syncrho data. the transmitter and recivier works with asyncronous data too.

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    SEROUT SerPin,BAUD,["UUUUUSYNCHRO",YourByte]
    RECEIVER SIDE
    Code:
    SERIN2 SerPin,BAUD,[WAIT ("SYNCHRO"),YourByte]
    Or a variant of it.
    Steve

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

  5. #5
    Join Date
    Sep 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Red face Hi

    well, i tested the first program and doestn works, then I use a LCD (16X2) for view the variable in the Reciever, the lcd show me the number and show me how works my program and i can view that my program is wrong because the data is send time and time again, and before a while the data changes. I mean first put p.e.: 0,0,0,0,0,3,3,3,0,0,0,0 during the switch is off an suposed the lcd put only zeros. and "viceversa"

    Then i try to fix the problem but now i doesnt pass anything, i cant recieve or i cant transmitt, i testes the pics and works perfectly, I thought that modules RF had been disturbed, And I connected pics directly and even so it does not pass anything, then I believe that it is my program and at this point already my mind is blocked some help?

    here the two codes: (when it worked )

    transmitter code:'TX CODIGO TRANSMISOR

    INCLUDE "modedefs.bas"

    TRISA=6

    DATOUT VAR PORTA.0
    ONN VAR PORTA.1
    OF1 VAR PORTA.2
    C VAR BYTE

    TX:


    IF OF1=1 THEN
    C=2
    ENDIF



    IF ONN=1 THEN
    C=5
    ENDIF



    IF C=2 THEN
    SEROUT DATOUT,N1200,[0]
    ENDIF

    IF C=5 THEN
    SEROUT DATOUT,N1200,[7]
    ENDIF


    GOTO TX



    reciever code:'RX CODIGO RECEPTOR

    INCLUDE "modedefs.bas"

    TRISB=1

    DATAIN VAR PORTB.0
    LEDVER VAR PORTB.1
    DATO VAR WORDS


    RX:

    SERIN DATAIN,N1200,DATO

    IF DATO=0 THEN
    LOW LEDVER
    ENDIF

    IF DATO=7 THEN
    HIGH LEDVER
    ENDIF

    goto rx

  6. #6
    Join Date
    Sep 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Thumbs down my mind is dead

    Hola, mi cabeza ya de plano tiene muchos golpes, como volví hacer todo, hagamos de cuenta que no uso los modulos rf, ahora solo comunico los pics con un cable directamente, pero no me sale nada. se supone que con un switch mando un dato para prender un led y si esta cerrado mando otro para apagarlo y no lo hace. ya revise los pics y si funcionan, ya me canse de cambiar el programa y nada la verdad ya no se que hacer. les juro que ya me duele la cabeza de estar piense y piense y nada mas no me queda. he hecho otros programas pero este en particular como me ha dado dolores de cabeza

    alguna ayuda aqui los codigos:

    'TX CODIGO TRANSMISOR

    INCLUDE "MODEDEFS.BAS"


    TRISA=1

    BOTON VAR PORTA.0
    VIATX VAR PORTA.1
    LEDVE VAR PORTA.2
    LEDRO VAR PORTA.3

    pause 500
    TX:


    IF BOTON=1 THEN
    GOSUB SEND1
    ENDIF



    IF BOTON=0 THEN
    GOSUB SEND2
    ENDIF


    GOTO TX


    SEND1:
    SEROUT VIATX,N9600,[7]
    LOW LEDRO
    HIGH LEDVE
    RETURN

    SEND2:
    SEROUT VIATX,N9600,[0]
    LOW LEDVE
    HIGH LEDRO
    RETURN
    .............................................
    ' RX CODIGO RECEPTOR


    INCLUDE "MODEDEFS.BAS"

    TRISB=1

    VIARX VAR PORTB.0
    LEDRO VAR PORTB.1
    LEDVE VAR PORTB.2
    DATO VAR BYTE

    RX:

    SERIN VIARX,N9600,DATO

    IF DATO=0 THEN
    HIGH LEDVE
    LOW LEDRO
    ENDIF


    IF DATO=7 THEN
    LOW LEDVE
    HIGH LEDRO
    ENDIF



    GOTO RX:
    .......................................

    ya no puedo mas estoy frito alguna ayuda porfavor

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 21:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 17:46
  3. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 23:03
  4. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 18:11
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 16:54

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