Design of multifunctional mouse based on 2.4GHz radio frequency communication

Publisher:ananan一二三四五Latest update time:2012-04-17 Source: 维库开发网 Keywords:2.4GHz  MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:2.4GHz  MSP430 Reference address:Design of multifunctional mouse based on 2.4GHz radio frequency communication

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

MSP430F5529 (III) Unified Clock System UCS-1
1. There will be many places to configure the clock in the future. 2. Typing is tiring, and uploading is even more tiring; 3. I will release a PDF version later, and interested students can download it for study.   There was a little omission in the previous explanation, so I will add it first ******************
[Microcontroller]
MSP430F5529 (III) Unified Clock System UCS-1
Introduction to MSP430 MCU IO Ports
The IO port is the most basic component for the processor system to communicate with the outside world. From basic keyboards and LEDs to complex peripheral chips, they are all read or controlled through the input and output operations of the IO port. In the MSP430 series, different microcontrollers have different numb
[Microcontroller]
MSP430Ware use notes to initialize XT1
1. Platform Description MSP430F5438 2. Why use MSPWare? Due to work reasons, STM32 is used more in school, and STM32 DriverLib is more convenient to use. When I first learned MSP430, I was back to the era of register operation, which was a little bit uncomfortable. Later, I found that MSP also has DriverLib, but not m
[Microcontroller]
Detailed explanation of the use of MSP430 timer/counter TimerA (I)
MSP430 Timer A is a 16-bit timer, the schematic diagram is as follows: Note: From the above figure we can see that Timer_A has three capture/compare registers: CCR0, CCR1, CCR2, which is different from 51. There are four clock sources, and frequency division is supported. After selecting the clock source, you need t
[Microcontroller]
Greenhouse temperature monitoring system module circuit based on MSP430 and DS18B20
  1 Temperature acquisition sensor DS18B20   DS18B20 is a single bus digital temperature measurement chip, which is easy to use, wear-resistant, collision-resistant, and has strong anti-interference ability. It can directly read the temperature of the object being measured. Its measurement range is -55~+125℃, and it
[Microcontroller]
Greenhouse temperature monitoring system module circuit based on MSP430 and DS18B20
Research on WDT in MSP430 microcontroller
Introduction   Software reliability has always been a critical issue. Anyone who uses software may experience the problem of a computer freezing or a program running away, and this situation also exists in embedded systems. Due to the limited anti-interference ability of microcontrollers, instrumentation at industrial
[Microcontroller]
Design of insulator telemetry system based on MSP430F149
0 Introduction Pollution flashover of insulator strings in high-voltage transmission lines is one of the important factors affecting the operation of power grids. With the development of power systems and the intensification of various types of pollution in the atmosphere, the pollution layer deposited on the su
[Test Measurement]
Design of insulator telemetry system based on MSP430F149
DC grounding detection system based on MSP430
The DC power supply system is mainly responsible for supplying power to control equipment, protection equipment, etc. in the process of power production. Insulation degradation and DC bus grounding are common faults in DC power supply systems. Once a DC power supply fails, it will affect the normal operation of the
[Power Management]
DC grounding detection system based on MSP430
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号