The System Design of Wireless Basketball Timer Based on MCU and NRF24L01

Currently, Basketball players must know the progress well in time in the game, the presence of electronic timer with LED display influences the basketball games. The wired operation influences the control distance, control reliability, control efficiency and so on. So how to make it longer, anti-interference, easy operation and high efficiency is a difficult problem. A kind of wireless basketball timer is designed based on micro-computer unit (MCU) and wireless nRF24L01 module to compensate for the existing disadvantages, which has LED digital tube of large size for the section number display and middle size for game display and 24s display. The user is easy to carry and control the timer wirelessly at any place in the basketball court using the sending control device. The test results show that the system, easy to control and stable to operate, is reliable to transmit the wireless data.


INTRODUCTION
In the current basketball games, players need to know 24 sec and the remaining time of each period match in time; electronic timer with the advantages of its convenient operation, compact size and visualization has been widely used in basketball games.NBA timing and score system was designed by a chip called 8031 of MCS-51.The system consists of time counting, score counting, keyboards and display sub-systems (Luo-Sheng, 2004).A new timing and scoring equipment for basketball match was designed and made by Chinese Basketball Association, used in 2004 CBA league match and NBA in Beijing, which was helpful for the present timing and scoring equipment specialized in sport venues and has great room for development and application (Zhang et al., 2006).The control system of basketball scoreboard with 16*16 matrix LED was designed based on single-chip microcomputer, which could be off-line and continuous long-term operation and so on (Wei-Yu et al., 2008).The design of hardware and software of timing-score system was achieved using 89C51, which had the functions of the total time and the total countdown, with its features of modular design, simple process structure, clear mandate and easy to prepare (Han et al., 2009).The device was based on P89V51RB2 single-chip microcomputer, which can show the current section, the remaining time and the score, according to actual situations, the time and score can be amended (Rong-Jian et al., 2010).The countdown circuit was designed based on STC89C52 single-chip microcomputer, which can countdown 999 days, accurate to seconds.The result of the experiment demonstrates the correctness and feasibility of the design (Ze-Shi, 2011).Although these timer or score systems are convenient to use, there are some disadvantages during the use of them, some are inconvenient for both players as a result of small size and the position of use and some are inconvenient to install and repair and low efficiency and reliability and so on, because of the long cable connect of between sending device and receiving device.In the current Chinese market, a electronic timer includes a sending device which can be moved and a receiving device which is fixed on or over the basketball frame, can provide real-time information of time for players and audiences.Still it is easy to cause bad connect because of the frequent connect of sending device and receiving device.In the basketball game, the basketball referee can need to move frequently, which is away from the sending device and cannot carry it due to the wire and must pass some information about the game to the live operator operating the sending device, which can lead to inaccurate and no timely information.According to the above reasons, a system based on MCU and wireless chip can be put forward which can send the information wirelessly and easy to carry, etc. Basketball timer is an indispensable instrument in basketball games, which used to show the information of time and quarter of the game.In addition, in order to accelerate the game, players should shoot at the basket within 24 sec, otherwise it will break the rule.In common, basket timer is connected with receiver from transmitter by RS232 serial.However, the electric cables are fragile and difficult to operate.So, wireless data transmission is a better choice.Some short distance wireless data communication such as Bluetooth, Zigbee, Wi-Fi that work on 2.4GHz, but these technologies are complicated and cost more, it is difficult to meet the rapid development and low cost requirement in general applications.nRF24L01 module is a new single chip RF transceiver device launched by Norway Nordic Semiconductor, built-in frequency synthesizer, a power amplifier, a crystal oscillator, a modulator module (Zhang et al., 2004) and fused with enhanced Shock Burst technology, with advantages of high transmission rate, small volume and low power consumption.NRF24L01 chip with PCB antenna has 100 meters effective transmission distance, which will be satisfied with the design requirement.LQ-nRF24L01 module of Beijing Long-qiu Intelligent Technology Center is used in this system (Xiu-Mei and Nai-an, 2004).
In this system, the user (operator) can set, modify and halt the match time by using its keyboard module.At the same time the match quarters changed, 24S ballcontrol time started and stopped.The system was easy to carry; anywhere within 100 meters from the timer display system it can be operated effectively.The overall system block diagram is shown in Fig. 1.

HARDWARE DESIGN OF THE SYSTEM
Keyboard module: The keyboard module is mainly used to set and modify the section number, the game time and stop time of the section, 24 sec of the start and stop operation.Considering the electronic basketball timer required function and easy to extend, a 4*4 matrix keyboard is used.MCU scans the matrix keyboard and reads the key value through P0 port per 100 ms.The interface of the circuit is shown in Fig. 2.

Sending and receiving (LQ-nRF24L01) module:
The system proposed a short distance of wireless data transmission design method based on the 2.4 GHz nRF24L01 chip, which has the advantages of low cost, low power consumption, fast development etc. nRF24L01 is a monolithic RF transceiver chip, with automatic response and re-transmitting function and the data can be wrote through the SPI Bus.nRF24L01 chip has very low power consumption, for example, working current is only 9 mA and receiving current only for 12.3 mA while -6dBm power is transmitted.And with 125 channels available and a variety of low power modes so that the energy-saving design more convenient, while the markets have many other modules based on nRF24L01 and easy to buy.LQ-nRF24L01 module is used in the design.
NRF24L01 has several working modes; senderreceiver model is only introduced, which has three modes such as Enhanced ShockBurst TM, ShockBurst TM and Direct mode.And that can be determined by configuration register.For the Enhanced ShockBurst TM mode, inside FIFO stack area is used and in order to minimize energy consumption the data are input with low speed, but are emitted with high speed (1 Mbps).So Enhanced ShockBurst TM technology can reduce average working current of the system.In the mode, nRF24L01 can process the prefix and CRC check code automatically, which is completed by CRC encoding and decoding circuit (Hong-Cai, 2008).During data transmission, the predix and CRC check code are added automatically, meanwhile CE signal is set high for 10 us until the completion of the transmission.While receiving data, the prefix and CRC check code will be deleted.CE port is mode control of the chip, under the condition of low CSN level, nRF24L01 status is decided by CE and nRF24L01configration register.

LED display module:
In order to improve the display effect and increased visibility, LED digital display device is used in the system.According to the display actual situation, LED digital tubes of middle size are adopted to display the section number and the game time and LED digital tubes of large size are adopted to display control time.Because of these LED digital tubes are drove by higher volt which 51-MCU cannot afford, ULN2803 driver chip with Darlington tube of sufficient magnification is used (Li et al., 2011) and the schematic diagram is shown in Fig. 4.
In order to reduce the complexity of the system, the dynamic scan mode is used to control the LED display here.The valid bit display method can improve the MCU efficiency, where once the bit is a valid value it could be displayed.

SOFTWARE DESIGN OF THE SYSTEM
C or Asm language can be used to design the MCU program with 51 kernels.And C language with the characteristic of simple and easy to understand, so it could accelerate the developed program speed, at the same time convenient transplantation between different MCUs.Asm language is relatively difficult to read and graft and the rate of development is slower, but it has the highest executable program efficiency (Hong-Cai, 2008;Yun-Xin et al., 2009).C language is chosen in the system because of the current C language in the powerful compiler can already has the similar efficiency compared with assembler language.Wireless basketball timer software design mainly includes the transmitting and receiving parts.
Transmitting program design: Main functions of the transmitting part are as follows: at first, the initialization of MCU and nRF24L01 module and nRF24L01 is set transmitting mode, then the keyboard is scanned at fixed time and the key value is got and that is transmitted wirelessly which is encoded by the nRF24L01 module.
Transmitting mode configuration of nRF24L01 module is as follows (Zhu and Zhang, 2011):

Receiving program design:
Main functions of the receiving part are as follows: while a valid packet could not be received, the data of different display buffers are read and displayed on the corresponding LED digital tube.And while a valid packet could be received, the receiving control system is interrupted and the received data in the nRF24L01 module are read and stored to the corresponding display buffers.Program flow diagram is shown in Fig. 6.
Receiving mode configuration of nRF24L01 module is as follows (Zhu and Zhang, 2011): • Set CE high, nRF24L01 for receiving mode • While RX_DR bit of the STATUS register becomes to high level, that confirms the FIFO buffer of nRF24L01 has received the data and MCU reads these data by the interrupt mode • Clear FIFO buffer after completing to read data

CONCLUSION
The study introduced a kind of wireless basketball timer based on the MCU and nRF24L01 module, the current some problem can be solved such as wiring inconvenient and so on.The system has the advantages of simple structure, convenient installation and repair, convenient operation, low cost and flexible layout, so it has great value in practical generalization and application.

Fig
Fig. 5: Transmitting program diagram high, CE low and configuring mode • Delay above 130 us • Configuration data is written to the LQ-nRF24L01module by I/O port of MCU • Set CSN low, completing configuration • Set the CE high, nRF24L01 for TX mode • Delay above 130 us • Data to be transmitted is written to the LQ-nRF24L01 FIFO buffer by I/O port of MCU • Set CE is low, transmitting through ShockBurst TX mode • Clear FIFO buffer after completing transmission • The program diagram is shown in Fig. 5.