An interactive Advent calendar

Power

I used a simple 12V power supply and a converter module (OKL-T/1-W12N-C) that stepped down the power to the 5V needed by the Rasp Pi. However, with a 90  percent efficiency rating, it delivers 1A of electrical current. One ampere is not enough for the project envisioned here. In a worst case scenario, the LEDs alone can use up one-half an ampere. Consequently, I decided to use two converter modules.

This approach has the added advantage of avoiding harmful effects to the Rasp Pi that might otherwise be caused by power supply disruptions through parts like the servo- and stepper motors. The little computer will get its power via the GPIO pin.

The voltage converter module used here is a switch converter that takes the entire amount of voltage received and pushes it through in small packages. From one power supply that delivers 12V and 1A, then, I can get two separate 5V units that each produce 1A of current. If I use a linear regulator, I will actually need a 2A power supply, because the regulator converts excess power into heat.

A filtering RC (resistor-capacitor) circuit smooths the impulse frequency back into a clean voltage to achieve a reasonably useful voltage output. The circuit therefore undertakes something akin to a voltage conversion without losing power.

The output voltage may be adjusted over a limited range by connecting an external trim resistor (Rtrim) between the trim pin and ground. The trim is a combination of a 1.8Kohm resistor and a 500-ohm potentiometer, making it simple to adjust to 5V. The converter fits easily on a breadboard after some quick soldering of a header row (Figure  4). Adding a capacitor to the circuit layout serves to dampen any peaks in current that the motors may generate at times.

Figure 4: The voltage converter module solders easily onto a breadboard.

Setting Up the Rasp Pi

The operating system used in this project was an updated version of Raspbian  [2]. After downloading and unpacking the images, you should install the system on the SD card using the command:

$ sudo dd if=2014-06-20-wheezy-raspbian.img of=/dev/sdd

When you first boot the system, be sure to expand the filesystem in the Raspi-config configuration tool, change the password for user pi, and set the locale and keyboard settings under Internationalisation Options to match your location and computer. If you are running more than one Rasp Pi on your network, then you will have to change the hostname in the Advanced Options, and you should enable SSH here, too, to access your Pi remotely.

A restart accepts the changes you made. The IP address of the Rasp Pi is shown at the end of the boot information, or you can find it with nmap. Log on to the console using:

ssh pi@<RaspPi-IP>

Next, update the operating system via apt-get and download and set up the WiringPi library  [3], found on Git, to control the GPIO interface:

$ sudo apt-get update
$ sudo apt-get upgrade
$ git clone git://git.drogon.net/wiringPi
$ cd wiringPi
$ ./build

To determine whether the GPIO interface has been set up successfully, use the command gpio readall (Listing  1). The software displays the pin-out of the GPIO interface; you'll use this information later.

Listing 1

Reading the WiringPi GPIO Setup

$ gpio readall
 +-----+-----+---------+------+---+-Model B2-+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 1 | 11 || 12 | 1 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 1 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 0 | IN   | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 0 | IN   | CE1     | 11  | 7   |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |  28 |  17 | GPIO.17 |   IN | 0 | 51 || 52 | 0 | IN   | GPIO.18 | 18  | 29  |
 |  30 |  19 | GPIO.19 |   IN | 0 | 53 || 54 | 0 | IN   | GPIO.20 | 20  | 31  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+-Model B2-+---+------+---------+-----+-----+

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content