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).

Block Diagram

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…

PiMagic First Prototype

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

pimagic rev4 schematic

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

The PiMagic Interface Board from croztech

First PCB (with error)

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

PiMagic PCB

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.

Parts List

R1………………….. 4K7 ,10%, 0.25W resistor
R2, R7, R8, R9…. 10K ,10%, 0.25W resistor (4 off)
R3………………….. 1K ,10%, 0.25W resistor
R6………………….. 22K ,10%, 0.25W resistor
R10………………… 12K ,10%, 0.25W resistor
R11, R12………….. 220R,10%, 0.25W resistor

(note that there are no R4, R5 !)

C1, C2…………….. 100nF, 63V polyester capacitor (2 off)
C3…………………. 100uF, 25V radial electrolytic capacitor

Q1, Q2 …………… 2N7000 N-channel MOSFET

Y1…………………. 16MHz ceramic resonator

F1…………………. 250mA polyfuse

LED1……………… 3mm orange LED
LED2……………… 3mm green LED

IC1………………… ATMEGA 328-PU microcontroller (with Arduino bootloader preloaded – “Standard Firmata” application is recommended)

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….

PiMagic on a Model B PiMagic on a Model B+

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:

  1. 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.
  2. 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.

Ohw-logo PiMagic is released as open source hardware – modifications, improvements and reuse are encouraged.   “Ohw-logo” by Brandon Stafford – http://oshwlogo.com/, http://www.oshwa.org/open-source-hardware-logo/. Licensed under CC BY-SA 3.0 via Wikimedia Commons.
Creative Commons Licence

PiMagic by @croz_tech is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


16 Responses to PiMagic – About

  1. […] 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 […]

  2. […] 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 […]

  3. […] 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 […]

  4. […] 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 […]

  5. […] 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 […]

  6. Jarek says:

    I love this idea. Unfortunately I ran accross a problem to get the PCB plans.
    Eagle 7.0 and 7.1 give an error that the files are not eagle format :S
    Any chance to get Gerber files ?

    • croztech says:

      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.

      • Jarek says:

        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.

      • croztech says:

        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.

  7. […] PiMagic to specjalna płytka dla Raspbery Pi, która pełni kilka funkcji: zabezpiecza piny GPIO, dodaje wyjścia analogowe, dodaje opcję podłączenia shieldów Arduino, oraz umożlwiwia podłączenie układu Atmega. Jako zabezpieczenia przeciwprzepięciowego użyto bezpiecznika polimerowego, który to jest element zabezpieczającym wielokrotnego użytku. Autorem projektu jest Steve Crozier,który zamieścił także krótki poradnik dotyczący użytkowania: PiMagic – Using it. […]

  8. Jarek says:

    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 ?


  9. croztech says:

    Hi Jarek,

    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.


    • Jarek says:

      It alive!
      Works well just now I need to get my head around the pyfirmata library.
      Again great job! Awesome project!

      • croztech says:

        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 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: