Communicating with a CAN bus through an LPT printer port

… because, why not?

A few months back, I found myself in a position where I needed to develop a proof of concept for a CAN bus data logging system, but the hardware hadn’t been finalised. At the time, there were talks of using x86-based hardware, which would eventually communicate with the CAN bus via an SPI CAN controller. Unfortunately the dev board was on back-order and I wanted to keep the project moving. Continue reading

Tasks: A Time-Triggered Scheduler for Arduino

This has been a long time coming. A few years ago (back in 2012!) I wrote a basic TT scheduler which was really more of a ‘proof of concept’ and not really friendly for an everyday Arduino user. It relied on a strong knowledge of C or C++ and needed Eclipse with an Arduino plugin to get it to work. I’ve promised myself since then that I’d  write a proper Arduino library to demonstrate time-triggered scheduling to Arduino IDE users as well as learning some C++ skills for myself. Continue reading

Printing to a Polaroid Pogo printer from any device via dropbox on Windows

So I’m currently planning my wedding, so it’s only apt that I talk about one of the mini projects that I’ve been working on. It involves a little Bluetooth printer, and difficulties in printing from iOS devices.

Continue reading

Accurate timing for smaller embedded projects


Previously, I have talked about high-precision, multi-task execution on an arduino / AVR based microcontroller.

But what if you don’t need a scheduler? What if you’re only doing one thing, and all of your functionality can easily be fit into a tick period of 5 or 10 ms, but you still want the timing precision to say “These operations will be executed every x ms, and take no longer than x microseconds”. Of course, on a reasonable-sized micro, you could use a TTC scheduler such as the one described in my previous posts, and only have one task, but what if you can’t afford the additional overhead of running the scheduler. If your project calls for a small 8-bit, 8 MHz micro such as the Microchip PIC12F family, you’re limited in both the code space, and processing power. You need to completely strip down the time-triggered philosophy to its bare bones Continue reading

Cloud Robotics Hackathon: Day 2

Today, in short, I made the robot work as a roamer. I’ve been chasing bugs all day, but finally got it working (almost) exactly how I want it. The video below shows how it was this afternoon, I’ve since tweaked some parameters and ironed out some bugs in the CAN transmission side of things so it now doesn’t get confused when it enters a wide open space with all the sensors reading maximum range. Continue reading

Further task scheduling with Arduino / AVR

** EDIT 27/04/2016: I have now created a ‘user-friendly’ library compatible with the Arduino IDE **

** EDIT: I have now added the code for this to a git repo here. **


My previous post on this topic showed a simple time triggered task scheduler for the Arduino / AVR microcontroller platforms. Although this worked very well, there were some areas which could be improved in the way the scheduler worked. To recap, the previous scheduler worked as follows:

How it worked:

  • The program sits in an empty loop when idle.
  • “Ticks” are generated by the timer driven interrupt.
  • Tasks have a period and an offset:
    • Period – How often the task is executed
    • Offset – The first tick in which the task is executed
  • The period and offset of the tasks are adjusted manually to spread the tasks out, ensuring that tasks don’t collide.
  • The ISR iterates through each task in the schedule and executes any task that is ready to run.
  • Doing this ensures that tasks are executed with precise timing (as precise as the ATMEGA timer allows). Continue reading

Reliable task scheduling with Arduino / AVR

** EDIT 27/04/2016: I have now created a ‘user-friendly’ library compatible with the Arduino IDE **

***Please note: This article is now for background information only. The code in this article has been revised, and can be found here. ***


There comes a point, when writing embedded software, where you need to time the execution of tasks more precisely than just having a list of functions in a loop. In order to make a system as predictable, and therefore reliable, as possible it is desirable to use a time-triggered scheduler. If you are unfamiliar with this concept, I recommend you have a scan of Dr Michael J Pont’s Patterns for Time Triggered Embedded Systems, and watch some of his lectures.

The idea is to use a small-scale operating system that runs on a microcontroller, using timer interrupts to execute tasks with microsecond precision. This isn’t a new idea; the aerospace industry have been using this approach for years to stop their aircrafts from making ‘premature landings’, but it’s rare to find it implementated on hobby-centric platforms such as Arduino. So I thought I’d have a go at writing my own. Continue reading

The Beatles: Hey Jude in C (Programming)

Bit of fun for a Saturday afternoon… This afternoon’s procrastination was sparked off this morning when I logged in to Facebook. Someone had posted this fantastic flowchart of the Beatles’ Hey Jude lyrics:


I immediately realised that if the song structure can be put into a flowchart, it can be coded. I’m always looking for fun ways of practicing my programming, and this was suitably humorous and trivial! So I fired up Eclipse, googled the lyrics and got writing. Continue reading

12-zone perimeter detection from 6 ultrasonic sensors

The proximity sensing in ‘An Accident Waiting to Happen’ was done by a PICAXE 28X2 microcontroller, reading 6 Devantech SRF-10 ultrasonic sensors mounted around the perimeter of the table. The PICAXE board was programmed in PBASIC using their proprietary IDE. The detection cones of the 6 sensors overlapped slightly, so there were area where an observer would only be detected by one sensor, and also areas in between these where they would be detected by 2 sensors. This gave us 12 ‘zones’ in which to detect objects. Proximity readings were taken by the 6 sensors in sequence, and this was output to the PLC as a 4-bit parallel signal representing which zone had the closest object. Continue reading