Author Topic: Two RFM69 on One Moteino  (Read 13299 times)

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Two RFM69 on One Moteino
« Reply #45 on: January 03, 2015, 06:24:14 PM »
<...snip>
Have you read this article ?

http://www.dorkbotpdx.org/blog/paul/spi_transactions_in_arduino

Kiwi

PS. My main interest is improving the RFM69 code base. To that end; Could the last line of readAllRegs() "unselect();" be removed ? To me it looks like redundant code, since "unselect();" is called in the preceding loop.
Whoa!  You're a WEALTH of information!  YES! This is exactly what is needed!  I've been considering creating my own mutex for this purpose but now I'll have to look at the code referenced in the article. THANKS!

re readAllRegs, I suspect, if you look at that code you'll find a select() in there somewhere, so, no, it's not redundant.uh, I just looked at the code and see the first unselect() nicely tucked behind the SPI.transfer() call so you are right about the second one. It is redundant and could mess up your counter scheme.

Tom
« Last Edit: January 03, 2015, 06:31:09 PM by TomWS »

donaldhwong

  • Jr. Member
  • **
  • Posts: 92
Re: Two RFM69 on One Moteino
« Reply #46 on: January 07, 2015, 05:13:34 PM »
If you do create a new thread, please posted here, so that I can follow up.

I am still waiting for a solution for TWO RFM69 on one Moteino.

Much obliged,
Donald

scottpenrose

  • NewMember
  • *
  • Posts: 13
Re: Two RFM69 on One Moteino
« Reply #47 on: January 08, 2015, 06:51:19 PM »
Rather than two RF69s, have you considered using a Mega for one of them and a standard Moteino output serial to one of the spare serial ports on the Mega.

On one Moteino you just gateway the data from the 1st radio to Serial in both directions. Then on the mega you listen to the second radio and the serial port.

Cost is therefore only an extra $12 for the CPU. And... multi tasking :-)

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Two RFM69 on One Moteino
« Reply #48 on: January 08, 2015, 07:08:30 PM »
Rather than two RF69s, have you considered using a Mega for one of them and a standard Moteino output serial to one of the spare serial ports on the Mega.

On one Moteino you just gateway the data from the 1st radio to Serial in both directions. Then on the mega you listen to the second radio and the serial port.

Cost is therefore only an extra $12 for the CPU. And... multi tasking :-)
AND this makes Felix a LOT happier for many reasons!   ;D

Good suggestion.
Tom

donaldhwong

  • Jr. Member
  • **
  • Posts: 92
Re: Two RFM69 on One Moteino
« Reply #49 on: January 08, 2015, 07:28:24 PM »
Hi Scott,

Yes, this is my back up plan.  YET,

Imagine we have three interrupts on MEGA, then I could use three RFM69 with one MEGA. 

Imagine the ease of coding just one MCU instead of three.

If Kiwi and Tom can pull this off, it will be a blessing for everyone involved with Moteino.

LOL
Donald

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Two RFM69 on One Moteino
« Reply #50 on: January 08, 2015, 07:58:11 PM »
Donald .... interrupts can happen randomly and even theoretically at the same time but they cannot be executed at the same time on a 1 core MCU/CPU. That's why there is interrupt management and context switching when multiple threads are running on the same pipelined CPU. Even large CPUs do that. It's called interrupt priority and preemption or context switching. If an interrupt of a higher priority happens while an interrupt or routine is running, the MCU/CPU state is saved on the "stack" - ie context switching (registers, stack pointer, current running address etc). Read more here: http://wiki.osdev.org/Context_Switching
I don't know if any of this makes any sense, I learned all about this stuff in college computer architecture courses.
So I think you are misunderstanding how MCU architecture is designed to work, hence you might be thinking adding more radios will add some kind of parallel or threading capability. Even radios can't all talk at the same time .. or they will only receive garbled messages, ie noise. Adding more wheels and engines to a car will not make it go faster, it will make it more complicated to make all the extra parts work with everything else, I hope this analogy helps the explanation.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Two RFM69 on One Moteino
« Reply #51 on: January 08, 2015, 08:58:36 PM »
Hi Scott,

Yes, this is my back up plan.  YET,

Imagine we have three interrupts on MEGA, then I could use three RFM69 with one MEGA. 

Imagine the ease of coding just one MCU instead of three.

If Kiwi and Tom can pull this off, it will be a blessing for everyone involved with Moteino.

LOL
Donald
Uh, Donald, I hate to disappoint you but I have absolutely no interest in working on two (or more) RFM69s on a single Moteino.  I've been working with the others regarding multiple SPI sources and the like - TOTALLY separate from the dual RFM69 issue (which is why I had the SPI thread separated from this conversation).  I don't see a use case for more than one RFM69 radio in a single node and definitely won't be working on it.
I will say that I like Scott's suggestion to use two processors and it would be easiest if both of them are Moteino Megas since they can communicate with each other via the second serial port.  This is a great solution for ease of development, maintenance, and uses the SAME RFM69 library as all other Motes...  (and I say this based on DECADES of programming experience - this is a very solid solution). No special code (from a library perspective) needs to be developed.

Tom

donaldhwong

  • Jr. Member
  • **
  • Posts: 92
Re: Two RFM69 on One Moteino
« Reply #52 on: January 09, 2015, 02:28:08 AM »
Thank you, Felix and Tom for your candid feedback.

I am not expecting.  I am just exploring into new frontier. Last time that I dealt with MCU was 1968.  I am already overwhelmed with everything that I am playing around with right now.

When we are able to manage SPI differently with proper interrupt queuing, I am sure we could connect to three RFM69W or other interrupt devices.

Look forward to that day.

Please keep me informed of your development.

Many Thanks,
Donald

donaldhwong

  • Jr. Member
  • **
  • Posts: 92
Re: Two RFM69 on One Moteino
« Reply #53 on: April 03, 2015, 10:52:51 AM »
To end this thread on a positive note..

I found Radiohead library.  It works fine with two RFM69..