PDA

View Full Version : RF and Manchester



Pesticida
- 30th October 2005, 14:10
Hi,
I open a new thread while nobody answered my old thread :-).
Did someone have a working Manchester code Encoder and Decoder ?
This what I find in forum dont work.


Regard Pesti.

sougata
- 31st October 2005, 18:43
Hi there,

Could you please elaborate. I have worked with Manchester Encoding schemes but not with PBP really.

Regards

Sougata

BigWumpus
- 31st October 2005, 19:05
Please give me some informations:

How many Bytes do you want to transfer ?
Are the receiver an Transmitter PICs ?

Pesticida
- 31st October 2005, 20:57
Hi,
Thanks people,yes the receiver is a pic and the transmitter is a pic,I have PIC16f870 and a UAA3201T.
For the moment I want to send from 1 to 5 byte no more, just for tests when this work then i can do more.
I attached the receiver to PortA.0 and I want to Decode the data for example 1 or more byte and then on PortA.1 send the data encoded to the transmitter.
I need a working manchester code ?!
And my second question is Are the binary data from receiver from left to right to be read or from right to left(I know that when I read binary data i starting from right 1,2,4,8,16,32 and so on) and to send did I send from left or right.
I write this little example to test if this work:

Main:
Manchesterword = %1001101001010110

For CounterA=0 to 7
If ManchesterWord.15=0 then
MyData=0
endif
If ManchesterWord.15=1 then

MyData=1
endif

ManchesterWord=ManchesterWord<<2

hserout[bin MyData]
next

pause 2000

goto main

Thanks people for the help.

Regard Pesti.

Melanie
- 31st October 2005, 21:08
Try searching the forum... code examples in this thread...

http://www.picbasic.co.uk/forum/showthread.php?t=198

Pesticida
- 31st October 2005, 22:04
Hi Melanie,
I have just tryed this code but dont work,I'm tryed with this example just to see if this work:
Define LOADER_USED 1


Include "modedefs.bas" ' Mode definitions for Serout
ADCON1=7
define osc 4

DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 207 ' 1200 Bauds
DEFINE HSER_CLOERR 1

''''''''''''''''''''''''''''''''''''''''''''''''De coder'''''''''''''''''''''''''''''''''''''''''
Main:
ManchesterWord = %1010101001010101


ErrorFlag=0
For CounterA=0 to 7
If ManchesterWord.1=0 then
MyData.7=0
If ManchesterWord.0=0 then ErrorFlag=1
else
MyData.7=1
If ManchesterWord.0=1 then ErrorFlag=1
endif
ManchesterWord=ManchesterWord>>2
If CounterA<7 then MyData=MyData>1
next
hserout [Mydata]
pause 2000
goto Main

I become all the time 255255255255127127...... and so on.

Regard Pesti.

Bruce
- 1st November 2005, 00:58
Here's a simple set of manchester encode/decode routines.


inbyte VAR BYTE
outword VAR WORD
inword VAR WORD
outbyte VAR BYTE
i VAR BYTE

Begin:
CLEAR
inbyte = 12 ' byte for test
GoSub Encode ' convert to Manchester word
inword = outword
GoSub Decode ' convert from Manchester word
outbyte = 0
goto begin

Encode:
For i = 0 to 7 ' loop for 8-bits
outword.0[(i*2)] = ~inbyte.0[i] ' Get bit value for bits 0,2,4,6,8,10,14 in outword
outword.0[(i*2)+1] = inbyte.0[i]' Get bit value for bits 1,3,5,7,9,11,13,15 in outword
Next i '
Return

Decode::
For i = 0 to 7 ' loop for 8-bits
outbyte.0[i] = ~inword.0[i<<1] ' outbyte bits 0-7 = inword bits 0,2,4,6,8,10,14
Next i ' Inverts each 2nd bit position in inword I.E. 01 = 0, 10 = 1
Return

Pesticida
- 1st November 2005, 08:13
HI,
Bruce thank you verymuch,now I can good sleep :-).
I must now this test !
Now I understand how word modifier are working.
Thank you .
Thank you.

Regard Pesti.

Pesticida
- 1st November 2005, 09:34
Hi,
I have another question Bruce how can I compare 2 or more bytes when I just a example receive from transmitter byte0 = 241 byte1= 246 on the decoder output?
Can I do that like this:
if (outbyte = $F1) & (outbyte = $F6) then hserout [outbyte]

Thanks.
regard Pesti.

Bruce
- 1st November 2005, 14:31
Hi Pesti,

Your example should work fine.

Pesticida
- 1st November 2005, 14:57
Hi Bruce,
I have analysed the data from my transmitter I become this when i push the button:
24124625025424224224824225424124625025424224224824 2254

But when I dont push the button ,the receiver send to PIC this"I think this is just noise or Alien data :-)" :
24224224324124024025525524324124124024025525524324 32412402532402552412402552522472472502502492462552 49244253240244247255245244255255255249248255249244 25524124125524724324324924024024025525324025525424 72432432412402442552552412542552442552552542472432 41241240255250251241242255253246247243241241255253 24724724324124124025525325525125125524124225525325 52422402522492532472432432412412402552552552412402 55254255246247243249243244255240255255240248255252 25425425424324124124425525524925425425225524725524 32552522542462472432412412402552432412482552402482 55251252252254246255248255253244255240255241240255 24624324324124124825524124024325524124024025524025 5251244255244248247255244248"FromHERE241246250254242242248242254241246250254242 242248242254ToHere"24224224324124024.............

I must to filter the data what I need :2412462502542422422482422542412462502542422422482 42254
I try this: if (outbyte = $F1) & (outbyte = $F6) then hserout [outbyte] but dont work !


How can I do this Bruce, simple as possible :-)

Thanks.
Regard Pesti

Bruce
- 1st November 2005, 15:07
A few things to consider.

1. If you do not clear a variable it will retain the last value placed in it.
2. Most inexpensive or sensitive RF receivers will output random noise spikes when the transmitter is idle.

Try sending data in packets of a specific size, and using some form of synchronization byte at the start of each packet. Receive your data in a specific number of bytes. If the first byte is not the synch value or character, dump the data packet.

It's rare that you'll see a solid RF application just flinging random data at a receiver.

Pesticida
- 1st November 2005, 20:02
Hi,
Did some one know how can I separate from a word bytes,Example :
I receive with serin 10 bytes,how can i show this bytes with serout.

Regard Pesti.