Introduction
The multifunctional wireless mouse includes a wireless transmitting part and a wireless receiving part, wherein the transmitting part is the key part related to its overall performance. This system builds a wireless transmitting module with nRF24L01 as the core. nRF24L01 is a new single-chip RF transceiver device that works in the 2.4-2.5 GHz ISM band; it has built-in frequency synthesizer, power amplifier, crystal oscillator, modulator and other functional modules, and integrates enhanced ShockBurst technology, in which the output power and communication channel can be configured through the program. nRF24L01 has low power consumption. When transmitting at 0 dBm power, the operating current is only 11.3 mA; when receiving, the operating current is only 12.3 mA; multiple low-power working modes (power-down mode and idle mode) make energy-saving design more convenient.
The multi-function wireless mouse is a battery-powered handheld device, and power consumption is an important criterion for measuring its performance. The main control chip selected for this design is MSP430F413, which is a 16-bit ultra-low-power mixed signal processor with a maximum current of 350μA in active mode and only 0.1μA in RAM data retention mode. The light sensor chip is ADNS-5030. This chip is small in size and low in power consumption. In working mode, its maximum working current is 17 mA; the LED is only lit when the light sensor is working, which will further reduce the power consumption of the light sensor (less than 1 mA).
This article introduces the development process of the transmitter part of the multifunctional wireless mouse, and discusses the precautions and optimization methods in its design and application. In the design process, paying more attention to details and optimization methods can make the design smoother and provide effective time for large-scale algorithms.
1 Hardware Circuit Design
The transmitting part of the multifunctional wireless mouse mainly realizes the acquisition of the displacement of the optical sensor and the key value, and transmits it to the receiver through wireless. It is mainly composed of the control part, the optical sensor part, the mouse button and keyboard part, and the wireless transmitting part. The system block diagram is shown in Figure 1.
1.1 Wireless Transmission Part
The wireless transmitter part is the main part of the multi-function wireless mouse. This design builds the wireless transmitter module with nRF24L01 as the core.
nRF24L01 has the characteristics of unconditional use of 2.4 GHz global open ISM band, built-in hardware CRC error detection and point-to-multipoint communication address control, data transmission rate of 2 Mb/s, 126 channels; can meet the needs of multi-point communication and frequency hopping communication; low power consumption, power supply voltage of 1.9 ~ 3.6 V, operating current of 22μA in standby mode, and only 900 nA in power-down mode. These are the main advantages of nRF24L01.
The circuit principle of the wireless transmitting part is shown in Figure 2.
1.2 Power Management
Handheld systems have strict requirements for low power consumption. The MSP430 series microcontrollers have five low power modes. If there is no operation for a certain period of time, it can enter a low power mode, and the operating current can be controlled below 10 μA. [page]
For peripheral devices, such as light sensors and wireless transmitters, a switch is set to cut off their power before the main control chip enters low power mode, so that the power consumption of the system is further reduced. When an operation comes, the main control chip returns from low power mode to active mode, and first turns on the power switch of the peripheral device, which can ensure the normal operation of the system. The low power power control circuit is shown in Figure 3. The switch is composed of a PNP type transistor, with the base as the input of the control signal, the emitter as the voltage input, and the collector as the voltage output. The level change of the control signal can control the on and off of the power supply on the line.
1.3 Light sensor part
The light sensor ADNS-5030 is used for mouse positioning. The normal operating voltage of ADNS-5030 is 3.3 V. In the design of the light sensor, the 3.0 V voltage output by the battery needs to be converted into the required 3.3 V voltage. The circuit uses the HT7733 chip to complete the voltage conversion. ADNS-5030 communicates data with the main control chip through the SPI bus, and its connection method is shown in Figure 4.
1.4 Buttons and Keyboard
The buttons of a multifunctional wireless mouse have basically the same functions as those of an ordinary mouse, except that the scroll wheel of an ordinary mouse is replaced with an up and down button design. The functions of these two designs are the same.
The keyboard is used to input Arabic numerals, letters and various function keys. The matrix mobile phone keyboard is used to save the I/O port resources of the main control chip.
2 Software design
2.1 General I/O analog SPI interface
The wireless transmitter chip nRF24L01 and the light sensor ADNS-5030 both use the SPI bus to exchange data with the main control chip. For cost considerations, the main control chip MSP430F413 selected in this design does not have an SPI bus interface, so a general I/O port is needed to simulate the SPI interface.
When using a general I/O port to simulate the SPI serial interface, the device SPI bus timing must be strictly followed. There are several things to note about the SPI bus timing of ADNS-5030: First, the serial clock frequency of the SPI bus should be less than 1 MHz. If the clock frequency of the SPI bus is too high, the device cannot respond in a short time, and the corresponding operation cannot be completed; second, ADNS-5030 requires a 50% duty cycle for the clock signal on the SPI bus. This requirement is not for all devices, but for specific cases where this requirement is made, it must be followed (experiments have proved that this conclusion is correct. The author fills the gap by adding empty instructions in the program to make its duty cycle meet the requirements of the device); third, there are many necessary delays in SPI bus operations, such as a 4μs delay between writing the address and reading the data in the read operation. If there is no such delay in the program, normal read and write operations cannot be performed.
2.2 Wireless Transmission Part
The working principle of nRF24L01 is as follows: when transmitting data, first configure nRF24L01 to transmit mode, then write the receiving node address TX_ADDR and valid data TX_PLD into the nRF24L01 buffer area through the SPI port according to the timing. TX_PLD must be written continuously when CSN is low, while TX_ADDR can be written once when transmitting. Then, CE is set to high level and maintained for at least 10μs, and data is transmitted after a delay of 130μs. If the automatic response is turned on, nRF24L01 will enter the receiving mode immediately after transmitting the data and receive the response signal (the automatic response receiving address should be consistent with the receiving node address TX_ADDR). If a response is received, it is considered that the communication is successful, TX_DS is set high, and TX_PLD is cleared from the TX FIFO; if no response is received, the data is automatically retransmitted (automatic retransmission is turned on). If the number of retransmissions (ARC) reaches the upper limit, MAX_RT is set high, and the data in TXFIFO is retained for retransmission again. When MAX_RT or TX_DS is set high, IRQ becomes low, an interrupt is generated, and the MCU is notified. When the transmission is successful, if CE is low, the nRF24L01 enters standby mode 1; if there is data in the transmit stack and CE is high, it enters the next transmission; if there is no data in the transmit stack and CE is high, it enters standby mode 2.
When receiving data, first configure nRF24L01 to receive mode, then delay 130μs to enter the receiving state and wait for the arrival of data. When the receiver detects a valid address and CRC, it stores the data packet in the RXFIFO, and at the same time, the interrupt flag RX_DR is set high, IRQ becomes low, an interrupt is generated, and the MCU is notified to fetch data. If the automatic response is turned on at this time, the receiver enters the transmitting state at the same time to return the response signal. When the reception is successful, if CE becomes low, the nRF24L01 enters standby mode 1.
nRF24L01 has four working modes: transmit, receive, standby and power-down. Its working state can be set by configuring the register, as listed in Table 1.
Standby mode 1 (Standby-I) is mainly used to reduce current consumption (in this mode, the crystal oscillator still works). Standby mode 2 (Standby-II) is entered when the FIFO register is empty and CE=1. In standby mode, all configuration words are still retained. In power-down mode (PowerDown), the current consumption is minimal, and the nRF24L01 does not work, but the values of all its configuration registers are still retained.
When the wireless transmitter is powered on and initialized, the following configuration is performed:
① The lower 4 bits of the CONFIG register are set to 1, which are 16-bit CRC check, chip power-on and receiving mode respectively;
②The SETUP_AW (address width) register configures the address width to 5 bytes;
③The SETUP_RETR (automatic retransmission) register is configured to automatically retransmit with a delay of 500 μs and retransmit 5 times;
④RF_CH (RF channel) register is configured to work channel 2 400MHz;
⑤The RF_SETUP register is configured to transmit power 0 dBm and Air Data Rate 1 MHz;
⑥Write the address into the address register.
One thing to note when configuring registers: When writing registers of nRF24L01, it must work in power-down mode or standby mode. After nRF24L01 is powered on and reaches 1.9 V, it will go through a 10.3 ms power-on reset and then enter power-down mode. This is an uncertain state. In this state, the write operation to the register cannot be completed, so a suitable delay must be added to allow the program to configure the nRF24L01 in power-down mode or standby mode.
When the light sensor or button is operated, the main controller writes the read signal into the TX_PLD of nRF24L01, and then the chip automatically generates the header and CRC check code and sends it out. When the response signal (ACK) is received, the flag bit success set in the program is set to 1, the data in the TX FIFO queue is cleared, and the next data can be written; if the response signal (ACK) is not received, the flag bit success is set to 0, and retransmission continues, and new data cannot be written.
[page]
2.3 Reading the optical sensor displacement value
Reading the displacement value of the optical sensor is actually reading its corresponding register. In the internal registers of ADNS-5030, the Motion register with address 0x02 is used to indicate whether there is displacement. If its highest bit is 0, there is no displacement; if the highest bit is 1, there is displacement. In addition, the addresses of the two registers used are DeltaX and DeltaY of 0x03 and Ox04. The values of these two registers represent the displacement in the X-axis and Y-axis directions respectively. The highest bit indicates the direction of displacement, 1 is negative direction, 0 is positive direction, and the lower 7 bits represent the displacement amount.
As shown in Figure 5, first determine whether there is displacement, that is, whether the highest bit of Motion is 1. If it is not 1, it means there is no displacement, and this query ends; if it is 1, it means there is displacement, and then read the values of DeltaX and DeltaY and send them out through the wireless transmission part.
After reading the DeltaX and DeltaY registers, the values in the registers are automatically cleared, but the Motion register is not cleared after reading. Therefore, the highest bit of the Motion register needs to be cleared to prevent the system from scanning the DeltaX and DeltaY registers without displacement, causing unnecessary waste.
Another point to consider is the resolution of the light sensor. After power-on reset, the light sensor resolution is the default 500 cpi (cells per inch), but the experimental effect is not good. During debugging, the displacement is not obvious. Later, the register value is modified to change its resolution to 1 000 cpi (there are only two resolutions of 500 cpi and 1 000 cpi). The cursor displacement effect is obviously better than the effect when the resolution is 500 cpi. This shows that this property of the light sensor is also very important.
2.4 Reading Keys and Keyboards
The design of the left and right buttons is slightly different from that of ordinary buttons. When using a mouse, you can see that when you press the left button and drag the mouse, you can select the options within the cursor movement range; similarly, the right button also has this function.
In the left and right key scanning program, when the program scans that a key is pressed (for example, the left key is pressed), the key value is sent out immediately. At this time, the left key value of the receiving end is always in the pressed state, and the scanning of the light sensor is not delayed; when the left key is lifted, the key lift instruction is sent to the receiving end, and the left and right key scanning is completed. In this way, when the left key is pressed and the mouse is dragged at the same time, the option within the cursor moving range can be selected.
The operation of the up and down keys is different from that of the left and right keys. In the scanning program of the up and down keys, two different situations should also be considered: inching and continuous. Inching means pressing a key quickly within a certain period of time and then releasing it immediately; while pressing a key and delaying it for a period of time before releasing it will be recognized by the program as continuous.
The keyboard has 20 keys, a 5×4 matrix, including 10 numeric keys from "0 to 9", 4 direction keys from "up, down, left, right", "←", "OK", "Esc" and 3 shortcut keys ("Show Desktop", "Browser" and "My Computer"). The 10 numeric keys from "0 to 9" are multiplexed keys, just like a mobile phone keyboard. Different key values can be entered according to the number of consecutive clicks within a certain period of time.
Conclusion
The hardware involved in this article has been debugged in practice. Experiments have proved that the MSP430 series of microcontrollers are low-cost and widely used in low-power products, and will be recognized by the majority of developers. This system has realized the basic functions of combining a mouse and a mobile phone keyboard, and its functions can still be supplemented in the future to improve the performance of a multi-functional wireless mouse.
Previous article:Design and Application Example of DSP Virtual I2C Bus Software Package
Next article:Microcontroller generates synchronized sine and cosine waves without CPU
Recommended ReadingLatest update time:2024-11-16 17:43
- Popular Resources
- Popular amplifiers
- High-frequency circuit design and production (by Yuichi Ichikawa, Masaru Aoki, and Shengpeng Zhuo)
- ESP32-C6 Series Chip Manual
- 【Application Note】Based on +STM32WB+ series product development +Zigbee smart energy (SE) application
- MSP430 series single chip microcomputer system engineering design and practice
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- CircuitPython controlled snowy Christmas tree
- When replying, just press CTRL+Enter to post directly. Details determine success or failure. You must be like Master Qiao.
- This circuit can adjust the voltage under no-load condition, but the voltage is only about 2V after the load is installed.
- Tmall Murata official flagship store, spend 1000-200, get a gift! What do you want to buy this Double 11?
- Understanding of op amp parameters
- How to adjust the minimum spacing
- Celebrate National Day, play with Guoxin! Jiefa invites you to try out the AC7801x motor demo board for free
- 7 must-know PCB design tips for engineers
- A problem with TL431 peripheral capacitors
- Briefly talk about car fuses