Two RFM69 on One Moteino

Started by donaldhwong, December 17, 2014, 06:29:38 PM

donaldhwong

Will the following declaration code work for a second RFM69 on Moteino?

radio2(7,3,false,1);  //CS on D7, D3 for IRQ
radio2.initialize(FREQUENCY,3,NETWORKID);  //Same gateway, because I need to listen to the same node with two gateways.

kiwisincebirth

https://lowpowerlab.com/forum/index.php/topic,648.msg3796.html#msg3796

See the link, I don't think the library supports it, but the thread went dead so not sure what eventually happened

Felix

Quote from: donaldhwong on December 17, 2014, 06:29:38 PM
Will the following declaration code work for a second RFM69 on Moteino?
radio2(7,3,false,1);  //CS on D7, D3 for IRQ
radio2.initialize(FREQUENCY,3,NETWORKID);  //Same gateway, because I need to listen to the same node with two gateways.
Try it, let us know what you find.
Do you want both radios on the same frequency and network, but different IDs? Not sure what that buys you other than more overhead to deal with.

donaldhwong

#3
Hi Felix,  Thank you.

Are you not concerned about the following from the previous reply from a no-result experiment conducted already with exact same code?

Quote
Interrupt is triggered at the RFM69 which last initialized.
What to do?

This is what I would have expected to happen, based on how the code has been written. The problem (as stated above) is the 'static' declaration of variables. In this case the variable 'static RFM69* selfPointer;'. If you search the code for this variable you will see it is used as part of interrupt handling.

Felix

Actually no. Moteinos are not designed to host 2 transceivers and I consider that an outlier experiment which I can try to help with but I can not support or encourage.
Besides the hardware implications there are memory issues you can run into by hosting two transceivers, as you already well know - the atmega only has 2K RAM. This leads to a pandora's box that i'd rather keep closed. If you are endeavoring to do such a project you are welcome to use the base library and modify that to support your experiments.

donaldhwong

Thank you Felix.  Understood.  If you don't mind answer a few questions:

1.  How do I upload a modified rfm69.cpp say RFM69x2.cpp into codebender? I only saw the code to include the rfm69.h but not the *.cpp.
2.  When I run the sketch, is it running in the 2k RAM, 1k EEPROM or 32k Flash?  Can not find any document so far.  I assume that that the EEPROM is for the boot loader.  Flash is the programming.  Ram is temporary storage.  Am I right?  Why are you worried about the 2k RAM?

Thank you for your kind support.
Donald

Felix

1) I think you can upload your own version of a library. For library development I suggest you do it on your PC/desktop and use the Arduino IDE and when you have a working version upload it to your own codebender account.
2) I suggest you do some C++ reading and some Arduino as well. These are vast subjects that can not be answered in a forum post. The 3 memories are fundamentally different. Your code and the bootloader both live in internal flash (32k). The RAM is used for dynamic allocation while your program is running.

donaldhwong

Thank you Felix.

If you believe that I may run into a RAM problem.  May I then exchange the two Moteino with the Moteino Mega?  I am willing to pay for whatever charges that you deem necessary?

Since I just got it and have not done anything other than load the sketch onto them.

Please advise.

As per your advise, I have just downloaded the Arduino and install your library into it.  They compiles fine and Serial monitor works.

Thank you for your guidance and support.

Felix

Donald, per my store policy, the sales are final and there are no returns for reasons other than DOA. I always try to help people with any questions and ask they do their bit of homework and read about what to expect from these products, what they can and cannot do etc.

donaldhwong

Hi Felix,

No problem at all.  If I run into ram problem, I just upgrade to Mega.  About that purchase I have a few questions:

1.  Do you sell a USB adapter or shield for Mega?
2.  Do you sell AA or AAA, or any kind of battery shield?

I did not find any such items in your store.

Thank you.

Felix

For MEGA use the FTDI Adapter for programming.
There is no AA shield, just connect a battery holder with at least 3xAA or a Lipo to "VIN" and you're good to go.

donaldhwong

Will your FTDI adapter work with Moteino Mega?

Thanks,
Donald

donaldhwong

Got my breadboard today and hooked up my second RFM69W.  Change the declaration as follows:
Quote#define RF69_SPI_CS               7 // SS is the SPI slave select pin, for instance D10 on atmega328

// INT0 on AVRs should be connected to RFM69's DIO0 (ex on Atmega328 it's D2, on Atmega644/1284 it's D2)
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
  #define RF69_IRQ_PIN          3
  #define RF69_IRQ_NUM          1

Guess what?  It works.  Now just have to figure out, how to edit the RFM69.cpp to talk to both RFM69W.


Felix

Yes the FTDIAdapter works for all non-usb Moteinos.
You will need 2 instances of the RFM69 class in your sketch, one for the native RFM69 on D2/D10 and one for the second one on D3/D7.

donaldhwong

Hi Felix,

D3 and D7 was how the second RFM69 were wired.  And it is working as per my post.

Now I need to get both of them working.  But I keep on having compiler error.  Please help.

See my post here: https://lowpowerlab.com/forum/index.php/topic,797.0.html

Many thanks.  This is the my last step.  Please help.