Summer Week #7 (6/26 – 7/2)

This week I made some significant progress by getting the bend sensor and the Arduino to interact via Bluetooth with the application to successfully update athlete’s workout tables. I also worked on updating the app and I briefly worked with XBees and CoolTerm before I talked with Katie and Ben and we decided to change how we’re planning on displaying feedback to the user.

Bend Sensor Code

Changing my code for the bend sensor was the first thing that I did this week. The previous bend sensor code worked to set starting and target positions and properly keep track of the number of reps and half-reps that had been completed, but it did not keep track of the reps in order, just the count, and the bend sensor code did not yet work with Bluetooth. I had some other Arduino code from last week that worked to keep track of the reps and half-reps in order and send the workout to an application but it was working with digital inputs instead of analog and it was limited as it did not allow me to change the number of reps that I would be assigning each workout.

I ended up integrating the two codes to create my new bend sensor code  where an athlete can set starting and target squat positions, properly keep track of the reps and half-reps that they have completed in order, and send their current workout progress via Bluetooth in the form of a string to an application. I additionally changed the way that the workout was being stored on the Arduino. Previously it was being stored in a two-dimensional array that we would create with the size of the first array being the number of sets assigned and the size of the second being the number of reps assigned per set. This would have been a problem because we could only create this 2-dimensional array with numbers (3 & 8) and not variables (sets & reps). If we set up our Arduino code like this then we would need to reload code with the number of assigned sets and reps every time that a new workout is assigned and we simply don’t want to do that. Instead we want users to be able to just set the number of assigned sets and reps on the app and send that to the Arduino. My solution to this problem was to use a 1-dimensional array instead which would just need to be created once and then reset whenever a new workout was assigned. The number of sets and reps could be set from the app and then we would update the 1-dimensional array until the number of assigned reps (sets * reps) had been reached. This array would need to be large enough to account for all of the reps that an instructor would assign. I originally tried using a 1-D array of size 1000 but that made both of my Floras crash so then I reset them and tried 500 which I’m assuming is more squats than any instructor would assign for one workout and it worked fine.

I’ll still need to make some updates to my Arduino code but most of them are pretty minor and I believe most of the code is complete. I’ll just need to change the code so that it still allows a user to send his or her workout after completing all of the reps (it currently allows you to send progress at any other point in the workout). I’ll also need to eventually remove a few of the delays or at least shorten them when we’re actually testing the knee sleeve. I’ll also need to learn how to parse packets that are sent from the app to change the number of sets and reps in the Arduino code. I might need to include functions that will allow athletes to reset starting and target squat positions. I’ll also need to include a function that will reset the array to all 0s when a new workout is assigned. Lastly, I’ll need to get the code to interact with our ambient display to provide real-time feedback on athlete’s squats.

XBee, CoolTerm, and the Ambient Display

Katie and I had talked last week about creating an ambient display that could be stuck onto a mirror in front of a squatter rather than on the side of the knee sleeve where the LED feedback might be a distraction. Katie suggested that we used XBees to create this display. Her idea was to connect our knee sleeve’s Flora to an XBee, which would wirelessly communicate with another XBee connected to another Arduino on the ambient display. It sounded like a pretty good idea so Katie and I went down to the prototyping lab on Wednesday and we set up a few XBees by soldering them. Afterwards, Katie gave me a brief introduction on how to use them and CoolTerm but we ran out of time and planned on meeting again on Friday to finish up my introduction to XBees.

Before Friday, I talked to Katie and Ben again about the XBees and the ambient display and we realized that using XBees was probably not the best solution for an ambient display. If we were to use XBees we would be adding another complexity to the project, making the knee sleeve more bulky, and we’d also only have enough pins left on the Flora to have 1 button on the knee sleeve when we probably will want more going forward. We discussed other solutions for an ambient display and came up with the idea to have a “squatting mode” on our mobile application. Athletes will enter squatting mode before exercising and place their phones in front of them, probably in a squat rack holder or possibly they could find a way to attach them to a mirror. As an athlete squats, the background colors on the phone will change from red to yellow to green as a squat goes from un-attempted to half-completed to complete and then back to red when the next rep is set to begin. It’s possible that this new solution could present a power problem depending on how many times we send information from the Arduino via Bluetooth to the phone, but I think we’ll be okay power-wise.

Updating the App

In addition to working on the bend sensor code and the ambient display I also worked on the PhoneGap mobile app this week. I moved the script for the table which was all in the index.html file into a JavaScript file called athleteTable.js. I was then able to edit the app so that it would update an athlete’s table whenever workout data was sent via Bluetooth from the Arduino. Additionally I fixed the app so that the table with an athlete’s progress would only appear after the phone had connected to the knee sleeve. Although that’s now done there’s still quite a bit of CSS work to be completed.

Plans for This Week

This week I’m planning to create the squatting mode on the application and to get my bend sensor Arduino code working with the squatting mode. I’ll also be working on making those minor updates to the bend sensor code that I mentioned earlier and I’ll be working on learning how to send and parse packets so I can set the number of sets and reps for a workout from the application. Additionally Katie has asked me to prepare a diagram to explain how I’m anticipating how the instructor and athlete sides of the mobile application will work with the knee sleeve and the database so I’ll be working on that as well.