SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By lucicop
#32879
Hi all,

I succeeded in designing a driver to send a packet with nRF24L01. Now I want to do a higher layer protocol to send packets bigger than 32 bytes, and for this I need to split them into 32-byte chunks. I have at most 4 chunks per big packet.

Now, my problem is that if I push packets in TX FIFO until it is full, and then after one packet is transmitted, I push the last one, at the receiver side I get all times only 3 packets. If I push the packets in turn, one by one, after DS interrupt, sometimes I get 4 packets at the receiver, sometimes 3 packets. I am not using auto-ack and retransmission, and this would probably solve the problem, but this is a particular case of the protocol, when I can't enable this: I'm sending broadcast packets, so I cannot wait for ACK.

Does anyone of you have an idea about this problem, or tried doing something similar and succeeded ? Thank you in advance for your help !
By iharris
#33018
Hi Lucicop,

I'm also working on a higher layer protocol using the previous version of that chip.

You will find that every packet is not guaranteed - especially since the band it uses (2.4Ghz) usually has tonnes of wireless routers etc doing their thing. So you can't guarantee anything will reach the other end. So naturally you need to take care of this yourself, or on the nRF24L01, you can as I understand it, have the chip itself retransmit if it doesn't get an ack.

In any case, it's always important to make sure data gets across okay if it's important.

cheers
Ian.
By lucicop
#33019
Hi,

Thank you for the reply.

The main problem is with the broadcast messages, as for the peer-to-peer messages it uses Enhanced Shockburst, which automatically makes sure that one packet arrived successfully on the other side. For broadcasting messages to more receivers, I cannot use this feature. I think that I will design my protocol in such a way that important messages are sent only peer-to-peer and not broadcasted.

Good luck with your protocol !

Regards,
Lucian
By marcovansteen
#33020
Hi Lucian,

Sometimes it is hard to avoid broadcasts, for example if you want to discover all nodes within range of the host.

In the protocol that I am planning to design, I will just transmit the same broadcast packet a few hundred times during 2 seconds, and have the nodes reply to this packet after 2 second + a random time between 10 and 100 ms.
This procedure can be repeated a few times to discover as many nodes as possible.

Advantages are:
- chance that broadcast packet arrives is much higher
- sensor node can receive this message even in a 'standby' mode where it turns on the ('battery eating') receiver only a few times per second.
- lower chance that the packets of replying nodes collide

What do you think of this approach?

Cheers,

Marco
By lucicop
#33022
Hi Marco,

I think it is a very good idea. But you should also take into consideration that nodes could be on different channels - sometimes you need to include frequency agility into your application. So you would need 2sec * MAX_NR_OF_CHANNELS_FOR_YOUR_TRANSCEIVER, which could become pretty big. My transceiver allows many channels, from which I use half - I have a step of 2 to avoid interference between adjacent channels.

My approach in the application is the following: have a coordinator that starts and takes a default address. Nodes that come online search for this coordinator by periodically sending ping messages and cycling through all the channels, until a coordinator is found. Then the connection is made.

Does your transceiver allow listen-before-talk ? If yes, you could avoid using the random interval. Are you thinking of sending each broadcast packet in your application for 2 seconds, or only a message to discover neighbour nodes ? If you plan to send each one, it could become a problem when you have many broadcasts to make.

I would be glad to exchange application ideas with anyone interested in this domain (wireless networks).

Regards,
Lucian
By marcovansteen
#33038
Hi Lucian,

Thanks, your idea is indeed more elegant! The frequency agility can be a serious advantage, and on my TRF2.4G module, receiving 'costs' 18 mA and sending at 0dBm takes 13 mA. So it may save batteries as well.

The node discovery was the only phase where I'ld need to broadcast packets. I plan a star topology afterwards.

I can not completely understand how with 'listen before talk', the randomization of the response moment can be avoided. My transceiver can do 'listen before talk'. However, if several nodes receive the same broadcast message at the same time, they will all listen, and 'hear' at the same moment that the channel is free. Then they'll start to send response packets all on the same time, making a big collision. Or not?

Well I like the discussion.
You now plan to send the 'important' packets peer-to-peer and not by broadcast. However that multiplies broadcast traffic by the number of nodes. How many nodes do you plan for?
Maybe there is a way in between. You could add a field to each broadcast message, telling the nodes at what 'time' to expect the next broadcast message. The nodes keep track of the time (maybe using a timer/counter). When the nodes do not receive a packet at the planned time, they send e.g. 10 packets with the same 'request for broadcast retransmit'. Etcetera.

Best regards,

Marco
By lucicop
#33040
Hi Marco,

You may be right about the collision when all listen at the same time. Anyway it's a useful feature and you should make use of it.

I need to find a solution for a connection management so a node knows when it is not connected to its coordinator anymore. The coordinator sends periodically beacon signals as broadcast, and if a node doesn't receive them for some time, it will start pinging the coordinator (and this is peer to peer). Then it might decide to start looking for its coordinator.

I am not thinking of sending important packets to each node in the system. I plan the system to accomodate a high number of nodes, so this would not be a suitable solution. I will just design the protocol in such a way that for an important message, a device will contact another device, and after this do a broadcast. I cannot use the timing scheme because broadcasts are irregular, based on the medium states. But anyway, I could send a broadcast packet x times, just to be sure one of them arrived.

What is your application ?

Regards,
Lucian
By RonnyM
#33069
Hey Lucian,
I believe I have an answer to your packet problem if you do not. Unlike the Chipcon parts that will take up to the bytes per packet number you state, the 24L01 must get a packet of the exact length of the number you put into "pipe width". If your final packet is less than 32 bytes, pad the rest.
Or, you can enable the variable byte payload and send any number of bytes up to 32. This drove me crazy for days because the data sheet is unclear that the pipe width number must be the exact number of bytes sent.
By lucicop
#33088
Hi Ronny,

Thank you for your answer. I am aware of the length problem for the packets, and I am always writing 32 bytes into the TX PAYLOAD register. I am not sure about the cause of the initial problem, but currently I'm sending each packet in turn and it's working. After the driver is finished, maybe I'll try finetuning it.

Now I have another problem regarding the pipes and the addresses for them. If I set the module to use only pipe 0, I can send data to the other module. However, only changing EN_RXADDR to 0x07 to use pipes 0, 1 and 2, I cannot send the packet to the same address. This seems very strange, and I have contacted Nordic support to get help.

Regards,
Lucian
By lucicop
#33099
There seems to be an issue regarding the addresses for receiving pipes. Assume I want them to have the addresses ABCDD, ABCED, ABCEE, I write the data as DDCBA, DECBA, EECBA. The transmit address is written the same. Still, I cannot get packets through. If I only write to Pipe0 address, then the packets are transmitted.

What could be the cause of that ? Can any of you enlighten me about how the RX addresses are written ? Has any of you tried and succeeded using other addresses than the default ones for the RX pipes ?

Regards,
Lucian
By RonnyM
#33136
Have you written the registers and then read them back to make sure the register write worked?
By lucicop
#33137
Yes, I have read them back and they were as I expected. It's driving me nuts, and probably it's something very simple I'm overlooking.
By RonnyM
#33138
As I remember, there was some qwirk to writing the higher number pipes that was discussed on this list. Brennen discussed it in a previous post.
By brennen
#33139
AFAIK, I tested sending and receiving on all the pipes with my library and everything worked out OK. I know that I tested all 6 pipes with the default addresses, and I'm pretty sure that I checked them with different addresses, too. I know for sure that I tested pipes 0 and 1 with different addresses, though, and that worked fine. If you want to see my code, go to my website (in my tagline below) and it's in the tutorials.
By lucicop
#33140
Hi brennen,

I have looked over your code, but I've seen no significant differences. I have Tutorial3 from your site and I see it uses default addresses. Is there anything special about writing those addresses ? Except that the last byte needs to be first, if I really care about the order.