Author Topic: Moteino & W5100 ethernet SPI support / SPI_HAS_TRANSACTION  (Read 37048 times)

Fernando Garcia

  • NewMember
  • *
  • Posts: 6
Re: Moteino & W5100 ethernet SPI support
« Reply #60 on: March 25, 2015, 06:36:12 PM »
Hello guys!

Kiwi, any chance to make this changes to RFM12B library?

I would like to make by myself but I'm not able to work with library core.

I'm using a  custom board with SD card, W5100 and RFM12B.

I can send datas via RF with this boards but I can't receive.

To send datas I had to change this line at CanSend() in .cpp

Code: [Select]
if (rxstate == TXRECV && rxfill == 0 /*&& (Byte(0x00) & (RF_RSSI_BIT >> 8)) == 0*/)

The SD card and W5100 are working fine apparently.

Here two videos showing the RF working



Thanks in advance!

Best regards.




 

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Moteino & W5100 ethernet SPI support
« Reply #61 on: March 25, 2015, 07:00:35 PM »
My library and my examples on other hardware, nice. I am famous.

Fernando Garcia

  • NewMember
  • *
  • Posts: 6
Re: Moteino & W5100 ethernet SPI support
« Reply #62 on: March 26, 2015, 10:01:44 AM »
Hi Felix!

I tried buy a Moteino in your store to use in my tests but the RFM12B is out of stock.

If you want know more details about what I'm doing look this topic.

Best regards.

Fernando Garcia

  • NewMember
  • *
  • Posts: 6
Re: Moteino & W5100 ethernet SPI support
« Reply #63 on: March 27, 2015, 10:58:02 AM »

3. I choose to change the Ethernet SS Pin, this requires a change to the Ethernet library, I published the change here. https://github.com/kiwisincebirth/Arduino/tree/master/Ethernet

Kiwi

Hi!

I would like to give a suggestion.

I'm using this method to change the SS pin. Is more complicated to edit library but you can work directly with EthernetClass.

Best regards.

 

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Moteino & W5100 ethernet SPI support
« Reply #64 on: March 27, 2015, 06:15:44 PM »
Hi Felix!
I tried buy a Moteino in your store to use in my tests but the RFM12B is out of stock.
If you want know more details about what I'm doing look this topic.
Best regards.
Yeah I had to discontinue RFM12B since there's really low interest in that module and also much lower performance than the RFM69. Nice project by the way.

kiwisincebirth

  • Jr. Member
  • **
  • Posts: 69
Re: Moteino & W5100 ethernet SPI support
« Reply #65 on: March 29, 2015, 12:12:48 PM »
Hello guys!

Kiwi, any chance to make this changes to RFM12B library ?

Thanks in advance!

Best regards.
Unfortunately no, the problem is that it isn't a simple change. Felix's RFM12b library doesn't actually use the SPI library, I believe it talks natively to the underlying HW. Thus a complete rewrite of the RFM12b library would be required.

Kiwi

Fernando Garcia

  • NewMember
  • *
  • Posts: 6
Re: Moteino & W5100 ethernet SPI support
« Reply #66 on: April 19, 2015, 01:42:27 PM »
Hi!

Kiwi, thanks for your answer.

Best regards.

RobW

  • NewMember
  • *
  • Posts: 1
Re: Moteino & W5100 ethernet SPI support
« Reply #67 on: July 03, 2015, 02:05:59 PM »
Hi there, in summary, since I lost my more detailed posting.

1. Use arduino 1.6.0, it contains the SpI transaction support to allow the two devices to play nice together.

2. Use the enhanced rfm69 library on my GitHub account, this adds the spi transaction support to the library.

3. I choose to change the Ethernet SS Pin, this requires a change to the Ethernet library, I published the change here. https://github.com/kiwisincebirth/Arduino/tree/master/Ethernet

Lastly, the Ethernet shield is 3.3v compatable, but does require 5v input power. In my setup I have a moteino mounted to a prototype shied which then has an Ethernet shield mounted to it. This means I am free to route any pin I want to pin 10 on the connector, to drive the Ethernet shield

I have been running my gateway without issue for well over a month now, the good thing is that I don't have worry about shutting it down correctly (like rasp pi) there is no OS or sd card to cause an issue.

Kiwi

Hello,

I'm building a RFM69 gateway connected to a W5200 DRDuino Ethernet shield mounted on a Uno R3 board.  I've found this thread enormously helpful in working out what to do.  However I still have a few questions that I'm hoping someone can help with:

1) compatibility with w5200.  I'm using a modified Ethernet library https://github.com/Wiznet/WIZ_Ethernet_Library

2) chip select for SPI bus.  As I understand it, both RFM69 and Ethernet libraries are programmed to use pin 10, causing a bus clash.  The fix is to change one of them.  Which is easiest to alter?

3) as I understand it the enhanced rfm69 library prevents the radio Rx/Tx creating an interrupt when another device is using the SPI bus.  Does the enhanced library function correctly with Arduino IDE 1.6.4?

4) is the converse an issue?  Could the W5200 create an interrupt when the radio Rx/Tx is using the SPI bus?  If so what code could I use to avoid this?

Many thanks for any advice

Rob


kiwisincebirth

  • Jr. Member
  • **
  • Posts: 69
Re: Moteino & W5100 ethernet SPI support
« Reply #68 on: July 26, 2015, 05:46:43 AM »
Hello,

I'm building a RFM69 gateway connected to a W5200 DRDuino Ethernet shield mounted on a Uno R3 board.  I've found this thread enormously helpful in working out what to do.  However I still have a few questions that I'm hoping someone can help with:

Many thanks for any advice

Rob
Hi Rob, sorry for late reply I am not very active on this forum.

1) compatibility with w5200 : I had a quick look at the library, and it doesn't appear to have been updated for the SPI (transactional) changes introduced in 1.6.x Basically it means that while an ethernet library is using the SPI bus there is nothing to stop an interrupt from the RFM69 radio from taking control and using SPI.

2) chip select for SPI bus : I would first look at hardware, is there anything limiting which pin you can move? Software. The RFM libraries support it OOTB, The Arduino W5100 libraries don't support the change without changing the libraries source code.

3) Does the enhanced library function correctly with Arduino IDE 1.6.4? ; The enhanced library was designed to support 1.6.x and above, it is its primary purpose. It is backwards compatible with < 1.6.x with the older SPI libraries.

4) is the converse an issue?  Could the W5200 create an interrupt when the radio Rx/Tx is using the SPI bus?  If so what code could I use to avoid this? ; The W5100 does not implement interrupts ( event though HW supports it ), not sure about W5200. However if it DID, and the W5200 libraries were upgraded to the new 1.6.x SPI libraries, then just a single line of code is required " SPI.usingInterrupt(...);" which registers the interrupt usage, which means that when and SPI usage occurs the interrupt can be disabled.

Hope this helps.

Kiwi

kiwisincebirth

  • Jr. Member
  • **
  • Posts: 69
Re: Moteino & W5100 ethernet SPI support
« Reply #69 on: July 26, 2015, 05:56:49 AM »
Update: While this thread has been dead for many months, my gateway is NOT. Has been running without an issue or any reboot required whatsoever. The good thing is that I can disconnect power without any issue whatsoever, unlike the RPi which it replaced. Very happy indeed.

In summary here is my overall setup.
Remote: Sensor-(Moteino/RFM69) ==>> Gateway: (RFM69/Moteino)-EthernetShield ==>> Server: MQTT -> NodeRed -> Other Applications

Kiwi

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino & W5100 ethernet SPI support
« Reply #70 on: July 26, 2015, 06:51:50 AM »
Update: While this thread has been dead for many months, my gateway is NOT. Has been running without an issue or any reboot required whatsoever. The good thing is that I can disconnect power without any issue whatsoever, unlike the RPi which it replaced. Very happy indeed.

In summary here is my overall setup.
Remote: Sensor-(Moteino/RFM69) ==>> Gateway: (RFM69/Moteino)-EthernetShield ==>> Server: MQTT -> NodeRed -> Other Applications

Kiwi
Glad to hear it, Kiwi, and glad to have you back!  I've recently added a gateway with Ethernet using your library and, I, too, am pleased at how well it's working.  No issues at all! 

It would be nice if I could check the link state through the W5100 interface, but that's a W5100 HW issue, outside of any SW capability.

Thanks for your hard work on this.
Tom

Robert

  • Jr. Member
  • **
  • Posts: 66
  • Country: be
Re: Moteino & W5100 ethernet SPI support
« Reply #71 on: October 17, 2015, 04:12:59 AM »
Hi,
Just to mention  an issue, when using Arduino Ethernet Shield and RFM transceivers.

There is a SPI Slave Select issue between the W5100 of the Ethernet Shield and the RFM interrupts.
(see  http://harizanov.com/2012/04/rfm12b-and-arduino-ethernet-with-wiznet5100-chip/).

Even I believe this has nothing to do with the Slave Select  shmitt trigger chip; the solution is very efficient, and consist in disabling the arduino interrupts  at W5100 at SS activation.

In my case using an ATMEGA2560 changing the W5100.h library from:

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  inline static void initSS()    { DDRB  |=  _BV(4); };
  inline static void setSS()     { PORTB &= ~_BV(4); };
  inline static void resetSS()   { PORTB |=  _BV(4); };
To

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  inline static void initSS()    { DDRB  |=  _BV(4); };
  inline static void setSS()     { cli ();PORTB &= ~_BV(4); };
  inline static void resetSS()   { PORTB |=  _BV(4); sei();};

This issue is particularly true when using a asynchronous RF and Ethernet messages (typically, with a  RFM transceiver, an Ethernet Shield and a MQTT broker (PubSubScribe library, 'loop' keep alive function) )

If this looks to be a very old issue (2012) it is not corrected in the Ethernet library of the Arduino IDE package (I have posted a note on the Arduino forum as well).

If we are forced to use unsupported library, may I suggest to add this modification to the new W5100.h library of Kiwi, in order to combine the flexibility of changing the Slave Select pin and the interrupt conflict issue.

Robert



TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino & W5100 ethernet SPI support
« Reply #72 on: October 17, 2015, 09:10:13 AM »
@Robert, the library posted on github by kiwi (referenced earlier in this thread) works well with RFM69 library.  I use this on a Moteino/Ethernet gateway running in my vacation home without any issues.

Let me know if you need specifics.

Tom

Robert

  • Jr. Member
  • **
  • Posts: 66
  • Country: be
Re: Moteino & W5100 ethernet SPI support
« Reply #73 on: October 17, 2015, 11:11:40 AM »
Tom,
This is currently the only issue I can describe.
The MQTT "PubSubClient.loop", polls at regular interval the MQTT Broker (via Ethernet). When this happens simultaneous with a RFM radio message reception, the Arduino activity is stopped.

Disabling the interrupt during the Ethernet Slave selection solves definitively the problem (my gateway is running for days now, while before it was hanging after few minutes). I suppose that this issue only happens with two asynchronous functions (Ethernet transfer and RFM interrupts).
If radio reception is synchronised (or chained) with an Ethernet one (or vice versa). The problem should not occur.

So I don't have special needs, the problem is solved for me, but it is a little bit cumbersome to manage different versions of the libraries.

Robert

 

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino & W5100 ethernet SPI support
« Reply #74 on: October 17, 2015, 12:05:08 PM »
Disabling the interrupt during the Ethernet Slave selection solves definitively the problem (my gateway is running for days now, while before it was hanging after few minutes). I suppose that this issue only happens with two asynchronous functions (Ethernet transfer and RFM interrupts).
If radio reception is synchronised (or chained) with an Ethernet one (or vice versa). The problem should not occur.
The SPI transaction support is supposed to be doing this (disabling interrupt) automatically.  You shouldn't need to do it explicitly in the ethernet code.

Tom