Code and Life

Programming, electronics and other cool tech stuff

Supported by

Supported by Picotech

DipTrace and PCB manufacture with Olimex

It’s time to wrap up my DipTrace tutorial series with a brief look at how to do Design Rule Check (DRC) with the PCB layout tool, and generate gerber files for board manufacture. Take a look at the previous part on how the board was done.

I chose Olimex PCB prototype service because it’s very inexpensive by itself: 30€ for a two-side 160x100mm euroboard plus 5.50€ for shipping. They also can panel your designs and I counted that 16 ATtiny2313 headers would fit into a single board while still leaving room to cut them apart. Read on what was needed to make sure my PCB design was ready for manufacturing!

Design Rule Check (DRC)

The first thing before ordering was to investigate Olimex requirements for the boards. I knew I had no overlapping drill holes and had taken care to use only drill sizes supported by them (35 and 39 mils), so the most important ones for me were:

  1. At least 8 mils spacing between tracks/pads
  2. At least 8 mils for pads (i.e. 16 mils larger pad than drill hole)
  3. Less than 20 % of area without solder mask
  4. Over 500 drill holes costs a bit extra

Read post

Benchmarking Raspberry Pi GPIO Speed

UPDATE2: You may also want to check out my Raspberry 2 vs 1 GPIO benchmark!

UPDATED: 2015-02-15! This article has been very popular, so I’ve now updated all the benchmarks using the latest firmware and library versions. The scope has also been upgraded to a PicoScope 5444B with better resolution and bandwith than the earlier models. :)

main2015

Don’t try this at home! Shorting GND and VCC with a probe might fry your Pi and more!

Method and Summary of Results

The basic test setup was to toggle one of the GPIO pins between zero and one as fast as possible. GPIO 4 was selected due to easy access and no overlapping functionality. This is basically the “upper limit” for any signalling one can hope to achieve with the GPIO pins – real-life scenarios where processing needs to be done would need to aim for some fraction of these values. Here are the current results:

Language Library Tested / version Square wave
Shell /proc/mem access 2015-02-14 2.8 kHz
Shell / gpio utility WiringPi gpio utility 2015-02-15 / 2.25 40 Hz
Python RPi.GPIO 2015-02-15 / 0.5.10 70 kHz
Python wiringpi2 bindings 2015-02-15 / latest github 28 kHz
Ruby wiringpi bindings 2015-02-15 / latest gem (1.1.0) 21 kHz
C Native library 2015-02-15 / latest RaspPi wiki code 22 MHz
C BCM 2835 2015-02-15 / 1.38 5.4 MHz
C wiringPi 2015-02-15 / 2.25 4.1 – 4.6 MHz
Perl BCM 2835 2015-02-15 / 1.9 48 kHz

Shell script

The easiest way to manipulate the Pi GPIO pins is via console. Here’s a simple shell script to toggle the GPIO 4 as fast as possible (add sleep 1 after both to get a nice LED toggle test):


#!/bin/sh

echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction

while true
do
	echo 1 > /sys/class/gpio/gpio4/value
	echo 0 > /sys/class/gpio/gpio4/value
done

Read post

Raspberry Pi Serial Console With MAX3232CPE

In addition to the audio, video, network and USB connectors, the Raspberry Pi also has 26 GPIO pins. These pins also include an UART serial console, which can be used to log in to the Pi, and many other things. However, normal UART device communicate with -12V (logical “1”) and +12V (logical “0”), which may just fry something in the 3.3V Pi. Even “TTL level” serial at 5V runs the same risk.

So in this short tutorial, I’ll show you how to use a MAX3232CPE transceiver to safely convert the normal UART voltage levels to 3.3V accepted by Raspberry Pi, and connect to the Pi using Putty. This is what you’ll need:

  • Raspberry Pi unit
  • Serial port in your PC or USB to serial -adapter
  • MAX3232CPE or similar RS-232 to 3.3V logic level transceiver
  • 5 x 0.1 uF capacitors (I used plastic ones)
  • Jumper wires and breadboard
  • Some type of female-female adapter

The last item is needed to connect male-male jumper wires to RaspPi GPIO pins. I had a short 2×6 pin extension cable available and used that, but an IDE cable and other types ribbon cable work fine as well. Just make sure it doesn’t internally short any of the connections – use a multimeter if in doubt!

The connections on Pi side are rather straightforward. We’ll use the 3.3V pin for power – the draw should not exceed 50 mA, but this should not be an issue, since MAX3232CPE draws less than 1 mA and the capacitors are rather small. GND is also needed, and the two UART pins, TXD and RXD.

Read post

Raspberry Pi arrived today!

A rather long wait ended today, when DHL dropped this little package off at work in the morning. I had placed my Raspberry Pi order in the first 24 hours when they started taking orders (or actually, registrations of interest) from RS Components, but it took about two months for me to receive the invitation to order, and three more weeks for the order to arrive.

Opening up the box, I was greeted with a very small computer, and two small leaflets, a quick start guide and a regulatory and safety pamphlet. The board is really quite small, just a few millimeters larger than a credit card. Two USB slots, HDMI, coaxial and stereo audio plugs and micro-USB for power, plus an ethernet jack.

I ran a quick test to see if everything worked. Initially, there was flicker on my projector (the only device with native HDMI input I currently have), but that turned out to be incompatibility with the HDMI switch I had – without it it worked just fine. I used the premade Debian image on a SD card and it worked perfectly.

Read post

USB HID keyboard with V-USB

There still seems to be a lot of traffic to my V-USB tutorials, so I thought I’d write a short follow-up post on USB keyboards. I already did a USB HID mouse post earlier, so you might want to check that out to understand a bit about HID descriptors and associated V-USB settings (in short, human interface devices send a binary descriptor to PC telling what kind of “reports” they send to the host on user activities).

As a basic setup, you’ll need a working V-USB circuit with one switch and one LED attached. Here, I’m using ATtiny2313 with the LED wired to PB0 and switch to PB1. The ATtiny is using 20 MHz crystal, so if you’re following my USB tutorial series and have that circuit at hand, remember to change that frequency in usbconfig.c before trying this out. Note the cool breadboard header I have, there will be more posts about that one to follow soon!

Read post

Repairing a Shuttle motherboard with new capacitors

Just a short post today, in case this will save someone’s day like it did my friend’s. He has a small Shuttle PC setup that suddenly stopped working about three weeks ago – the machine seemed to power up, but no picture came to screen. After some googling, he found out that the motherboard of this specific MB+case combo sometimes dies because of failed capacitors. And indeed, the biggest caps on the MB seemed to have a slight bulge on the top. So he called me if I could help him to replace them, to see if that would help.

The first thing to do was of course procure similar caps. The possibly failed models were three 1500 uF, 10V caps, so I got four new ones to replace them.

Removing the old caps

The first task was to remove the old capacitors from the motherboard. Because we wouldn’t be needing them, we used some force and cutters to first remove the capacitors themselves, and then set out to remove the legs with a solder iron. Unfortunately, the lead-free solder had a melting point beyond the number 7 tips of my Weller Magnastat, and no amount of heating was able to remove the legs!

Read post