Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help with my manchester encoding

Status
Not open for further replies.

Zaindroid

Newbie level 6
Newbie level 6
Joined
Dec 10, 2013
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
79
hi,
i need help with my manchester encoding code, i have written a code (code and proteus simulation is provided below).this code takes an input from virtual terminal and then encodes that received input using manchester encoding. after encoding it sends the encoded data back to virtual terminal. The problem i am im facing is: i am receiving something back but it is some garbage value. Plz help me in this regard.

#include <reg51.h>
sbit rs= P2^0;
sbit rw= P2^1;
sbit en= P2^2;
void SendData(int txbyte);
void delay(unsigned int itime);
void lcdcmd(unsigned char digit);
void lcd_data(unsigned char alpha);
void lcd_init();
void serial_port();
void main(void)
{
int mybyte;
serial_port();
lcd_init();
while (1)
{ //repeat forever
while (RI==0); //wait to receive
mybyte=SBUF; //save value
lcd_data(mybyte); //write value to port
//delay(250);

SendData(mybyte);

RI=0;


}
}
void SendData( int txbyte)
{
int i,j,b,me,x;
b = txbyte;
for (i=0; i<2; i++)
{
me = 0; // manchester encoded txbyte
for (j=0 ; j<4; j++)
{
me >>=2;
if ((b & x) == x)
me |=0x40; // 1->0
else
me |=0x80; // 0->1
b >>=1;
}
SBUF=me; //place value in buffer
while (TI==0);
TI=0;
delay(50);
}
}

void delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}


void lcdcmd(int digit)
{
P1=digit;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
}


void lcd_data(int alpha)
{ if (alpha==0x08)
lcdcmd(1);
else
P1=alpha;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
}

void serial_port()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}

void lcd_init()
{
lcdcmd(0x38);
//delay(250);
lcdcmd(0x0E);
//delay(250);
lcdcmd(0x01);
//delay(250);
lcdcmd(0x06);
lcdcmd(0x80);
} //delay(250);
 

Attachments

  • hyper_lcd.rar
    12.7 KB · Views: 99

The shown manchester-like encoding generates two dc-balanced bytes form a single binary byte and help to manage binarty data transmission with simple RF modules.

It must be omplemented by a respective decoding step at the receiver side.

A fully operational manchester encoded radio protocol involves these elements:
- preamble
- sync character
- manchester encoded data
- crc

On the receiver side, the decoder should be synchronized on the bit level, which isn't possible with a hardware UART.
 

so thankful of you for replying
but
what do you mean by not possible with hardware UART?
is the code fine and its just simulation problem?
kindly explain this a bit.
 

Firstly the data has to be decoded in software to display it. There's no decoding part in your code.

Secondly I mentioned that when using the manchester encoded data for a radio link, you should have a receiver with bit-level synchronization for best performance. A hardware UART can't do this, the tasl has to be performed in software.
 

can you help me or suggest some links about "bit-level synchronization".
 

Personally I'm not using software decoders rather than RF chips that handle the protocol in hardware. There's a VirtualWire library for Arduino that can be used as a template for similar designs. **broken link removed**
 

but i am working with 8051, so need assistance according to that?
 

i have written a code for transmitter and receiver side, i am attaching my code and proteus simulations.(trans-receive.rar)
in this code i have tried the transmitter to simply encode the 0x41 into manchester code and receiver on receiving the 16-bit manchester code, convert it back to 0x41 and dislays it over lcd. kindly check this, its not working for me.plz help me.
 

Attachments

  • trans-receive.rar
    14 KB · Views: 90

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top