Blog Page

This, Jen, is the Internet

Matt 0 Comments

This isn’t much more than an “I made a thing” post. You have been warned.

The Internet!

I’m sure many of you are familiar with the iconic British sitcom “The IT Crowd”. There are so many memorable quotes and gags, but my favourite has always been “The Internet” from the series 3 episode “The Speech”. I liked the episode so much that I decided to build my own replica of the little black box.

The box was the hardest part to find. I recognised is as a Maplin project box, but Maplin are long gone from the high street, and the online incarnation don’t seem to sell them. Thankfully I never throw anything out, and I had one in a box in my garage that I bought years ago. The next step was to build a circuit that could sit inside the box – hence my renewed interest in the astable multivibrator circuit.


The circuit board inside the box was designed in Kicad. It measures 40mm x 40mm so is small enough to fit into many different project boxes and enclosures. I added M3 mounting holes to the corners, though in the end I didn’t end up using them when mounting the board inside the project box.

The board in Pcbnew, Kicad’s board layout view.

The component footprints are not included on the silkscreen. Ordinarily it is a good idea to include them if you have the space, but because I wanted to be able to select different component values for different flashing rates I left them on the fabrication layer. Having them already there means that should I decide to make a board where fixed values are required I can switch them back to the silkscreen layer easily.

The transistor, LED and capacitor component footprints are all customised. I wasn’t sure what transistor I’d end up using so instead of using one of the standard TO-92 footprints I created one that showed which pin should go where. This is useful because while some transistors like the 2n2222 are manufactured so that pin 1 is the emitter, pin 2 is the base and pin 3 is the collector, others such as the BC547 have the collector and emitter reversed. The pin pitch of the footprint is 1.27mm, so transistors can be soldered flush with the board. This is aesthetically pleasing, but can be difficult to solder.

The capacitor footprint has 3 pins, so that parts with a 2.5mm or 5mm pin pitch can be used. This was for my convenience, because most of the electrolytic caps I have have a 2.5mm pitch, but the multilayer ceramic caps I have all have a 5mm pitch, and I wanted to avoid bending the leads as much as possible.

The LED footprint is based on a standard footprint, but I added polarity markings so that if pin headers were used instead of soldering the LED directly to the board it would be easy to see which way round to plug the connector in.

The board mounted inside the box

To get the board to work with only one LED the second LED footprint must be shorted with a link. It is a good idea to use a higher value resistor between the voltage rail and the positive side of the shorted LED pad. This will limit the current through the transistor so that when the LED is off less current is being shorted to ground.

I used the following component values to achieve the short flash followed by a long pause:

R1330 Ω
R2470 kΩ
R31 MΩ
R447 kΩ
C11 μF
C210 μF

Lessons learned

This was a fun little project, and it feels good to get back to using KiCad again. Making my own component footprints was interesting, and I’m proud of how this board turned out.

The only change I would make if I was to have a second batch made would be to change the TO-92 footprints to ones with a pitch of 2.54mm. The transistors end up sitting higher on the board so they aren’t as aesthetically pleasing, but they are much easier to solder. I did design an alternative version of the board in Kicad, but I haven’t bothered to get it manufactured.

A render of the version of the board with 2.54mm spacing between the transistor legs.

I was going to use stand-offs to mount the board inside the box, but I didn’t have any plastic ones that I could glue to the bottom plate. Instead I used double-sided tape strips. It’s not ideal, but I didn’t want to screw through the bottom of the box.


If you want your own astable multivibrator PCB I’ve included download links below for the Kicad project and gerber files for both versions of the board.

Gerbers (1.27mm TO92)
Gerbers (2.54mm TO92)
KiCad Project

The Astable Multivibrator

Matt 0 Comments

One of the first circuits I ever build on a breadboard was the ubiquitous astable multivibrator. Two NPN transistors, two capacitors, two LEDs and four resistors. It’s a circuit that just about every electronics engineering student and hobbyist builds at some point in their life. Sure, a 555 in astable mode uses fewer components, and is much more flexible, but unless you know what happens inside that little 8 pin black box it may as well be magic. The classic astable multivibrator has no tricks hidden away – it’s all there for you to poke at and and analyse.

Schematic of the astable multivibrator

How It Works

The circuit takes advantage of the imperfections inherent in all electronic components. Every component of a given type is slightly different due to factors such as the manufacturing process and the raw material used. This can be undesirable in some situations, but it is essential in the case of the astable multivibrator.

When power is first applied current flows to the bases of both transistors through R2 and R3, charging C1 and C2. As soon as one of the capacitors reaches the base emitter saturation voltage of the connected transistor (around 0.6v depending on the transistor used) it will go into saturation and turn on.

Let’s assume that it is Q1 that goes into saturation. It will turn on and allow current to flow through it, turning on LED D1. While this is on, capacitor C2 starts charging up through resistor R4 and LED D1. Meanwhile, C1 will begin to charge through R2.

As soon as the voltage across C1 reaches the base-emitter saturation voltage of Q2 (again, around 0.6v) it turns on Q2, lighting up LED D2 and causing capacitor C2 to discharge nearly instantly. This causes the voltage on the opposite side of C2 to drop considerably, bringing the base of Q1 below 0.6v and turning it off.

Now capacitor C2 starts charging up via R3 and C1 starts charging up to 5v. Once the voltage across C2 reaches the emitter-base saturation voltage it turns Q1 back on, discharging C2 and turning Q2 off.

The whole cycle repeats as long as the circuit is powered.

Choosing Component Values

The oscillation frequency is determined by the values of resistors R2 and R3, as well as capacitors C1 and C2. The total period of oscillation (T) can be determined by adding together the periods of time that each transistor is switched on. These values (t1 and t2) can be calculated using the following formulas:

T = t1 +t2
t1=0.693 x C1 x R2
t2=0.693 x C2 x R3

All time values are in seconds, all resistor values are in ohms, all capacitance values are in farads.

0.693 is derived from the RC time constant, or τ. At 0.693 of one time constant the capacitor is at 1/2 of its maximum charge.

Finding the frequency (ƒ) of oscillation is a simple case of finding the inverse of T.

ƒ = 1/T

Using the schematic above, where C1 and C2 are 47 μF, and R2 and R3 are 47 kΩ, we can calculate the frequency with the following equations:

t1=0.693 x 0.000047 x 47000 = 1.530837
t2=0.693 x 0.000047 x 47000 = 1.530837
T = 1.530837 + 1.530837 = 3.061674
ƒ = 1/3.061674 = 0.326618706 Hz

Resistors R1 and R4 should be of a lower value than resistors R2 and R3. When the circuit is being used to flash LEDs then a value should be chosen based on the forward voltage and operating current of the LED. If not using LEDs in the circuit then keep the resistor values of R1 and R4 lower than R2 and R3. If you choose values that are too high the circuit will not oscillate.

See the table below for a pre-calculated table of frequencies and component values.

Capacitor Values
1 nF10 nF100 nF1 μF10 μF
Resistor Values
1 kΩ724.638 kHz72.464 kHz7.246 kHz724.638 Hz72.464 Hz
2.2 kΩ329.381 kHz32.938 kHz3.293 kHz329.381 Hz32.938 Hz
4.7 kΩ154.178 kHz15.418 kHz1.542 kHz154.178 Hz15.418 Hz
10 kΩ72.464 kHz7.246 kHz724.638 Hz72.464 Hz7.246 Hz
22 kΩ32.938 kHz3.294 kHz329.381 Hz32.938 Hz3.294 Hz
47 kΩ15.418 kHz1.542 kHz154.178 Hz15.418 Hz1.542 Hz
100 kΩ7.246 kHz724.638 Hz72.464 Hz7.246 Hz0.7246 Hz
220 kΩ3.294 kHz329.381 Hz32.938 Hz3.294 Hz0.329 Hz
470 kΩ1.542 kHz154.178 Hz15.418 Hz1.542 Hz0.154 Hz
1 MΩ724.638 Hz72.464 Hz7.246 Hz0.7246 Hz0.0725 Hz

What can I use it for?

The most basic use of this circuit is to blink one or two LEDs. I built one up on stripboard when I was quite young and used it to flash two LEDs back and forth on my model railway level crossing.

Another use would be to connect the emitter of one of the transistors to the bass of another transistor. This allows the circuit to switch higher current loads, such as a relay.

It is also useful as a basic tone generator. To do this, connect a speaker instead of a relay to the configuration and swap the capacitors for two 47nf capacitors. This will output a tone that is roughly 700 Hz.

More to come…

I encourage you to build up the circuit on a breadboard and see what you can come up with. In my next post I will be showing a project I have built using the astable multivibrator at its core.

Cheetah SpecDrum 808 Kit

Matt 0 Comments

I’ve been playing around with the SpecDrum again and I’ve created another kit for it. You can get 808 sounds any number of ways in 2019 – The TR-8, sample packs, iPhone apps – and now the Cheetah Specdrum.

Unfortunately my real SpecDrum isn’t working so well right now, so I’ve had to emulate it. I think the caps need replacing on it because its output is very distorted and it keeps dropping out.


Demo song TZX

Loading your own samples into the Cheetah SpecDrum

Matt 10 Comments

Back in the 1980s in the UK the Sinclair ZX Spectrum reigned supreme as the king of the home micros. Sure, it didn’t have all of the bells and whistles that other micros of the time had, but it was cheap, and required nothing more than a portable TV and a cheap cassette deck to unlock hours and hours of fun.

My Spectrum with its SpecDrum.

It didn’t take long for folks to see the potential in the machine, and before long they were making it do weirder and weirder things. One of my favourite devices to stick on the back of my Speccy is the Cheetah SpecDrum – a little box that turns the Speccy into a drum sequencer. Released in 1985, the SpecDrum cost a mere £29.95 (£89.29 in 2018 money) compared to the cost of a full blown drum machine which could cost 10 times that.

Originally the kit came with a pretty bland sounding set of samples; the sort of thing you’d expect from a LinnDrum or similar. Cheetah then released 3 further cassettes with Afro, Latin and Electo sounds. There was a rudimentary kit editor included in these add-ons, but it only allowed swapping sounds from the same slot, and had no function to add custom sounds.

There’s not much inside the SpecDrum; just a Ferranti DAC, a quad op-amp and a quad NOR gate chip.

I bought my SpecDrum years ago, and played with it for about a week before putting it away and forgetting about it. The problem wasn’t the clunky interface or the lo-fi sound quality – it was that the sounds were all quite dull and dated. Unless you really want to make music that sounds like lost Human League demos then you’re a bit stuffed.

I decided to find a way to solve this problem. It’s quite long-winded and there are a few steps required, but this blog describes how I managed to do what I suspect nobody has done before – loaded their own sample data into the SpecDrum software.

Peeking in the memory

First job was to find out how the thing was storing its samples in memory, and where. Using the FUSE emulator, which very handily emulates the SpecDrum hardware, I loaded up the software and used the memory explorer to look for clues. There was nothing obvious, so I used the debugger to look at the Z80 machine code as it was running. The software doesn’t directly read from memory to the SpecDrum’s DAC – instead it sums each of the active voices, converts them from a signed number to an unsigned one and then spits it out of port 0xDF. I decided to dump the RAM and load the raw data into Audacity, which handily allows the import of raw data. Bringing it in as 8 bit signed samples I was able to actually play the drum samples in Audacity. I tried a few sample rates, but eventually 20 kHz sounded the closest to the output of the SpecDrum. I’ve since learned that the SpecDrum software sends an OUT instruction every 173 T states, which works out at 20.231 kHz – thanks to djnzx48 over at the forums for that brilliant piece of info.

How the samples are stored

The way the samples are stored is slightly strange. The first oddity is that the drums are stored out of order, but only just. Sample 2 through 8 are in order, and then sample 1 is tacked onto the end. The second oddity is that while the samples are of a fixed length, some samples are 3072 bytes, whereas others are 2048. There doesn’t seem to be any means of adjusting these sample lengths either, as the tapes that contain the additional kits have only contain the sample names and the raw sample data. Sample data starts at 0x8400 (33792 in decimal) and the block is 21504 bytes long.

The SpecDrum software groups the drum channels into three groups. It can play one sound from each group at a time, but not more than one from each group. This poses some limitations on what you can do with the SpecDrum, but the official kits are laid out in such a way that it’s not much of an issue. For example, Open hat and closed hat are in he same group, and you’re not likely to want to use both of those sounds at the same time.

The table below shows how each of the base kit is stored in memory, and which group each drum is part of. I’ve used decimal to show the memory addresses as this is most useful when putting sample data together in Audacity.

Drum NoGroupMem. Offset
Length Standard Kit
3230723072Mid Tom
4261443072Lo Tom
63112642048Hihat C
73133123072Hihat O

Preparing samples in Audacity

Let me be up front about this – Audacity is a pretty terrible audio editor. The interface is awful and it’s not very flexible. One very strong advantage it has though is that it import and export raw PCM samples without the header portion. The other advantage is that you can set the sample rate to any arbitrary value.

The settings I use for bringing in raw sample data

Importing raw sample data is very simple. From the File menu choose Import and then Raw Data. This is useful if you want to grab a copy of any samples from the existing sample tapes. The settings you need are pictured here. Signed 8-bit PCM, Little-endian, Mono and a sample rate of 20231 Hz. This isn’t super important so long as the project sample rate matches the rate you import at, but setting it to 20231 means that what you hear coming out of Audacity should match what you will here coming out of the SpecDrum.

If you’re starting a project from scratch you need to do a few things before you import your own samples. First of all, at the bottom of the window set the project sample rate to 20231 Hz and right click the three position counters and set them to “samples”. This helps when lining up your imported samples.

The next step is importing audio. You can do this by using the Import Audio tool in the File menu. Most samples will either be 44.1 kHz or 48 kHz, and may be in stereo. In order to use them with the SpecDrum you need to either discard one channel or mix the sample down to mono, and then resample the audio to 20231 Hz. Audacity has the functions to do these for you in the Tracks menu.

Once the audio has been resampled it can be trimmed to the right size. I do recommend sticking to the groupings laid out above if assembling a drum kit, as it makes the most sense from a polyphony point of view.

The way I assembled the Toybox kit is I imported each sample onto their own separate tracks and edited them down to size. For some samples a fade-out was required. Then I copied each one to a “master” track, making sure that the sample boundaries lined up with the memory offsets detailed above. The final track should be 21504 samples long.

When exporting the audio it is a good idea to knock the gain down a bit. The SpecDrum uses a relatively simple means of summing the samples together. Rather than clipping the output “wraps around” and can make unpleasant clicking noises. I also added a slight -6db roll off at 7kHz to kill off any high frequency noise that might cause aliasing.

Export the audio using “Other uncompressed files” as the file type, RAW (header-less) as the header type and “Signed 8-bit PCM as the encoding.

Getting the samples back in

The first way I got my own samples into the SpecDrum software was to use the “Import Binary Data” feature in FUSE. This reads the contents of a file and puts them into the memory of the emulated Spectrum. Provided the samples you created were of the right format and length you should just be able to import the file from Audacity to memory address 33792. The drums won’t have custom labels or anything like that, but if all you’re interested in is proving the concept then congratulations – job done. This was the way I first managed.

The real goal was to be able to use the kit load feature of the SpecDrum software – as this would let me load in my own kits on my real Speccy.

The way I did this was to look at the Afro Kit tape and try to understand how the data was stored. To do this I opened a TZX tape image of the Afro Kit tape in a tool called ZX-Blockeditor to view the structure of the tape. The TZX consists of two blocks; a header with some text in it and the raw sample data stored as unsigned 8-bit samples. The header file contains the names of the drums as they appear in the software. The file must begin with a lowercase c, and then each drum must have a seven character label. Any spare characters must be padded with spaces. Strangely, unlike the sample data stored in memory, these labels are in the correct order as they appear in the software.

Below are the header portions of the Afro Kit tape and my Toybox tape.


Prepare the header in your text editor of choice and save it as a .bin file.

In ZX-Blockeditor create a new file and under Edit choose “Compose Data Block”. Then choose “Custom Data” from the pull down menu and then use the little folder icon to import your prepared header file.

I’m running ZX-Blockeditor using Wine on a Mac, so it looks pretty rough. On Windows it looks a lot smoother.

Repeat the steps above for the raw sound date, but this time use standard data instead of custom data.

Save the TZX and you’re done. Congratulations – you just created a drum kit for the SpecDrum!


SpecDrum Toybox (TZX)
SpecDrum Toybox (raw TZX blocks as templates to work from)

Introducing the RC2014

Matt 1 Comment

Until earlier this year my idea of building my own computer was screwing a bunch of parts into a case and wiring everything together – the most complicated tool required being a crosshead screwdriver. This changed when I found Spencer Owen’s RC2014 project.

The kit is available in a few different forms, but I bought the “full monty” version – an 8-slot backplane with modules for the CPU, clock generator, RAM, ROM and serial interface. Notice that there’s no video interface – more on that later.

The machine is based on a Zilog Z80 CPU; the same processor used by the Sinclair Spectrum, Amstrad CPC, TRS-80, MSX and countless other classic computers. There is a whopping 32 KB of RAM to play with, and the system is clocked at a blistering 7.3728 MHz.

The kit comes with every component you need as well as comprehensive build instructions. The modular nature of the kit means you don’t have to tackle the 400+ solder joints all in one go. Thankfully everything is through-hole mounted, so although there’s a lot of soldering at least it isn’t horrendously small stuff. There’s very little to do in the way of configuration. The instructions tell you which jumpers to set for default operation, so provided you’ve not messed up with the soldering you should be able to switch it on and get started with Microsoft Basic version 4.7.

To use the RC2014 you’ll need a PC or Mac running a terminal emulator program and a USB serial adaptor with a standard FTDI-style 6 pin plug. Make sure your software is configured for 115200 baud, 8 bit data, no parity and 1 stop bit. Flow control should be disabled. Under Windows you can use PuTTY or Tera Term. Linux users can use something like Minicom from within the terminal. The computer doesn’t plug directly into a display, although there is a module available that uses a Raspberry Pi Zero as a terminal emulator. This gives you a HDMI-enabled “video card” along with a keyboard interface.

The base kit is a great way to get started with homebrew computing, and because it uses a backplane there are plenty of options for expansion. Spencer has a range of additional boards on his Tindie store, and there are many third-party modules available online. I’ll be talking about some of my boards in a future post.

Simple Digital Noise Generator

Matt 0 Comments

Here’s a little noise-making circuit I’ve been working on. It has a sound reminiscent of vintage sound chips, such as the AY-3-8910.

It works by using a D flip flop clocked by a 555 timer to sample and hold the signal from a ring oscillator. The high speed and frequency instability of the ring oscillator (close to 4 MHz) makes an ideal noise source, and the variable sampling frequency affects the frequency content of the noise.

This is a good example of the Nyquist theorem in action. As the clock rate of the 555 is lowered the high frequency content of the noise disappears. There is naturally a lot of aliasing, as this is a 1-bit signal, and there is no reconstruction filter on the output, but the frequency roll-off is still clearly audible.


Parts list


CD4070 XOR Gate (IC1)
NE555 Timer (IC2)
CD4013 D Flip Flop (IC3)
LM386 Audio Amplifier (IC4)


1 kΩ
1.5 kΩ
10 kΩ
100 kΩ Log. Potentiometer


10 nF (x2)
220 µF

Planning circuit layouts with DIY-LC

Matt 0 Comments

At some point there will be an Arduino project that is just too good to take apart. You can’t leave it on the breadboard forever, but building a circuit on prototyping board can be confusing for beginners.

The best way to make this process easier is to plan the layout of your circuit before you start building. I used to use graph paper to do this, but then I found a great free tool called DIY-LC.
Read More →

Arduino Tip: 7 segment LED display with 4094 shift register

Matt 0 Comments

This is my first Arduino example sketch – hopefully the first of many.

This sketch allows you to control a 7 segment LED display using an Arduino and a 4094 shift register. Only 4 data pins are used on the Arduino, rather than 8 if you were to control the 7 segment display directly. For this example I used a common cathode LED display.

Simply copy the code below into the Arduino IDE, build the circuit explained in the notes and watch the numbers count up.

Arduino 7 Segment Display

Read More →