Pages: 1 [2]   Go Down
Author Topic: noob confuse with SPI - setSS() missing / RFM70 module  (Read 6091 times)
0 Members and 1 Guest are viewing this topic.
ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 7
Posts: 1545
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Fred thank you for the help actually if you see this>> http://www.hoperf.com/upload/rf/RFM70.pdf then you can note on the page 22 that im connecting correctly and i have double checked my connections as such they are fine , im just not having the Decoupling caps in the systems thats just a small difference but i checked the power on the wireless modules its comingin fine to them.
Logged

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

ਫ਼ਤੇਹ ਕਰੂਂ !

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 7
Posts: 1545
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One thing more , Is there a need to set CHANNEL's in both of these modules tx and rx both, However i have tried also with this by setting them to same channel that is 1.
Logged

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

ਫ਼ਤੇਹ ਕਰੂਂ !

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 7
Posts: 1545
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Im now receiving like this: after making some changes and putting a ATmega168 in one of the modules instead of an ATmega8

Code:
Data received:
Sending data
Data sent OK
Data received:
Data sent OK
Data received:
->f
->L
->™
->™
->–
->e
->L
->É
Data sent OK
Data received:
Data sent error
Data sent OK
Data sent OK
Data sent OK
Data sent error
Data received:
Data received:
Data received:
Data sent OK
Data received:
Data sent error
Data received:
Data sent OK
Data sent OK
Logged

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

ਫ਼ਤੇਹ ਕਰੂਂ !

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 7
Posts: 1545
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

now again the problem BOTH The modules just keep on sending nothing received.
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,

You receive events, so there cant be much wrong anymore.

Start just in the simplest case: one side is only sending, the other side is only receiving.
(comment out all sending code on the receiving side, at least
Code:
//RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);

I inserted a debug line to print out how many bytes are received:
Code:
       .....
if (RFM70.RxDataReadyInterrupt())
    {
       Serial.print("Data received, length: ");
       byte rx_len = RFM70.Receive_Packet(RFM70_buf);
       Serial.println(rx_len);
       if (rx_len)
       {
          for(byte i=1;i<rx_len;i++)
          {
            Serial.print(i);
            Serial.print("->");
            Serial.println(RFM70_buf[i]);
       ......
          }
The number of Bytes sent is the last argument in the RFM70.Send_Packet() command.
The same number of bytes should be received on the receiving end.


ATMEGA8:
My driver uses only GPIO functions, so I don't see any problem to use ATMEGA8, but maybe there is just a Pin numbering problem and SCK, MISO and MOSI uses different Pins compared to ATMEGA168.
 
Logged

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 7
Posts: 1545
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I did similar to this yesterday, But im going to again try so that both our time investment is beneficial.
Logged

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

ਫ਼ਤੇਹ ਕਰੂਂ !

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 7
Posts: 1545
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok i received this:

Code:
ata received:
Data sent OK
Data received:
->s
->3
->3
->3
->3
->™
->™
->œ
->Ì

->Ï
->ÿ
->ÿ

->ÿ
->ÿ
->ÿ
->ÿ
Data sent OK
Data received:
Data sent OK
Data sent error
Data sent error
Data received:
Data sent error
Data received:
Data sent OK
Data sent error
Data received:
Data sent OK
Data received:
Data sent error
Data received:
Data received:
Data sent OK
Data sent error
Data received:
Data sent OK
Data received:
Data sent OK
Data sent error
Data received:
Data sent error
Data sent error
Data received:
Data received:
Data sent error
Data received:
Data sent error
Data received:
Data sent OK
Data sent error
Data sent error
Data received:
Data sent error
Data sent OK
Data sent OK
Data received:
Data sent error
Data sent OK
Data received:
Data received:
Data received:
Data sent OK
Data sent error
Data sent OK
Data received:
Data received:
Data sent OK
Data sent OK
Data received:
Data received:
Data received:
Data sent OK
Data sent OK
Data sent error
Data received:
Data sent OK
Data sent error
Data received:
Data sent error
Data received:
Data sent error
Data received:
Data sent OK
Data received:
Data received:
Data received:
Data received:
Data sent OK
Data received:
Data sent OK
Data sent OK
Data sent error
Data sent OK
Data sent error
Data received:
Data received:
Data received:
Data sent OK
Data received:
Data received:
Data sent OK
Data sent error
Data received:
Data sent OK
Data sent OK
Data sent OK
Data sent error
Data received:
Data sent OK
Data received:
Data received:
Data received:
Data sent OK
Data sent error
Data received:
Data received:
Data sent OK
Data sent error
Data sent OK
Data sent OK
Data sent error
Data sent error
Data received:
Data received:
Data sent error
Data received:
Data sent OK
Data received:
Data received:
Data sent error
Data sent OK
Data sent error
Data sent OK
Data sent error
Data sent OK
Data sent error
Data received:
Data received:
Data sent OK
Data received:
Data received:

with this in Tx:
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();
    }
   
  }
}

and this in Rx:

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

"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

Hello,

I am confused about your serial output:
Was this from the TX or RX side?

I am asking because I see Data sent OK and Data received, but if you uncomment the sending on the RX side you should never get Data sent OK bacause you are not sending anything.

My log output is on the TX side:
Code:
Arduino Start
Sending data
Data sent OK
Sending data
Data sent OK
Sending data
Data sent OK
Sending data
Data sent OK

And on the RX side:
Code:
Data received, length: 4
0->65
1->66
2->67
3->68
Data received, length: 4
0->65
1->66
2->67
3->68


Fred
Logged

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

Hello,

one more question: which Arduino version do you use?
Serial.println(RFM70_buf); should always give you a number under Version 1.0 and not a character.
To be sure you can use Serial.println(RFM70_buf, DEC);

Fred
Logged

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 7
Posts: 1545
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

HI i have used 0022 IDE
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 ported my RFM70 Driver from Ver 0.22 to 1.0.1 some month ago, but I never tried if still works under 0.22.
But as you see in my log output, at least with IDE 1.0.1 and Atmega 328P/16MHZ/5V it works over a distance of several meters.
But as I am using only GPIO functions, I don't see any problem to use other ATMEGAs, I used the same driver on an ARM Cortex M3 (also GCC) successfully, changing only the PROGMEM to Constant and and the GPIO Read/Write commands.


Nevertheless, if you still have problems use the low level debug by uncomment the //Serial.print commands in the RFM70.cpp file, this gives you the information what realy happens on the SPI level together with the datasheet. This was very useful for me at the beginning for debugging.

One more info for you:
It is also possible to use W_ACK_PAYLOAD_CMD (RFM70.Send_Packet(W_ACK_PAYLOAD_CMD,tx_buf,len); ) to do a toway communication with only one side transmiting, see the RFM70 datasheet. Use the RFM70.TxEmptyFlag(); function to avoid TX buffer overflow.

Fred
Logged

Pages: 1 [2]   Go Up
Jump to: