RF: Manchester coding works. Very important for newbies. If you have patience, you can send large strings WITHOUT manchester coding. I also found that if you send the data INVERTED it will generally get there in better shape. Sending SYNK bits as a header is a great idea, and using the SERIN2 command with a qualifier will make life sooooooo much easier....... Here is my example:
transmittemp:
let i=0
for i = 0 to 2
portd.1=1 'switch on TX module
pause 125 ' wait a 125 mS to stabilise TX module
serout2 PORTd.0,16780,[44,44,44,44] 'sends command to temp module
pause 25 ' wait a little to organise PIC's thoughts
next i ' Next Pass
portd.1=0 ' Switch off TX
portc.3=1 ' Switch on RX
pause 25 ' 25 mS to stabalise
SERIN2 PORTc.4,16780,350,failuretemp,[wait("*"),STR temp\17] ' Get data - IF it begins with *
portc.3=0 ' Switch off RX
if temp[0] <> "*" then goto transmittemp ' If RX is not good, try again
if temp[15] <> "." then goto transmittemp ' If RX is not good, try again
HSEROUT [str temp\21,13,32,CR] ' Display the good data
clear ' Clear the array
Now, some of you experts might find this long winded, but it WORKS. If the RX doesn't receive what it wants, then it ignores the data and asks for it again from the temp module.
For those who are interested, this is part of the Temp module code, the one that reveices the command and sends the Temp afterwards....
tempsend:
portc.1=0 : ' Switch OFF RX module
portc.3=1 ' Switch ON TX module
for c =0 to 2 '
pause 50 'pause 50 mS
SEROUT2 PORTc.2,16780,[$55,$55,$55,$55,$55,"**Temperature ",dec2(temp/100),".",dec1 (Temp/10),"+"]' $55 is a SYNK bit, and the * is an indicator for the RX module.
PAUSE 25 ' Pause 25mS
next c ' next pass
portc.3=0 : goto main
Temp[0] is the first character in the Temp array AFTER the first "*" is ignored. This is a great way of checking that the data you received is actually data and not garbage (from your alarm keyfob or garage door opener), and I have put 2 checks in because there are 2 different data sets to be received, both are of different lengths.
I have had this working fine for about 4 hours, but previously without the Temp[0] checks I had it working for about 24 hours and only lost about 5% of the data I sent. Not bad eh?
What I would like are comments from all you lot out there who know this stuff better than I do. Several people on the forum have helped me out on this project with different suggestions and ideas, and general help, and now that I have learned how to do this I want to spread the knowledge to anyone who has a similar problem to what I had.
As ever, I accept no responsability for bad grammer, mispelled words or the weather.
Cheers,
Noel
Bookmarks