Pages: [1] 2   Go Down
Author Topic: noob confuse with SPI - setSS() missing / RFM70 module  (Read 7209 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

as said I'm am not an expert. I want to get a RFM70 modul running and tried/copied the example code from http://www.rkner.at/home/news.avr.rfm70.html

I am not sure how outdated the code is even it says 2011. But they used WProgram.h and Spi.h which is now Arduino.h and SPI.h.

I changed "Spi.mode(1<<SPR0)" to "SPI.setDataMode(1<<SPR0)". But I am not 100% sure if this is right.

They also call "Spi.setSS()" quite often. But I can't find any replacement.

So did anything change with the SPI library. Is there a document about this?

Or is there any other example running RFM70 available?

Any suggestions are welcome.

thx n rgds
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Spi.setSS() should probably be "digitalWrite(ssPin, LOW)" where 'ssPin' is whatever pin you are using for the Slave Select signal.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

did you get it to work?
I'm stuck with the same problem.

You also want to check out this site
http://www.voti.nl/rfm70/index_1.html
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have the same problem. I have replaced the "Spi.setSS()"  with "digitalWrite(10, LOW)", and I have run over other problems when compiling.

Quote
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_pcmd(const uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:70: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:71: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:75: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_reg(uint8_t, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:80: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:81: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:84: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'uint8_t read_reg(uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:91: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:94: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_reg_pbuf(uint8_t, uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:142: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:143: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:147: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void read_reg_pbuf(uint8_t, uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:152: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:153: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:159: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'uint8_t send_packet(uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:168: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:173: error: 'class SPIClass' has no member named 'setSS
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_pcmd(const uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:70: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:71: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:75: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_reg(uint8_t, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:80: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:81: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:84: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'uint8_t read_reg(uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:91: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:94: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_reg_pbuf(uint8_t, uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:142: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:143: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:147: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void read_reg_pbuf(uint8_t, uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:152: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:153: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:159: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'uint8_t send_packet(uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:168: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:173: error: 'class SPIClass' has no member named 'setSS

The problem seem's to be in the .cpp library file.  I think he is using different Spi.h and WProgram.h. I really nead this RFM for my project but I dont know how to repair it.
Also I replaced all the "Spi.[...]" forms in the library files with "SPI.[...]", as seen in the quoate of the debbuging
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone,
I also tried the code from
http://www.rkner.at/home/news.avr.rfm70.html,
but I found out that it is not really Arduino compatible.

So I ported my own RFM70 driver from the original HopeRF example code.
It is working, but it is slow because I am not using the Arduino SPI driver.
If you are interrested tell me and I can post my code here.

Fred



Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a page (http://goews.com/rfm70) with a Chat project example using two RFM70 modules and ATMEGAs.  Though it is strictly AVR code, not Arduino, but it may help.
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Superfred-  Please post your code!  I cannot find any online.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello sbright33,

here is the link to the library: skip.co.at/RFM70/RFM70.zip
unpack it to C:\Program Files (x86)\arduino-1.0\libraries\RFM70.

Pinout:
CE   Pin 9
CSN  Pin 10
SCK  Pin 13
MISO Pin 12
MOSI Pin 11
IRQ  Pin 8

and don't forget the 3.3 V stepdown converter!

Please ask me if you have any questions!

Example code (not all was tested):
Code:
#include "RFM70.h"

RFM70class RFM70;

byte RFM70_buf[MAX_PACKET_LEN];  //RFM70 data buffer
unsigned long RFMSendTime = 0;   //next send time
int RFMSendSpeed=1000;           //send packet every 1000 msec


void setup()
{
    Serial.begin(57600); 
    Serial.println("Arduino Start");   
    RFM70.begin();
    RFM70.Initialize();
    RFMSendTime = millis();
 
}

void loop()
{
    rfmTask();                                    //check for RFM70 event in polling mode
    if (millis() > RFMSendTime)                   //send packet
    {                                                   
      RFMSendTime = millis() + RFMSendSpeed;
      RFM70_buf[0]=0X41;     
      RFM70_buf[1]=0X42;
      RFM70_buf[2]=0X43;
      RFM70_buf[3]=0X44;     
      RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);
      Serial.println("Sending data");       
    } 
}

void rfmTask()                //RFM70 event handler
{
  if (RFM70.RfmInterrupt())
  {
    if (RFM70.TxDataSentInterrupt())
    {
       Serial.println("Data sent OK");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.TxDataSentErrorInterrupt())
    {
       Serial.println("Data sent error");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.RxDataReadyInterrupt())
    {
       Serial.println("Data received: ");
       byte rx_len = RFM70.Receive_Packet(RFM70_buf);
       if (rx_len)
       {
          for(byte i=1;i<rx_len;i++)
          {
            Serial.print(i);
            Serial.print("->");
            Serial.println(RFM70_buf[i]);
          }         
       }   
     }
  }
}


Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks will try it later!  I feel like I've been paid back for all the hard work I've done on the motor code...
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello sbright33,

here is the link to the library: skip.co.at/RFM70/RFM70.zip
unpack it to C:\Program Files (x86)\arduino-1.0\libraries\RFM70.

Pinout:
CE   Pin 9
CSN  Pin 10
SCK  Pin 13
MISO Pin 12
MOSI Pin 11
IRQ  Pin 8

and don't forget the 3.3 V stepdown converter!

Please ask me if you have any questions!

Example code (not all was tested):
Code:
#include "RFM70.h"

RFM70class RFM70;

byte RFM70_buf[MAX_PACKET_LEN];  //RFM70 data buffer
unsigned long RFMSendTime = 0;   //next send time
int RFMSendSpeed=1000;           //send packet every 1000 msec


void setup()
{
    Serial.begin(57600); 
    Serial.println("Arduino Start");   
    RFM70.begin();
    RFM70.Initialize();
    RFMSendTime = millis();
 
}

void loop()
{
    rfmTask();                                    //check for RFM70 event in polling mode
    if (millis() > RFMSendTime)                   //send packet
    {                                                   
      RFMSendTime = millis() + RFMSendSpeed;
      RFM70_buf[0]=0X41;     
      RFM70_buf[1]=0X42;
      RFM70_buf[2]=0X43;
      RFM70_buf[3]=0X44;     
      RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);
      Serial.println("Sending data");       
    } 
}

void rfmTask()                //RFM70 event handler
{
  if (RFM70.RfmInterrupt())
  {
    if (RFM70.TxDataSentInterrupt())
    {
       Serial.println("Data sent OK");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.TxDataSentErrorInterrupt())
    {
       Serial.println("Data sent error");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.RxDataReadyInterrupt())
    {
       Serial.println("Data received: ");
       byte rx_len = RFM70.Receive_Packet(RFM70_buf);
       if (rx_len)
       {
          for(byte i=1;i<rx_len;i++)
          {
            Serial.print(i);
            Serial.print("->");
            Serial.println(RFM70_buf[i]);
          }         
       }   
     }
  }
}




This is code for transmitting? How recive? I have 2 arduino's and 2 rfm70 mnodule.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Fajkowsky,

this code is transmitting and receiving.

Ecery second we are sending one packet:
Code:
    if (millis() > RFMSendTime)                   //send packet
    {                                                   
      RFMSendTime = millis() + RFMSendSpeed;
      RFM70_buf[0]=0X41;     
      RFM70_buf[1]=0X42;
      RFM70_buf[2]=0X43;
      RFM70_buf[3]=0X44;     
      RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);
      Serial.println("Sending data");       
    } 

We are constantly polling the RFM70 status:
Code:
rfmTask();

If the data was sent successfully or an error occoured we switch back to RX Mode:
Code:
RFM70.SwitchToRxMode();

So this code sends every second one packet, the rest of the time the RFM70 is waiting in receive mode.

If you load this code in two Arduinos with RFM70s, it can work but if both are sending exactly the same time it will not. To overcome this you can have only one sending and one receiving (delete the send code in one) , or you choose different (maybe random) send times (like Ethernet wait a random time if the sending was unsuccessful), or you use a polling mode where the master tells the slave when to send.

Tell me if you have still questions.
Fred



Logged

ਪੰਜਾਬ
Online Online
Edison Member
*
Karma: 12
Posts: 1618
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i have done exactly the same setup of yours and i also cared for this following thing:

Quote
If you load this code in two Arduinos with RFM70s, it can work but if both are sending exactly the same time it will not. To overcome this you can have only one sending and one receiving (delete the send code in one) , or you choose different (maybe random) send times (like Ethernet wait a random time if the sending was unsuccessful), or you use a polling mode where the master tells the slave when to send.

The its not receiving anything , i have deumilanove on receiver side with atmega8 and the uno on the sender side.
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi NI$HANT,

do you get any serial info from polling rfmTask() like "Data sent OK" or "Data sent error" on the sender side?
You should get at least "Data sent error" if the Receiver side is off.
If not it seems that you have a hardware problem.

Do you use this pinout?
CE   Pin 9
CSN  Pin 10
SCK  Pin 13
MISO Pin 12
MOSI Pin 11
IRQ  Pin 8

and don't forget the 3.3 V stepdown converter!

Fred

Logged

ਪੰਜਾਬ
Online Online
Edison Member
*
Karma: 12
Posts: 1618
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
do you get any serial info from polling rfmTask() like "Data sent OK" or "Data sent error" on the sender side?

Hi Fred i just get the "Sending data" on serial from the TX and Arduino start on the rx and nothing else and i have tried using the original code of yours at both the tx and rx and also tweaked the code to just BE a tx or a rx so no interference happens, still it works the same NOTHING is there.
Code:
Do you use this pinout?
CE   Pin 9
CSN  Pin 10
SCK  Pin 13
MISO Pin 12
MOSI Pin 11
IRQ  Pin 8

Yes, exactly this connectivity.
Quote
and don't forget the 3.3 V stepdown converter!

I just powered the modules from 3.3v at other sites the people were doing the same and i read i think that the SPI pins on RFM70 are 5v tolerant.
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I was using 1K Resistors to seperate the 5V Arduino and the 3.3 V RFM70.
I can't say if the RFM70 is 5V tolerant.

The logic of my code is:
Every second a packet is sent,
and independently RFMTask() is polling the IRQ pin.

This Pin goes low if one of the following events occour:
-Data sent OK (Ack from receiver received)
-Data sent Error (no Ack received)
-Data received

RFM70.TxDataSentInterrupt(), RFM70.TxDataSentErrorInterrupt() and RFM70.RxDataReadyInterrupt() functions checks the RFM70 on SPI level which of the events trigged the IRQ (and clears the IRQ).

If you still have problems you can uncomment the //Serial.print commands (there are many of them) in the RFM70.cpp file (you may have to restart your Arduino IDE to activate the change) to get low level trace printout of the SPI interface data.
You can send me the Trace data for debugging.

My code don't stop if the RFM70 is not present, so you get no error but you will receive no events.

Fred


Logged

Pages: [1] 2   Go Up
Jump to: