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
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.
Fig.2.1 TFmini Plus
TFmini Plus(as shown in Figure 2.1). For detailed information, please refer to the TFmini Plus instruction.
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/。
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.
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.
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.
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
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.
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.
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.
Fig.5.1 System workflow diagram
Fig.5.2 Work data