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):
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.
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.
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
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.
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.
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
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
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.