CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

nRF24L01+ full driver by Eduardo Guilherme Brandt
Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 18, 19, 20  Next
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
zamzam23



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PostPosted: Mon Jan 28, 2013 6:07 am     Reply with quote

I have solved this problem.

"#define RF24_SPI STREAM_SPI//Redirects SPI2 port to RS24_SPI stream "

this line must be before that line:

#USE SPI(SPI1, MASTER, BAUD=1000000, MODE=0, BITS=8, MSB_FIRST, STREAM=RF24_SPI)

--------

the pins are true.so what is the problem you think?

Here is my part of code for sending data:
I am sending the same data every push the buton.
Code:


   int bbuf[40];
   RF24_initPorts();
   RF24_default_config();
   RF24_TX_SET();
       
while(1)
{
if(input(buton))
{
while(input(buton));
output_bit(led, 1);delay_ms(1000);
bbuf[0] = 0b00110011;
RF24_TX_putbuffer(true,1,bbuf[0]);
output_bit(led, 0);
}
}


and here is the receiving data:
when I got the data, I will turn on the green led. and than waiting for new data.

Code:

   int RXbuffer1[32];
   int RXdatasize, RXpipe;
   RF24_initPorts();
   RF24_RX_SET();       //Receiver on

   while(true)                                                                 
   {
   while(RF24_RX_getbuffer(&RXpipe,&RXdatasize,RXbuffer1)!=true)
      {
         output_bit(red,1);
          delay_ms(100);
         output_bit(red,0);
          delay_ms(100);
      }
     //got the data
        output_bit(red,0);
       output_bit(green,1);delay_ms(100);
       output_bit(green,0);delay_ms(100);
    }




can you look these part of codes? any problem you see?
Hexadec



Joined: 09 Jan 2013
Posts: 7

View user's profile Send private message

PostPosted: Mon Jan 28, 2013 8:20 am     Reply with quote

Try the sample code that Eduardo so kindly put together.

This will test your hardware and show you how to use the drivers.
zamzam23



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PostPosted: Mon Jan 28, 2013 9:05 am     Reply with quote

eduardo,

I have two questions. pls answer them:

1-)in your examples, you have used 16f628 with #use delay(clock=14.31818M).

is it important that it is #use delay(clock=4M) or 20M?

2-) if I use software SPI, must I delete the spi_read() functions at the driver you shared at the fisrt page or no need any changes in your driver?
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Mon Jan 28, 2013 9:30 am     Reply with quote

zamzam23,

1 - No, in this case it is not important the speed of your uC, using SPI. nRF24 supports SPI rate up to 10Mbps. (I've already tested it using 12MHz SPI datarate to nRF24 without problems(but it is out of Nordic nRF24L01+ specifications). PIC16F628 has no hardware SPI (only software using CCS C).
**Just one note: SPI maximum speed depends on your uC speed. Some uCs can´t reach above 1 or 2Mbps.

2 - Yes, the line below is a way of putting things work with hardware SPI in some CCS C compiller versions with some uCs. I asked CCS about that, but I've have not gotten a definitive answer for that.
For example, with PIC16F876A hardware SPI it was not necessary.
With software SPI it is never necessary.

Sorry, but I forgot to talk about this important thing.

Code:
   //rv = spi_read();             //It´s necessary due to spi_xfer read bug


Thanks
_________________
Eduardo Guilherme Brandt
zamzam23



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PostPosted: Mon Jan 28, 2013 4:14 pm     Reply with quote

Yes it is working now Smile)

Thanks you and Eduardo and Hexadec.

One more question:

When I want to send and get nec[0]=1, it works.

transmiter:
Code:

nec[0]=1;
RF24_TX_putbuffer(false,1, nec[0]);
while(RF24_IRQ_state()==false);
RF24_STATUS_clr_IRQs(IRQ_ALL);

receiver:
Code:

while (RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer1)!=true );
       
if(RXbuffer1[0]==1)
  {
   //catched the data right
  }

But I send and get the data nec[0]=33, it doesn't work.
transmiter:
Code:
nec[0]=33;
RF24_TX_putbuffer(false,1, nec[0]);
while(RF24_IRQ_state()==false);
RF24_STATUS_clr_IRQs(IRQ_ALL);

receiver:
Code:

while (RF24_RX_getbuffer(&RXpipe, &RXdatasize, RXbuffer1)!=true );
       
if(RXbuffer1[0]==33)
  {
   //never catch data
  }

What am I doing wrong??
zamzam23



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PostPosted: Mon Jan 28, 2013 6:31 pm     Reply with quote

I think, I can send just string between " and ".
but if I want to work with integers, I have to use atoi() and itoa() functions, right?
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Tue Jan 29, 2013 1:36 pm     Reply with quote

Dear zamzam23

See nRF24_commandList.txt

The function is defined as follow:

Code:
int   RF24_TX_putbuffer(short int burst, int datasize, char *buffer);   //Transmit data(1 to 32 bytes) to actual address


The third parameter is a pointer(*buffer), not a value.

nec[0] is a value. nec is the pointer of the array.
So, the correct is:

Code:
nec[0]=1;
RF24_TX_putbuffer(false,1, nec);


Good Luck zamzam23!
_________________
Eduardo Guilherme Brandt
zamzam23



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 12:24 pm     Reply with quote

Thanks.

I have a little problem:

Your driver works good now. but sometimes( for example in house from one room to the other) the data isn't received. how can I fix this problem?
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 12:29 pm     Reply with quote

Config to 0dBm of power(as default).
Config data rate to 250kbps(nF24 has more sensivity at low bitrates)
Use a module with an external antenna connector instead of in-circuit antenna.

*I´ve reached easily more than 200m inside building(with just one wall behind transmitter and receiver and in-circuit antenna). In open air it should reach 200 to 1000meters. But it depends on conditions(walls, air humidity, tichness of walls, metal fences, etc...).

I suggest you **not use burst transmittion, with 16bit crc also.
_________________
Eduardo Guilherme Brandt
zamzam23



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 1:25 pm     Reply with quote

0 db is the max power as the datasheet.
I am using a internal antenna module. I have no external antenna module now.

here is I am using for transmitter: RF24_TX_putbuffer(false,32,"123");(no brust)

I am trying to send data 20m indoor.(between 3 walls)

any way for better transmit?
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 4:03 pm     Reply with quote

3 walls is too much for a 0dBm(1mW) transmitter.

Try this 100mW unit: http://www.ebay.com/itm/2-4Ghz-nRF24L01-Transceiver-Module-w-Power-Amplifier-/300743045237?pt=LH_DefaultDomain_0&hash=item4605aeb075

After try that 100mW unit, tell me what happens.

Good Luck

ps: This 100mW unit uses nRF24L01 without the plus "+" signal. There´re little differences. We talked about these differences some posts before, look for that please. Another guy told me some differences in maximum speed or something like that.
_________________
Eduardo Guilherme Brandt
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 4:05 pm     Reply with quote

zamzam23, **please check your country rules about wifi maximum power.
_________________
Eduardo Guilherme Brandt
zamzam23



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PostPosted: Mon Feb 04, 2013 8:47 am     Reply with quote

I have decrease my rate (from 2mbps to 250kbps) and now it is better.

Can I do something else with software for better transmission (not HW)?
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Mon Feb 04, 2013 4:08 pm     Reply with quote

zamzam23 , I don´t know nothing more about it.
_________________
Eduardo Guilherme Brandt
dezso



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

PostPosted: Sun Feb 10, 2013 11:22 am     Reply with quote

Don't know where is my stupidity but I cant make this work not even your test on with 16f876, I'm using 2xf876a instead of 628, but that shouldn't mater..
Tried with completely new project, 100% unmodified nRF24L01P.c/h
guarantied matching pin config, even swapped the modules for new ones in case one got damaged.
SPI send a burst of data to the module for 500us than nothing happens, no more data send or receive from SPI on either of the modules.
Help me out here, can some one send me a RX/TX working project either for MPLABX or 8..

Thanks
_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 18, 19, 20  Next
Page 7 of 20

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group