Almost two weeks been working on RC transmitter using nRF 2.4GHz transceiver, it is working pretty fine..requires little more testing.
in total transmitter sends 5 byte payload which are
10 bytes for throttle data 0-1000
9 bytes for yaw -180 to 180
6 bytes each for pitch and roll -30 to 30
plus 9 extra bits..which can be used to cut-off throttle, turn on LED’s or changing modes and stuff.
How usually the reciever works is it recieves the analog joystick data and 1’s and 0’s from switches in digital packets..decrypts them..and writes pwm on the 4 channels and 1’s and 0’s on the rest.
What I managed was nano on the reciever ends acts as a I squared C slave to arduino uno(master)(which is interfaced with IMU and doing all the PID and stuff) and reads the packets as they from nano..decrypts them and uses them. Code which I used for this was from wire library master reader and slave sender.
To read 4 channels, 8 interrupts are triggered(pin change interrupts are what usually used)..so instead of 8 pinchange interrupts for 4 channels..master directly reads the packets..saved pins and definitely performs better.
PID control loop is running at 100Hz..and RC data is updated at 50Hz..which is good. Frequency can only be increased further more by increasing the air data speed..which would then decrease the range.
one weird thing I noticed with bitmath