Back
 OALibJ  Vol.8 No.8 , August 2021
Design of Intelligent Riding System Based on STM32
Abstract: Today’s riding equipment is mostly for professional riding users, with single function and high price. According to this situation, this paper intends to design an intelligent riding system based on STM32, which can provide key riding data for riders at a reasonable price. To a certain extent, it can ensure the safety of riders on the way, and achieve the purpose of healthy riding and green travel. The design is mainly composed of four parts, namely the main control part, detection part, display part and alarm part. Firstly, the STM32F103ZE microcontroller is used as the main control core, and the heart rate sensor, blood oxygen sensor and Hall sensor are expanded to realize the data acquisition and display of the rider’s heart rate, blood oxygen, speed and mileage. Secondly, the intelligent riding instrument will compare the real-time collected data with the preset threshold, and start the sound light prompt and voice alarm when a certain data is close to or beyond the preset range. In addition, this design realizes automatic lighting in the dark through photosensitive sensor. Finally, this design adopts solar power supply mode; the intelligent riding instrument designed in this paper can measure the riding speed, mileage, heart rate and blood oxygen of the rider, and is easy to operate.

1. Introduction

In recent years, due to the increasing traffic jam and the increasing number of cyclists, people begin to use bicycles to achieve travel, fitness, entertainment and other purposes; with the advent of today’s era of intelligent control, for riding groups, the demand for designing a simple and affordable intelligent riding equipment is rising. In recent years, the intelligent auxiliary riding equipment, such as intelligent riding clothes, bicycle code table, intelligent riding glasses and other auxiliary riding equipments, is difficult to be accepted by cycling enthusiasts due to the problems of difficult operation, strong professionalism, not suitable for ordinary people, expensive price, single function and so on. This design is to solve the needs of ordinary cyclists and design an intelligent riding instrument, which has high performance, small size, low cost, simple operation and other characteristics. In this paper, an intelligent riding instrument is designed, which can monitor the heart rate and blood oxygen of the rider, measure the speed and mileage during riding, and automatically turn on the light when it is dark. At the same time, it also solves the problem of lack of lighting for the bicycle, more humanized and intelligent, easy to be accepted by riders.

2. Design of Intelligent Riding System

This design is based on STM32F103ZET6 microcontroller, combined with sensor data acquisition technology and intelligent control technology, a smart riding system with functions of heart rate, blood oxygen monitoring, speed mileage measurement, automatic light on in dark is constructed. The intelligent riding system designed and constructed can set alarm value with one key, and can reasonably and effectively master the speed and mileage; if the speed and mileage reach the present value, it will sound an alarm to remind the rider to pay attention to the speed control and reasonable rest; At the same time, this design can also measure the heart rate and blood oxygen of the rider. If it exceeds the preset value, it will also give a beep alarm to the rider, so as to ensure that the rider can travel scientifically and healthily. In order to further ensure riding safety and avoid accidents caused by viewing riding data, the device is also equipped with a voice reminder module. When the speed, mileage, heart rate and blood oxygen reach the present value, the voice module will give voice reminder to ensure that the rider can obtain riding data information in time.

2.1. Design of System Hardware Circuit

The intelligent riding instrument can be divided into main control module, detection module, display module, alarm module and power supply module. STM32 is used as the main control module; STM32F103ZE is an SCM of STM32 Cortex-M3 core series. The detection module is composed of MAX31000 heart rate and blood oxygen module, Hall sensor and photosensitive sensor; The display screen is an OLED screen with no backlight and low power consumption [1]; SYN6288 speech synthesis module and buzzer are selected as alarm module. The power module is composed of solar panel, voltage regulator module, TP4056 charging module and lithium battery. The hardware design is as follows: do of Hall sensor is connected to PA0 port of single chip microcomputer, Ao is analog output, so it is not connected in this design; In the photosensitive sensor, do is connected to PB9 port, Ao is analog output, so it is not connected; The heart rate and blood oxygen sensor is connected with PB6 and PB7 ports, and communicates with MCU by IIC communication mode; The independent keys are respectively connected to PD3, PD5, PD7, PC1 and PF2 ports, and the corresponding IO port needs to be configured as pull-up input mode; The LED light is connected to port PD1, the buzzer alarm is connected to port PE9, and the voice module SYN6288 is connected to port PB10 and PB11; The OLED panel is connected to ports PA1, PA3, PA7, PC3 and PC5.

2.2. Heart Rate and Blood Oxygen Module Sensor Circuit

In this design, the heart rate and blood oxygen module MAX31000 is used to measure the heart rate and blood oxygen; the operating voltage of the chip is between 1.8 V and 3.3 V, while the module can choose 3.3 V or 5 V as the input. The standby current is very small. It is an ultra-low power consumption sensor. It has two red LED lights and a photoelectric detector.

The measurement of heart rate and blood oxygen uses the method of photocapacitance pulse wave memory [2], which is a noninvasive method to detect blood changes between fingers by means of photoelectric method; The heart rate value can be obtained by reading ADC value, and then by correlation algorithm. By reading the temperature value of the chip, the deviation caused by the temperature can be corrected; the deviation of heart rate and blood oxygen value can also be corrected by simply shading the module and improving the congestion degree of the measuring part.

The heart rate and blood oxygen module adopt IIC communication mode. SCL and SDA are clock interface and data interface respectively. PB6 and PB7 of MCU are SCL and SDA of I2C1 respectively. Therefore, the SCL and SDA of heart rate and blood oxygen module are connected to PB6 and PB7 of MCU respectively. The working voltage of single chip microcomputer is 2.0 V - 3.6 V, which is 3.3 V this time; the working voltage of heart rate and blood oxygen module is 1.8 V - 3.3 V, which is 3.3 V this time. The interface circuit is shown in Figure 1.

Figure 1. Interface circuit diagram of heart rate and blood oxygen module.

2.3. Design of Speed and Distance Measuring Circuit

In this paper, Hall sensor is selected to realize the speed and mileage detection function [3]. Through the combination of Hall sensor and magnetic chip, the magnetic chip is placed outside the tire to measure the number of turns of the tire and record the time to measure the speed and mileage. The record of the number of turns of the tire is input and captured by the MCU, and the record of the time is completed by the timer TIM5; The do in the sensor is connected with PA0 of single chip microcomputer. The sensor circuit is shown in Figure 2.

2.4. Design of Automatic Light on Circuit in Case of Dark

The design of photosensitive sensor has four interfaces, the supply voltage is 3.3 V, you can choose digital and analog output, this design selects digital output. When driving to the dark road, the interrupt of MCU will be triggered, and the interrupt service function will turn on the light. The interface circuit is shown in Figure 3.

2.5. Design of Voice Alarm Circuit

The speech alarm module adopts SYN6288 speech synthesis module and UART communication mode to receive the text data to be synthesized and realize the conversion from text to speech or TTS speech. Its TXD pin is connected to PB11 in MCU, and RXD is connected to PB10. The voice interface circuit is shown in Figure 4.

Figure 2. Hall sensor circuit diagram.

Figure 3. Interface circuit diagram of photosensitive sensor.

Figure 4. Voice alarm interface circuit diagram.

2.6. Design of Voice Alarm Circuit

The design of intelligent riding instrument uses solar panels and TP4056 charging protection module to supply power for MCU. TP4056 will output a fixed voltage and current to charge a single lithium battery. PMOSFET is the main internal structure of the module, which has an anti reverse charging circuit design inside, and no additional battery protection circuit outside; TP4056 also has thermal protection function. If the temperature is too high, the output current will be reduced, which can effectively avoid the chip damage caused by overheating. The charging interface circuit is shown in Figure 5.

2.7. The Circuit Design of Display Module

The display module adopts 1.3-inch OLED screen, uses SPI communication, and integrates DC/DC boost circuit. It has higher luminous efficiency and low energy consumption. It is driven by SH1106. The display module can display speed, mileage, heart rate, blood oxygen, time, etc. The interface circuit of display module is shown in Figure 6.

3. Software Design of Intelligent Riding Instrument

Keil uVision 5 is selected to write the software program of the whole design, which is produced by Keil software company of the United States [4]; Operators can control several monitors at the same time only through one computer, which provides a very efficient and clean development environment for users.

In this design, C language is chosen as the programming language of software [5], because C language has many advantages compared with other programming languages, such as strong flexibility, structure and portability; And the program in this design adopts modular programming method, which is easy to transplant.

3.1. Main Program Design

After downloading and burning the program, the software program will first initialize each module, such as system clock, delay function, OLED display, etc. The main program of the intelligent riding instrument is roughly divided into two parts, one is to display the speed, mileage, heart rate and blood oxygen data by pressing the function key, the other is to display the current set riding data alarm value by pressing the set key. The main program design is shown in Figure 7.

Figure 5. Circuit diagram of solar charging interface.

Figure 6. Display module interface circuit diagram.

Figure 7. Main program flow chart.

3.2. Software Design of Heart Rate and Blood Pressure Acquisition Module

Connect SDA and SCL of MAX30100 to PB6 and PB7 of MCU. I2C communication mode read the original signal of red light and infrared light, after Butterworth first-order low-pass filtering, we can get a relatively pure signal reflecting the characteristics of blood flow, and finally display the calculated heart rate and blood oxygen value. The program design of heart rate and blood oxygen is shown in Figure 8.

3.3. Program Design of Speed and Distance Measurement

Through connecting the do interface of Hall sensor to the single chip microcomputer PA0, the software program is used to set PA0 as the floating input mode, and the level state in PA0 is detected. If magnetic elements pass by around PA0, do output is low level; At this time, the input capture library function is used and timer TIM5 is turned on. When the timer stops timing the next time when low power is captured, the timer will read the timing time in the timer and turn the tire around for one week; Therefore, the circumference of the tire can be calculated by the radius of the tire, and the riding speed and mileage can be calculated by using the circumference of the tire and the time recorded by timer TIM5. The speed measurement and ranging procedure are shown in Figure 9.

Figure 8. Flow chart of heart rate and blood oxygen measurement.

Figure 9. Flow chart of speed and distance measurement.

3.4. Program Design of Automatic Light on in Dark

By connecting the do interface of the photosensitive sensor to the single chip microcomputer PB9, the software program is used to set the PB9 as the floating input mode to detect the level state in PB9; If the PB9 port is read as low level, it indicates that the current ride enters the dark area and enters the interrupt service function. Through the program, the PD1 port is pulled up and the LED is turned on, so as to achieve the effect of turning on the light automatically when it is dark; If the PD9 port is read as high level, it indicates that the current riding is still in a bright area, and the PD1 port state will not be changed, and the LED light will be turned off normally. Figure 10 shows the subroutine of turn on light in case of dark.

4. Experiment and Result Analysis

In this design, the internal resource RTC in STM32F103ZET6 is used to display the clock by timer, and bat power is added to make the power down time of MCU not lose; Experiments show that this part of the software code can achieve the purpose of displaying real-time time, as shown in Figure 11.

This design uses Hall sensor and magnetic accessories to achieve the purpose of measuring speed and distance. The test results show that the program can measure the average speed, even speed, mileage data, by changing the motor speed found that the speed also changes accordingly, to achieve the desired vision. As shown in Figure 12.

The design adopts the heart rate and oxygen module MAX30100 to collect the heart rate and oxygen data. When switching to the function of measuring heart rate and oxygen, when the fingertip is placed above the red LED lamp, the heart rate and oxygen data can be measured after about 5 seconds. The results show that the measured heart rate oxygen signal has certain accuracy and meets the expected expectation. As shown in Figure 13.

In this project, the photosensitive sensor and white LED light are used to simulate the experiment of turning on the light automatically when it is dark. When the light is sufficient, the white LED light goes out; when you block the photosensitive element with your finger, the white LED lights up when you enter the dark road. The test results show that the effect of automatic lighting in dark is obvious, and the expected effect is achieved. As shown in Figure 14.

In this design, the buzzer and voice module are used to alarm the riding data, so as to remind the riders to pay attention to the effective control of speed, heart rate and mileage, and achieve the original intention of healthy travel. Set the heart rate warning value to 70, put the fingertip on the heart rate and blood oxygen measurement module, when the measured heart rate value is greater than 70, the buzzer will sound and the human voice of “too fast heart rate” will be issued, which is in line with the expected effect.

Figure 10. Flow chart of automatic light on in case of dark.

Figure 11. Time display test.

Figure 12. Speed mileage measurement test.

Figure 13. Measurement of heart rate and blood oxygen.

Figure 14. Turn on light test in case of dark.

Completed the function test of each module of the intelligent riding instrument, and tested the whole machine. They can successfully detect heart rate, blood oxygen, speed mileage, modify time, set warning value, and finally display on the LCD screen; In addition, the voice alarm and automatic light on function are also normal.

5. Summaries

This paper introduces an intelligent riding instrument based on STM32F103ZET6, which combines the functions of speed, mileage, heart rate and blood oxygen detection. The intelligent riding instrument has the advantages of simple hardware circuit, good real-time performance and simple operation, and can provide key riding data on the way. It has a certain role in promoting the development of healthy cycling and low-carbon travel.

Acknowledgements

Supported by Heilongjiang postdoctoral Fund (Project No.: LBH-Z17194).

Supported by the scientific research startup fund of Guilin University of Technology (Project No.: GUTQDJJ2019174).

Cite this paper: Yan, J.C., Mo, Y.B. and Yu, Y.N. (2021) Design of Intelligent Riding System Based on STM32. Open Access Library Journal, 8, 1-11. doi: 10.4236/oalib.1107700.
References

[1]   Yang, J.L. (2020) Analysis of TFT-LCD and OLED in Display Technology. Electronic Components and Information Technology, No. 4, 6-7.

[2]   Er, D., Ye, S.M. and Zhou, Y.C. (2012) Design of Eliminating Motion Interference of Oto Photo Capacitive Pulse Wave Sensor. Sensors and Microsystems, No. 31, 119-122.

[3]   Gao, Z.Q. and Zhao, X. (2019) Design of Intelligent Bicycle Code Table Based on STM32. Computer Products and Circulation, No. 2, 95.

[4]   Liu, G.Q., Chen, D. and Ma, X.R. (2020) Debugging and Simulation of Keil C Programming by Hand (Part One). Electronic Newspaper, 3, 1.

[5]   Wang, D.F. (2009) 100 Cases of C Language Application of Single Chip Microcomputer. Electronic Industry Press, Beijing.

 
 
Top