1. Auto-measuring Instrument for Body Flexion
1.1 Application Background
Sit and reach (as shown in Figure 1.1) is a physical exercise program and a physical fitness test program for Chinese primary and secondary schools. Its purpose is to measure the possible range of motion of the trunk, waist, hip and other joints at rest, which mainly reflects the extensibility and elasticity of the joints, ligaments and muscles and the development level of the body's flexibility. Sit and reach is one of the compulsory items in the entrance examination of physical education in China.
Fig.1.1 Sit and reach
1.2 Application Profile
This system is an automatic measuring device designed and developed by using TFmini Plus of Benewake LIDAR, Arduino-UNO board, 0.91 inch OLED module, BY8301-16P module, speaker and traditional sit and reach measuring instrument.
Function: complete the automatic measurement of body flexion, display and broadcast the measurement results, reduce the process of manual reading, and make the process of sports testing more intelligent and humane.
2. System Elements and Wiring
2.1 System Elements
- Benewake Standard TFmini Plus
Fig.2.1 TFmini Plus
TFmini Plus(as shown in Figure 2.1). For detailed information, please refer to the TFmini Plus instruction.
- Arduino UNO Board
Fig.2.2 Arduino UNO
Arduino UNO board（as shown in Figure 2.2）. For detailed introductions, please refer to the following two websites:
English Official Website：http://www.arduino.cc/。
- 91 Inch OLE Module
Fig.2.3 OLED display
Specifications: 0.91 inch OLED display (as shown in Figure 2.3), 128 * 32 dot matrixes, IIC communication interface, compatible with 3.3-5V.
Function: display the measurement results.
- BY8301-16P Module
Specifications: voice module (as shown in Figure 2.4), working voltage is DC 3.6-5V, in favor of MP3/WAV format, support UART serial communication protocol, comes with 3W amplifier or external power amplifier.
Function: control the speaker to broadcast the prompt information and measurement results.
- BY-90-1W Passive Speaker
Specification: Speaker (as shown in Figure 2.5), power is 8Ω and 1W.
Function: broadcast prompt information and measurement results.
As shown in Figure 2.6, as the host of the system, used to write and upload programs to the UNO board.
- Traditional Measuring Instrument of Sit and Reach
Fig.2.7 measuring instrument for body flexion
Dupont line – connect the TFmini Plus and UNO board;
USB data cable - used for UNO board and computer communication and power supply.
Fig.2.9 System wiring
- TFmini Plus line specification：
Fig.2.10 TFmini Plus line specification
TFmini Plus power supply is 5V, directly connected to 5V and GND of Arduino board. Other LIDARs need to consult product specifications to ensure respective power supply.
- For the Arduino UNO board, the connection for serial communication needs to pay more attention to:
- The TX line of TFmini Plus is connected to pin 4 of the board (RX of the Serial2), and the RX line of LIDAR is connected to pin 5 of the board (TX of the Serial2).
- The voice module is connected to 5V and GND of UNO board, the TX terminal is connected to pin 2 of board (RX of the Serial1 of a software serial port), and the RX terminal of LIDAR is connected to pin 3 (TX of the Serial1 of a soft serial port), Software serial port1 is defined in voice library. The voice module can only connect pin 2 and 3 of UNO board in sequence according to the library, Otherwise, the library must be modified (supporting setting volume 0-20).
- 91-inch OLED connects 5V (or 3.3V) and GND directly, SCL and SDA connect UNO board SCL and SDA correspondingly.
3. Principle of the automatic measurement of body flexion
Fig.3.1 Diagram of Automatic measurement system for body flexion
Fig.3.2 Flow chart of principle of automatic measurement of body flexion
As shown in Fig. 3.1 and Fig. 3.2, the system diagram and working flowchart of the automatic measurement of body flexion are presented respectively.
Firstly, we include the voice and OLED library head files, define essential variables, initialize serial port, voice module and OLED display module, read LIDAR data, calibrate the system, and set start = dist1, zero = dist0;
Then, read the data, judge the position initialized status init_stat and the relationship between the distance measured by the LIDAR and the start. If the requirements are not met, obtain the data and make a judgment again. If the requirements are met（!init_stat（not initialized） && D==start（the actual distance is equal to the initial position of the calibration）），the voice module broadcasts "ready" and starts measuring;
During measuring, continue to judge the position initialization status init_stat and the relationship between diatance and start. If the requirements are not met, obtain the data and make a judgment again. If the requirements are met（!init_stat（initial position completed） && D==start（the baffle leaves the initial position）），Check whether the slide board moves at any time. If it is unmoved, it will go through about 2.3s, the measuring is steady, and the measurement results are broadcasted and displayed;
Finally, determine if the next test is needed. if not, power off, and end the test.
4. System Programming
This routine requires adding OLED libraries and custom libraries voice and oled.
0.91OLED library files：
voice library files：
oled library files：
#include "voice.h"//include the self-defined head file, voice and oled.
#include<SoftwareSerial.h>//incorporate the SoftwareSerial head file
SoftwareSerial Serial2(4,5); //define a SoftwareSerial named Serial2,regarding pin4 as RX, pin5 as TX.
/*If there are multiple serial port more than one, such as DUE board，you could use the serial port directly.*/
/*define the basic data of TFmini Plus*/
int check;//store the checksum of TFmini Plus
int uart;//store the standard data of TFmini Plus
const int HEADER=0x59;//data packet's frame head
/*define some essential parameters of Auto-measuring Instrument for Body Flexion*/
int D;//the distance measured by the TFmini Plus
int d=0;//the last distance
int result=0;//the result of calculation
const int zero=34;//the zero position calibrated after installation and before test.
const int start=50;//the start position calibrated after installation and before test.
boolean init_stat=false;//define the initiating status of position.
Serial.begin(115200);//configure the baud rate as 115200 bps between Arduino UNO and PC.
Serial2.begin(115200);//configure the baud rate as 115200 bps between Arduino UNO and TFmini Plus.
oled_begin();//initialization of OLED module.
voice_begin();//initializing the voice module.
voice_setvolume(18);//set the volume of the voice module as an integer between 0 and 20.
if (Serial2.available())//monitor whether there is data input from the lIDAR.
if(Serial2.read()==HEADER)//check if the first data is the data packet's frame head 0x59 defined in the cummunication protocol.
if(Serial2.read()==HEADER)//check if the second data is the data packet's frame head 0x59 defined in the cummunication protocol.
for(k=2;k<9;k++)//store the remaining data into the uart.
if(uart==(check&0xff))//verify the checksum according to the cummunication protocol.
D=uart+uart*256;//compute the actual distance
if(!init_stat && D==start)//judge the position's initialized status and the relationship of distance measured by the TFmini Plus and start.
for(k=15;k>=1;k--)//only getting fifteen datas steady and uninterrupted can satisfy the need in case of data fluctuation.
CHA = cha;
init_stat=true;//set tht status as true after completing the position initialization.
if(D!=0 && D!=start && init_stat)//judge the position's initialized status and the relationship of distance measured by the TFmini Plus and start.
for(k=23;k>=1;k--)//only getting twenty-three datas steady and uninterrupted can satisfy the need in case of data fluctuation.
VAR = var;
init_stat=false;//set tht status as false after completing the test and waiting for the next initialization.
5. System Work and Data Review
Fig.5.1 System workflow diagram
- After the system is installed, power on the system, upload the program, calibrate start and zero position；
- The slide board is placed at the start position, and after the voice module broadcasts "ready", measurement begins；
- After the slide board leaves the start position, it cannot be paused for a long time, generally within 2.3s. When the slide board is stopped and steady measuring is performed, display and broadcast the measurement results.
5.2 Data Review
Fig.5.2 Work data
- The measurement resolution of the TFmini Plus is 5mm. If the measurement accuracy is mm, there will be a larger error, so only the resolution of cm can be realized accurately. During the next upgrade, the mm-level measurement can be realized with a higher precision product.
- The auto-measuring instrument for body flexion will not broadcast during the measurement process, but it cannot be stopped for a long time (less than 2.3s).
- The system is one test at a time, and after the measurement is completed, it needs to be re-homed to the starting point.