PDA

View Full Version : telecontrolli RF module



ngeronikolos
- 13th August 2009, 14:52
Hello to every picbasic fan,

I have just return from summer vacations and I am back for more coding...

I bought from a local shop a set of Tx and Rx 433Mhz RF Modules RT4 and RR3 by telecontrolli.

See datasheet
RT4: http://www.telecontrolli.com/pdf/transmitter/rt4.pdf
RR3:http://www.telecontrolli.com/pdf/receiver/rr3.pdf
Does anyone have any experience with them???
I failure to make a link.

My project
Tx
16f627 -4Mhz Ext.osc- rt4 -Antenna wire 17cm

Rx
16f627 -4Mhz Ext.osc -rr3 -Antenna wire 17cm -USART RS232


I use the manchester code from Ioannis(thanks)
-------------------------------------------------------------------
'tx
encoded var word
mydata var byte
mydata="T"
loop:
gosub encod_r
serout2 PORTB.0,813,[$55, $55, $AA, encoded.lowbyte,encoded.highbyte]
pause 1000
goto loop

encod_r:
For i=0 TO 7
IF mydata.0[i]=0 Then
encoded.0[i*2]=0
encoded.0[i*2+1]=1
Else
encoded.0[i*2]=1
encoded.0[i*2+1]=0
EndIF
Next i
Return
--------------------------------------------------------------

'rx
encoded var word
mydata var byte


loop:
SERIN2 reception, 813, [WAIT($AA),encoded.lowbyte,encoded.highbyte]
gosub decod_r

serout2 info, 813, [mydata]

goto loop


decod_r:
For i=0 TO 7
IF encoded.0[i*2]=0 Then
IF encoded.0[i*2+1]=1 Then
mydata.0[i]=0
EndIF
Else
mydata.0[i]=1
EndIF
Next
Return
------------------------------------------------------------------

My usart connecting with my PC is working BUT the link is dead.

Please any help is usefull
Nikos Geronikolos

dhouston
- 14th August 2009, 13:53
I am not a fan of the technique (oft recommended here) of supposedly training the receiver with a series of $55 and/or $AA. It is difficult to distinguish these alternating bits from the random noise that is always present at the output of a superregenerative receiver. See...http://davehouston.org/RFTipsTricks.htmfor an explanation.

Also see...http://davehouston.org/PIC-RX-TX.TXTfor sample code that uses a different technique that really does a better job of what the other technique purports to do - train the receiver by setting its AGC and ATC levels without the need for the receiver to distinguish $55 from noise. For short data transfers, I prefer the NEC protocol given in the first examples. Scroll down to see SerOut2/SerIn2 examples. I only recommend the latter for longer data transfers (and manchester coding is useful here).

You might also find it worthwhile to actually see the receiver output which you can do by using your soundcard to record it and then a Wave editor to view it. See...http://davehouston.org/learn.htm

For short data transfers, I also recommend repeating each transmission 3-5 times. That way you can look for the lengthy start pulse on each pass through your main loop. If you get a pulse that's about half the full width, branch to the routine that receives the data. That way you do not need to block other activity by waitng for the start condition.

Ioannis
- 14th August 2009, 15:17
More to what Dave noted, my experience with Telecontroli was not the best. So I switched to other brands and finally I made my own using chips by ATMEL and Intersil or Philips.

Aurel was one that I trusted before.

Now, as I see it, $55 is %01010101 and $AA is %10101010, so if the PIC catches somewhere in the middle the string it cannot distiguish whether is a 55 or AA or something else.

May be you can try a different start character instead of $AA.

Ioannis

ngeronikolos
- 14th August 2009, 17:33
Thanks both of you for your knownledge,

I have just made it work BUT with some problems...
I loose packets...

In the site of Tx I sent every 3secs a number that increase every loop.
In the site of the Rx I receiver less than the 50% of the total Tx pakets.

That is my code:
---tx-----------------------------------------------------

include "modedefs.bas"
@ DEVICE PIC16F627, HS_OSC
@ DEVICE pic16F627, WDT_ON ' watchdog timer
@ DEVICE pic16F627, PWRT_ON ' power-on timer
@ DEVICE pic16F627, MCLR_OFF ' master clear options (internal)
@ DEVICE pic16F627, BOD_OFF ' brown-out detect
@ DEVICE pic16F627, LVP_OFF ' low-voltage programming
@ DEVICE pic16F627, CPD_OFF ' data memory code Protect
@ DEVICE pic16F627, PROTECT_OFF ' program code protection

DEFINE OSC 4
CMCON = 7 'Turn off comparators
VRCON = 0
INTCON = 0 ' Disable interrupts

encoded var word
mydata var byte
i var BYTE
mydata=0

loop:
gosub encod_r

serout2 PORTB.0,813,[$55, $55,$55, $55, $CC, encoded.lowbyte,encoded.highbyte]

pause 3000
mydata=mydata+1
goto loop

'------------------Manchester encoder-------------------------------
encod_r:
For i=0 TO 7
IF mydata.0[i]=0 Then
encoded.0[i*2]=0
encoded.0[i*2+1]=1
Else
encoded.0[i*2]=1
encoded.0[i*2+1]=0
EndIF
Next i
Return
'------------------Manchester encoder-------------------------------
END


----rx------------------------------------------------------------------

include "modedefs.bas"
@ DEVICE PIC16F627, HS_OSC
;@ DEVICE pic16F627, INTRC_OSC_NOCLKOUT ' system clock options
@ DEVICE pic16F627, WDT_ON ' watchdog timer
@ DEVICE pic16F627, PWRT_ON ' power-on timer
@ DEVICE pic16F627, MCLR_OFF ' master clear options (internal)
@ DEVICE pic16F627, BOD_OFF ' brown-out detect
@ DEVICE pic16F627, LVP_OFF ' low-voltage programming
@ DEVICE pic16F627, CPD_OFF ' data memory code Protect
@ DEVICE pic16F627, PROTECT_OFF ' program code protection

DEFINE OSC 4
CMCON = 7 'Turn off comparators
VRCON = 0

' DEFINE VARIABLES FOR SERIAL TO PC 2400 8-N-1
DEFINE HSER_RCSTA 90H
DEFINE HSER_TXSTA 20H
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25

encoded var word
mydata var byte
i var BYTE
PAUSE 500
hserout ["RF Module RT4 and RR3", 13,10];<---------------------------

loop:
SERIN2 PORTB.0, 813, [WAIT($CC),encoded.lowbyte,encoded.highbyte]
gosub decod_r

hserout ["mydata = ",DEC mydata, 13,10] ' Display mydata on PC SERIAL RS232


goto loop

'------------------Manchester decoder-------------------------------
decod_r:
For i=0 TO 7
IF encoded.0[i*2]=0 Then
IF encoded.0[i*2+1]=1 Then
mydata.0[i]=0
EndIF
Else
mydata.0[i]=1
EndIF
Next
Return
'------------------Manchester decoder-------------------------------
END


and I receiver the following in my PC

RF Module RT4 and RR3
mydata = 3
mydata = 5
mydata = 11
mydata = 13
mydata = 15
mydata = 16
mydata = 21

instead of
mydata = 1
mydata = 2
mydata = 3
....

Please advice
Regards
Nikos

Ioannis
- 14th August 2009, 21:40
Obviously you loose time with the pause 3000 and the receiver has lost the previous transmission. So it waits for the next valid one.

Try to send 3-5 timesin a loop the same Serout.... and then wait 3000ms.

Like this:


loop:
gosub encod_r
for i=0 to 4
serout2 PORTB.0,813,[$55, $55,$55, $55, $CC, encoded.lowbyte,encoded.highbyte]
pause 100
next i
pause 3000
mydata=mydata+1
goto loop


Receiver may get 1 or more times the data and then you have to filter out. But that is easy to do. First get the transmission right.

Ioannis

P.S. It is OK here to use the same variable i.