Maker Pro
Maker Pro

Manchester encoding

L

lerameur

Hello

I am doing and RF application with PIC chip and using picbasic pro to
write my code. My poblem is that I have a 8 bit number I want to send
serially. The serout command work up to 8 bit , so the number should
not be distorted, Althought I want to use manchester encoding which
will double the bandwidth (16bit), therefore I cannot use the serout
command which is only good for 8 bit.Doe someone know how to bypass
this problem.
thanks
ken
 
J

James Beck

Hello

I am doing and RF application with PIC chip and using picbasic pro to
write my code. My poblem is that I have a 8 bit number I want to send
serially. The serout command work up to 8 bit , so the number should
not be distorted, Althought I want to use manchester encoding which
will double the bandwidth (16bit), therefore I cannot use the serout
command which is only good for 8 bit.Doe someone know how to bypass
this problem.
thanks
ken
Yes, send 2 bytes.
 
R

Rubicon

Hello

I am doing and RF application with PIC chip and using picbasic pro to
write my code. My poblem is that I have a 8 bit number I want to send
serially. The serout command work up to 8 bit , so the number should
not be distorted, Althought I want to use manchester encoding which
will double the bandwidth (16bit), therefore I cannot use the serout
command which is only good for 8 bit.Doe someone know how to bypass
this problem.
thanks
ken

Ken,

********************************************
To receive 16bit Manchester and decode to 8bit

incode=0 'clear 16bit translation WORD vairable

rec_code=0 'clear 8bit translated code BYTE

serin2 portb.0,1646,300,noserin,[wait (qualifier), incode.lowbyte,
incode.highbyte]

for rx=0 to 7 'for-next loop 8 times - BYTE vairable

rec_code.0[rx]=~incode.0[rx<<1] 'translate 16bit Manchester code. WORD
'(01 to 0 & 0 to 1)

next rx 'repeat for-next loop
if rec_code=whatever_code then 'Compare 8bit rec-code and execute if
'it matches constant "whatever_code"

'1646=600bps driven,true,no-parity
'300 is the timeout before going to the noserin subroutine
'qualifier is an 8bit code that must be received first

****************************************************
To send out 16bit Manchester I've only used 16bit WORD constants and
sent them. Try the reverse of the above translation code.

serout2 portb.0, 18030,
[$8,qualifier,trans_code.lowbyte,trans_code.highbyte]

'18030 = 600bps driven,inverted,no-parity - different from the
receiver in inverted/true as it suited my application. You will
probably need to alter this for your required bps and application.
The $8 was a 4bit binary 1000 space I tried here for the receiver for
some reason.

It would be better for you if you tried the link below but search the
archives first.
http://www.picbasic.co.uk/forum/

Good luck,

Rubicon.
 
L

lerameur

********************************************
To receive 16bit Manchester and decode to 8bit

incode=0 'clear 16bit translation WORD vairable

rec_code=0 'clear 8bit translated code BYTE

serin2 portb.0,1646,300,noserin,[wait (qualifier), incode.lowbyte,
incode.highbyte]

for rx=0 to 7 'for-next loop 8 times - BYTE vairable

rec_code.0[rx]=~incode.0[rx<<1] 'translate 16bit Manchester code. WORD
'(01 to 0 & 0 to 1)

next rx 'repeat for-next loop
if rec_code=whatever_code then 'Compare 8bit rec-code and execute if
'it matches constant "whatever_code"

'1646=600bps driven,true,no-parity
'300 is the timeout before going to the noserin subroutine
'qualifier is an 8bit code that must be received first

****************************************************
To send out 16bit Manchester I've only used 16bit WORD constants and
sent them. Try the reverse of the above translation code.

serout2 portb.0, 18030,
[$8,qualifier,trans_code.lowbyte,trans_code.highbyte]

'18030 = 600bps driven,inverted,no-parity - different from the
receiver in inverted/true as it suited my application. You will
probably need to alter this for your required bps and application.
The $8 was a 4bit binary 1000 space I tried here for the receiver for
some reason.
From the picbasic pro manual , I read that serout commandis use to
send 8 bit packet, you are using it to send a word (16bits), so what is
the deal there ?
Why does it work with a word size...
ken
 
L

lerameur

by the way, I am trying to use an array with picbasicpro

lcdout $FE,$C0, bin encoded1[3]

I thought it would give the 4 th digit of the array in binary, but
instead it gives me a 13 bit number... what is going on .

ken
 
R

Rubicon

********************************************
To receive 16bit Manchester and decode to 8bit

incode=0 'clear 16bit translation WORD vairable

rec_code=0 'clear 8bit translated code BYTE

serin2 portb.0,1646,300,noserin,[wait (qualifier), incode.lowbyte,
incode.highbyte]

for rx=0 to 7 'for-next loop 8 times - BYTE vairable

rec_code.0[rx]=~incode.0[rx<<1] 'translate 16bit Manchester code. WORD
'(01 to 0 & 0 to 1)

next rx 'repeat for-next loop
if rec_code=whatever_code then 'Compare 8bit rec-code and execute if
'it matches constant "whatever_code"

'1646=600bps driven,true,no-parity
'300 is the timeout before going to the noserin subroutine
'qualifier is an 8bit code that must be received first

****************************************************
To send out 16bit Manchester I've only used 16bit WORD constants and
sent them. Try the reverse of the above translation code.

serout2 portb.0, 18030,
[$8,qualifier,trans_code.lowbyte,trans_code.highbyte]

'18030 = 600bps driven,inverted,no-parity - different from the
receiver in inverted/true as it suited my application. You will
probably need to alter this for your required bps and application.
The $8 was a 4bit binary 1000 space I tried here for the receiver for
some reason.
From the picbasic pro manual , I read that serout commandis use to
send 8 bit packet, you are using it to send a word (16bits), so what is
the deal there ?
Why does it work with a word size...
ken

Ken,

Forgive me for too much Xmas cheer.

My application, from memory was a simple remote control. Instead of
taking a byte, encoding it each time a button was pressed and then
sending it I just used a 16bit already Manchester encoded WORD
constant and sent that - in two parts. Lowbyte and then highbyte with
a qualifier byte and perhaps a preamble at the start.

Serout or Serout2 sends in user specified values like 8N1, 8bits,
no-parity, 1-stop bit. Thats 8bits or one byte at a time so for a WORD
vairable it takes two bytes for a WORD - lowbyte and highbyte. If you
read the PICBASIC PRO manual you'll see that it drops the preamble,
qualifier and other Serout bits.

Manchester encoding takes a single byte (8bits) and makes it a WORD
through encoding (16bits). Serout2 can't handle that directly so you
need to break it down into bytes - lowbyte/highbyte. Hence the
encoding/decoding required.

I have dug out the printout that I used to do what I needed and below
is the code provided by Greg Yent from the picbasic.com forum
archives. Alter it to suit your needs.

TempWord VAR WORD
TXData VAR BYTE
RXData VAR BYTE

'assign your special data to TXData


ENCODE:

for i = 0 to 7
TempWord.0[i<<1]=~TXData.0
TempWord.0[(i<<1)+1]=TXData.0
next i

Serout TXOut, 7,[Preamble, Sync, TempWord.Highbyte, TempWord.Lowbyte]

*************************************


Serin RXIn, 7, 100, NoRX, [Sync], TempWord.Highbyte, TempWord.Lowbyte

Decode:
for i = 0 to 7
RXData.0=~TempWord.0[i<<1]
next i

'RXData is the byte you've been looking for

*************************************

As for your other post I am in no way even close to being proficient
in Picbasic Pro. I am not by any stretch of the imagination an expert
and I have not as yet needed to deal with an LCD screen. This is why I
suggest you use the links below as residing there are the true experts
in PicBasic and PicBasic Pro, one such is the guru Melaine.

Just remember to search their archives first for your Manchester
encoding/LCD answers before asking in the forum as they may be
commonly asked and answered questions.

The Forum
http://www.picbasic.co.uk/forum/

The Archive
http://list.picbasic.com/cgi-bin/board-search.cgi

The PicBasic Pro Manual
http://www.melabs.com/resources/pbpmanual/contents.htm


Regards,

Rubicon.
 
Top