Go Down

Topic: reliable datagram RF22 library question (Read 3660 times) previous topic - next topic

Boffin1

Mar 20, 2013, 12:52 pm Last Edit: Mar 20, 2013, 12:56 pm by Boffin1 Reason: 1
For my next project, which is a remote control and telemetry link to a very large robot,  I want to have a safe wireless link with a range of at least 300meters.  I can use a decent antenna at the control centre, and a dipole on the robot, so range should be no problem.

I have used the RFM22B modules before, but only in the basic simplex mode,   I now have 2 of them hooked up on the bench and using the RF22 libraries "reliable datagram"  example from Mikem , with 2 Duemilanova boards for now ( they will have embedded chip pcbs in the final units ).

It worked first time, and I have found how to simply read the temperature and signal strength etc.

Now I am looking at how to structure my data, (  which is joysticks and switch data going to the robot, and a few oil pressure, fuel guage, temperature , signal strength and GPS position data coming back )

I was planning to collect the data and put it in a buffer to send, all in the main loop as usual.

In Mikes example below, he has defined the data and datalength between the setup and loop sections ?
Is there significance to this ?
I guess thats the same as having them at the top with the definitions if they are not going to change ?  

and I can find no reference to        while (1)  ?  and why    // Dont put this on the stack:

Code: [Select]

// rf22_reliable_datagram_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging client
// with the RF22ReliableDatagram class.
// It is designed to work with the other example rf22_reliable_datagram_server
#include <RF22ReliableDatagram.h>
#include <RF22.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
// Singleton instance of the radio
RF22ReliableDatagram rf22(CLIENT_ADDRESS);
void setup()
{
Serial.begin(9600);
if (!rf22.init())
Serial.println("RF22 init failed");
// Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
}
uint8_t data[] = "Hello World!";
// Dont put this on the stack:
uint8_t buf[RF22_MAX_MESSAGE_LEN];
void loop()
{
while (1)
{
Serial.println("Sending to rf22_datagram_server");
// Send a message to rf22_server
if (!rf22.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
Serial.println("sendtoWait failed");
else
{
// Now wait for a reply from the server
// Serial.println(rf22.lastRssi(), HEX); // of the ACK
uint8_t len = sizeof(buf);
uint8_t from;
if (rf22.recvfromAckTimeout(buf, &len, 2000, &from))
{
Serial.print("got reply from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
}
else
{
Serial.println("No reply, is rf22_datagram_server running?");
}
}
delay(500);
}
}


With my mobile phone I can call people and talk to them -  how smart can you get ?

PaulS

Quote
Is there significance to this ?

No. Anything declared outside of a function is global. Whether that happens before the first function, between functions, or after the last function does not matter.

Quote
and I can find no reference to        while (1)  ?

It's running an infinite loop, inside an infinite loop, so it's silly. Get rid of it.

Quote
and why    // Dont put this on the stack:

It's suggesting that the array should not be passed as an argument to a function. Passing arguments makes use of the stack. Of course, it would only out the address on the stack, and there is no problem with that, so the comment is useless.

Boffin1

Thanks Paul,   I shall move on now then
With my mobile phone I can call people and talk to them -  how smart can you get ?

oric_dan

On a different point, have you verified the RFM22s can communicate out to 300m?
I would check this before going very far with the rest of it. What frequency are you
using, 433 Mhz? BTW, I have the RFM12, 1 mW module, and got range to about
120 feet [36m] at 433. RFM22 will certainly be a lot farther.

How do you plan to connect antennas to the modules? They are made for those 1/4
whip antennas [ie, piece of wire soldered on]. Do you know if the modules will
function properly with something else, like a soldered-on coax leading to a external
antenna?


Boffin1

I have only got these modules hooked up accross the bench at the moment , but I want to test the range tomorrow.

I had over 150m range with the modules in the simplex mode ( I didn't check further as I was at the end of the road and only needed 100m ! )
With my mobile phone I can call people and talk to them -  how smart can you get ?

oric_dan

Well, 150m sounds pretty darn good, :-). I tried the little nRF2401+ modules a couple of
weeks ago, and got only about 10m range [1 mW, 2.4Ghz] - disappointing.

I am also wanting longer range for my largish 4WD robot, which is intended to go off
across fields the size of baseball pitches, etc, so 150m sounds great. As the robot will
actually be "autonomous", for fail-safe, I plan to have the base station [me] continually
pinging the robot, and if the signal drops out, then the robot will backtrack along its
previous outgoing path until it's back in range.

Boffin1

Looks like we are on a similar course agaIn  with this project.

I don't know how you were testing the RFM22B modules, but I have them hooked up to the 3.3v of the Arduino, and I found I need a 4700mFd cap on the 3v3 supply line to take the pulse when it transmits at full power.

I also want to monitor the SSR reading every second or so, at both ends, and display it on the LCD with a warning light if either drops below a  certain level.

I am thinking of having the robot send its housekeeping data every second, so as to monitor the comms, and hold back when receiving " driving" data from the remote.

I am going to add a LED flash ( can't use pin13 as its  SPI ) and take a walk with the one arduino on a battery tomorrow, I will try it with the 170mm whips both ends.

Have you got the RX and TX tied to the GPIO pins ?   

I will post the range results tomorrow.
With my mobile phone I can call people and talk to them -  how smart can you get ?

oric_dan

#7
Mar 20, 2013, 07:54 pm Last Edit: Mar 20, 2013, 07:56 pm by oric_dan Reason: 1
Forgot to mention, for my RFM12 range test, one node was inside the house and the other
node on the street with me carrying, so inside to outside, rather than direct LOS. What I
did was send an entire packet of 24 bytes or so from the host, and test for correct receipt
at the remote, and then flash an Led. Also, 170 mm whips.

I have a couple of RFM22s, but not tested as yet. I was jury-rigging a lashup a couple of
weeks ago, but one of the pads fell off the pcb from the soldering heat, and the tiny 6-mil
trace snapped off. 6-mil traces, PITN.

Yesterday, I figured out I will stick the RFM22 to an XBee pcb using double-sided tape, and
tack solder to the pads, then jumper the XBee socket pins on my Arduino test pcb over to
the SPI pins, etc. Need some 2mm male headers. Another job in the queue.
https://www.sparkfun.com/products/8276


Boffin1

Well the range test with the reliable datagram was hardly worth me putting some sandals on, it faded out at about 7m range !

I had looked at the data to the module, and it looked so fast compared to my normal projects.

I couldnt find a way to change the data rate, so I delved into the RF22 library cpp file, and changed the power to 17 dBm, and the baud rate to the one I used on the simplex mode.  (  i have no idea what it means ! )

There is a  spreadsheet to calculate the set up , but it doesn't work in openoffice :-(
My changes :-

   // setModemConfig(FSK_Rb2_4Fd36);     
    setModemConfig(GFSK_Rb2Fd5);
  //  setTxPower(RF22_TXPOW_8DBM);
    setTxPower(RF22_TXPOW_17DBM);/

I can now walk 50m to the end of my road with it still working, and I am going to take them out on a straight road to test.
It did fade through 3 buildings, but my appication is in the open air...
With my mobile phone I can call people and talk to them -  how smart can you get ?

Boffin1

#9
Mar 21, 2013, 02:28 pm Last Edit: Mar 21, 2013, 03:16 pm by Boffin1 Reason: 1
Hmmm,    not the range I was hoping for,  I had a LED toggle on and off when a valid length message arrived ( sent every 500ms )

I got 150m solid signal, but after that it would skip a flash, but never actually stopped receiving even up to  250m, it just missed flashes more often.

OK I will be using a yagi at the TX, and perhaps a dipole at the RX, so it could work, but its got to be reliable.

The fact that it still received at over 250m seems to suggest that the RF strength isn't the problem, perhaps its a signal/noise bandwidth issue (   I hate RF , even when I was a radio ham 50 years ago ! )    

The fact that the range went from 7 meters to 150 just with my library pot luck twiddles makes me think that perhaps I am a quarter of the way to the answer, but don't know enough about the software.

I used SIM20 modules last year on a project, but the  documentation is atricious, so I dont think I can get that working in a  semi-duplex mode.
I got 500m range with them, also with a 170mm antenna wire.

These RFM22Bs are a third of the price, so I would like to get them going properly,  and perhaps use the diversity combiner mode with 2 antennas to avoid dead spots.

I have just found this on a picaxe forum  

 "I was just doing some long range LOS tests with the 434Mhz tuned RRM22, I got 100% reception reliability at 4.3Km with 25mW output, 50% reliability at 12mW. This was using 5khz deviation and 250bps data rate with Manchester enabled. "

Anyone know how to set these parameters ( OK perhaps not that slow  ) up with the RFM22B  , there is a spreadsheet thing to calculate it, but as I said it doesn't work on my Openoffice :-

http://www.hoperf.com/upload/rf/RF22B%2023B%2031B%2042B%2043B%20Register%20Settings_RevB1-v5.xls


I basically want to send 10 bytes every half second,  and receive similar from the robot, so its not  a lot of data.



With my mobile phone I can call people and talk to them -  how smart can you get ?

oric_dan

I don't know the ins and outs of setting all the module parameters. I did read the d/s for
the RFM12, and it does have a huge amount of parameters that can be set. About the
only thing I know is, you can increase the range by reducing the transmit RF data rate
[not the baudrate between Arduino and module]. Also, many of the cheaper 433 devices
use only 9600 bps RF transmit rate, and they seem to have a longer range.

I asked Bob [docedison] about soldering coax to the RFM22 teminals, he sent this
[I thought he was gonna post it himself] ...
Quote
Were I you I'd advise him to use RG316 coax,It's 50 ohm teflon about the same size as RG174 and directly solderable. The receivers are matched to a 50 ohm load, standard for RF. The RG316 is the same size as 16 Ga THHN house wire. RG 174 is polyethylene and hard to solder unless you are familiar with the cable it also has about 3 DB loss @ 433 MHz with 4" of cable and it leaks like a sieve. Were it possible, and much better for him to find a board with a connector footprint there and put a connector in it.

oric_dan

Quote
4700mFd cap

BTW, I don't understand what that value is. 4700 micro-farads? A huge cap?

Boffin1

Thanks, and thanks to Bob re the coax, I will bear that in mind,
What I tend to do latlely is to mount the transceiver on the antenna, and use ribbon cable to the 328 board,

Yes the  4700uF  is a  huge cap that can allow a current surge from the 3.3v  arduino line for the transmitter.
With my mobile phone I can call people and talk to them -  how smart can you get ?

Excellent Idea,  @ Boffin.. I might reccommend a separate 1117-3V3 regulator at the transceiver... and another 4700 uF cap although with your own regulator should work fine with 22uF. Good Luck In the Contest...

Bob
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Boffin1

I am only using the 4700mFd while I am checking it out on the Arduino board, as the onboard 3v3 supply cant handle the rush, but I scoped the cap and it hardly dips at all.     
With my mobile phone I can call people and talk to them -  how smart can you get ?

Go Up