Tristate Multiplexing

Tristate multiplexing (or Charlieplexing) is a simple to use technique to expand the number of LEDs that you can light from a simple microcontroller. This post explores the concept, and looks at some interesting calculations we can do when thinking about them.

I’ve been meaning to get around to writing something of a tutorial on the basics of assembly programming using a PIC microcontroller for a while: and this post stared off as the first part of that… But then, in the best traditions of geekery, I got distracted by the interesting mathematics behind the scenes, and instead this post was born. But I’ve not given up on the idea and I will get back to that. Eventually. (But don’t hold your breath). Instead this post is written without any reference to any specific microcontroller architecture, and so you can use the ideas described here on a PIC, an Arduino, and it should even work on a Raspberry Pi (though I’ve not actually tried that yet).

To begin, let’s think about a simple situation where we have a microcontroller which we wish to use to control two LEDs. The simplest implementation is to use one of the microcontroller’s GPIO pins for each LED. This works well for a small number of LEDs; but very quickly gets expensive in terms of the number of pins it uses if you want more than a handful of LEDs; and depending on what else your microcontroller needs to do (and/or how many pins it has available to begin with) it soon becomes unsuitable.

The solution is to multiplex the LEDs – that is to say connect more than one LED to each pin, and use a combination of multiple pins to select the one we want.

Continue reading “Tristate Multiplexing”

GPIO with sysfs on Raspberry Pi (Part 2)

In my last post on using sysfs for GPIO on Raspberry Pi, I showed you how you can use the sysfs file system to manipulate the state of the GPIO pins.

This time, we’re going to explore how to do the same thing programmatically. I’m going to walk you through developing a C library to control the GPIO – but exactly the same principles could be used in any other language.

Why C? Well, mostly because I like C. But proficiency in C is useful if you’re going to be working with embedded systems, and microcontrollers; so it’s a good language to use. I’m also picking C because there are a lot of tutorials & libraries using Python – and few (if any) working with C. None of which is to say that Python isn’t a great language (and if you don’t know it – then I highly recommend learning it too).

Continue reading “GPIO with sysfs on Raspberry Pi (Part 2)”

GPIO with sysfs on a Raspberry Pi

GPIO_Closeup

The Raspberry Pi (in case you’ve been living under a rock for the last six-months) is a cheap ($25) ARM Linux computer, primarily designed to be used to help teach kids to learn programming & computer science.

It’s also makes a pretty nice alternative to something like a BeagleBone, if you’re looking to play with some embedded computing technology. Whilst it’s less powerful than BeagleBone (and has less GPIO connectivity), Raspberry Pi does have a few advantages. It’s cheap, and it has an HDMI output – meaning that you can interact with it directly, without the need to ssh in from another computer.

The whole ethos of the Raspberry Pi foundation is to make the device as easy to use as possible: to encourage children (and adults!) to play with it, and learn to program. As with Arduino though, this user-friendly layer doesn’t mean that you can’t get your hands a little dirty and see what’s going on underneath.

Continue reading “GPIO with sysfs on a Raspberry Pi”

MintyBoost

MintyBoost

The MintyBoost is an open-source, small form-factor, USB charger which runs on AA batteries – and lets you charge your mobile phone, tablet or other USB device, without the need for mains power or a computer.  It was designed by one of the leading proponents of the open-source hardware movement, LadyAda – aka MIT Engineering graduate: Limor Fried

All the details of the circuit can be found on the project’s web-site.

Continue reading “MintyBoost”