Interrupts handling

Started by Dominic_be, November 04, 2015, 09:03:48 AM

Dominic_be

This is my first application with Moteinos.
With one gateway and multiple nodes ( with one node for beginning ! ).

The nodes :
A sensor provide a pulse train on pin3. I work with interrupt1 to handle this.
The period of the pulse train is recorded and periodically sended to the gateway "on request".
The request period is 500 ms.

My problem :

The code work fine but it seems that the RF transmission interferes with the timing of int1.

For example with a pulse period of 400 ms, periods recorded are sometimes so :
.... 400 - 400 - 420 - 380 - 400 - 400 -...

It seems that interrupt1 handling code must wait during RF transmission.

Is that right?

Somebody can help me to find a solution?



TomWS

Quote from: Dominic_be on November 04, 2015, 09:03:48 AM
This is my first application with Moteinos.
With one gateway and multiple nodes ( with one node for beginning ! ).

The nodes :
A sensor provide a pulse train on pin3. I work with interrupt1 to handle this.
The period of the pulse train is recorded and periodically sended to the gateway "on request".
The request period is 500 ms.

My problem :

The code work fine but it seems that the RF transmission interferes with the timing of int1.

For example with a pulse period of 400 ms, periods recorded are sometimes so :
.... 400 - 400 - 420 - 380 - 400 - 400 -...

It seems that interrupt1 handling code must wait during RF transmission.

Is that right?

Somebody can help me to find a solution?
Which version Arduino IDE are you using and do you have the latest RFM69 library?

The reason I ask is that the earlier version of the IDE forces the RFM69 library to mask ALL interrupts when the radio is being accessed.  With IDE version 1.6.0 and later, SPI Transactions were introduced so that ONLY INT0 would get masked during SPI transactions (IFF RFM69 was the ONLY SPI user that also used interrupts), leaving INT1 still enabled.

If you have IDE 1.6.0 or later, then you can use the RFM69_ATC library ( https://github.com/TomWS1/RFM69_ATC ), which adds SPI Transaction support to the RFM69 library, and you should be able to reduce the jitter on your Int1 interrupts.

Tom


Dominic_be

Hi Tom,
Thanks for your reply.
I use the Arduino IDE 1.6.5 and the latest version of RFM69.
I will add the RFM69_ATC library.
Thanks,
Dominic

TomWS

#3
Quote from: Dominic_be on November 05, 2015, 06:25:00 AM
Hi Tom,
Thanks for your reply.
I use the Arduino IDE 1.6.5 and the latest version of RFM69.
I will add the RFM69_ATC library.
Thanks,
Dominic
In adding the library in this case, the only thing that should change is the radio declaration:
RFM69 radio;

would change to:
RFM69_ATC radio;


Everything else should be the same.  UPDATE: And adding the include file, of course!
#include <RFM69_ATC.h>


Let me know if it isn't!

Tom

Dominic_be

Oups! problem , compilation error :

Arduino : 1.6.5 (Windows XP), Carte : "Arduino/Genuino Uno"

C:\Documents and Settings\Dominique\Mes documents\Arduino\libraries\RFM69_ATC\RFM69_ATC.cpp: In member function 'void RFM69_ATC::sendFrame(uint8_t, const void*, uint8_t, bool, bool, bool, int16_t)':
C:\Documents and Settings\Dominique\Mes documents\Arduino\libraries\RFM69_ATC\RFM69_ATC.cpp:119:48: error: 'RFM69_CTL_RESERVE1' was not declared in this scope
     SPI.transfer(RFM69_CTL_SENDACK | (sendRSSI?RFM69_CTL_RESERVE1:0));  // TWS  TODO: Replace with EXT1
                                                ^
C:\Documents and Settings\Dominique\Mes documents\Arduino\libraries\RFM69_ATC\RFM69_ATC.cpp:128:39: error: 'RFM69_CTL_RESERVE1' was not declared in this scope
       SPI.transfer(RFM69_CTL_REQACK | RFM69_CTL_RESERVE1);     // TWS: ASK for ACK + ASK for RSSI
                                       ^
C:\Documents and Settings\Dominique\Mes documents\Arduino\libraries\RFM69_ATC\RFM69_ATC.cpp: In member function 'virtual void RFM69_ATC::interruptHook(uint8_t)':
C:\Documents and Settings\Dominique\Mes documents\Arduino\libraries\RFM69_ATC\RFM69_ATC.cpp:151:34: error: 'RFM69_CTL_RESERVE1' was not declared in this scope
   ACK_RSSI_REQUESTED = CTLbyte & RFM69_CTL_RESERVE1; // TWS: extract the ACK RSSI request bit (could potentially merge with ACK_REQUESTED)
                                  ^
What should I do?
Where declare this variable and with what value?

Dominic


TomWS

This is my whoops...  For the moment, add the following line to RFM69_ATC.h:
#define RFM69_CTL_RESERVE1  0x20


I guess my library is out of sync with the latest RFM69 library.
I apologize for this.  I'll try to take care of this this weekend.

Tom