Wednesday 21 December 2016

How does a simple Turbo Trainer Work?

My job in the real world is to support the development of Engine Test Facilities for Jaguar LandRover (JLR) in the UK. Specifically I have a team that support and develop software systems for data delivery, although I know a lot about the non-computer systems. I have developed and deliver a training pack for new employees joining the business as Engine Test Bed Operators that covers a wide range of material.

One of the topics is the dynamometers we use, these being a mix of Eddy Current machines and AC motors. During the discussion I mention my turbo trainer as a type of Eddy current dyno, but with permanent magnets rather than electro-magnets.

Wikipedia has a page about what Eddy Currents dynamometers are here: link.

This image shows the principle. Basically the disk passing through the magnetic field causes currents to be induced in the disk. These currents (eddy) generate an opposing force to the direction of motion and hence this resistance is how power is absorbed. The force is function of the velocity (and of course the magnetic strength and resistance of the disk). Basically for a given design doubling the speed means doubling the power dissipated. the resistance dissipated as heat by the currents flowing through the resistance of the metal.

 

I had not really given the exact mode of operation of my turbo trainer a lot of thought but a couple of things coincided recently and I partially disassembled it to fix an issue.

Firstly I was in my garage to re-build my Giant Defy as a turbo (only) bike after it was possibly damaged when I got knocked off in Nov 2015. Secondly, as I was in the garage I partially disassembled my turbo trainer to try and sort out why it was stuck on a quite high load setting - in some respects training at a higher load makes it a little easier when actually riding on the road but at the same time the load can be just too high and make the turbo sessions unpleasant.

I took the cover off and this was the view of the end of the roller:



It is possible to see the disk and a small cooling fan. I think the disk has holes to aid cooling.

The end cover has 6 magnets in a fixed position:



I had assumed that the cable adjuster moved some magnets radially - low load was with the magnets further out and high load with the magnets fully covering the disk. This was clearly not the way this works. I removed the 3 screws and pulled the fan and the disk off the shaft to find  second set of magnets:



These magnets are mounted on an adjustable plate that rotates about 30deg. This rotation moves these magnets into full alignment or out of alignment, this increasing or decreasing the effective magnetic field and hence the eddy currents and hence resistance. This is a really simple and effective design. Here is a schematic:

 

What's also interesting is that this simple set of magnets and metal disk is capable of absorbing around 400W+ (I don't know what my trainer is rated at but I know that I can't get any where near the limit).

Some minor fettling of the assembly and lubrication of the cable adjuster seemed to sort eveything out and I can now easily adjust the load (via magnet positions).

So one better working turbo trainer later I can "train" better.

Sunday 11 December 2016

Strava Data Analysis - A PC Based Visual C# Solution


See latest version here: link

Note - I am keen for people to test the code I have written whilst I continue to develop it. I will release the source code later (when I work out how this can be done), so for now I have built an application for installation.

Thus this post will continue to change and evolve to capture document this application fully

The application looks like this:



Currently it only does one thing - connect to Strava, download all rides between to user definable dates and allow this to be exported as a Tab Separated file. "Ride Data" means the averaged/final data for a ride (description, average speed, duration etc.). (I have development version that can download the second by second GPS data but this needs more work).

So what do you need to do to use this tool?
  • Create your own Strava Application
  • Install this DotNet application and run it
The reason you need to create your own application is you need a "Strava Token" which you receive when you create an application that ties the data to your account. I think it can access other peoples data as well but I don't understand the documentation for this.

Creating your own Strava Application
On Your Account page you will find a link to create an application. You need to enter 4 pieces of information to get an application. Here is my information (that I can change my existing application): 


You need to enter an Application Name, a website (I have used this Blog as a link at the moment), a description and finally an "Authorisation Callback Domain". This is where I failed but some Googling the problem suggested that "localhost" would get you through, which it did. These settings don't support an online solution but I don't want that - I wanted to be able to connect and get my data using a PC offline tool only

With these entries you can actually create an application and you'll get the following tokens/data:



You will need the "Access Token" to use the application. You can copy and paste from the web page into the application. Don't share your token with others. The Access Token is a 40 character hexadecimal number.

Next you need to get the application. I have put it on my Google Drive and it should be shared with anyone with this link here. Extract it from the .zip file and run setup. All should be OK.

Note that this application uses the DotNet framework so this must be installed. Most Windows PCs will already have this. I am not sure the minimum version required - refining the installer and updates is on the list of things to do!

Once its started you'll need to paste in your Strava Access token in the box and then press the Start Button. 

All being well after a period of time your data should appear in the application. There is currently no progress indicator - so please wait. The longer the data window and the more activities you have to download the longer it takes to get the data - as much as 30 seconds or more. 

Once its complete you can then export the data.

Closing the programme should save your Strava token which will be read next time you run the application.

This is a very short introduction. More details will follow as quickly as I can update this page. Please report all issues via the comments section of this post

Detailed Narrative
Some time ago (2013) I wrote a small tool that downloaded your Strava data using Excel and the wget utility. I documented it here (link) and made it available for download.

However this was thwarted when Strava withdrew support for the API that I was using so my tool stopped working. I gave up looking for alternative solutions at the time as I could download similar data using the great Veloviewer. However this solution was a bit flaky (not sure if it was my browser or what) but it was inconsistent.

I occasionally looked at the Strava Blog and saw that support for external applications was supported but it looked complicated - for example it looked like you needed to call from a web server and use JSON - whatever that is. (see bottom of page for a summary of JSON). However intermittent and continued reading showed that there were also libraries

Language Libraries

The Strava API is implemented using RESTful HTTP JSON patterns. A number of 3rd party language specific libraries exists to wrap this functionality and make usage seemless.

Alongside this were a set of links (replicated below) of all the different libraries implemented by individuals:

 The one that was attractive to me was the .NET library. I have previously written a number of applications in old fashioned C and Delphi, as well as dabbled in VB (the latter because I use Microsoft products a lot at work and have needed to add VBA processing to Excel). I have also played with various versions of Microsoft Visual Studio so was familiar. So I decided to have another go, and chose C# this time (I don't really know why)

There were several steps required (not necessarily in this order:
  • Get Visual Studio
  • Get the Stravadotnet packages
  • Create a Strava Application
  • Read some documentation
  • Try the examples
  • Understand a bit better using Visual Studio
  • Get the examples to work
  • Try various things
  • Work on an example
  • Test and trial the example
  • Get a working piece of code
  • Share with the world
JSON (JavaScript Object Notation is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999.