|
|
View previous topic :: View next topic |
Author |
Message |
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
|
Posted: Mon Jan 28, 2013 6:07 am |
|
|
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
|
|
Posted: Mon Jan 28, 2013 8:20 am |
|
|
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
|
|
Posted: Mon Jan 28, 2013 9:05 am |
|
|
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
|
|
Posted: Mon Jan 28, 2013 9:30 am |
|
|
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
|
|
Posted: Mon Jan 28, 2013 4:14 pm |
|
|
Yes it is working now )
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
|
|
Posted: Mon Jan 28, 2013 6:31 pm |
|
|
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
|
|
Posted: Tue Jan 29, 2013 1:36 pm |
|
|
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
|
|
Posted: Sat Feb 02, 2013 12:24 pm |
|
|
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
|
|
Posted: Sat Feb 02, 2013 12:29 pm |
|
|
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
|
|
Posted: Sat Feb 02, 2013 1:25 pm |
|
|
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
|
|
|
Eduardo__
Joined: 23 Nov 2011 Posts: 197 Location: Brazil
|
|
Posted: Sat Feb 02, 2013 4:05 pm |
|
|
zamzam23, **please check your country rules about wifi maximum power. _________________ Eduardo Guilherme Brandt |
|
|
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
|
Posted: Mon Feb 04, 2013 8:47 am |
|
|
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
|
|
Posted: Mon Feb 04, 2013 4:08 pm |
|
|
zamzam23 , I don´t know nothing more about it. _________________ Eduardo Guilherme Brandt |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Sun Feb 10, 2013 11:22 am |
|
|
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 |
|
|
|
|
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
|