We are in an era where the Internet of Things and digitalization are booming, but there are still many scenarios in our lives that can be empowered and improved through digitalization. In modern life, health is the first priority, and physical health cannot be separated from exercise. In view of the lack of data analysis links in existing gym fitness scenes, I hope to design a universal detection device for motion data detection, and integrate fitness data into It can be transmitted to the mobile phone for viewing in real time, or the data can be analyzed on the computer, and the analysis results can be fed back to the formulation of exercise plans and other aspects.
In order to realize the functional design of sports data detection equipment, I analyzed the movement patterns of most of the existing gym equipment and found their commonalities. The motion space of the gym is fixed, so its motion can be described as periodic reciprocating motion, and single-cycle motion can be described in terms of linear displacement and angular displacement. Therefore, the number of exercises, frequency, etc. can be calculated through the ranging sensor and angle sensor, and then combined with the model of the fitness equipment (obtaining the amount of exercise in a single cycle), we can estimate the overall amount of exercise, the number of exercises, and the frequency of exercise in a fitness session. Wait for data. Data can be transmitted to the mobile phone APP through the Bluetooth module , or transmitted to the network through other methods.
The device is designed as a battery device. When Bluetooth is not connected, the device sleeps and when Bluetooth is connected, the device wakes up. Comes with a charging module, with LED indication when charging .
1. Hardware functional requirements analysis
What we want to make is a device for detecting periodic motion, and periodicity is judged by angle and distance, so an angle sensor and a distance sensor are needed. I chose the commonly used MPU6050 angle sensor and Vite Smart VL53L0 infrared ranging. Sensor; secondly, the data processing and control core. I chose the very versatile Hangshun HK32F103C8T6 chip as the main control; then there is the data communication part, which can be used to communicate with mobile phones or access the network in other ways, using the Huicheng HC08 Bluetooth module , at the same time, the ZIGBEE communication module interface is reserved , which can be welded to the ZIGBEE module of Zeyao A40 ; finally, there is the power supply and power consumption control part. The power supply uses a 1s lithium battery, the module integrates a charging circuit, and is mainly reduced to 3.3V through a voltage stabilizing chip. Controlled power supply, each functional module is equipped with a power control switch, which can power off unused functions through pin signals.
2. Detailed explanation of hardware function blocks
2.1 HK32F103C8T6 chip system circuit
figure 1
As shown in Figure 1 , in addition to the most basic crystal oscillator circuit, reset circuit and download circuit, the main control circuit also adds functional circuits for power detection and power-down storage. The crystal oscillator circuit includes an 8M crystal oscillator and a 32.768K crystal oscillator. The load capacitance of the 32.768K crystal oscillator is 10pf . Capacitance smaller than this may cause the crystal oscillator to not oscillate. The power detection uses divided voltage detection and capacitor voltage stabilization filtering. The power-down storage uses AT24C02 memory chip, which uses EEPROM communication.
2.2 Sensor circuit
figure 2
As shown in Figure 2 , the VET smart VL53L0 infrared ranging sensor uses a 6Pin interface, which can receive data through the serial port or IIC . The motion detection module can be connected to two VIT smart ranging modules at the same time, and uses the MODBUS protocol to obtain the distance; The angle sensor uses the MPU6050 chip and uses IIC for data acquisition. The troublesome thing is that it is difficult to weld the MPU6050 chip. It is best to use a hot air gun to weld and then use a soldering iron to repair the welding.
2.3 Communication circuit
image 3
As shown in Figure 3 , the communication part uses the HC08 Bluetooth module, which can be directly used for communication and debugging through its mobile phone APP ; the ZIGBEE module is a reserved communication method and can be used for multi-module network communication, and its software functions have not yet been developed.
2.4 Power supply and charging circuit
Figure 4
As shown in Figure 4 , the motion detection device uses a MicroUSB port for charging, and can perform serial port DEBUG at the same time . The charging chip uses an SGM4056 charging chip, and the step-down voltage stabilizing part uses a 662K chip, and reverse connection protection is added.
2.5 Power consumption control circuit
Figure 5
As shown in Figure 5 , the motion detection equipment uses DTC115EE transistors and SI2333MOS tubes to form a power control switch. The main control can control the power supply of each part according to the real-time operating environment, thereby reducing power consumption.
1. Software code structure analysis
The software first uses STM32Cube for configuration generation, including pin configuration, clock configuration, download configuration, ADC configuration, timer configuration, serial port configuration, etc. (For details, please refer to the attached source code). Then use Keil5 to develop on the generated code , add folders and files, the final code structure is shown in Figure 1 , the added folder contains " APP ", " UART ", " SYSTEM ", " EEPROM ", " MPU6050 " . The " APP " folder contains upper application layer functions, and contains a simple task system designed by myself, which is called in the main function; the " UART " folder contains the underlying function encapsulation of the serial port, which is called by the application layer function; The " SYSTEM " folder contains clock and sleep related functions; the " EEPROM " folder contains read and write functions related to power-off saving; the " MPU6050 " folder contains angle sensor related underlying functions. The main.c file contains a detailed description of the code structure, as shown in Figure 1 .
figure 1
2. Detailed explanation of software function files
2.1 " APP " folder file
The " APP " folder contains three C files, All_Data , All_Task , App_Function . The All_Data file contains parameter initialization functions, which can be used to store some basic information of the device and save parameters after power-off. The All_Task file contains the basic functions for building a task system, and its h file details its transplantation method. It is an original task system that can be promoted, as shown in Figure 2 . The App_Function file contains the top-level function of each task function.
figure 2
2.2 “ UART ” folder file
The " UART " folder contains six C files. The Uart file contains the lowest-level reading and writing functions of the serial port and supports the printf printing function. The Uart_Comunicate_Profile file contains serial communication protocol related functions. The Uart1 , Uart2 , and Uart3 files each contain data receiving functions for three serial ports . The Modbus_Profile file defines related structures.
2.3 “ SYSTEM ” folder file
The " SYSTEM " folder contains a C file, including clock and sleep-related functions, including key wake-up and scheduled wake-up functions. Scheduled wake-up is not used yet.
2.4 “ EEPROM ” folder file
The " EEPROM " folder contains a C file containing the basic functions for software IIC communication.
2.5 “ MPU6050 ” folder file
The " MPU6050 " folder contains four C files, which can convert the original data of mpu6050 into a three-dimensional angle. This part of the code is transplanted into a flight control code.
Please enter content...
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet