RF receive using PIC USART

Status
Not open for further replies.

col_implant

New Member
Hi,

I'm developing RF communication using two PIC18F2520s and melexis TX / RX ICs for a medical implant. Data transmission has been verified, as has reception up to the input pin of the RX PIC USART.

My data is Manchester coded, as recommended, and I'm wondering how to synchronize the receiver PIC USART since standard serial start bit (long one followed by a transition to zero, or vice versa) cannot be implemented. The preamble we use is 0x55 three times (i.e. clock run 01010101 x3) followed by start byte 0x75.

The problem is that in initial RX IC synchronization it often takes one or two bit toggles to receive data so the first bits of the preamble are often lost. The USART RCIF flag seems to go high at random and the data in the RCREG is not correct (most often 0x00). This even occurs when no data is transmitted, since digital noise is output from the RX IC. To some extent this can be minimized by monitoring the RX IC RSSI level and only looking at the RCREG when the RSSI level is above a certain threshold.

However if I send only one data byte (or two Manchester encoded) and search the RCREG only for the start code 0x75 it seems to work, regardless of whether the bits of the preamble are lost or not. Its makes no sense that the USART knows where the 0x75 byte starts and ends if there is say 2 1/2 preamble bytes before it. This is a solution but obviously not optimum as preamble/start code would need to be sent for each data byte.

Any help would be greatly appreciated.
 
Simply don't use the USART, it's not suitable for Manchester coding.

Check my tutorials which do RF comms not using the USART.
 
Hey, thanks but I have checked out you site before. The intorduction to (tutorial 12) seems quite detailed but are there specifics of 12.1 etc?? Seems only to specify what is required to do tutorial

Also I'm using MPLAB and unfortunately IT here would probably not allow a third party development tool to be installed, is this required??
 
col_implant said:
Hey, thanks but I have checked out you site before. The intorduction to (tutorial 12) seems quite detailed but are there specifics of 12.1 etc?? Seems only to specify what is required to do tutorial

That's all it provides, the Manchester routines aren't mine, I give the source reference for them, the transmit side is trivial, it's the receive side that's complicated.

Also I'm using MPLAB and unfortunately IT here would probably not allow a third party development tool to be installed, is this required??

I don't use any third party development tools?, I use MPASMWIN, the assembler that MPLAB uses - it's installed along with MPLAB, and MPLAB can't assemble code without it.
 
Oh I missed the asm file downloads... pretty important I guess.

I'm gonna jump straight into 12.2, and maybe leave the transmitter as is... using the USART, as it is working fine.

Thought I would need to use your WinPicProg to do the tutorials.

Thanks!
 
col_implant said:
Oh I missed the asm file downloads... pretty important I guess.

I'm gonna jump straight into 12.2, and maybe leave the transmitter as is... using the USART, as it is working fine.

I wouldn't have thought leaving the transmitter as is would work?, as it's a completely different system - a UART isn't really suitable, as you don't have start or stop bits as such in Manchester coding. A UART works by using exact bit lengths (105uS for 9600 baud), but neither radio or IR accurately transfers these pulse lengths, which is why Manchester coding is used. Manchester uses the transistion from high to low, and from low to high, to signify the bits - the length of them doesn't matter.
 
Ok thanks for saving the frustration later on!.

Theres the problem that Microchip dont fully explain the USART operation... only a simple functional explanation is given....

A complete comms overhaul it is then! I'll let you know how it works out!

Thanks Again!
 
is this really the simpler solution??? The complexity has me overwheled... im finding the code impossible to debug when I integrate it into my own program
 
col_implant said:
is this really the simpler solution??? The complexity has me overwheled... im finding the code impossible to debug when I integrate it into my own program

What's to debug?, just cut and paste the subroutines?.
 
Ok maybe i did a little too much too soon, I read through the code and took a reasonable understanding and then integrated it into my asm files, making changes (which should not have affected fuctionality).

Now Ive gone right back to basics, on tutorial 12.1 making only the changes necessary to operate on the PIC18F2520 (ie header, include, my config, changed I/Os, FSR,INDF -> FSR1,INDF1, removed bank selection RP0/RP1, changes rlf ->rlcf, clrw -> clrf w) No other changes.

TX: No problems, 20 header 1's generated followed by 0.

RX: Almost always the header detected is too short, (usually bitcnt=7), and sometimes I get no mid frame transition errors.

From a comms point of view my setup is pretty ideal, lamda/4 antenna in close proximity, 19 of the 20 start bits appear clearly at the PIC input. I have even removed the RF and placed a wire between the two micros, the errors are the same
 
Last edited:
From a comms point of view you could ignore the tx/rx modules, and just connect them pin to pin. Have you modded the code for the clock rate you're using?, as far as I remember it's written for 4MHz?.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…