nRF24L01 - Does CE and CSN pins need PWM pins for an Arduino Nano?

Hi, I am currently using the nRF24LO1 to control a remote control quadcopter powered by an Arduino Nano. I am currently powering 3 of my 4 motors using pins 6, 5 and 3 for the AnalogWrite command in pulse width modulation. However I need another pin that can support PWM for my 4th motor so what I'm asking is does the CE pin and CSN require pins 9 and 10 to operate? (As I can define them in my main code).

For reference I am following this tutorials pin configuration (and I already have it working):

Simple nRF24L01 Tutorial

You can use any pins for CE and CSN. However pin 10 must be set as OUTPUT for the Arduino to operate as an SPI master. It would normally be OUTPUT when used for PWM so that should be no problem.

...R

Hi, I am still following @Robin2's tutorial on pin configuration. The only difference I've made is I've changed the CSN pin on the quadcopter only from D10 to D8 as I'm now using D10 as a PWM output for a motor. My transmission line stopped receiving incoming data after both wiring and changing the pin in the code.

Again, literally just changed pin 10 to be pin 8 on the receiver.

Any thoughts?

depre:
Again, literally just changed pin 10 to be pin 8 on the receiver.

I can't read your image. Please don't post pictures of text - just copy and paste the text.

You need to post the complete code for the pair of programs YOU have uploaded to your two Arduinos.

...R

Rx Serial Monitor Output:

SimpleRx Starting

And nothing else...

Tx Serial Monitor Output:

SimpleTx Starting
test1) Data Sent Message 0 Tx Failed
test2) Data Sent Message 0 Tx Failed
test3) Data Sent Message 0 Tx Failed
test4) Data Sent Message 0 Tx Failed
test5) Data Sent Message 0 Tx Failed
test6) Data Sent Message 0 Tx Failed
test7) Data Sent Message 0 Tx Failed
test8) Data Sent Message 0 Tx Failed

And so on...

In the RX program you have posted in Reply #4 you have not set Pin 10 as OUTPUT - see Reply #1. The default for all pins in INPUT

...R

I got it working by adding the line to the setup of the Rx.

pinMode(10, OUTPUT);

I'm curious why does it now work when pin 10 is not used by the Rx? The pin is now unaffiliated as i'm using pin 8 instead?

Edit: I've been commenting parts of my code out from the main loop and it appears that i can only receive packets if the packet arrives at the exact time as the transceiver reads. And with more lines of code resulting in reading at less times. Is there a way I can put the receiver code in some sort of thread?

Update: Threading has helped a small amount (I've been using protothreading from TimedAction.h) however it appears that when i activate the motors nothing gets through. Potentially it is the noise? I can't seem to think of anything else.

depre:
I'm curious why does it now work when pin 10 is not used by the Rx? The pin is now unaffiliated as i'm using pin 8 instead?

If you read the Atmega 328 datasheet you will see that Pin 10 must set as OUTPUT to make the chip work as an SPI master.

Edit: I've been commenting parts of my code out from the main loop and it appears that i can only receive packets if the packet arrives at the exact time as the transceiver reads.

Again, without seeing the exact code you are using I can't tell exactly what you have tried.

The nRF24 will receive the message at the same time as it is transmitted. Wireless messages cannot hang around in the atmosphere waiting to be picked up at a later time.

If you don't read the message before the next message is sent then things are going to get messed up. Your Tx program needs to deal with the timing - don't send messages too often.

Update: Threading has helped a small amount (I've been using protothreading from TimedAction.h) however it appears that when i activate the motors nothing gets through. Potentially it is the noise? I can't seem to think of anything else.

Yet again, I have no idea what precisely you have tried.

Rather than use a library to manage timing I suggest you just use millis() as illustrated in Several Things at a Time

And, BEFORE you try any complicated timing make sure the simple system works.

...R

I've edited the code to be timed with millis(). Here is what i've got, Still no data coming through

Edit: Had no luck

I suggest you take everything out of the receiver program except the wireless code. When you have that working then you can start adding in the other stuff.

...R

Turns out there was an issue with the board so I re-soldered everything onto a new one however the Arduino transceiver is receiving empty packets while using the code from reply #4. The console logs look like:

SimpleRx Starting

  1. Data received
  2. Data received
  3. Data received
  4. Data received
  5. Data received
  6. Data received
  7. Data received
  8. Data received
  9. Data received
  10. Data received
  11. Data received
  12. Data received
  13. Data received
  14. Data received
  15. Data received
  16. Data received
  17. Data received
  18. Data received
  19. Data received
  20. Data received
  21. Data received
  22. Data received
  23. Data received
  24. Data received
  25. Data received
  26. Data received
  27. Data received
  28. Data received
  29. Data received
  30. Data received

SimpleTx Starting
test1) Data Sent Message 0 Tx failed
test2) Data Sent Message 0 Tx failed
test3) Data Sent Message 0 Tx failed
test4) Data Sent Message 0 Tx failed
test5) Data Sent Message 0 Tx failed
test6) Data Sent Message 0 Tx failed
test7) Data Sent Message 0 Tx failed
test8) Data Sent Message 0 Tx failed
test9) Data Sent Message 0 Tx failed
test10) Data Sent Message 0 Tx failed
test11) Data Sent Message 0 Tx failed
test12) Data Sent Message 0 Tx failed
test13) Data Sent Message 0 Tx failed
test14) Data Sent Message 0 Tx failed
test15) Data Sent Message 0 Tx failed

The receiver is receiving packets faster than the Tx is transmitting them and relieving packets when the transmitter is turned off.

depre:
The receiver is receiving packets faster than the Tx is transmitting them

That usually means that the receiver is not getting anything and there is a problem of communication between the Arduino and the nRF24 it is attached to.

Try the program in Reply #29 in this Simple nRF24L01+ Tutorial

...R