Saturday, 8 April 2017

"Retro" Cycling Jersey

I am not over keen on personal photos but I got a "retro" Peugeot cycling jersey for Christmas and today was the first day of the year the weather was good enough for short sleeves

I think its an iconic (risk of overused word) jersey and looks great:

Not Tom Simpson

Whether I do it justice compared to the originals I'll leave it to you:

Tom Simpson


Sunday, 12 March 2017

Star Hill and Rowdow Lane

A sunny ride saw me attempt for the 3rd time the climbs of Star Hill, near Dunton Green, Kent and Rowdow Lane, near Otford.

I have done these twice before but earlier in the year when it was colder and I was on a heavier bike. The warmer weather meant  was on my much lighter Scott and partly as a result set PB on both climbs

I also had my Garmin Virb running so here's a couple of videos of the ascents:

Star Hill:


Rowdow Lane:


Both climbs feature in the Cycling Climbs of the South East, part of Simon Warrens' 100 Greatest Cycling Climbs series of books

Saturday, 11 February 2017

Strava Data Analysis - A PC Based Visual C# Solution - V1.1.0.8 - Updates Feb 1017

Updates of Note Dec 2017

Please see the latest version here: http://midlandscyclist.blogspot.co.uk/2017/12/strava-data-analysis-pc-based-visual-c.html


This post has some useful information but refer to the latest version above

Updates of Note Feb 11 2017
  • Detailed instructions on how to read data that was collected in your privacy zone (if you have set one)
  • Now reads power, temperature and smoothed gradient values in the stream data
  • Small other changes
Version 1.1.0.8 can be downloaded here: link

See other posts here: Post 1 and here: Post 2

After several internal versions and having got to the point to being able to extract and export "stream data" which I then viewed in Excel I realised that I was always missing the beginning and end of the data when I was looking at rides when recorded starting from home. It took a a while to realise that this was because I have set a privacy zone and the default Access Token only gives access to my public data. A lot of research and coding has so far failed to address this in any meaningful way. However I now understand the process and and have been able to get a method to give an Access Token for the full stream data. Its quite involved and is laid out as follows.

The first step is to go the the Authorisation page of your application:



In my case I have set the Authorisation Callback Domain as "localhost":


When I select the Authorise button Strava tries to open a  web page on localhost. This however causes an "404 - Not Found" error page to be opened as there is no server/application to respond:


However you do get back the interim token you need. This is shown in the page address bar of your browser:


You need to copy and keep this code - all the text after "&code=".

Next we need to send this code, together with the application ID and the"Client Secret" Token to Strava to get another Access Token which will be the one that we need.

The Strava API help pages describe this method using techniques I am not familiar with. It seem to use "CURL" which appears to be a means of sending web requests without a browser. I failed to achieve this with many iterations and trials.

I then found another method which was to create a small web page (local file) and open this page in your browser.

This is the code for the webpage:

<html>
<body>
<form action="https://www.strava.com/oauth/token" method="POST">
Client Id
<input type="text" name="client_id" value="YOUR_CLIENT_ID">
<br><br>
Client Secret
<input type="text" name="client_secret" value="YOUR_CLIENT_SECRET">
<br><br>
Code
<input type="text" name="code" value="CODE_FROM_PREVIOUS_STEP">
<br><br>
<input type="submit" value="Submit"></form>
</body>
</html>
 
You can dowload it from here: link

You then enter your client ID, Client Secret and the interim token above (I have obscured my private data in the screen shot below. Also as I iterated several times and then created the screen shots for this Blog later, the access token below is not the same as the screen shot above - but normally it would be)
   
 Paste in the access token and press Submit:
  
You'll then get a file back from Strava - save this file and then open it. In this instance it opened in Visual Studio so I assume that the ".json" extension is associated with this application:



The first response is a new access token (obscured in the screen shot above) which is for this user and allows access to their private data - its persistent so there's no need to repeat the process more than once as long as you keep the key (and in fact my application will store this in an .ini file). Copy and paste in to my application next time you run it.

I am looking at how to do this programmatically as this method is pretty user unfriendly.

Once I had the stream data I also found that 3 of the data streams for power, temperature and smoothed  gradient were not being acquired. Further analysis between the Strava documentation and the StravaDotNet packaqe suggested that Strava had altered the descriptive names of these 3 streams, namely from Watts to watts (power), from Temperature to temp and from GradientSmooth to gradient_smooth. I was using StravaDotNet as a "package" so it was a "black box" and I could not edit the code.

Whilst the source for StravaDotNet is supplied I did not know how to rebuild it as a package.

Some considerable iterations later I have worked out how to stop using it as a package and use the source files "as is". Once I had worked this out I could run through the source files and rename "Watts" to "watts" etc. Once I had made these relatively small changes (although a lot of work was required to get to that point) I could then get this previously missing data into the application. 

In this case I had written the code relatively well (I used a few classes) so extending the code to process 3 more streams was actually quite quick. Whether its well written code or could be better is a different matter of course

Further work:
Get the application to authorise directly without needing to do all the above
Filter data by activity type
Error checking
Some graphics
Get segments from an activity and segment data

Saturday, 7 January 2017

Strava Data Analysis - A PC Based Visual C# Solution - V1.0.0.6

See latest version here: link

Updated Version - V1.0.0.6

Please read this first post for instructions. This is needed to understand what the application does and how it works

The update is from my Google Drive here: V1.0.0.6

This version sees a number of updates:
  1. internally modified as to how the  data grid views are filled and managed. Later versions will use this further and provide additional functionality. For example exporting data is improved
  2. Added the ability to extract the raw time based data from a particular activity. This is the data that is collected during an activity. V1.0.0.1 generated a list of activities and the overall data from that activity
  3. Uses the activity data and generated a simple set of statistics
To set up and use the Application see the link above


To use the new activity data feature load in the activities in the date range required as before.
Select the activity that you want the data for
Double-click in the left most column of that activity and wait for a while. The tab "Activity Data" will contain the time based data and the tab "Activity Stats" will contain basic statistical data.


The Main Window

The Activity Data
Note here that for this ride I was not in my privacy zone so the data does start at 0 seconds. Also I started to ride then stopped and restarted. The Garmin will not log 0 speed so there is a minute "gap" in the time based data.

This exported data can the be plotted or processed in your favourite analysis tool. Here is an Excel version of the data:




The Basic Activity Statistics


Issues to be aware of:
  1. There's minimal error trapping at the moment.
  2. There's no progress indication so it might look like its hung - getting the activities over a wide date range can take quite a long time (depends on the number, connection speed etc.). This needs some improvement
  3. Your data will be exported in TAB separated format. This allows the application to retain commas if used in the activity name - i.e. "First Ride of the year, muddy" for example.
  4. If the activity name includes the " character this is replaced by the ' character -
    i.e. "First Ride of the year, to the "Big Mountain"" for example will be replaced by
    "First Ride of the year, to the 'Big Mountain'"
  5. When you export your activity data, if you have a privacy zones set up any data in this zone is not currently available.
  6.  The .Net Strava API I am using seems a little out of date. For example the official Strava API includes temperature, power etc in the streams. In the Strava API these are "watts" and "temp" but the .Net API refers to these as "Watts" and "Temperature", so even though the data stream contains the data it cannot be accessed. All the source code is provided so I suspect that I'll need to use it differently and modify the code to make it work. This looks "difficult" for someone of my current knowledge level, but is possible
Further Planned Improvements
  1. More fully test the deployment of the application and the installation process. I think the free version of Visual Studio is more limited in the respect
  2. Look for a better way to authenticate the application. Having to create your own application and paste in the token is pretty un-user friendly
  3. Using #2 get access to the private data to get a full data set irrespective of privacy zones
  4. Add simple graphs of activity data
  5. Add simple statistics and graphs of activities data
  6. Enable a means to filter activity types - i.e. Cycling, running etc, and where appropriate filter these further - i.e. for cycling split out rides and turbo trainers for example, or by year for activities
  7. Ability to delete data points where the data is redundant or un-representative
  8. Get more of the data available - so segments etc
  9. Bulk export of all activities or within a date range

Monday, 2 January 2017

WInter Riding

Here's a short video of climbing Rose Hill (almost the top of the Lickey Hills) near Birmingham

Starting in Barnt Green it climbs to the foot of the Hill and then in the mist drops back down the Old Birmingham Road

As with all my rides at the moment, slow and hard work:


My 2016 Year on Strava

Here's my 2016 Year according to Strava:

Click on the Hyperlink not the picture!



 And here is my Veloviewer infographic:

 

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.