Interval training consists of timed bursts of exercise interspersed with timed rest periods. A variety of regimens have been created, probably the best known is Tabata[1] which consists of 20 seconds intense work followed by 10 seconds rest for a total of 8 repetitions – so 4 minutes total.
Using a stopwatch for intervals is somewhat error prone so a number of timers have appeared on the market to fill this niche.
The catch with the interval timers I have seen is that you are entering your intervals into a little box using only a few keys, a frustrating and error prone method.
My solution, store the interval data as a .txt file on an SD card where it can be easily edited using standard software e.g. Notepad, you then pop it into GymGeneral, select the file you want and run it.
Connections:Data logging shield (SD card) attached to SPI bus as follows:
MOSI - pin 11
MISO - pin 12
CLK - pin 1
CS - pin 10
Touch sensors:
Power to positive and ground, signal wires to Arduino external interrupt pins 2 and 3.
LCD backpack:
Power to positive and ground, SDA to Arduino SDA and SCL to Arduino SCL.
Piezo sounder:
Positive to Arduino PWM pin 9, negative to ground.
Software description:The software was an exercise in code reuse.
The display backpack uses the NewLiquidCrystal library and I also used the setup code from the same page [2] for my display, please note that my display is one of the weird ones that use address 0x3F most use 0x27 so if you don’t see anything locate and modify this number first.
I had not used an SD card with the Arduino so I played around with the Arduino ReadWrite tutorial [3] to work out how to read the data from the SD card.
My next step was to play around with the Arduino Listfiles tutorial [4] code to work out how to navigate through the files on an SD card.
I copied large blocks of code from the above examples into my project and made a few minor modifications of my own; I added code so that after the last filename is read we loop back to the first and altered the way the files are displayed.
The display routine is based along the lines of model, view controller. The idea of this is to decouple the display and controls form the body of the program. The downside is the use of global variables as a means of communication between the different blocks of code.
I used hardware PWM to generate the tones from a small piezo sounder element. The sounder is attached to pin 9, the frequency of the PWM output of this pin is controlled by timer 1, I chose this pin as I could alter the PWM frequency without affecting the delay() function which runs using timer 0 [5].
The delays are handled using Arduino delay() I think this is acceptable for accuracy in this context [6]. I accept that for long routines the timings will become increasingly skewed due to the file reads and the loop code, I have made no attempts to quantify this.
The data for the intervals in the text file is taken as blocks of 4 comma separated integer values [7].
The format of the data:
<Repeats>,<Tone>,<On time in tenth seconds>,<Off time in tenth seconds>,
Tone uses 1 for low frequency and 2 for the high frequency.
Example:
20,2,1,9, = 20 repeats of high frequency, on for 1 tenth second, off for 9 tenths second.
So for the Tabata regimen the text file will contain the following:
20,2,1,9,10,1,1,9,20,2,1,9,10,1,1,9,20,2,1,9,10,1,1,9,20,2,1,9,10,1,1,9,20,2,1,9,10,1,1,9,20,2,1,9,10,1,1,9,20,2,1,9,10,1,1,9,20,2,1,9,
You may want to add a small delay at the start to allow yourself to get set; I normally give myself 15 seconds e.g. 15,1,1,9, .
I also tend to add a longer beep at the end to mark the completion of the workout e.g. 3,1,10,0, (a low tone of 3 seconds)
Operation:Set up on or more interval files on the SD card.
Cycle down through the available files using the touch sensor attached to Arduino pin 2 until the name of the file you want is displayed.
The other touch sensor acts as the enter key, when it is pressed the intervals will start to play.
There is no stop function.
Notes:The circuit layout shows a different SD card reader than the one I used and listed above.
On the name GymGeneral I did a UK Intellectual Property Office trademark search and USA trademark electronic search (TESS) and found nothing remotely similar. (7/Sept/2017)
In the context of my project I have taken interval training to be a synonym for high intensity interval training (HIIT) whereas in reality much longer regimens can also be categorized in this way e.g. the first week of Couch to 5K consists of 8*1 minute runs interspersed with 90 second rest periods [8].
References:[1] https://en.wikipedia.org/wiki/High-intensity_interval_training#Tabata_regimen (retrieved 7/Sept/2017)
[2] https://arduino-info.wikispaces.com/LCD-Blue-I2C (retrieved 5/Sept/2017)
[3] https://www.arduino.cc/en/Tutorial/ReadWrite (retrieved 24/Aug/2017)
[4] https://www.arduino.cc/en/Tutorial/listfiles (retrieved 24/Aug/2017)
[5] https://playground.arduino.cc/Main/TimerPWMCheatsheet (retrieved 8/Sept/2017)
[6] https://forum.arduino.cc/index.php?topic=53579.0 Topic: Accuracy of Arduino delay() command (retrieved 5/Sept/2017)
[7] http://forum.arduino.cc/index.php?topic=277648.0 Topic: Reading SD card with CSV format into chars and ints (retrieved 8/Sept/2017)
[8] http://www.nhs.uk/Livewell/c25k/Pages/couch-to-5k-plan.aspx (retrieved 11/Sept/2017)
Comments