I've been boxing for well around 3 years now and quite honestly, I still believe I'm at the same skill level as I was 3 years ago. So, what better way to put this theory to the test than to record my progress and measure how fast* I can punch a speed bag with a Displacement vs. Time graph? :-)
*Disclaimer: I use velocity and frequency interchangeably.
Hardware Setup:- Place the Particle Argon on the breadboard
- Using a jumper wire, connect the GND pin of the Particle Argon to the "Gnd" pin of the ultrasonic sensor.
- Using another jumper wire, connect the VUSB pin of the Particle Argon to the "Vcc" pin of the ultrasonic sensor.
- Using a third jumper wire, connect D3 on the Particle Argon to the "Echo" pin of the ultrasonic sensor.
- Using a fourth jumper wire, connect D7 on the Particle Argon to the "Trig" pin of the ultrasonic sensor.
Creating a Displacement vs. Time graph requires 4 things:
- Assigning a value to "rest:" In other words, at what distance will the speed bag be at equilibrium? This should be your first call to getDistance(), assuming that the speed bag isn't moving.
- Collecting time, like a stopwatch: Because we'll be graphing our data, we'll need to know the time of the position of the speed bag at all times. In other words, when the speed bag is at x position, y seconds have passed. We'll be using millis() to find time.
- Collecting displacement: Displacement is a measure of how far away an object is from its starting position or equilibrium. We'll need to know how far away the speed bag is from equilibrium at all times.
- Continuously publish two variables of data (displacement and time) to the Particle Console. To bypass the limitations of Particle.publish(), we'll be encoding the string as JSON (see lines 48-50).
Flash your Particle Argon will the code attached below.
Setting Up Your Google Sheets:These next few steps are adapted from Gustavo Gonnet's "Pushing Data to Google Docs" project and the site he links as well. I'll be listing the relevant info here, but if you'd like a more in-depth explanation, take a look at their articles.
- Go to Google Sheets and name the first two columns "displacement" and "time" respectively. It is incredibly important that your headers match the variable names you specified in Particle.publish().
- Follow the "The Sheet" section on this website and make sure to save your script URL! This will be important for when we create the WebHook integration on the Particle Console.
- Go to the Particle Console > Integrations > WebHook
- Under the "Custom Template" tab, copy the following code, but change the URL to your own Google Script URL and deviceID to that of your own device.
Now that your code is working, it's time to put it to the test!
- Place your ultrasonic sensor in a position where it is directly facing your speed bag.
- Connect the Particle Argon to a portable charger or battery pack and wait until it's breathing cyan.
- Wait a couple of seconds before punching your speed bag. Remember, the first call to getDistance() will assign a value to "rest" and you need to make sure the object is not moving until "rest" is assigned a value. Also, try to hit the bag as straight as possible.
Here is a picture of my setup:I hot glued a piece of plastic to the wooden beam facing my speed bag and secured the breadboard using velcro:
After you've hit the bag for at least 30 seconds, disconnect the Particle Argon and check your Google Sheet. You'll see the data from your session.
In regards to some outliers, like displacement being 38.05 in my screenshot above, that is most likely due to the fact that at times, my speed bag traveled at an angle and not directly in line with the ultrasonic sensor. Since most of the data looks right, you can insert a "Smooth Line Chart" on Google Sheets by:
- Selecting all data > Insert > Chart
- Selecting "Smooth line chart" under "Chart Type"
- Changing "X-axis" to "time" and "Series" to "displacement"
- Changing the "axis-titles" to "Time (s)" for the x-axis and "Displacement (in)" for the y-axis.
- Optional: further customizing your graph with a different color and displaying plot points.
Using this image as a reference for what is defined as a "cycle, " count how many concave down slopes you have. My data has 9, but it will differ for everyone depending on how long you recorded data.
Once you have counted your cycles, you can divide that number by the total number of seconds your data recorded to find frequency (or "velocity").
Frequency = number of cycles/seconds
My frequency = 9 cycles/37 seconds = 0.24 hz (hz are the unit for cycles/seconds).
Beyond just frequency, the graph can give you important insight into what happened during that whole interval: the narrower the graph is at a given interval, the faster you were hitting the bag, and the wider it is, the slower you were going.
Comments