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.
3691381914?profile=original

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

3691381972?profile=original

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

3691382006?profile=original

Fig.2.2 Arduino UNO

Arduino UNO board(as shown in Figure 2.2). For detailed introductions, please refer to the following two websites:

Chinese Community:http://www.arduino.cn/

English Official Website:http://www.arduino.cc/

  • 91 Inch OLE Module

3691381989?profile=original

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

3691382026?profile=original

Fig.2.4 BY8301-16P

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

3691381929?profile=original

Fig.2.5 speaker

Specification: Speaker (as shown in Figure 2.5), power is 8Ω and 1W.

Function: broadcast prompt information and measurement results.

  • Computer

3691382062?profile=original

Fig.2.6 computer

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

3691382075?profile=original

Fig.2.7 measuring instrument for body flexion

  • cables

3691382044?profile=original

Fig.2.8 cables

Dupont line – connect the TFmini Plus and UNO board;

USB data cable - used for UNO board and computer communication and power supply.

2.2             Wiring

3691382117?profile=original

Fig.2.9 System wiring

  • TFmini Plus line specification:

3691382098?profile=original

 Fig.2.10 TFmini Plus line specification

3691382143?profile=original

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

3691382165?profile=original

Fig.3.1 Diagram of Automatic measurement system for body flexion

3691381949?profile=original

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:

System program:

#include "voice.h"//include the self-defined head file, voice and oled.

#include "oled.h"

#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[9];//store the standard data of TFmini Plus

int k;

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.

int VAR[23]={0};

int var;

int num=0;

const int start=50;//the start position calibrated after installation and before test.

int CHA[15]={0};

int cha=0;

int count=0;

boolean init_stat=false;//define the initiating status of position.

 

void setup()

{

  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.

}

void loop()

{

  Serial2.listen();

  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.

    {

      uart[0]=HEADER;

      if(Serial2.read()==HEADER)//check if the second data is the data packet's frame head 0x59 defined in the cummunication protocol.

      {

        uart[1]=HEADER;

        for(k=2;k<9;k++)//store the remaining data into the uart.

        {

          uart[k]=Serial2.read();

        }

        check=uart[0]+uart[1]+uart[2]+uart[3]+uart[4]+uart[5]+uart[6]+uart[7];

        if(uart[8]==(check&0xff))//verify the checksum according to the cummunication protocol.

        {

          D=uart[2]+uart[3]*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.

          {

            cha=D-start;

            for(k=15;k>=1;k--)//only getting fifteen datas steady and uninterrupted can satisfy the need in case of data fluctuation.

            {

              CHA[k]=CHA[k-1];

            }

            CHA[0] = cha;

            for(k=0;k<15;k++)

            {

              if(CHA[k]==0)

              {

                count++;

              }       

            }

            oled_measuring();

            if(count>=15)

            {

              voice_ready();

              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.

          {

            var=abs(D-d);

            for(k=23;k>=1;k--)//only getting twenty-three datas steady and uninterrupted can satisfy the need in case of data fluctuation.

            {   

              VAR[k]=VAR[k-1];

            }

            VAR[0] = var;

            for(k=0;k<23;k++)

            {

              if(VAR[k]==0)

              {

                num++;     

              }

            }

            if(num>=23)

            {

              result=zero-D;

              oled_result(result);

              voice_num(result);

              Serial2.listen();

              init_stat=false;//set tht status as false after completing the test and waiting for the next initialization.

            }

            d=D;

            num=0;

          }

        }

      }

    }

  }

}

5.              System Work and Data Review

5.1             Workflow

3691382208?profile=original

3691382208?profile=original

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

3691382178?profile=original

Fig.5.2 Work data

6.                Attentions

  • 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.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Activity