- Home >> Technical Service >> Bluetooth
Bluetooth BLE module system
BLE software and hardware modules and system composition
This article is based on the BLE module, the scheme is from the selection design of the hardware circuit to the realization of the software function, and finally forms the Internet of Things system to realize the positioning control of the smart device; 1. The basis of the Internet of Things is the hardware module of the smart device, 2. The Internet of Things The implementation is to embed the smart device module into the electrical equipment and support it with software. 3. The Internet of Things to indoor positioning control system is to add an algorithm model on the basis of completing 1 and 2. This article will introduce the hardware and software parts of BLE in detail .
1. BLE hardware system module
The design of the hardware circuit mainly includes 3 important modules and 1 functional module. The 3 important modules are the main control design, power supply design, and antenna design. In this paper, the main control module and power supply module are included in the main control circuit design, which will be introduced in detail below .
1.1 Main control circuit design
This topic design adopts CSR1010 of CSR Company as the CPU main control chip. Its characteristics are: it has 64KB of running memory and 64KB of storage memory, the maximum output power of Bluetooth low power consumption is 75dBm, and the lower limit of the power of Bluetooth low power consumption receiving signal is -92.5dBm, support Bluetooth 4.2 specification, the host protocol stack includes ATT, GATT, SM, L2CAP, GAP, etc., the current in sleep mode is less than 900nA, using 32.768KHz and 16MHz dual crystal oscillator system clock, the former is used in sleep mode, and the latter Ordinary working clock, switching power supply, programmable general-purpose PIO controller, 10-bit high-precision built-in ADC, 12 digital PIO ports, 3 analog AIO ports, support UART serial communication, I²C communication, SPI bus Program EEPROM, external flash chip, support SPI emulation, support 4-way PWM mode, interrupt wake-up and watchdog function.
(1) EEPROM circuit design: CSR1010 does not have an embedded program memory, so an EEPROM chip with a storage capacity of 512Kb is connected externally during design. The chip model is AT24C512. For the requirements of module miniaturization, the package is selected as 8-lead SOIC , where 1, 2, and 3 pins are address bits, 4 and 8 are GND and VCC respectively, 5 is the data pin SDA, 6 is the clock pin SCL, and 7 is the write protection pin. Its principle design is shown in Figure 4.2: the program is burned into the chip through the SPI bus.
(2) Clock circuit design: The low-power design scheme adopted by the chip is: normal mode and sleep mode work alternately to achieve low-power output. In sleep mode, a low-speed clock with a crystal oscillator frequency of 32.768KHz is used. In working mode, a high-speed clock with a crystal oscillator frequency of 16MHz is used. The advantage of this dual-crystal oscillator design is that the clock is more accurate and reduces the loss caused by internal clock frequency division.
(3) Power supply circuit design: The design of the power supply module is the primary factor to ensure the stable operation of the entire circuit. The design of the input power supply module and the drive circuit module is shown in Figure 4.5: VDD_BAT is the total input power supply, and its threshold value is 1.8v~4.4 Between v, connect a large capacitor of 47uf to a ferrite (drawn in the total circuit design) to realize energy storage and filtering, and prevent damage to the circuit by the impact current; the threshold value of VBAT_REG_IN and VDD_CORE is 0.8v~1.35 v and 0.65v~1.2v, the function of these two modules is to provide a stable working voltage for the digital circuit module, and the voltage control of VDD_CORE can be realized through software programming.
An important task of the subject research is to embed the BLE intelligent control module into the electrical appliance, and realize the conversion of power frequency power to DC power on the power supply; in the design, the 24v constant voltage DC power is step-down and stabilized, and the 3.3v constant voltage source is derived The chip uses, that is, VDD_BAT in Figure 4.5 is equal to 3.3v.
In the figure, VBAT is the input voltage of 24v, using 5.6v Zener diode and J3Y triode to form an amplifying circuit, outputting 5v voltage to supply power to LM117, in which LM117 is a voltage stabilizing IC chip, this design uses LM117-3.3 model, that is, the input voltage Control 4.75v~10v, the output voltage is constant at 3.3v, and the current threshold is 0~1A.
1.2 Antenna circuit design
The matching degree of the antenna will directly affect the transmission quality of the electromagnetic wave signal, the transmission distance and the accuracy of the channel model. Commonly used antennas for Bluetooth include inverted F antennas, serpentine antennas, and integrated ceramic antennas. Here are the first two types.
(1) Inverted F antenna: Inverted F antenna is a quarter-wavelength antenna. The antenna has two directions. One end is connected to GND, and the other end is used as the transmitting end of the radio frequency signal. The feedback point is located between the two ends. The structure of the antenna structure is simple, the design is convenient, and the cost is low; its disadvantage is that the bandwidth is narrow.
(2) Serpentine antenna: The length of the serpentine antenna depends on its geometric structure and near-ground distance. In this paper, referring to the physical properties of the serpentine antenna, the model structure of the antenna is obtained through HFFS simulation design. According to the working frequency band of Bluetooth, the center frequency of the antenna is 2.44GHz; the board of this subject is FR4, the corresponding dielectric constant is 4.5, the loss angle is 0.02, and the thickness of the board is 0.8cm. Among them, the 7 pins of the chip are RF Theoretically, the characteristic impedance behind the port needs to be matched to 50Ω, so the length and width of the antenna can be obtained through HFSS software simulation.
1.3 Functional circuit design
The BLE minimum system board leads to multiple I/O ports to realize the connection with the functional circuit. The CSR1010 chip has a total of 32 pins, including 12 PIO pins. The three pins PIO9, PIO10 and PIO11 are used as functional modules during design. The output port is connected to the triode drive circuit, and the high and low levels output through the I/O port make the triode work in the switching state, that is, the interactive change between the saturation state and the cut-off state, and the collector of the triode is connected to the pull-up load.
2. BLE software module
The realization of software functions is divided into two major modules: first, it is the programming of the CSR1010 main control CPU chip, which drives the smart device to work, and realizes the communication between multiple smart devices and the direct control of electrical equipment; second, the programming and software of the mobile terminal Optimization, to complete the information interaction between users and intelligent control equipment and the indirect control of electrical equipment.
2.1 Bluetooth related protocols
The BLE protocol stack is the basis for implementing Bluetooth-related functions. The BLE4.2 protocol stack is mainly divided into two modules: 1. host (host) and 2. controller (controller). The protocol framework is shown in Figure 4.10. The controller mainly includes the physical layer protocol of BLE and the link layer protocol. The host layer includes the logical link control adaptation protocol (L2CAP), attribute protocol (ATT), security manager ( SM), Generic Attribute Protocol (GATT) and Generic Access Protocol (GAP).
(1) Logical Link Control Adaptation Protocol (L2CAP): L2CAP is one of the cores of the BLE protocol stack and the upper-layer protocol of the baseband. Its function is to convert the data submitted by the baseband into a packet format for the call of the upper-layer application , and only supports asynchronous connectionless data (ACL). L2CAP defines 3 channels according to different functions: 1. A connection-oriented channel used between multiple devices, 2. A connectionless channel used as a broadcast, and 3 a signaling channel used to create commands.
(2) General attribute protocol (GATT): GATT is the basis for establishing a BLE connection. Its main function is to send or receive the attribute data segment of the signal, and realize the data exchange between two devices. It is realized by defining the service (Service) and the characteristic (Characteristic) In BLE communication, one service contains multiple feature data segments, each feature has a uniquely identified 16-bit or 128-bit UUID; in terms of connection, GATT defines a Master master device that can connect multiple Peripheral slave device, so during the experiment, one mobile terminal can control multiple BLE devices at the same time, but one BLE device can only be connected and controlled by one mobile terminal. The principle of its realization is that a BLE device will no longer Send a connection request signal; the concept of multiple BLE device ad hoc networks is introduced here, that is, the slave device will intermittently send a signal to the master device to request to be connected.
(3) General Access Protocol (GAP): In the BLE protocol framework, GAP is an application layer-oriented protocol, which defines two communication methods for BLE devices: connection communication and broadcast communication; at the same time, the master device and slave mentioned above The device is defined in the GAP specification, and functions such as scanning, connection, communication, and interruption of the device are realized through HCI commands. Among them, there are two implementation methods of broadcast communication, broadcast data and scan reply. The former is used as a signal generator to radiate and broadcast outward, and the latter realizes the processing of data from the GATT layer.
2.2 Driver module
The programming of the smart device driver module involves the writing of Bluetooth protocol specifications and the realization of circuit functions by the software driver layer. The software used is CSRµEnergy SDK 2.4.5.13 (xIDE); the APP design is to program on the mobile terminal device to realize the exchange of user information. The Android4.3 system and the android studio programming environment are used here.
(1) Driver module: The software driver module is divided into three parts: the implementation of protocol specifications, I/O port programming to realize circuit functions, and Mesh ad hoc network driver programming.
(2) The writing of the protocol specification mainly includes GAP and GATT: the functions implemented by GAP: write the BLE device name into EEPROM gapWriteDeviceNameToNvm(), update the device name updateDeviceName(), read the GATT information GapHandleAccessRead( ), write operations on GATT information GapHandleAccessWrite(), etc.; the functions implemented by GATT include: setting broadcast parameters gattSetAdvertParams(), broadcast timer execution gattAdvertTimerHandler(), start broadcasting GattStartAdverts() and stop broadcasting GattStopAdverts(). As shown in Figure 4.11: This figure shows the flow chart of BLE smart device registration, broadcast and connection in the protocol specification.
(3) I/O programming: first, initialize the clock, hardware, and data structure of the application, register the attributes of the firmware in the database, and write the system event driver; then, write the 12 PIO ports and some registers of the CPU chip, among which Including the setting of 4-way PWM, which is implemented by modulating the pulse frequency, period, and duty cycle to realize the control of the switching frequency of the triode circuit; and output the current in the form of a look-up table, that is, to look up the preset table. the corresponding output value.
(4) Mesh ad-hoc network programming: mainly through several functional functions to process Mesh information, including data initialization, reading/writing GATT messages, notifying and replying to GATT slave devices, and writing Mesh events; BLE devices in Mesh The network has 3 states: not connected, connected, and connected, and the network key needs to be sent from the state of connecting to connected.
2.3APP design
The function of the APP software is to realize the control of the functional circuit and the control of indoor positioning and navigation; the project uses a mobile terminal based on the android4. 4.3) The system provides functional modules such as BLE adapters and managers; the implementation steps are 1. Instantiate the BluetoothManager (BluetoothManager) object, 2. Obtain the instantiated object of the Bluetooth Adapter (BluetoothAdapter) through the BluetoothManager, 3. Turn on Bluetooth That is, enable the instantiated object of the adapter, 4. search for Bluetooth, 5. create a Bluetooth device, and connect.
3. BLE smart device control system and functional architecture
The smallest system board designed by the CSR1010 chip is used as the control unit of the smart device, and the functional circuit is designed as a MESH lamp for smart lighting. The smallest system board is embedded in the functional circuit module to realize the control of the smart device by the mobile terminal; deploy smart control devices indoors As a BLE base station, and radiate signals to space, each base station transmits a broadcast signal with a unique UUID identification code, and realizes indoor positioning control and navigation through the RSSI network formed by different base stations. The system frame is followed by the mobile terminal, the minimum system board, and the functional lighting module. For complex indoor spaces, the distance between deploying BLE smart lighting devices is 8 meters, effectively controlling accuracy and cost.
Summarize
This article first introduces the design of the hardware circuit from the aspects of chip selection and functional structure, including the clock circuit, antenna circuit, functional circuit, and power drive circuit; then, the software first introduces the implementation of the BLE protocol stack from L2CAP, GATT, GAP, etc. and application, as well as the realization of function-driven module and Mesh ad hoc network, combined with the mobile phone terminal, briefly describes the principles of smart device control, indoor positioning navigation, path planning and other functions; finally, briefly outlines the architecture of the indoor positioning control system.
The above are the BLE software and hardware modules and system components introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. for you. If you have Bluetooth product design and development needs, you can trust us. We have rich experience in custom development of smart electronic products. We can evaluate the development cycle and IC price as soon as possible, and can also calculate the PCBA quotation. We are a number of chip agents at home and abroad: Songhan, Yingguang, Jieli, Ankai, Quanzhi, realtek, with MCU, voice IC, BLE Bluetooth IC, dual-mode Bluetooth module, wifi module. We have hardware design and software development capabilities. Covering circuit design, PCB design, single-chip microcomputer development, software custom development, APP custom development, WeChat official account development, voice recognition technology, Bluetooth development, wifi technology, etc. It can also undertake the research and development of smart electronic products, the design of household appliances, the development of beauty equipment, the development of Internet of Things applications, the design of smart home solutions, the development of TWS earphones, the development of Bluetooth earphone speakers and other products.
- TOP