This webpage keeps a record of some of the miscellaneous projects, mainly electronics and computing, that I work on now and then, and also provides an access point to live data feeds from some of my projects.

Raspberry Pi Laser Engraver and Drilling CNCs

From several disc drives and a floppy disc reader, that had been discarded, I salvaged, resoldered, and reprogrammed the stepper-motor controlled linear drives to allow programmatically controlled precise movement. By mounting two of these linear drives perpendicular to each other, I was able to accurately control the position of each of the X and Y axes. By attaching a pen to one linear drive, I was able to start using this simple 'plotter' to draw some basic shapes.

In the early days of this plotter, I programmed shapes by typing numbers into the code by hand, sometimes drawing out the shapes manually and using a ruler to measure the dimensions I was trying to replicate. The quality of this plotter was very poor, but given it had been built entirely from either parts found at a local tip, or lego, with many hacks to get things working I was pleased to get any sort of result at all.

The four-phase stepper motor is a common sight in consumer disc-drives, to date I've probably disassembled a dozen and all but one have used a stepper motor combined with a worm gear to slide the carriage back and forth. To control them myself I resoldered new wires onto the motor and used an L293D dual H-bridge driver to control the sequence of pulses for each axis.

By writing some very basic drawing software in java, that exports a file similar to G-code readable by a control script for the Raspberry Pi, I was able to turn these linear drives into a simple, but reasonably accurate, CNC drawing machine.

One of the first plots I tested was a basic sinusoid, to test the capabilities of the CNC when plotting both curves and straight lines. I later made a standalone python script that could process and plot monochromatic bitmap images directly, which allowed the printing of more complex images, and I tested this by printing off several crests and emblems.

Although my first plotter worked very well, I had basically rebuilt the printer except with a far more convoluted and less effective design, and whilst being a fun gimmick it had limited practical use. I felt the ink pen was limiting the possibilities of my design, so I decided to upgrade the pen to a laser. I purchased for around £25 a 200mW 650nm laser module - the diode was housed in a heatsink and had focusable optics - which I powered with an ATX power supply, salvaged from the same discarded PCs as I got the disc drives. I managed to get some great results burning away into some old cardboard, although the laser had no problem scorching wood either.

The final step of this small scale CNC was to modulate the laser using PWM, and to alter the speed of the lower tray to achieve a different intensity of burn as desired. This allowed the processing of greyscale bitmaps, culminating in a very nice laser-engraved cardboard Mona Lisa.

For the time-lapse of the laser CNC printing out Mona Lisa, and some footage of how the CNC works, please see the videos below.

After the success of the small scale CNCs, I decided to set to work on building a full scale version capable of wielding a rotary tool to engrave and/or cut a wider range of materials. This next iteration was also built from scrap, this time mostly using discarded printers instead of disc drives. This whole CNC was extremely economical using almost entirely recycled parts, with my only purchases being the rotary tool itself (a cheap Dremel knockoff from Amazon for £11) along with three stepper motors (£1.75 each), 20 ball bearings (£3-4), some threaded rods (£2), and miscellaneous nuts and bolts. I also built a much more sophisticated control script, that runs in python and is able to interpret G-code files to control the CNC accordingly.

The (outdated, see below) code for the G-code interpreter can be found here.

As can be seen from the video above the scrap-based full-scale CNC was functional, but had several systemic problems due to its bare-bones design. As such I decided to up the ante a little bit, and after buying some rectangular metal bars to use as rails, wooden planks for the frame of the CNC, and a few other miscellaneous bits and bobs I was able to put together a more sophisticated CNC that was not limited by my working with scrap materials. Many, many, failed designs, ball bearings, and trips to B&Q later I eventually came up with a working design which I replicated on each axis of the CNC, to build a functional large scale milling machine.

The much updated and far more sophisticated python program to control the full-scale CNC can be found here.

My first full scale tests of the new CNC are now on Youtube and they worked fantastically! More to follow in the next couple of weeks...

Orbital Mechanics Simulation

Having taught myself Java from programming books, I decided to take crash Advanced Higher Computing Science in my final year at school. The coursework for the qualification, which constituted 60% of my final mark, was by far the largest and most sophisticated programming project I had done at the time, and consisted of an orbital mechanics simulation based game, where the player must fly around and avoid gravitational wells, passing through goalposts to complete each level.

The .jar file to run the program, and the source code for the project, can be viewed and downloaded here.

One of the most interesting aspects of this program was just how realistic the incredibly simple physics simulation was, the data was sufficient that basic signal processing techniques could be used to analyse the simulations afterwards. By logging the simulated position and velocity as the player traversed the gravitational fields, some interesting results were plottable;

I later reprogrammed some of the core orbital mechanics code in the simplified-Javascript educational tool from Khan Academy, which provides a very nice interface with which to mess around with simulation parameters, and has proved fun to play around with.

By expanding my code to simulate the gravity of not just one entity (the player), but instead n arbitrary entities, I was able to achieve a simple N-body simulation. I was inspired to do this after the detection of gravitational waves by LIGO. Some of the results of this more general simulation were very aesthetic; here three clusters of entities collapse into one and coalesce together under their own force.

Finally, I wrote an Android version of the N-body simulator, which can be used to replicate the same coalescence simulation above. This app is published on the Google Play Store, which (so far) has been received positively by users. The Google Play listing can be seen here. I wrote this software when I was fairly new to programming, and may go back and do a rewrite at some point, rewriting the gravitational computations using a method other than the simplistic O(n2) 'brute force' calculation method.

Weather Station

In autumn of 2016 I built a small solar powered Arduino based weather station, to log temperature, humidity, and air pressure. Once stored, the data can be viewed on this website, providing a live feed.

Live weather feed is still living on the old server HERE.

Here is an image of the first build, about to begin testing:

The components on-board are:

Several issues exist with the weather station to date; the clear acrylic causes a major greenhouse effect, when it gets humid, the humidity is often exaggerated, and will frequently max the sensor out to it's highest possible reading. When the the station is in direct sunlight (which is good for the solar panels!), the same issue affects the temperature. On sunny days, large spikes can be seen at the time of day when the sun shines onto the weather station. The location of the station is limited as the low power of the transceiver requires reasonable proximity to the 'base' transceiver, located inside in a Raspberry Pi.

Hybrid Rocketry

I have been building hybrid rocket engines from time to time for several years now, all of which have been mounted statically and tested in place; I am more interested in the engineering of the engine than actually launching metal projectiles into the sky above residential Edinburgh, which, for obvious reasons, isn't a good idea. I started off small, using simple aluminium tubes loaded with polythene as fuel, and gaseous oxygen from a small oxygen tank designed for use with a welding torch, as oxidiser. There are several videos of these early burns on my Youtube channel.

My latest hybrid rocket iteration is a much larger motor, with a 30mm diameter, 1.5mm thick mild steel tube making up the main body of the rocket, and stainless steel hip flask and kitchen funnels providing the divergent/convergent shape for the all-important nozzle. The nozzle assembly is sealed together using exhaust paste, designed for sealing up cracks in car exhausts at high temperatures, and I my educated guess is that the key areas (mostly around the nozzle) that will get the hottest during a burn, should be able to withstand temperatures of around 1000'C. This design may seem excessive, but after previous rockets failed due to the aluminium body melting, or softening to the point of structural failure, these measures are likely to be necessary.

I have only conducted one full test with this larger rocket to date, and sadly the paraffin wax I was using as fuel had such a low regression rate that it burned far too slowly to produce any serious thrust, even with high energy fuel additives in the form of powdered Aluminium and/or Magnesium. Rather underwhelmingly the fuel just melted, and wax poured out the nozzle before it could burn. However, I have now received a delivery of pelleted polythene fuel, which I expect will burn far more vigorously (the granulated nature of the fuel should make a big difference, due to the increased surface area).

Before I run the burn with the plastic fuel, I plan on setting up a proper 'newtonmeter' to measure the thrust produced by the rocket. Proper meters for measuring force this way are very expensive, and will provide an unnecessary quality for my needs, so for a mere £4 I purchased a very basic set of scales, which I plan on mounting in such a way that the rocket thrusts onto the scales, and gives a measurable reading. In future rocket tests that I perform I will set up a camera to record the analogue reading from the scales, and extract quantitative values from it after.

Raspberry Pi

Almost all of my hardware related projects have involved a Raspberry Pi at some point: I use them as controllers for my CNCs; a Raspberry Pi is the base transceiver for my weather station (which communicates station in the garden); this webpage used to be hosted by a Raspberry Pi - in fact this page itself was just a side project after I setup the original Raspberry Pi server to allow me to remotely use WakeOnLAN with my main PC.

Since my original Raspberry Pi server was running 24/7, I thought it would be fun to setup some sort cooling system to monitor the temperature - although the low power chips on the Pi are unlikely to ever overheat unless under serious load, possibly while overclocked. I used the GPIO of the Pi, along with the CPU temperature and a basic transistor driver circuit to control a fan from an old computer with a Python script to achieve very low level control of the temperature.

The Pi server setup (with the weather station transceiver), and a graph showing how precisely the temperature can be set to a desired level, are shown below.

I am upgrading this old Raspberry Pi to a newer one very shortly - I have carried out a similar hack to add a fan to the new one since the old one just looked so adorable with it's mini fan on it, and will update this section in due course as I upgrade the server.

Miscellaneous Projects

Stepper Motor Music

As an early test of the stepper-motor powered linear drives used in the small CNC, I programmed the stepper motor to step at specific microsecond timings, and so to step at specific frequencies. This timing control enables the vibrations from the motors to target exact pitches, and so musical notes to be played. By hard-coding the timings of "Still Alive" from Portal, I was able to run a short test and play some music. I plan on making a python script to parse a MIDI file to play notes on the full sized CNC at some point in the future.

The old and inefficient code for this project is here.

Programming IR LEDs as Remote Controls

Using an Infrared LED desoldered from a discarded remote control, I programmed an Arduino to emit the modulated hex code signals required to control my monitor.

Arduino code for this project here. (This does not include the java script that converts the hex signals available on the internet into raw microsecond pause time data)