- Home >> Technical Service >> Bluetooth
Bluetooth motion detection system
Design of Motion Detection System Based on Bluetooth Technology
With the development of sensor technology, modern industrial control has become more precise, and more real-time detection and processing sensors have been widely used. In vehicle applications, the traditional sensor measurement and control network is a wired monitoring network, which uses shielded wires or wires for signal transmission. Many different sensor devices are integrated into the car control system to measure whether the car is functioning properly. Fault diagnosis and other operations can be performed by viewing the parameter values of each sensor in the car, but the research on the overall motion detection sensor of the car body is still shallow. Therefore, this paper proposes a vehicle-mounted motion detection device based on Bluetooth wireless technology, which is a networked intelligent sensor based on TCP/IP protocol. Compared with ordinary fieldbus-based sensors, the sensor is not only small in size, but also easier to install. The sensor is suitable for installation in various positions inside the vehicle. The system is distinguished from the vehicle control system and other detection systems through Bluetooth wireless signal transmission to reduce signal redundancy and signal congestion. Therefore the system can be called a stand-alone motion detection device.
In many applications, it is very important to obtain information about its own motion state from within itself without relying on the outside world, and the inertial measurement unit plays this role. The Inertial Measurement Unit (IMU) is composed of a micro gyroscope, a micro accelerometer, an application specific integrated circuit (ASIC), an embedded microcomputer and corresponding software. It uses an I2C bus interface internally to measure the angular velocity and acceleration of the carrier, etc. Information is a type of MEMS. Micro-Electro-Mechanical Systems (MEMS) put complex systems with specific functions on a small silicon chip at a lower cost, and combine various micro-detection sensors and micro-mechanical devices with microelectronics. The integration of components makes the system more integrated and the size of the sensor smaller.
1. Function analysis of motion detection system
In order to analyze the Bluetooth wireless attitude detection sensor, the system can be divided into three parts according to the data transmission process:
(1) Sensor data acquisition module. Use algorithms such as dynamic Kalman filter to collect, filter and integrate the original sensors; (2) Sensor data wireless transmission module. Master and use the parameters and configuration of the Bluetooth sending module; (3) Data display and storage module. Use the mobile app to receive and save data.
2. The overall design of the motion detection system
This system includes software and hardware design. The hardware circuit uses STM32 series ARM chips, uses the I2C bus communication method to communicate with the accelerometer gyroscope, and uses the serial port to communicate with the Bluetooth chip HC05, and the Bluetooth module sends data to the Android phone. Software programming Use Keil, IAR, Eciplse software to program the module. Use Keil software to complete the collection of sensor data information and data packaging processing; use IAR to complete the configuration operation processing of the Bluetooth module, set the Bluetooth transmission mode, baud rate and other parameters; use Eclipse to complete the programming of the mobile terminal App, use the mobile phone to automatically The built-in Bluetooth communication interface acquires data, then parses and unpacks the data, displays the obtained data on the screen of the mobile phone and saves it.
3. Block diagram of motion detection system hardware design
3.1 IMU inertial measurement unit
The main control chip of the IMU is STM32F103T8, ARM 32-bitCortex-M3 core, which has 64 KB flash memory, 20 KB running memory, 7-channel DMA, and 7 timers. Through the 8 MHz crystal and the PLL inside the STM32, the controller can run at a main frequency of 72 MHz. Since the attitude calculation requires a large amount of memory for mathematical operations, a chip with a faster processing speed is used for more calculation optimization.
The sensor on the IMU is connected to the STM32 through the I2C interface, and the data interrupt pin of the sensor is connected to the IO of the STM32, so that after the sensor completes the ADC conversion, the STM32 can read the latest and fastest data in the first time and respond quickly change, get the status and conversion results of each sensor. Among them, the MPU6050 is an integrated 6-axis processing motion component, including a three-axis gyroscope and a three-axis accelerometer, which can accurately track fast and slow motion. The HMC5883 uses Honeywell's geomagnetic sensor, which has a low-sensitivity solid-phase structure for orthogonal axes, and can be used to measure the direction and magnitude of the Earth's magnetic field. BMP180 is a pressure sensor with high precision and ultra-low energy consumption, which can be converted into altitude after measuring atmospheric pressure.
3.2 Bluetooth module
The SPP-C Bluetooth module used by the sensor is an intelligent wireless data module that follows the V2.1+EDR Bluetooth specification. Except P12 and P5 are special I/O ports, other P ports are programmable input/output interfaces, and the serial ports UART-TX and UART-RX both use CMOS interfaces. This module is mainly used in the field of short-distance wireless data transmission. It can be easily connected with the Bluetooth device of the PC, and the data can also be communicated between the two modules.
4. Motion detection system sensor software design
4.1 IMU sensor data acquisition
The IMU data acquisition process includes the initialization of the data acquisition and processing chip STM32 and the three sensors, that is, first power on and initialize the STM32 chip system, complete the I2C interface initialization and serial port initialization, and then initialize the configuration of the three sensors.
(1) Initialize MPU6050: MPU6050 initialization is shown in Figure 5, and the software configuration process is as follows: (1) Reset MPU6050 by power management register 1 (0X6B); (2) Configure by gyroscope configuration register (0X1B) and acceleration sensor The register (0X1C) sets the full-scale range of the angular velocity sensor and the acceleration sensor; (3) The interrupt is configured by the interrupt enable register (0X38); (4) The AUX I2C interface is set by the user control register (0X6A); (5) The FIFO enables (6) Configure the sampling rate of the gyroscope by the sampling rate frequency division register (0X19); (7) Set the digital low-pass filter by the configuration register (0X1A); (8) Configure the digital low-pass filter by the power management register 1 (0X6B) Set the system clock. Generally, the x-axis gyro PLL is selected as the clock source to obtain a higher-precision clock; (9) The angular velocity sensor (gyroscope) and acceleration sensor are enabled by the power management register 2 (0X6C).
(2) Initialize HMC5883: The HMC5883 initialization program is shown in Figure 6. Set the working mode 0 of HMC5883 in the software, which is the continuous measurement mode. In continuous measurement mode, the device measures continuously and updates the data to the data register. The sampling average number in the process of measuring the output is set by the configuration register A as 8 cycles, and the output rate is 75 Hz. Then use the standard magnetic field generated inside the HMC5883L sensor for preliminary calibration, and finally read the value of the calibrated magnetometer ADC.
(3) Initialize the BMP180: it needs to be configured in the software: (1) issue a pressure (or temperature) conversion command; (2) read the original data from the UP (UT) register after a period of time; (3) to get the Celsius The temperature and hPa pressure need to use the correction data, which are stored in the E2PROM of the BMP085, and can be read out during initialization through I2C.
4.2 Bluetooth wireless module configuration
Bluetooth HC05 is a master-slave integrated Bluetooth serial port module, which can make it work in the master or slave state. When the Bluetooth device is successfully paired and connected, it does not need to consider the internal communication protocol of Bluetooth, and directly uses Bluetooth as a serial port. After the connection is established, the two devices share a channel, one device sends data to the channel, and the other device can receive the data in the channel. In order to establish this channel connection, Bluetooth needs to be set to AT mode for pairing connection. Use the AT command of the Bluetooth module to configure it, and set the module to slave mode.
5. Mobile Android software
5.1 Overall Design of Motion Detection System
In order to complete the software development of the mobile App, first establish its use case diagram to describe the purpose of the user using the App. First, the user opens the App icon to enter the software, completes the matching and connection of the Bluetooth device, and then selects the data information that the user wants to obtain according to the user's needs, and finally the user saves the required data information. According to the realized function, it is divided according to the method of the realization class. It involves bluetooth communication service, the event monitoring and processing mechanism in the interaction between the user and the mobile phone graphical interface, and the real-time dynamic refresh display of data. Use case diagrams and deployment diagrams are designed while designing the software.
5.2 App Implementation Framework
The functions provided by the application are listed in the AndriodMenifest.xml file, and all components that need to be used must be configured and registered here, including Activity, Intent, Service and ContentProvider. When using the built-in applications in the system (such as telephone service, Internet service, SMS service, GPS service, etc.), you need to declare the usage permission in this file. This file is also required by all Android applications and describes the package. Global variables, including public application components and the implementation class of each component, as well as operable data resources, running space, etc.
Activity in the software is the core class of Android, and its function is equivalent to the main function in c. The full name of this class is android.app.Activity. Activity is equivalent to a form (Form) in a C/S program or a page of a Web program. Each Activity provides a visual area. Various Android controls can be placed in this area, such as buttons, images, text boxes, etc.
The AndroidMenifest.xml file configures the Android running version conditions of the software, and first executes DeviceListActivity.java to obtain the device list, and uses the Intent to call the DataMonitor.java program. DeviceListActivity inherits the Activity class, and DataMonitor inherits the FragmentActivity class. Both call the BluetoothService.Java function to complete the Bluetooth communication when they are executed. Both DeviceListActivity.java and DataMonitor.java are composed of visual component View and its subclasses. These components are placed on the window at the specified position according to the XML layout file.
5.3 Data processing and display
DataMonitor is a class that inherits FragmentActivity. FragmentActivity inherits from Activity. It provides methods to operate Fragment. Therefore, Fragment can be embedded in Activity to achieve the desired layout effect. The first thing implemented in DataMonitor is the oncreate method, which calls the Bluetooth connection when DataMonitor is initialized, and puts the View on the Activity through the setContentView method. After binding, the Activity will display the controls on the View. The rest are the onStart (), onResume (), onPause (), onStop () and onDestroy () methods inherited from the parent class, without modification, to complete the overloaded basic methods of the Activity life cycle.
In the case of ensuring that the Bluetooth is connected, use the handler interface to complete the interaction between the Widget of the Activity and the thread in the application. Override the handleMessage method in the handler class to receive information through this method. The received information indicates the status of receiving messages at the current moment, which are MESSAGE_STATE_CHANGE, M ES SAGE_READ, M ES SAGE_DEVICE_NAME, MESSAGE_TOAST. The first state indicates that the Bluetooth is in the connection state; the second state represents the data reading state; the third state is the device name reading state; the fourth state is the data display state, which can display the data on the mobile phone screen. Through OnclickConfig (View v) and ControlClick (View v), the interface display and jump functions are completed. In ControlClick, the displayed content can be selected, and the corresponding output data can be selected according to the pressed button. The onRecordBtnClick(View v) method is to save the data to the SD card when the user presses the "Record" button, and stop recording data information when the user presses the "Stop" button.
5.4 Bluetooth transmission BluetoothService
To develop Bluetooth, first add administrator authority and Bluetooth development authority to the AndroidManifest.xml file. After enabling Bluetooth, use isEnabled() to query the status of the current Bluetooth device. If it returns false, it means that the Bluetooth device is not enabled and needs to be packaged. An ACTION_REQUEST_ENABLE request to the intent calls the startActivityForResult() method to enable the Bluetooth device. Use the methods of the BluetoothAdapter class to search for remote devices, and use the mArrayAdapter.Add method to display the set of Bluetooth devices that can be paired, so as to select a device for communication.
Scanning the device only needs to call the startDiscovery() method, and the application needs to register a BroadcastReceiver for the ACTION_FOUND action to receive the information scanned by the device. Enable its own device, encapsulate the ACTION_REQUEST_DISCOVERABLE action in the intent and call the startActivityForResult(Intent, int) method. Establish a connection between two bluetooth devices and complete the client and server codes. One starts the service to listen, and one initiates a connection request (using the MAC address of the server-side device). They are considered connected when they both have a Bluetooth socket on the same RFECOMM channel. getInptuStream() gets the input stream, and getOutputStream() gets the output stream for data transmission.
epilogue
In this paper, we propose a wireless pose sensor detection system based on Bluetooth and inertial measurement unit, which is designed for the hardware and software of the sensor. Use the integrated 6-axis processing motion components MPU6050, BMP180, HMC5883 and STM32 to form an IMU (inertial measurement unit), send the data to the mobile phone via Bluetooth, and then display and save the data on the mobile phone. The system designed in this paper has good real-time performance, and the accuracy meets the detection requirements of general moving objects.
The above is the design of the motion detection system based on Bluetooth technology 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, the development of children's toys, and the research and development of electronic education products.
- TOP