Difference between revisions of "Exercise Recorder"

From Microduino Wiki
Jump to: navigation, search
(Equipment)
Line 1: Line 1:
{{Language| Excercise Recorder}}
+
{{Language| Exercise Recorder}}
 
{| style="width: 800px;"
 
{| style="width: 800px;"
 
|-
 
|-
 
|
 
|
 
==Objective==
 
==Objective==
DIY an electronic device to remind movement time and count all kinds of exercises.  
+
You can set exercise time and when it comes to the pre-set time, a buzzer will ring. Only after completing the required times of exercise can the buzzer stop. Here we adopt Microduino-Motion module to record your motion and count. 
[[File:exercise recorder.jpg|600px|center|xyz]]
+
[[File:Exercise_record-image.jpg|600px|center]]
 +
 
 +
==Principle==
 +
Setting exercise time with Microduino-RTC and when it comes to the pre-set time, a buzzer will ring. Only after completing the required exercise frequency can the buzzer stop. Here we adopt Microduino-Motion module to record your motion and count, and an OLED display module to show the current time and amount of exercise.  
 +
[[File:Exercise_record-sch.jpg|600px|center]]
  
==Schematic==
 
Microduino-motion can detect motion change. The buzzer will make sound along with movement counting. Timing each exercise by RTC module, it can record four times of exercise. The current date and time will be displayed on OLED, which can be adjusted via Bluetooth on your phone. 
 
 
==Equipment==
 
==Equipment==
 
{|class="wikitable"
 
{|class="wikitable"
 
|-
 
|-
|Module||Number||Function
+
|Module||Number||Function  
 
|-
 
|-
|[[Microduino-CoreUSB]]||1||Core board  
+
|[[mCookie-CoreUSB]]||1||Core board  
 
|-
 
|-
|[[Microduino-Sensorhub]]||1||Sensor pin board  
+
|[[mCookie-Hub]]||1||Sensor pin board  
 
|-
 
|-
|[[Microduino-Motion]]||1||Altitude detection modules
+
|[[mCookie-Motion]]||1||Attitude detection module
 
|-
 
|-
|[[Microduino-BT]]||1||Bluetooth module  
+
|[[mCookie-OLED]]||1||Display module  
 
|-
 
|-
|[[Microduino-OLED]]||1||Display module
+
|[[mCookie-RTC]]||1||Real time clock
 
|-
 
|-
|[[Microduino-RTC]]||1||Clock module
+
| [[mCookie-BM]]||1||Battery management
 
|-
 
|-
| [[Microduino-BM]]||1||Battery management
+
| [[mCookie-Duo-V/]]||1||Extension board
 
|-
 
|-
| [[Microduino-Duo-V]]||1||Extensive board
+
| [[Microduino-Buzzer]]||1||Buzzer sensor
|-
 
| [[Microduino-Buzzer]]||1||Buzzer  
 
 
|}
 
|}
 
+
*Other Equipment  
*Other Equipment :
 
 
**One battery  
 
**One battery  
**Lego
+
**LEGO shell
 
+
[[File:Exercise_record-module.jpg|600px|center]]
==Hardware Buildup==
+
==Preparation==
*Setup 1:Connect CoreUSB to PC, open example program, select the right board and download program.  
+
*Setup 1:Connect the CoreUSB and PC/Mac with a USB cable, open Arduino IDE.
[https://github.com/Microduino/Microduino_Tutorials/blob/master/MCookie_Tutorial/sport_10dof/sport_10dof.ino sport_motion]
+
[[Image:CoreUSB_Ble_pc.jpg|600px|center]]
*Setup2:Stack all modules. Connect OLED and Sensorhub to Duo-V.
+
*Setup 2:Click Files > Examples > mCookie > _305_PersonalTrainer, upload the program.  
[[File: Exercise_record_setup_1.jpg|600px|center|thumb]]
+
[[File: _305_PersonalTrainer_load.jpg|600px|center]]
*Setup3:Connect two Buzzer modules to D6 pin of Sensorhub.
+
* Setup 3:Load the code, select the right board and COM port for program download. When it pops up a notice of "Done Uploading", it means the program has been written into the CoreUSB module.
[[file:Microduino-sensorhub_rule.JPG|thumb|800px|center]]
+
[[File: _305_PersonalTrainer_load-ok.jpg|600px|center]]
[[file: Exercise_record_6.JPG|thumb|800px|center]]
 
*Setup4:Connect battery to BM.  
 
[[file: music_boxz _bm.JPG|thumb|800px|center]]
 
  
 
==Software Debugging==
 
==Software Debugging==
*Function Description
+
*Motion detecting
**“bluetooth()”  Receive Bluetooth data on the phone for time adjustment.
 
**“time_long()”  Calculate exercise time.
 
**“large_time()”  Exercise time is sorted by exercise regimen.
 
**“lagre()”Exercise regimen is sorted from large to small.
 
**“draw()” OLED displays function values.
 
**“setRtcTime” Clock setting function.
 
 
 
*Bluetooth serial port usage
 
 
<source lang="cpp">
 
<source lang="cpp">
#include <SoftwareSerial.h>
+
change_gx = (abs(gx) + abs(gy) + abs(gz)) / 3;
SoftwareSerial mySerial(4, 5); // RX, TX
+
  //Serial.println(change_gx);
 
+
  if (change_gx > 80 && !sport_en)
//#define my_Serial mySerial
+
    sport_en = true;
#define my_Serial Serial1
+
  else if (change_gx <= 10&&!sport_num)
 +
  {
 +
    timer_0 = millis();
 +
    sport_num = true;
 +
  }
 +
  if (sport_num)
 +
  {
 +
    if (millis()-timer_0 > 1000)
 +
    {
 +
      change_gx = (abs(gx) + abs(gy) + abs(gz)) / 3;
 +
      if (change_gx <= 10)
 +
      {
 +
        sport_num= false;
 +
        sport_en = false;
 +
        timer_0 = millis();
 +
      }
 +
    }
 +
  }
 
</source>
 
</source>
 
+
*Motion counting  
*Movement counting
 
 
<source lang="cpp">
 
<source lang="cpp">
  if (gy > 80 && ax > -50)
+
if (sport_change != sport_en && time_en)
    sport_en = true;
 
  else if (gy < -80 && ax < -50)
 
    sport_en = false;
 
 
 
  if (sport_change != sport_en)
 
 
   {
 
   {
 
     if (sport_en)
 
     if (sport_en)
 
     {
 
     {
       num += 1;
+
       Sport_num -= 1;
 
       tone(buzzer_pin, 300);
 
       tone(buzzer_pin, 300);
       Serial.println(num);
+
       if (Sport_num == 0)
 +
      {
 +
        time_en = false;
 +
        noTone(buzzer_pin);
 +
      }
 
     }
 
     }
     else
+
     //else
      noTone(buzzer_pin);
+
    //  noTone(buzzer_pin);
 
+
    //Serial.println(sport_en);
 
     sport_change = sport_en;
 
     sport_change = sport_en;
 
   }
 
   }
 
</source>
 
</source>
 +
*
 +
==Hardware Buildup==
 +
*Setup1:Connect Microduino-Buzzer to the D6 pin of Microduino-Hub.
 +
[[file: Exercise_record_6.jpg |800px|center]]
 +
*Setup 2:Connect the activated battery box and the BM module.
 +
[[File:CoreUSB_Ble_steup2.jpg|600px|center]]
 +
*Setup 3:Stack all modules together freely and complete the circuit buildup part.
 +
[[File: Exercise_record _steup3.jpg|600px|center]]
  
 +
==Code Debugging==
 +
[[File: Exercise_record _debug1.jpg|600px|center]]
 +
1.For the first use of Microduino-RTC, you need to set the initial time through programs, find the code section based on the picture above, set according to the local time and load the program into the RTC module through the CoreUSB module.
 +
[[File: Exercise_record _debug2.jpg|600px|center]]
 +
2.After that, you can add "//" in the front of the code section and the code will turn gray. At this time, please re-load the program into RTC module and then you can record time freely.
 +
[[File: Exercise_record _debug3.jpg|600px|center]]
 +
3.Find the code section above, set the exercise time, load the code into the CoreUSB module after the setting, you'll find when it comes to this time, the buzzer will go alarm.
 +
[[File: Exercise_record _debug4.jpg|600px|center]]
 +
4. Find the code section above, set the exercise frequency, load the code into the CoreUSB module after the setting. When the buzzer goes on, the screen will switch to the display of the sports frequency. The buzzer will not stop until you complete the pre-set exercise frequency.
 
==Result==
 
==Result==
You can count the sit-ups, dumbbell and other exercises.  
+
This project can be used in exercise counting for sit-up, dumbbell lifting and so on.  
 +
[[File:Exercise_record.jpg|600px|center|excercise]]
  
 
==Video==
 
==Video==
  
 
|}
 
|}

Revision as of 08:13, 19 January 2016

Language: English  • 中文

Objective

You can set exercise time and when it comes to the pre-set time, a buzzer will ring. Only after completing the required times of exercise can the buzzer stop. Here we adopt Microduino-Motion module to record your motion and count.

Exercise record-image.jpg

Principle

Setting exercise time with Microduino-RTC and when it comes to the pre-set time, a buzzer will ring. Only after completing the required exercise frequency can the buzzer stop. Here we adopt Microduino-Motion module to record your motion and count, and an OLED display module to show the current time and amount of exercise.

Exercise record-sch.jpg

Equipment

Module Number Function
mCookie-CoreUSB 1 Core board
mCookie-Hub 1 Sensor pin board
mCookie-Motion 1 Attitude detection module
mCookie-OLED 1 Display module
mCookie-RTC 1 Real time clock
mCookie-BM 1 Battery management
mCookie-Duo-V/ 1 Extension board
Microduino-Buzzer 1 Buzzer sensor
  • Other Equipment
    • One battery
    • LEGO shell
Exercise record-module.jpg

Preparation

  • Setup 1:Connect the CoreUSB and PC/Mac with a USB cable, open Arduino IDE.
CoreUSB Ble pc.jpg
  • Setup 2:Click Files > Examples > mCookie > _305_PersonalTrainer, upload the program.
305 PersonalTrainer load.jpg
  • Setup 3:Load the code, select the right board and COM port for program download. When it pops up a notice of "Done Uploading", it means the program has been written into the CoreUSB module.
305 PersonalTrainer load-ok.jpg

Software Debugging

  • Motion detecting
change_gx = (abs(gx) + abs(gy) + abs(gz)) / 3;
  //Serial.println(change_gx);
  if (change_gx > 80 && !sport_en)
    sport_en = true;
  else if (change_gx <= 10&&!sport_num)
  {
    timer_0 = millis();
    sport_num = true;
  }
  if (sport_num)
  {
    if (millis()-timer_0 > 1000)
    {
      change_gx = (abs(gx) + abs(gy) + abs(gz)) / 3;
      if (change_gx <= 10)
      {
        sport_num= false;
        sport_en = false;
        timer_0 = millis();
      }
    }
  }
  • Motion counting
if (sport_change != sport_en && time_en)
  {
    if (sport_en)
    {
      Sport_num -= 1;
      tone(buzzer_pin, 300);
      if (Sport_num == 0)
      {
        time_en = false;
        noTone(buzzer_pin);
      }
    }
    //else
    //  noTone(buzzer_pin);
    //Serial.println(sport_en);
    sport_change = sport_en;
  }

Hardware Buildup

  • Setup1:Connect Microduino-Buzzer to the D6 pin of Microduino-Hub.
Exercise record 6.jpg
  • Setup 2:Connect the activated battery box and the BM module.
CoreUSB Ble steup2.jpg
  • Setup 3:Stack all modules together freely and complete the circuit buildup part.
Exercise record steup3.jpg

Code Debugging

Exercise record debug1.jpg

1.For the first use of Microduino-RTC, you need to set the initial time through programs, find the code section based on the picture above, set according to the local time and load the program into the RTC module through the CoreUSB module.

Exercise record debug2.jpg

2.After that, you can add "//" in the front of the code section and the code will turn gray. At this time, please re-load the program into RTC module and then you can record time freely.

Exercise record debug3.jpg

3.Find the code section above, set the exercise time, load the code into the CoreUSB module after the setting, you'll find when it comes to this time, the buzzer will go alarm.

Exercise record debug4.jpg

4. Find the code section above, set the exercise frequency, load the code into the CoreUSB module after the setting. When the buzzer goes on, the screen will switch to the display of the sports frequency. The buzzer will not stop until you complete the pre-set exercise frequency.

Result

This project can be used in exercise counting for sit-up, dumbbell lifting and so on.

excercise

Video