PDA

View Full Version : Help with Manchester Encoding



jhorsburgh
- 11th August 2008, 12:46
Hello All,
A while ago I found a code posted by dhouston for Manchester encoded RF communication. http://www.picbasic.co.uk/forum/showthread.php?t=6261
I have been trying to compile the code using Microcode Studio and the PBP compiler but have come across some problems.

The first problem I came across was the PIC fuse settings, the code would not compile when the “@ __config” line was present. I did some searching and found that when using Microcode Studio with PBP, the fuse settings needed to be written differently;

It is written like this in dhouston’s examples (MPASM);
<code>@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF</code>

Converted fuse settings, thanks to Melanie’s Post(PM);
<code>@ DEVICE PIC12f629, INTRC_OSC_NOCLKOUT
@ DEVICE PIC12f629, WDT_OFF
@ DEVICE PIC12f629, PWRT_ON
@ DEVICE PIC12f629, MCLR_OFF
@ DEVICE PIC12f629, BOD_ON
@ DEVICE PIC12f629, CPD_OFF</code>

I made the changes and removed “CP_OFF” from the code because I don’t think the 12F629 supports that setting. The Transmitter code then compiled successfully with no errors.

Unfortunately the Receiver code did not compile successfully, it produces the same three errors for both line 41 and 42.

Line 41: <code>If RF[0]+RF[1]<>&HFF Then init</code>
Line 42: <code>If RF[2]+RF[3]<>&HFF Then init</code>

Errors produced by Microcode Studio whilst compiling;
ERROR Line 41: Bad expression. (RX.pbp)
ERROR Line 41: Bad expression or missing THEN. (RX.pbp)
ERROR Line 41: IF without a matching ENDIF. (RX.pbp)
ERROR Line 42: Bad expression. (RX.pbp)
ERROR Line 42: Bad expression or missing THEN. (RX.pbp)
ERROR Line 42: IF without a matching ENDIF. (RX.pbp)

Can anyone see any problems with the code that could cause such an error? I have attached copies of the full code just in case.

Thank you all for your help,
Jeremy

Ioannis
- 11th August 2008, 13:16
try to put the result of the addition into a temp var and then do the comparisson.

Ioannis

skimask
- 11th August 2008, 14:01
Line 41: <code>If RF[0]+RF[1]<>&HFF Then init</code>
Line 42: <code>If RF[2]+RF[3]<>&HFF Then init</code>



If RF[0]+RF[1]<>&HFF Then init
If RF[2]+RF[3]<>&HFF Then init

What is this?
I don't see any reference to &H to represent hexadecimal in the PBP manual...Assembler yes, PBP no...


If ( RF[ 0 ] + RF[ 1 ] ) <> $FF Then init
If ( RF[ 2 ] + RF[ 3 ] ) <> $FF Then init

jhorsburgh
- 13th August 2008, 02:35
Thanks Skimask, i made the changes to the code and it compiled with no errors.

I managed to download the HEX files to both the transmitter and reciever chips and installed them back into the circuit. I connected it to the computer and started HyperTerminal. When i powered the circuit up, Hyperterminal displayed "uB=" three times and then no more information was displayed.

I am still new to this so i am not sure whether i have stuffed up the circuit or the code. I have attached a copy of the circuit design, can anyone's see anything wrong with it or programmed it incorrectly?

Thanks again,
Jeremy

skimask
- 13th August 2008, 03:55
I managed to download the HEX files to both the transmitter and reciever chips and installed them back into the circuit. I connected it to the computer and started HyperTerminal. When i powered the circuit up, Hyperterminal displayed "uB=" three times and then no more information was displayed.
Re-Read your PBP manual SLEEP section VERY VERY carefully.
Then compare that chapter to your code and you will have your answer.

I believe that the thread referenced in post #1 is flawed in one particular aspect (it also contain the phrase 'this example has not been tested'), and it is this aspect in which yours is also flawed...

jhorsburgh
- 14th August 2008, 05:14
Thanks Skimask, i had to read over the SLEEP definition a couple of times but i got it in the end. The code worked fine when there is a wire between the PIC's but when i use the RF Modules the first signal goes through to the computer but after that only 30% make it.

I looked around and found that almost all similar project use an external oscillator, so i changed it to external and added leds to both circuits so i know when a signal is sent and recieved. That didn't really do much more than tell me that the reciever wasn't getting the signal.

Would a preamble be needed to make this more reliable. If so how would i go about doing that?
Thanks,
Jeremy

Ioannis
- 14th August 2008, 08:46
Are your modules capable of sending serial data? If not, then manchester encoding - decoding is a must. Also preamble always needed.

This case has been brought up many times, just have a look around.

Ioannis

jhorsburgh
- 18th August 2008, 03:29
Thank you all for your help.
I have moved back to SEROUT/SERIN to keep things simple. The RF seems to be working great, now i just have to get the IR working.

Thanks Again,
Jeremy

Ioannis
- 18th August 2008, 09:09
Serin/Serout has nothing to do with the modules ability to send raw binary or encoded data for Data slicer balancing. Be carefull with that.

Ioannis