My Humax YouView box died recently and I’ve had a craving to build a new DVR, I’ve still the tuners left over from my previous HTPC the JukeboxHD.

For frequent readers you’ll know I’ve been trying Linux more and more so to start with I tried building a Kodibuntu based HTPC using an old laptop.  After a few days of playing I still couldn’t get my tuners to be picked up so decided to give Mediaportal a go.  I used this on my first HTPC way back when with some success but never for live TV, I have to say it’s come along a great deal as within 20 minutes I was watching live TV from my old HD HomeRun tuners.  I decided that before taking the plunge, and waiting for payday, I ran on the old laptop for a few weeks to make sure it was stable and it was.

It would also give me a few weeks to research the latest options in embedded motherboards as I’d like to build the whole thing, including the case, to replace my now deceased set top box.

Simple requirements; Small, low power (consumption), and fanless.  To use my existing HD tuner, a Blackgold BGT3620, it would also need a PCIe slot.  Functionally it would also need to be able to record a couple of TV channels at once while watching a movie.

After a bit of hunting I came across the ASRock Q1900TM-ITX, a fanless quadcore Baytrail-D motherboard in the Thin-ITX format.  This is the same 17cm x 17cm base as Mini-ITX however this board is only 20mm or so tall!  For a low profile HTPC build it’s difficult to beat.  I was concerned about performance but then came across this video of the Mini-ITX version of board running Windows 8.1 and Mediaportal, it booted to MP so fast I was convinced;


For software, Windows 8.1 and Mediaportal 1.11 and the final hardware specs are;

  • ASRock Q1900TM-ITX
  • Corsair Vengeance 8GB RAM (low voltage)
  • Seatgate 1TB SSHD
  • Blackgold BGT3620 tuner
  • Silicon Dust HDHomeRun (first gen)
  • Microsoft eHome IR transceiver

The case is going to be custom built, the design has already begun but more on that in a later post, but for now I can say that boot times are around ~25 seconds from cold to Mediaportal’s homescreen and I can record six shows while watching HD video (1080p) over the network.  Already exceeded expectations and I’ve not even started tinkering yet! For those curious; all six channels were SD, CPU was just over 50% and it was using ~21Watts according to my power measuring plug.  It also using ~21Watts when idle which I need to figure out too.

I have to say, after being initially worried about a Baytrail board I’m not worried any more!

As the case isn’t built yet the “Woody” is currently sitting naked on my coffee table.  The name comes from the design of the new case but I can’t resist double entendre!

The components currently lack a case, I tend not to let that stop me!
The components currently lack a case, I tend not to let that stop me!

For those curious as to how thin Woody’s board is, have a look at it compared to my workphone;

Samsung Galaxy S4 on the left, ASRock Q1900TM-ITX on the right.  Considering one is a full PC motherboard the difference in size is impressive.
Samsung Galaxy S4 on the left, ASRock Q1900TM-ITX on the right. Considering one is a full PC motherboard the difference in size is impressive.

All in all, happy so far and can’t wait to get the case built!  It will involve a laser cut transparent lid and 3d printed brackets for the tuner.  I figured it a good excuse to learn a few new tricks along the way.

Stay tuned for more!

Unity UI for DeskCycle Arduino Speedometer

[Updated, see end of article]

Since my last post I’ve improved the Arduino speedo code to respond to requests and also tweaked the gear ration to be a bit closer to my road bike.  I’ve also implemented a simple speedo interface using Unity.

Unity DeskCycle Speedometer
Unity DeskCycle Speedometer

The Unity application also automatically searches the COM ports on the machine until it finds the Arduino speedo, it’s a bit hacky but works and means I don’t have to implement a COM port selection UI.

I’m going to add functionality to save off the readings to CSV log files too, at a later date I’ll add some kind of analysis in but getting the data saved is the important thing for now.

Update:  CSV functionality has been added and I’ve tweaked the interface too.

DeskCycle Arduino Speedo
DeskCycle Arduino Speedo Interface

For the Arduino portion of this weekend long hack, see here.

Arduino Speedometer for the DeskCycle

All my previous jobs were based in the town I live in so I used to be able to cycle to work, with my current job it’s far enough away I can’t reasonably cycle to work.  As such, and as the company is jokingly referred to as the “Cake-apult” for the amount of cake we seem to go through, my weight has inevitably increased.  To try and remedy this I’ve recently purchased a DeskCycle.  I would like to give a walking desk a go at some point but this seems a far easier solution and as sitting down for extended periods is linked to many problems I figured it worth a go.

It arrived earlier this week and I managed to cycle while sat at my desk for over two hours each day, I felt knackered by the end of it so it was certainly having an effect!  The only issue for me is the speedo.  The creators of DeskCycle designed the device such that the speedo is accurate when the resistance is set to maximum, this results in the speed and calories calculated too high if you have the resistance set lower.  They provide a calorie calculator to provide a more accurate set of results once you’ve punched in the values your speedo provides.

On to the how;

Looking at the bike it looked like the speedo works in the same way to the speedo on my road bike, a switch is closed once per revolution of the flywheel.  I connected my multimeter to it in continuity tester mode and it confirmed my theory.  As the bike uses a 3.5mm headphone jack for a cable it was simple enough to make a cable to connect to the header on my Arduino.

DeskCycle/Arduino Speedo Cable
DeskCycle/Arduino Speedo Cable

The cable has a 3.5mm headphone jack at one end, tip and ground in use, and a pair of header pins at the other.  Connected to the Arduino via a bit of breadboard, I’ve connected using pin 7 in pullup mode with the other end of the switch connected to ground.

DeskCycle/Arduino Speedo Pinout
DeskCycle/Arduino Speedo Pinout

Once connected I’ve followed the timer tutorial provided by Amanda Ghassaei to calculate the RPM by counting the interval between revolutions.  One thing I learned is that the millis() function uses timer0 internally so if you want to use that function and a timer interrupt then use timer1 or timer2.

The code can be found on github in the dcspeedo repo.

DeskCycle/Arduino Speedo Debug Screenshot

Next up is a simple application that reads the RPM and calculates speed and distance to display it on my PC to start with.  I’m intending to add some cool functions like map integration to do virtual challenges such as Lands End to John O’Groats and similar which should be good for a laugh.

Also, this same code will be the basis of the digital speedo adapter for my Mini so two birds with one stone!  As practice for my Mini speedo, and more practice for stuff for work, I’m going to write it using C# and Unity 5.

Update:  The Unity part is done, more information here.

Ending Illegal Fishing Using Games Technology

As we’ve just had our big media launch of the project I thought I’d share some information about the project I’ve been working on as part of my job at the Satellite Applications Catapult here in the UK.

For the passed 18 months we have been working on a project with Pew Charitable Trusts with the goal of building a system to use satellite derived data to track and deter illegal fishing at sea. Around one in five fish sold today is illegally caught so it’s a certainly a big problem to tackle.

Our system uses a live feed of vessel positions, currently provided by ExactEarth, using satellite AIS (Automatic Identification System) combined with a few other data sources to create a near real-time and historical view of fishing activity around the world.

We’re using the Unity games engine for data visualisation and as the interface to the system, both on our video wall and desktop machines, and we have a tablet version in the works. The video wall runs at 11536×3252 and Unity runs a treat!

We’ve a lot of vessels tracked at any point in time, all of which are rendered and animated on the screen at an accelerated rate for analysis. We are building the system using MMOs as inspiration as we’ve all seen how it’s possible to organise and work in a large group of people in raids to achieve a common goal. Having analysts working globally with large sets of data, it seemed a good model of interaction to follow.

A few screenshots and a video of the software in action are below, as the son of an engineer and ecologist I’m happy to say I’m proud of the work we’re doing and this is only the beginning!





A full screen, compressed, screenshot from our operations room running the Virtual Watchroom software as part of Project Eyes on the Seas.
A full screen, compressed, screenshot from our operations room running the Virtual Watchroom software as part of Project Eyes on the Seas.

More information on the project, can be found here;

We’re considering doing a live presentation of the system in a few weeks using Twitch or similar, if anyone would be interested in a demo or if you’ve any thoughts or comments please feel free too leave them below.


Dad’s Clock

Work has been mental for a few months so despite doing odds and sods on Hugo and a buttload of work on our illegal fishing project at work (hopefully more on that soon) I’ve not posted anything in a while so thought I’d post about a clock I’m building for my Dad.

My dad’s an engineer, heavy fabrication mostly, designing and building access platforms for the nearby oil refinery for over 40 years and since he drove me school on my first day on his crane he’s been a big influence.

Dad's Crane

As a reference to his engineering heritage and my current work  with satellite data I’m building an Arduino based clock that uses the GPS time signal to set the time and uses a set of voltage panels as the face.  The GPS receiver is the Adafruit Ultimate GPS board and I’m using a DS1307 based board for the real time clock.  The Ultimate GPS board is a bit OTT but it does allow me to receive a time signal indoors, as I only need one signal to get the time rather than the multiple signals needed for a full fix it works quite well.

The code is a work in progress but you’ll find it on my github page.

Project Hugo – The What

In my previous post I covered why I want to modernise my Mini and in this post I want to cover some of the intended mods.  Some are simple, some are sensible and some are downright bonkers and I intend to tackle them in that order!  As I’m still driving my first car, second if you don’t count the POS I had for a few weeks, I’ve never really had mod cons other than in rentals!  A ’96 Vauxhall Corsa Merit by the name of Neville, normally aspirated 1.7D that came with a radio, not even a cassette player!  I intend to make up for this with gusto.

The original vague plan to modernise the car was to add little mod cons here and there that modern cars have like central locking, an alarm and electric windows and for ICE I figured a Bluetooth/DAB head unit would do the trick.  I’ve since decided to build a full digital dashboard, replacing the analogue instrument cluster, and designing a system that wouldn’t look out of place in a car of today.

I started with this idea back when I though implementing CAN was a good idea but I’ve since learned how much of a pain wiring looms are so sod that!  Rather than replacing the loom I’m going to integrate with the existing, replacing the control switches in the dash with solid state relays to enable computer control but maintaining the original wiring loom.  This gives the benefits of modern control but better still keeps the original design in place so I can still ask for help from Mini experts.

The basic architecture of the system will be a microcontroller board monitoring and controlling car systems in real time and a PC based interface to act as the interface.  This gives the benefit of a real time monitoring system that comes online very quickly but can hand that information to a PC which has the power to do something with it.  Speed, tachometer, temperatures and the existing instruments will all be consumed in various manners by the microcontroller, likely an Arduino, then transferred to the PC using serial.  This project will only metaphorically fly but will share learnings from an earlier project.

The Toys


The PC will very likely be one of the Intel NUC machines, with a Core i5 processor, up to 16GB RAM and HD 5000 graphics it’ll be more than fit for purpose.  Another bonus of these machines is that they have very low power requirements for the spec and can run off 12-19V, with a DC-DC PSU they are ideal.


For screens I’ve decided to go big or stay home, to that end two iPAD retina screens will be repurposed and embedded in the dash; one as the instrument cluster and another as a secondary screen in the centre for navigation and entertainment purposes.  The screens in question should be powered by the Oscar adapter, an open source controller board that is ideal for my needs as it is based on Arduino and give full control of screen brightness, with a light sensor this means I can adapt the screen brightness to ambient conditions and not be blinded while driving late at night.  Plus the resolution and pixel density is astonishing for the price and as they are designed for tablet usage the power requirements are tiny too!


For Entertainment I’ve decided not to bother writing an MP3 player interface for it and will instead give it two main sources; Radio and an external player.  For DAB I have purchased a Monkey Board, it’s an open source DAB/FM receiver designed for hobbyists to build their own digital radios and the holy grail for Car PC enthusiasts!  For the external player I’ve a Bluetooth module which supports hands-free calling and A2DP, at a tenner it’s a no brainer.  I’m also going to have a line in socket so that anyone in the car can easily hook up and play their tunes.  A computer controlled input switch should do the trick to get the audio from these devices to the PC and from their to a 4ch car amplifier.


Doing all this and leaving the engine as is would be daft, the car currently has it’s original 998 engine coupled to a four speed box.  On top of the stage 1 kit my friend Chris fitted I’m planning on moving up to stage 2 or 3 and replacing the gearbox with a five speed option, likely from Minispares.  Their five speed boxes have a standard ratio for gears one to four, giving the standard acceleration curve for the car, but the fifth gear is an overdrive gear and takes the stress off the engine while cruising.  They are ideally suited for the smaller engines so should be a good combo and make motorway driving a lot easier.

The Grand(er) Plan

All of the above is pretty mundane and doable, now we get to my aspirations.  Starting with a simple idea that everyone takes for granted; an auto-choke.


Like all old petrol cars, my Mini has a choke.  As I’ve been driving a diesel for 14 years this is a new concept to me and after researching how they work, should be easy to automate.  A choke controls the fuel/air mix into the engine to allow more fuel into the engine when you first start it to allow it to warm up, as it does so you let the choke out and allow more air into the engine.  As my setup will have a temperature sensor in the engine and as I’ve access to 3d printing kit I’m going to make an actuator that hooks into the end of the choke cable and automates this process.

Climate Control

Yup, I’ve set myself the challenge of installing not air-con but a climate control system.  This precedent has kind’ve already been set as the Japanese model Minis had aircon units as an option with a chiller unit mounted under the passenger side of the dash.  Rather than follow this model I’m intending to source a combined cooler/chiller unit, one of these to be precise.  It’ll be a tight fit but by replacing the fan switch with a relay or other driver and using a similar actuator as the autochoke for the heater cable I reckon it’s doable.  Mounting the plumbing may be tricky but as there are already Minis with aircon they have proven it can be done, I just need to figure out how.

Computer Vision

I’ve been interested in robotics since the first time I saw Transformers and computer vision technology has always intrigued me.  To that end I’m going to use Open CV along with a slew of camera to enable lane tracking along with vehicle and obstacle detection.  There are loads of examples of this already working so I’ll not be starting from scratch.  The Core i5 should now make a lot more sense!


I work for the Satellite Applications Catapult and the biggest project I’ve worked on thus far involved making lots of interactive maps.  As such, it would be rude not to integrate satnav into the system really!  Not sure what tech I’ll be using yet but I’ve plenty of ideas and options.

Thermal Imaging/Night Vision

Yeah, why the hell not?  Modern cars have night vision as an option and KITT could see in the dark so why the hell not?  For night vision I have the simple option of a modified webcam with the IR filter removed, coupled with halogen headlights that throw out a lot of IR this should give a longer view of the road at night than my eyes can pick up.  For seeing through fog, I’m thinking a PathfindIR should do the trick.  This will be a hell of an expensive upgrade though so definitely the last item to be added, if ever!


That’s the plan, ambitious as all hell!  I’ll be starting with the microcontroller as knowing how fast your going and how much fuel you have left is key and then building up from there.  More details on each item as I build, and inevitably rebuild, each part!

Project Hugo – The Why

I’ve been planning the restoration of my classic Mini, which goes by the name Hugo, for years now and he is finally road legal!  The only issue is that a few days after this happened the wiring loom burned out…  While waiting for the new loom to be delivered my friend Chris has been doing some work on the shell to replace a few rusty panels and I’ve been researching some of the things needed to get my dream car up and running.  Before getting into the how of the project I’d start with the what and why, to that end I figured a post on the history of the project may be in order.

I’ve wanted a Mini my as long as I can remember and decided to buy myself one for my 30th birthday, a friend of a friend had a Mini 30 for sale for a decent price and that’s that!  The initial plan was to cram a VTEC engine in there, an idea my 15 year old self had after reading of one of the first conversions in the mid 90s in MiniWorld Magazine and as look would have it I knew someone who had a VTEC for sale, which I bought.  For three years the engine and car sat in my garage gathering dust, I’d bitten off far more than I could chew.

Earlier this year I decided it was time to crap or get off the pot;  The complexity of the build was daunting, so much so I didn’t know where to start, so I hadn’t.  To that end I decided to ditch the engine swap, sticking with the original, and concentrate on getting the car on the road then seeing what happens.  The long term plan has always been to modernise the car which was part of the reason to go VTEC, so I figured I’d stick to that idea and attempt to rebuild the car as if it was designed now rather than then.  Same engine but tuned and made as reliable as possible.

There are many purists out there that will balk at what I’m intending to do, taking the Mini and tweaking it here and there, and that by modernising it I’m making something that isn’t a Mini any more.  Here’s the thing;  The Mini has been hacked since day one, it has a long history of modifications, tweaks and rebuilds and without this spirit of tweaking we wouldn’t have the Cooper, the history of rallying and hell, even the Italian Job!  The heart of the Mini would remain but modern conveniences would be introduced.

“Modern conveniences” started with central locking and electric windows; it’s since grown to include a full digital dashboard, an auto-choke of my own design and thermal imaging.  More on this and the mechanical mods planned in an upcoming post.

So, that’s the why of the project.  TLDR; Because I can.

Reverse Tunnels and RaspBMC

I’m once more dabbling in Linux at work so figured I’d give RaspBMC another go with my new knowledge of Linux troubleshooting workarounds…

First of all I thought I’d have a play with SSH so set up a reverse tunnel to access my Pi remotely.  I followed the same steps in this article to no avail;

If I ran the script manually I could create the tunnel no problem, it just wasn’t being created automatically which was a pain.  Turns out that RaspBMC disables cron out of the box so this needed to be re-enabled;

Last of all I found that, as before, my Pi keeps randomly hanging requiring a reboot.  A friend of mine introduced me to the hardware watchdog on the Pi that can be used to reboot if the device goes unresponsive and so far so good;


That’s all for now, the new wiring loom is going in the Mini soon though so expect more automotive posts soon!

Geoserver, Leaflet Angular Directive and viewParams

Catchy title, I know…

In the big GIS project I’m working on we have a large set of data, 100 million rows+, which needs to be rendered as an overlay.  This turned out to be tricky as I’m not really a GIS developer and learning as I go. I figured it out through trial and error so I’m writing this post to help those like me, hopefully I’m using the correct keywords I was looking for so that SEO picks this up!

Our frontend architecture is as follows;

To create the tiles in Geoserver we ended up creating a parametric SQL layer, more info on that here, and we are adding it as a WMS layer.  What I discovered in the end is that to pass the viewParams through to Geoserver you need to add a layerParams option with viewParams within it, for example with start and end as SQL parameters;

layerParams: {
    viewParams: "start:'2014-01-01T00:00:00.000Z';end:'2014-01-31T00:00:00.000Z'"

In a WFS call the equivalent would be to append the following and one thing to note in both cases is to properly escape the characters;

Hope this helps!