Lerameur
I suspect you too are using one of the ASK modulated RF modules. I understand from your code that you are Manchester coding the data to send to keep the module happy. However, I find the modules work best when you have just 4-5 bytes to send. Keep the messages short. So, I have used the following technique to send data properly. Of course, it helps to mention that RF shielding is very important for the receiver module in case you have the OEM version.
Code:
// wait for a packet marker RJ
serin2 RxD, Baud, [WAIT("RJ"), HEX1 Acc1]
// now disable the receiver since we got the data we need
RxDisable = 1
// if the data is for me, process it
if (ID = Acc1) then
pause 100 ' this delay is to allow the RX01 to turn off
' to prevent RF collision with multiple devices
Pot PotPort, 255, Acc1 ' read pot position and send
// Send the reply with ACC1 having the value to send
// the lower case rj is the packet marker to indicate acknowledge
Serout2 Txd,Baud,[$55,$55,$55,"rj", HEX1 ID,",",Dec2 Acc1]
endif
As you see, I haven't used any encoding and do happen to send the data properly. The trick here is that keeping the message short tricks the receiver into reading the data properly before the signal strength droops at the receiver end.
You may add LRC (Checksum) which will help you choose the good data packets and throw away the corrupted ones.
Jerson
Bookmarks