SERIN2 – SEROUT2 and Manchester mistake.


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2006
    Location
    North of France
    Posts
    18

    Question SERIN2 – SEROUT2 and Manchester mistake.

    Hello, i'm trying to send some datas over wireless network from a pic to another one.
    For the explanation, pic sender is PICTX and the other is PICRX.

    My pics are 12F683 both.

    The code sent by the PICTX seems to be okay

    Example : If PICTX send the letter " d " in Manchester style over the 433Mhz network, i can read 01 10 10 01 01 10 01 01 on the input pin of PICRX.
    Okay but not perfect because i haven't work enough to send the WakeUp string in Manchester style….

    This is the code i use for the PICTX :

    '---------- Begining

    @ device PIC12F683, intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, protect_off, bod_on
    OSCCON = %01110000
    DEFINE OSC 8
    ansel = 0
    cmcon0 = 7
    trisio = %000011
    INCLUDE "modedefs.bas"
    SYMBOL TRANSMISSION = GPIO.2
    DEFINE CHAR_PACING 100

    LOW TRANSMISSION
    Clear
    Pause 200

    '---------- End of header and now here are the variables

    CounterA var Byte
    MyDataIn var Byte
    ManchesterWord var Word[6]

    '---------- End of variables and now, here is the heart

    MyDataIn = "d"
    GOSUB EncodeManchester
    serout2 TRANSMISSION, 16468, [$55,$55,$55,$aa,IBIN16 Manchesterword,13,10]
    END

    '----------Manchester Encoding

    EncodeManchester:
    ManchesterWord=0
    For CounterA=0 to 7
    If MyDataIn.0=0 then
    ManchesterWord.14=1
    else
    ManchesterWord.15=1
    endif
    If CounterA<7 then ManchesterWord=ManchesterWord>>2
    MyDataIn=MyDataIn>>1
    Next CounterA
    Return
    'EOF
    '-------------

    Well, now, let's talk about my PICRX.
    I did a mistake into my code but i don't find wich...

    I'm not able to decode my manchester words.

    This is the code i use for PICRX:

    @ device PIC12F683, intrc_osc_noclkout, wdt_off, pwrt_off, mclr_off, protect_off, bod_on
    '----

    OSCCON = %01110000
    DEFINE OSC 8
    ansel = 0
    cmcon0 = 7
    '----
    trisio = %001000 ' Input pin is GPIO 3

    INCLUDE "modedefs.bas"

    LED VAR GPIO.0
    RECEPTION VAR GPIO.3
    INFO VAR GPIO.2
    CounterA var Byte
    ErrorFlag var Bit
    WakeUp var Byte
    MyDataOut var Byte
    ManchesterWord var WORD[6]

    Clear
    Low LED
    LOW INFO
    FLAG = 1
    Pause 1000

    '----

    Wait55:
    SERIN RECEPTION, n9600, WakeUp
    If WakeUp = $55 Then
    SERIN RECEPTION, n9600, WakeUp
    If WakeUp = $55 Then
    SERIN RECEPTION, n9600, WakeUp
    If WakeUp = $55 Then
    SERIN RECEPTION, n9600, WakeUp
    If WakeUp = $aa Then
    goto Receive
    ENDIF
    ENDIF
    endif
    endif
    Goto Wait55
    END

    '----------

    Receive:
    SERIN2 RECEPTION, 16468, [ManchesterWord] ' MY ERROR IS HERE I THINK!!
    serout2 INFO, 16468, ["This is ManchesterWord : ",IBIN16 ManchesterWord,13,10]
    GOSUB DecodeManchester
    IF ERRORFLAG THEN
    serout INFO, N9600, ["Error !",13,10]
    Pause 300
    goto Wait55
    ENDIF
    serout INFO, N9600, ["Value is Okay. (",MyDataOut,")",13,10]
    GOSUB Action
    GOTO Wait55

    '----------

    Action :
    If (MyDataOut = "c") Then
    High LED
    Pause 1000
    Low Led
    Endif
    Return

    '----------

    DecodeManchester:
    ErrorFlag=0
    For CounterA=0 to 7
    If ManchesterWord.1=0 then
    MyDataOut.7=0
    If ManchesterWord.0=0 then ErrorFlag=1
    else
    MyDataOut.7=1
    If ManchesterWord.0=1 then ErrorFlag=1
    endif
    ManchesterWord=ManchesterWord>>2
    If CounterA<7 then MyDataOut=MyDataOut>>1
    Next CounterA
    Return

    'EOF
    '-----------------------


    I’m sure it’s a stupid error but i’ve tried many things and i didn’t found.
    Any help ?

    Thanx a lot.
    Lyd.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    I looked at you code and see that you are using the internal OSC, I would not spend much time de-bugging until these are changed to externals.

    99.99% of the time internal OSC are not reliable enough for serial com.

    Go with a "resonator" the kind with three pins, and built in caps.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2006
    Location
    North of France
    Posts
    18

    Default

    Thanx mackrackit i know what you say but my problem is not here because, if i don't use the Manchester Encoding/Decoding, it work like a charm, event at 9.6Kbps (i'm glad to saw that).

    When i transmit in "clear mode" everything is good.

    My error is here :

    SERIN2 RECEPTION, 16468, [ManchesterWord]

    Because ManchesterWord is double sized than normal byte.
    I've tried with SERIN2 RECEPTION, 16468, [STR...

    but it's impossible because ManchesterWord is "VAR WORD".

    Because i'm just beginner with serin / serout, i don't know all the tips and there is probably one wich can do the rest.

    (and sorry for my bad English language, mine is French)
    Lyd.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    This is my best guess, but I am not sure as I do not see anything else.

    Where you have IBIN16 , try not using the I. This adds an extra character to the 16 digit string. Worth a quick try?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default

    This should do it:

    SERIN2 RECEPTION, 16468, [ManchesterWord.Byte0,ManchesterWord.Byte1]
    Last edited by Kamikaze47; - 4th September 2007 at 16:51.

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    IBIN16 is sending % followed by 16 bytes of data. Not just 16-bits. This produces an
    ASCII 0 or 1 for each bit in the word.

    Try something like;
    Code:
    serout2 TRANSMISSION,16468,[$55,$55,$55,$aa,Manchesterword.LowByte,Manchesterword.HighByte]
    On the receiving end, try something like;
    Code:
    SERIN2 RECEPTION, 16468, [WAIT($aa),ManchesterWord.LowByte,ManchesterWord.HighByte]
    This way SERIN2 on the receiving end simply ignores your $55 and waits for $aa before the
    16-bit data packet.
    Last edited by Bruce; - 4th September 2007 at 16:50.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Jan 2006
    Location
    North of France
    Posts
    18

    Default

    Well i've just done a test :

    This is what i send: 0110100101100101
    This is what i get on the RXPIC input pin named RECEPTION and connected to the RF 433Mhz circuit: 0110100101100101

    You can see it's the same datas.

    Now, if i do
    SERIN2 RECEPTION, 16468, [ManchesterWord]
    SEROUT2 INFO, 16468, [BIN16 ManchesterWord,13,10]

    This is what i get on the RXPIC pin named INFO : 0000000000100101

    So my error is a pure coding mistake, not RF.

    Thanx for you help.

  8. #8
    Join Date
    Jan 2006
    Location
    North of France
    Posts
    18

    Default

    Quote Originally Posted by Bruce View Post
    IBIN16 is sending % followed by 16 bytes of data. Not just 16-bits. This produces an
    ASCII 0 or 1 for each bit in the word.

    Try something like .../...
    Well, it's fantastic, you just turned my simple remote to remote-control ;O)

    Yes, your solution works fine.

    Many thanx all for your fast replies.

    Lyd.

  9. #9
    Join Date
    Jan 2006
    Location
    North of France
    Posts
    18

    Default

    Quote Originally Posted by Kamikaze47 View Post
    This should do it:

    SERIN2 RECEPTION, 16468, [ManchesterWord.Byte0,ManchesterWord.Byte1]
    Yes, it' s the same code as bruce just posted too.
    I just need to modify my serout on TXPIC too.

    Nice to saw all your replies.

    Lyd.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55

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