PiMagic – About

Introduction to the PiMagic

Around 18 months ago, not long after getting my hands on the Raspberry Pi, I concluded that whilst this is a great, low cost computer which is great for educational needs and has the right level of power for a lot of my projects it’s rather lacking in the I/O department. Fundamental issues are:

3.3V logic at the I/O pins rather than 5V

No protection of the I/O pins – for educational use there will for sure be many dead-Pi’s

No analogue inputs

Generating PWM or using the one-wire protocol needs to be software driven (bit-banged)

Now this could be easily remedied with the addition of one of the commonplace add-on cards e.g. the Gertboard, but for me this has too much functionality, is too configurable (read complicated), is physically bulky and is expensive (relatively). An commonplace alternative solution is to connect an Arduino, but this is still a little bulky for some of my projects and uses up a valuable USB port (admittedly not such an issue on the new B+).

At the time therefore I set out to design what I now call the PiMagic.

Block Diagram

I decided that an Arduino clone was the way to go. Not only would the hardware be cheap and the part-count would be low, but also the board would be compatible with the plethora of shields and existing projects out there. All these shields and existing projects can now be expanded with the power of Raspberry Pi!

Having ruled out the use of USB, I decided that using the onboard UART was easier than SPI or I2C giving most flexibility with software and operating systems. In addition, one GPIO line is used also to provide a reset pulse allowing reprogramming of the Arduino software in-situ (if needed).

The block diagram shows that a level-shifter circuit is needed to convert between the 3.3V logic of the Raspberry Pi and the 5V logic of the Arduino world. A standard ATMEGA 328P is used (with Arduino bootloader for reprogramming over the UART connection) and running Firmata application software by default. The board uses a 16MHz resonator (rather than a crystal to keep the price low) and the footprint will be that of standard Arduino headers to allow plugging in of additional, standard shields.

Finally, a 250mA polyfuse is added in the 5V line, since a known issue with early Raspberry Pi’s is burning of PCB tracks through pulling too much current on the 5V line.

Overall with the fuse, the 328P and the polyfuse it should be pretty difficult to accidentally damage the Raspberry Pi when experimenting via the PiMagic board.

First Prototype / Proof of Concept

The first prototype was build on a prototyping board using a AdaFruit level shifter which worked well. The design was then refined and transferred onto a shield as proof of concept… see below…

The full schematic for the PiMagic is shown below (click to zoom)…

I first presented the shield briefly at Wuthering Bytes 2013 – here’s the slides which give an overview…

After laying out the PCB our good friends at Ragworm etched the prototype board…

It should be noted that there is an error on this board, which is reflected in the uploaded source files. The transistors Q1 and Q2 have the legends upside-down so please note this – if assembling a Rev01b board the flats of the transistors should go at the top and the centre leg needs to be re-formed with small pliers (fixing this is on the to-do list below).

You’ll notice that with a little careful placement I was able to free up enough board real estate to allow pass-through pads for all of the Raspberry Pi’s expansion connector and even a small prototyping area at the bottom.

Downloads: The full schematic and PCB layout can be downloaded from the GitHub repository right here.

28 pin DIL IC socket, 6 way header, 8 way header (2 off),10 way header, 13×2 way header (you may need to buy a 14×2 way header or two 14×1 trimming off one row)

and finally the PiMagic PCB

Assembly Instructions

Whilst assembling the Rev01b prototype I generated a time-lapse video.

Solder assembly is actually quite straightforward – as usual starting with the low-profile parts first (resistors) I then move through the IC socket, the LEDs (flat to the board), the transistors (after forming the legs with pliers), polyester capacitors, resonator, polyfuse (after straightening the legs – I know some will say the kink is there for a reason), the headers bottomside, the headers topside and last the electrolytic cap (being the tallest part). Finally soldering done I insert the pre-programmed ATMEGA328P and we’re all set to go.

When it’s all done it should look something like this….

Here it is installed on a Rev B raspberry Pi, and on a Rev B+. It’s compatible with both but of course doesn’t feed through the extra I/O port pins (and the mounting hole doesn’t align). Actually it sits rather well on the PIMORONI case.

Project Status & License

The project is mostly complete and the examples page shows some applications of the PiMagic in use. There are a few issues right now that need some more attention:

The hack to toggle port pin #4 during reprogramming with avrdude is troublesome and unreliable. This is maybe a timing issue with different revisions of Raspbian or could be to do with the requirements of the Arduino bootloader. This needs investigation but I’m not ruling out a customised version of avrdude rather than trapping for the DTR pin toggle in the OS and redirecting this to pin #4.

A small change is needed to the Q1, Q2 PCB layout – last time I trust someone else’s library – the pins are mirrored hence these transistors should be inserted upside-down compared to the silkscreen on the current (Rev01b) layout.

16 Responses to PiMagic – About

[…] one of those guys and has done something about it by creating a pretty neat solution he calls the PiMagic. It’s a Pi Plate that has an on board ATMEGA328 running an Arduino bootloader. The RaspPi and […]

[…] one of those guys and has done something about it by creating a pretty neat solution he calls the PiMagic. It’s a Pi Plate that has an on board ATMEGA328 running an Arduino bootloader. The RaspPi and […]

[…] one of those guys and has done something about it by creating a pretty neat solution he calls the PiMagic. It’s a Pi Plate that has an on board ATMEGA328 running an Arduino bootloader. The RaspPi and […]

[…] one of those guys and has done something about it by creating a pretty neat solution he calls the PiMagic. It’s a Pi Plate that has an on board ATMEGA328 running an Arduino bootloader. The RaspPi and […]

[…] one of those guys and has done something about it by creating a pretty neat solution he calls the PiMagic. It’s a Pi Plate that has an on board ATMEGA328 running an Arduino bootloader. The RaspPi and […]

Hi Jarek. I’ve just uploaded the latest Rev01c board files and the gerbers too. However please treat this as beta since I haven’t assembled/tested the prototype board just yet. This should be done in a couple of days.
Oh, and Rev01c is in Eagle 7.1.0 format.

All is ok.
Tried with Eagle 7.0, 7.1 and then 6.4 with errors.
Silly thing that github was the issue. Downloaded the master file for the repository and from there the board and schematic are ok.

On thing. I would suggest to put a diode to avoid charging the Pi through the GPIO 5V and 3.3V if someone wants to connect to the Pi Magic that consumes some more power than 1Amp and add a external power source to the 5V and 3.3V pins on the shield.

Glad you managed to get the Eagle files working. I’ll have to investigate just what’s going on there.

The diode sounds like a fine idea for an extra element of protection. I didn’t actually intend to ever power the PiMagic itself externally (only connected peripherals) but I could see that some might want to power that too. As a quick hack you could up-end one leg of the polyfuse and solder in a diode in series, but with a bit of shuffling I’m sure I could make space in the layout for a diode. I’d suggest a schottky (such as the 1N5817) to keep the volt drop minimal.

Started assembling my board.
Just one fast question that keeps me up sometimes.
Do You solder ‘bridges’ over the top/bottom layers to continue the paths ? You solder mainly on the bottom side but when checking the elements on top there is a path moving on top layer moving to different components.
Do I need to place some bridges to make sure the paths are continued or these are just some leftovers from measuring and development of the board ?

Good to see you’re building up a board 🙂
No, the PCB is double-sided so connections are made by the copper top and bottom. Sometimes signals are transferred from top to bottom by “vias” or small plated holes which have no components in them. There are no solder bridges to be made, so please don’t.

Great news! I still need to add some more info on other applications for the board, and indeed on how to reprogram the firmware in-situ from the pi. In the meantime remember to spread the word on this project 🙂