Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
Thread Tools Display Modes
Old 7th November 2007, 11:15 AM   (permalink)
Default RF receive using PIC USART

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.
col_implant is offline  
Reply With Quote
Old 7th November 2007, 11:33 AM   (permalink)
Default

Simply don't use the USART, it's not suitable for Manchester coding.

Check my tutorials which do RF comms not using the USART.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 7th November 2007, 11:43 AM   (permalink)
Default

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 is offline  
Reply With Quote
Old 7th November 2007, 11:49 AM   (permalink)
Default

Quote:
Originally Posted by col_implant
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.

Quote:

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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 7th November 2007, 01:12 PM   (permalink)
Default

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 is offline  
Reply With Quote
Old 7th November 2007, 01:41 PM   (permalink)
Default

Quote:
Originally Posted by col_implant
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 7th November 2007, 02:42 PM   (permalink)
Default

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!
col_implant is offline  
Reply With Quote
Old 14th November 2007, 04:38 PM   (permalink)
Default

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 is offline  
Reply With Quote
Old 14th November 2007, 05:40 PM   (permalink)
Default

Quote:
Originally Posted by col_implant
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?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 15th November 2007, 01:34 PM   (permalink)
Default

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 by col_implant; 15th November 2007 at 03:07 PM.
col_implant is offline  
Reply With Quote
Old 15th November 2007, 03:44 PM   (permalink)
Default

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?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 15th November 2007, 04:05 PM   (permalink)
Default

Yea thats what I have done now.

I'm also using a 4MHz crystal so no mods required there
col_implant is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
High ADC sampling rate PIC, 18F needed? bananasiong Micro Controllers 24 28th October 2007 12:13 PM
URGENT!! 16F877 & USART & Interrupt & Recieve Problem DaMieN Micro Controllers 0 18th September 2007 10:52 AM
Rf Pic flemmard Electronic Projects Design/Ideas/Reviews 1 9th September 2007 08:33 PM
16F628A USART - Sync receive mode kenmac Micro Controllers 14 6th June 2006 09:16 PM
Send and Receive In PIC16F873 With USART lht782002 Micro Controllers 0 26th April 2006 03:21 PM



All times are GMT. The time now is 07:49 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.