Summer Week #10 (7/19- 7/23)

Since my last blog post, I’ve focused on finishing up the Arduino code and the Squat Mode, trying to connect the PhoneGap app to a local database, creating my summer poster, and designing the knee sleeve.

Arduino Code and Squat Mode

Since my last post I’ve made significant progress with the MuscleMemory’s Arduino code and the application with its Squat Mode.

Previously my code sent data for every rep in the entire workout using multiple strings consisting of 14 or fewer bytes. This previous way of sending data worked to some extent but it wasn’t great, as it would send multiple strings that included data on un-attempted reps or reps that had already been updated and weren’t going to be updated again. Each one of those additional sends containing information that the app didn’t really need resulted in a waste of power. Additionally it should be noted that every send required a .2 second delay at the end of it as it takes that long for the app to process what it’s been sent. If there are two sends that occur in under .2 seconds (28 bytes total) then the app would read it all as one send of over 20 bytes and then break up the 28 bytes that it was sent into 20 bytes and 8 bytes when it should be broken up into 14 bytes and 14 bytes. This .2 second delay after every send is another reason why we don’t want to have too many sends as multiple sends would result in multiple .2 second delays that would interrupt the athlete’s workout.

I’ve edited the code so that updating the app will now only require us to send one string – a string that consists of 17 or fewer bytes and includes the rep that was just updated. By not sending multiple strings that represent every rep in the workout we are reducing the amount of power that the knee sleeve will require and also preventing the .2 second delays from adding up into lengthy delays. The reason why our string now sends 17 bytes instead of 14 is because the string now includes the number of reps remaining in the workout which will range from 000 to 100. This change to the string made it so the app’s squat mode can now easily display the number of reps remaining in the workout to athletes. The app’s squat mode is now functioning exactly how it should and the only thing left to do with it will be to make a few CSS changes.

Another important change that I made to the app and Arduino code this week involved setting the number of reps in a workout on the Arduino from the app. I had talked to Katie about this earlier this summer and we had thought that this would need to involve parsing a packet sent from the app, but I believe I’ve found a much easier solution. I’ve edited the app, just for testing purposes, to include a text field where users can enter the number of assigned reps for a workout and then send it to the Arduino. The Arduino then reads what was sent (it’ll have to be a number), sets what it received as the number of assigned reps for a workout, and then lights up green to let you know the workout has been assigned. Then when the workout is completed the starting and target positions are no longer considered set and the Arduino sends the relevant workout data before being erasing it and waiting for the next workout to be sent.

The last change that I made in the Arduino code was a small one, but pretty important nevertheless. After I began working with a new bend sensor that I soldered and set up, I found out that flex sensors are only meant to bend in one direction and the sensor that John had taped on to the knee sleeve was actually bending in the wrong direction. I fixed this so that the new bend sensor bends in the correct direction on the knee sleeve that I’m working with, but that also changed the values so that now the target position value is actually lower than the starting position value. This just resulted in me having to change the way that the percentage of the squat, x, is being calculated.

PhoneGap Issues with the Database

This week I followed these instructions and set up my local server the correct way this time for OS X El Capitan and connected it to a phpMyAdmin database. I then attempted to follow the instructions for creating a simple mobile app that connects to a local MySQL database and tested my version of the app on my phone. I feel like I have set everything up how I’m supposed to, but I keep encountering the same issues that I was before with tap/click events and changing pages. I’m now testing on my phone rather than my laptop and I’m noticing that I’m receiving an error in the XCode console whenever I try to tap on a button. The error message reads:

“Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1”

 I’ve searched for solutions to this problem and some people have suggested trying data-href tags instead of href tags on buttons while others believe it’s just an issue with PhoneGap version 2.7 (I’m running PhoneGap 6.1). I tried using a data-href tag but was unsuccessful. I’m thinking that it’s possible that this tutorial for connecting a PhoneGap app to a MySQL server is outdated now as it’s from 2012, but there aren’t many other in-depth tutorials for this that I’ve found online. I think that I’ll be able to figure out what’s going wrong with this PhoneGap/MySQL example sometime soon, but with this upcoming week being the last of summer I think it would be better to prioritize other parts of the project to make everything more presentable for the poster session on Friday.


This past Thursday Katie asked us to have our poster for the July 29th REU poster session in the slides for the Friday morning meeting so I drafted a poster, which can be seen below.



There’s still a little bit of work to be done as I’d like to make some changes to the Fritzing diagram, the colors, and the spacing, but that shouldn’t take too long. I’ll also need to add an NSF logo and disclaimer and ask Katie if I gave credit to the right grant because this grant is different from the one that she told me to give credit to at WISH. After I make those small changes my poster should be ready to be printed Tuesday and presented Friday.

Designing the Knee Sleeve

This Friday I went down to the Prototyping Lab and soldered a new bend sensor for the knee sleeve. I then planned out with Katie where the Flora, Bluefruit LE, battery, push button, and bend sensor will all be located on the knee sleeve. We did this by having me squat with the knee sleeve on so that I could find out where sleeve moved the least and where I could feel the Flora and the battery the least. I found that the knee sleeve with the Flora did feel a little bit awkward just about everywhere on my leg but that the top right corner of the knee sleeve, which I wore on my right leg, was probably the best location to place the Flora and battery. We then settled on where to place the bend sensor and calculated that a 400mAh battery would probably be large enough for our user study.

Plans for This Week

This week I’m hoping to focus on aspects of the project that will make the MuscleMemory Bluetooth Application more presentable. This will probably include creating a page just for sending a workout on the app, updating a lot of the CSS, sewing together a prototype knee sleeve, and of course updating my poster.