10233 views|2 replies

50

Posts

0

Resources
The OP
 

Crazy Shell AI open source drone SPI (2.4G dual-machine communication) [Copy link]

1. NRF24L01 1.1 Introduction to NRF24L01

NRF24L01 is a single-chip wireless transceiver chip produced by NORDIC that works in the 2.4GHz~2.5GHz ISM band. The wireless transceiver includes: frequency generator, enhanced "SchockBurst" mode controller, power amplifier, crystal oscillator, modulator and demodulator.

The output power, channel selection and protocol settings of NRF24L01 can be set through the SPI interface. Therefore, it has extremely high compatibility and can be connected to almost all single-chip microcomputer chips to complete wireless data transmission. In addition, the power consumption of NRF24L01 is also very low. When working in the **** mode and the **** power is 0dBm, the current consumption is only 11.3mA, and it is 12.3mA in the receiving mode. The current consumption is even lower in the power-down mode and standby mode. Therefore, NRF24L01 can be widely used in wireless keyboards and mice, wireless access control, radio stations, intelligent industrial equipment, toys and other occasions.

The characteristic parameters of NRF24L01 are listed in the following table.

Parameter name

Parameter characteristics

Small size

QFN20 4x4mm package

Wide voltage operating range

1.9V~3.6V, input pin can withstand 5V voltage input

Operating temperature range

-40℃~+80℃

Operating frequency range

2.400GHz~2.525GHz

****power

Selectable as 0dBm, -6dBm, -12dBm and -18dBm

Data transfer rate

Support 1Mbps, 2Mbps

Low power design

The operating current is 12.3mA when receiving, 11.3mA at 0dBm power, and only 900nA in power-down mode

Multi-channel design

126 communication channels and 6 data channels to meet the needs of multi-point communication and frequency modulation

Multi-mode

Support enhanced "ShockBurst" working mode, hardware CRC check and point-to-multipoint address control

Single data transmission

Each data packet can transmit 1 to 32 bytes of data

interface

4-wire SPI communication port, communication rate up to 8Mbps, suitable for connecting with various MCUs, simple programming

Interrupt

The MCU can determine whether data reception and data transmission are completed through the IRQ pin block

The following figure shows the actual picture of NRF24L01 chip

image.png

2.2.4G dual-machine communication 2.1 How to use NRF24L01

NRF24L01 sends data in the form of packets. The specific packet format is shown in the following table.

Preamble

address

Packet Control Word

Load data

CRC

NRF24L01 needs to perform a series of parameter configurations before communication. When configuring its parameters, NRF24L01 must work in standby mode, that is, the CE pin is pulled low. The configuration process in the sending mode is shown in the following table.

1

Write the send address and receive the reply channel address

2

Enable reply channel

3

Enable receiving address

4

Set the automatic resend time and resend times

5

Setting up the communication channel

6

Set parameters (power, gain, etc.)

7

Set mode (send, receive)

The process of configuring the receiving mode is shown in the following table.

1

Configure the receiving channel address

2

Set the effective data width of the receiving channel

3

Enable channel auto-answer

4

Enable receiving channel address

5

Setting up the communication channel

6

Set parameters (power, gain, etc.)

7

Set mode (send, receive)

After the configuration is completed, the sending and receiving process begins. The sending process is shown in the following table.

1

Write data to FIFO and wait for IRQ send completion interrupt

2

Read the value in the status register

3

Write the value read from the status register into the status register

4

Determine the value in the status register read previously to determine whether the transmission is completed or failed

5

Clear the fifo register

The receiving process is shown in the following table.

1

Read the value in the status register

2

Write the value read from the status register into the status register

3

Determine whether the value in the status register is accepted successfully

(If successful, read the data in the fifo and clear the fifo)

3. 2.4G dual-machine communication experiment

The 2.4G dual-machine communication experiment involves the remote controller and the flight control, and the 2.4G channels of both are set to 110. First, configure the left joystick button on the remote controller to the external interrupt mode. Once the joystick button is pressed, the string "Remoter" is sent to the flight control. After the flight control receives it, the LED flight status light flashes, and then the string "Airplane" is sent back to the remote controller. After the remote control receives it, the power indicator flashes. Whether the remote controller or the flight control uses NRF24L01, the hardware SPI of STM32 is used. The difference is that the remote controller uses SPI2, while the flight control uses SPI1. The SPI configuration method of STM32 can refer to the flight control development foundation "SPI (six-axis sensor data acquisition)".

3.1 Remote Control

In this experiment, the remote controller triggers the sending of wireless data through external interruption. For specific external interruption configuration, please refer to "Remoter Development Practice-Interruption". In this interruption, the "Remoter" string is sent to the flight control. The specific code is shown in the figure below.

image.png

The initialization code of NRF24L01 on the remote control is shown in the figure below.

image.png

The receiving process of the remote controller is implemented by polling in the main loop. After receiving the information sent by the flight control, the power indicator light flashes. The specific code is shown in the figure below.

image.png

3.2 Flight Control

The wireless data reception of the flight control end is implemented in the main loop. After receiving the information sent by the remote control, the power indicator light flashes and "Airplane" is sent back to the remote control end. The specific code is shown in the figure below.

image.png

The initialization code of NRF24L01 on the flight controller is as follows.

image.png

3.3 Experimental Phenomena

Download the remote control code to the remote control and the flight control code to the flight control. Power on and press the left joystick button of the remote control. You can see that the LED flight status lights at the bottom of the four motors of the flight control are flashing, and then the power indicator of the remote control is also flashing. This means that the flight control has received the information from the remote control and sent the information back to the remote control, and the remote control has also received the return information from the flight control. The following figure shows the flight control flight status lights, the left button of the remote control and the power indicator.

image.png

3.遥控器开发基础-【5】SPI(2.4G双机通信).pdf

792.66 KB, downloads: 8

This post is from Creative Market

Latest reply

Download the remote control code to the remote control and the flight control code to the flight control   Details Published on 2021-9-12 13:09
 
 

6547

Posts

0

Resources
2
 

NRF24L01 parameter configuration is very clear, thank you for sharing

This post is from Creative Market
 
 
 

46

Posts

0

Resources
3
 

Download the remote control code to the remote control and the flight control code to the flight control

This post is from Creative Market
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list