Go Down

Topic: Please, I am looking for a code to continuously transmit with NRF905 module (Read 6033 times) previous topic - next topic

trifonc

Hi everybody!

I have a NRF905 module and I would like to make a transmission to last at least 10 to 15 seconds in order to my frequency counter can capture and measure the emission frequency.

I do not know to program in the field of Arduino, and as only perform this test .... I wouldn't like to learn programming for Arduino (it needs to many hours for that unique purpose)

Can someone help me with a modification of the program that appears on the bottom to transmit continuously for ten or fifteen seconds (or more) given time?

I am using the this configuration http://www.electrodragon.com/w/index.php?title=NRF905_Transceiver_433MHz-Wireless_Module  

The files are in:   http://www.electrodragon.com/wp-content/uploads/2011/11/NRF905-for-arduino.zip  

thank you very much

PaulS

Quote
I wouldn't like to learn programming for Arduino (it needs to many hours for that unique purpose)

I don't think I'm interested in helping you. It would take to long.

Go troll somewhere else.
The art of getting good answers lies in asking good questions.

trifonc

I was experimenting with a loop if (var.1, var <32000; var + +)   but I could not.

If so, thanks anyway.

a greeting

BulldogLowell

I would recommend posting the sketch you want to modify (placed within code tags using the hash button above).

It seems a lot to ask, having people hunt down your code.


AWOL

Code: [Select]
I was experimenting with a loop if (var.1, var <32000; var + +)   but I could not
I see no loop.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

AWOL

"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

BulldogLowell

have you actually tried the TX code you have?

What is it doing/not doing that you need it to do/not do?

trifonc

Quote
have you actually tried the TX code you have?

What is it doing/not doing that you need it to do/not do?


Hi,   well I think the module works. But I am trying the module transmiting some bytes (don't worry which) during some seconds, time enough for my frequency counter takes the exactly frequency is it transmitting.

Now, with the TX code, the module transmit only 0,5 or 1 second; it is not enogh for the frequency meter takes mesure.

Trying it, I included and " if (var=1; var <32000; var++)" in loop code, but I didn't get nothing.

Im asking for somebody that can tell me wich code I need to include for it.

I don't know if with a loop "if" or with AUTO_RETRAN instruction ....

Thank You.

--------------------------------------------------------------------

Post information:

the code module included only transmit a little bit information that takes miliseconds to transmit.
My frequency meter needs one ore two seconds receiving signal to mesure the frequency, so ......... I need a longer signal from module to try mesure it.
Don't worry the info to transmit!  There is no RX to receive!!! I don't need it!!   becuase only a frequency meter will receive the signal!!!

AWOL

Quote
and " if (var=1; var <32000; var++)" in loop code, but I didn't get nothing.

Because it is not a loop.
I'm not sure what it is.
See my earlier comment.

Please, change your quote tags into code tags, so we can read the code you posted.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

trifonc

Hi again,  I'm very sorry .... i didn't understand you about code tags. :-(

I will try now do this correctly.

File: NRF905.ino:

Code: [Select]
#include <NRF905.h>
#include <SPI.h>

#define BUF_LEN          32
#define CONF_LEN         10

#define NRF905_CSN       10

unsigned char tx_buf[BUF_LEN]= "Hi, Arduino   \r\n";
unsigned char read_config_buf[CONF_LEN];

byte tx_address[4]= {0xcc,0xcc,0xcc,0xcc};

void setup()
{
   unsigned char i;
   
   pinMode(NRF905_CSN,OUTPUT); //to make sure SPI works
   
   nrf905=NRF905(NRF905_CSN);
   
   nrf905.init();


   /**
       default configuration, need to specify frequency
       choose Z-Wave frequency band, support :
       US 908.42Mhz
       EUROPE 868.42MHz
       AFRICA 868.42MHz
       CHINA 868.42MHz
       HK 919.82MHz
       JAPAN 853.42MHz
       AUSTRALIA 921.42MHz
       NEW_ZEALAND 921.42MHz
       BRASIL 921.42MHz
       RUSSIA 896MHz
   */
   nrf905.write_config(US);


   nrf905.read_config(read_config_buf);

   Serial.begin(9600);

   for(i=0; i<10; i++)
   {
       Serial.print(read_config_buf[i],HEX);
       Serial.print(' ');
   }
   
   tx_buf[12] = '0';
}

void loop()
{
   /** transmit data packet with default TX Address */
   nrf905.TX(tx_buf);
   
   /** transmit data packet with specified TX Address */
//    nrf905.TX(tx_buf, tx_address);
   
   // NOTE: TX_Address and RX_Address must be the same
   
   /** Count Sending times */
   tx_buf[12]++;
   if(tx_buf[12] == 0x3A){
     tx_buf[12] = '0';
   }
   delay(50);
}




and NRF905.h :

Code: [Select]
#ifndef NRF905_h
#define NRF905_h

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif


/** nrf905 instruction set */
#define WC 0x00
#define RC 0x10
#define WTP 0x20
#define RTP 0x21
#define WTA 0x22
#define RTA 0x23
#define RRP 0x24

typedef enum
{
   US = 0,             /** 908.42Mhz */
   EUROPE = 1,         /** 868.42MHz */
   AFRICA  = 2,         /** 868.42MHz */
   CHINA = 3,          /** 868.42MHz */
   HK = 4,             /** 919.82MHz */
   JAPAN = 5,          /** 853.42MHz */
   AUSTRALIA = 6,      /** 921.42MHz */
   NEW_ZEALAND = 7,    /** 921.42MHz */
   BRASIL = 8,         /** 921.42MHz */
   RUSSIA = 9,         /** 896.00MHz */
} nrf905_freq_type;


class NRF905
{
public:
   NRF905(void);
   NRF905(int css);

   void init();
   void write_config(unsigned char *conf_buf);
   void write_config(nrf905_freq_type freq_band);
   void read_config(unsigned char *conf_buf);
   void RX(unsigned char *TxRxBuffer);
   void RX(unsigned char *TxRxBuf, unsigned char *RxAddress);
   void TX(unsigned char *TxRxBuf, unsigned char *TxAddress);
   void TX(unsigned char *TxRxBuf);

private:
   void set_rx(void);
   void set_tx(void);
   unsigned char check_ready(void);

   void RxPacket(unsigned char *TxRxBuffer);
   void TxPacket(unsigned char *TxAddress, unsigned char *TxRxBuf);

   //----------------------------------------------NRF905 IO------------------------------------------------------
   int TXEN;
   int TRX_CE;
   int PWR;
   //----------------------------------------------NRF905 SPI---------------------------------------------------
   int CSN;
   //----------------------------------------nrf905 status IO---------------------------------------------------------
   int AM;
   int DR;
   int CD;
};

extern NRF905 nrf905;

#endif





and file NRF905.ccp :

Code: [Select]
#include <NRF905.h>
#include <SPI.h>

/** define a ultity */
NRF905 nrf905;

unsigned char config_info_buf[10]={
       0x76,                   //CH_NO,868.4MHZ
       0x0E,                   //output power 10db, resend disable, Current Normal operation
       0x44,                   //4-byte address
       0x20,0x20,              //receive or send data length 32 bytes
       0xCC,0xCC,0xCC,0xCC,    //receiving address
       0x58,                   //CRC enable,8bit CRC,external clock disable,16MHZ Oscillator
};

PROGMEM unsigned int freq_tab[10] = {
   0x13e,
   0x076,
   0x076,
   0x076,
   0x177,
   0x02b,
   0x17f,
   0x17f,
   0x17f,
   0x100,
};

//-------------------initial nRF905---------------------------------------------
NRF905::NRF905(void)
{
   TXEN=5;
   TRX_CE=4;
   PWR=3;
   CSN=10;
   AM=9;
   DR=8;
   CD=7;
}
NRF905::NRF905(int css)
{
   TXEN=5;
   TRX_CE=4;
   PWR=3;
   CSN=css;
   AM=9;
   DR=8;
   CD=7;
}

void NRF905::init(void)
{
   pinMode(CSN, OUTPUT);
digitalWrite(CSN, HIGH); // Spi disable

pinMode(DR, INPUT); // Init DR for input

pinMode(AM, INPUT);// Init AM for input

pinMode(CD, INPUT);// Init CD for input

pinMode(PWR, OUTPUT);
digitalWrite(PWR, HIGH);// nRF905 power on

pinMode(TRX_CE, OUTPUT);
digitalWrite(TRX_CE, LOW);// Set nRF905 in standby mode

pinMode(TXEN, OUTPUT);
digitalWrite(TXEN, LOW);// set radio in Rx mode

SPI.setBitOrder(MSBFIRST);
   SPI.setDataMode(SPI_MODE0);
   SPI.begin();

   /** wait for nrf905 STANDBY */
   delay(3);
}

//---------------wite to configuration register-----------------
void NRF905::write_config(unsigned char *conf_buf)
{
digitalWrite(CSN,LOW); // Spi enable for write a spi command
/** send write configuration command */
SPI.transfer(WC);
for (int i=0;i<10;i++) // Write configration words
{
  SPI.transfer(conf_buf[i]);
}
digitalWrite(CSN,HIGH); // Disable Spi
}

void NRF905::write_config(nrf905_freq_type freq_band)
{
   if(freq_band < 10){
       config_info_buf[0] = (unsigned char)freq_tab[freq_band];
       if(freq_tab[freq_band]&0x100){
           config_info_buf[1] |= 0x01;
       }else{
           config_info_buf[1] &= ~0x01;
       }
   }
   // Spi enable for write a spi command
digitalWrite(CSN,LOW);
/** send write configuration command */
SPI.transfer(WC);
for (int i=0;i<10;i++) // Write configration words
{
  SPI.transfer(config_info_buf[i]);
}
digitalWrite(CSN,HIGH); // Disable Spi
}

void NRF905::read_config(unsigned char *conf_buf)
{
   digitalWrite(CSN,LOW); // Spi enable for write a spi command

   /** send read configuration command */
   SPI.transfer(RC);
for (int i=0;i<10;i++)
{
  conf_buf[i] = SPI.transfer(0x00);
}
digitalWrite(CSN,HIGH); // Disable Spi
}

void  NRF905::RX(unsigned char *TxRxBuffer)
{
   set_rx(); // Set nRF905 in Rx mode
   while (check_ready()==0);
   delay(1);
   RxPacket(TxRxBuffer);
   delay(1);
}

void NRF905::RX(unsigned char *TxRxBuf, unsigned char *RxAddress)
{
   if(config_info_buf[5] != RxAddress[0] ||\
      config_info_buf[6] != RxAddress[1] ||\
      config_info_buf[7] != RxAddress[2] ||\
      config_info_buf[8] != RxAddress[3]){

       config_info_buf[5] = RxAddress[0];
       config_info_buf[6] = RxAddress[1];
       config_info_buf[7] = RxAddress[2];
       config_info_buf[8] = RxAddress[3];

       write_config(config_info_buf);
   }

   set_rx(); // Set nRF905 in Rx mode
   while (check_ready()==0);
   delay(1);
   RxPacket(TxRxBuf);
   delay(1);
}

void NRF905::TX(unsigned char *TxRxBuf, unsigned char *TxAddress)
{
   set_tx();
   delay(1);
   // Send data by nRF905
   TxPacket(TxAddress, TxRxBuf);
}

void NRF905::TX(unsigned char *TxRxBuf)
{
   set_tx();
   delay(1);
   // Send data by nRF905
   TxPacket(config_info_buf+5, TxRxBuf);

}

void NRF905::TxPacket(unsigned char *TxAddress, unsigned char *TxRxBuf)
{
int i;
digitalWrite(CSN,LOW);
// Write payload command
SPI.transfer(WTP);
for (i=0;i<32;i++){
   // Write 32 bytes Tx data
SPI.transfer(TxRxBuf[i]);
}
digitalWrite(CSN,HIGH);
delay(1);

   // Spi enable for write a spi command
digitalWrite(CSN,LOW);
// Write address command
SPI.transfer(WTA);
// Write 4 bytes address
for (i=0;i<4;i++){
SPI.transfer(TxAddress[i]);
}
// Spi disable
digitalWrite(CSN,HIGH);

// Set TRX_CE high,start Tx data transmission, CE pulse
digitalWrite(TRX_CE,HIGH);
delay(1);
digitalWrite(TRX_CE,LOW);
}

void NRF905::set_tx(void)
{
digitalWrite(TRX_CE,LOW);
digitalWrite(TXEN,HIGH);

// delay for mode change(>=650us)
delay(1);
}


void NRF905::set_rx(void)
{
digitalWrite(TXEN, LOW);
digitalWrite(TRX_CE, HIGH);

// delay for mode change(>=650us)
delayMicroseconds(800);
};

unsigned char NRF905::check_ready(void)
{
   if(digitalRead(DR) == HIGH) {
return 1;
}
else{
return 0;
}
}

void NRF905::RxPacket(unsigned char *TxRxBuffer)
{
int i;
   digitalWrite(TRX_CE,LOW);
digitalWrite(CSN,LOW);
   delay(1);
SPI.transfer(RRP);
   delay(1);
for (i = 0 ;i < 32 ;i++){
TxRxBuffer[i]=SPI.transfer(NULL);;
       delay(1);
}
digitalWrite(CSN,HIGH);
   delay(1);
digitalWrite(TRX_CE,HIGH);
delay(1);
}








I hope now would be ok.
And sorry for inconveniencies.
--------------------------------
Awol, thank for cleaning and info!

mauried

Why do you want to measure the frequency?
Its a GFSK modulated radio, your frequency counter wont make much sense of it.

trifonc


Why do you want to measure the frequency?
Its a GFSK modulated radio, your frequency counter wont make much sense of it.



:~    :~    Glub!

I have an ASK /OOK module of 433 Mhz and I can read the frequency, so I thought I would be able to read this other module (NRF905)

So ........  will I not be able to read the frequency of this NRF905 module?

Must I suppose that will happen the same with the  NRF24L01 module?

Thanks for the info.

cartoonist

The Nordic nRF905 product specification v1.5 says on page 17:

Quote
For test purposes such as antenna tuning and measuring output power it is possible to set the transmitter
so that a constant carrier is produced. To do this, TRX_CE must be maintained high instead of being
pulsed and Auto Retransmit should be switched off. After the burst of data is sent the device continues to
send the unmodulated carrier.
You do not need a new P.C., you need a new O.S.  Linux is free, safe, easy, fast and reliable.

Go Up