Thursday, September 26, 2013

mbedR3uino: mbed adapter for Arduino shields

The mbedR3uino is a vertical shield adapter for the mbed prototyping platform.  It provides compatibility with standard Arduino shields including the pins added to Arduino Uno R3 to make shields more independent between main boards.

This is the project I wanted three years ago.  Finally the need, inspiration, materials, and dependent projects converged.  The ability to easily add pluggable hardware to the mbed had been demonstrated when I created the In-between Shield for mbed which plugged into the mbed workshop board adding flash memory to the mbed which plugged into the shield. 

 
I have developed a number of prototype shields for Arduino using a ProtoShield that have been compatible with my various Arduinos, Netduinos, and other development boards providing plug compatibility with Arduino shields.  With the addition of the new R3 pins: SCL, SDA, IOREF some more platform independence has occurred allowing the shield (or at least its I/O) to run at the same voltage as the target platform, and a standardization of the location of the I2C pins.  The SPI pins which were originally reserved for ICSP or initial programming of the Arduino also became a standard.  I opted to skip the SPI/ICSP pin compatibility and stick with the Uno SPI pin layout for simplicity; a future version should include the SPI/ICSP pins in their expected location.  An R3 version of the ProtoShield was found here and I had seeedstudio build the PCBs.

The mbedR3uino is named because mbeduino was already taken.  Inserting the R3 in the name gives it some uniqueness while expressing its meaning.  The adapter consists of two pluggable pieces.  The first plugs into the workshop board above the mbed providing a footprint identical to the mbed.  Components were added to the ProtoShield to plug it into the first piece, and wire the connections to the Arduino R3 headers.  The result is that Arduino shields can be connected to the mbed.


Standard height 0.45" header pins were used to connect the ProtoShield to the above mbed adapter.  The above mbed adapter used taller 0.7" header pins so the PCB barely clears the height of the mbed, only touching the mini USB socket.  Since my prototyping boards have solder terminals only on one side, and to keep them clean looking I try to solder only on the bottom, hidden from view, I used needle nose pliers to push the pins so the plastic is flush with the top of the pins, and then carefully solder the pins from the bottom of the board not getting them too hot or the pin could waver out of place.  Once all the pins are soldered into place they hold very securely.

Note that the mbed workshop board or equivalent is required.  It already provides SD, Ethernet, and USB connectivity.  I have a revA board which pin 9 is held high to 3.3V (intended for SD card detect?), so to allow it to be used for the UART, I cut the trace on the workshop board.  An alternative to using the workshop board would be to have dual row headers and connect the columns for all pins 1-40, as done in my mbed Text LCD development board.  It is relatively easy to also solder a USB B connector, and an Arduino shield can be used for an SD card.  Connecting an Ethernet jack directly to the mbed can be done using a breakout board.

All the available pins on the mbed are either connected to the Arduino headers, or a few are broken out for additional expansion: since the workshop board already uses pins 5-8, they were left as an expansion; CAN and battery lines are implemented as jumpers for expansion.  Analog pins and power pins are where they should be, one UART is wired to D0/D1 for Arduino compatibility, and one SPI is wired for original Uno compatibility (D13-D10).  One pair of I2C pins are in the new R3 location, and the same pins are also wired to the same location as done with the Leonardo: D2/D3.  The remaining D14 and PWM pins are wired to the remaining Arduino header pins.  The schematic below shows how I chose to map the pins between the boards.

Schematic - Click on image to view larger

Saturday, September 7, 2013

3V-5V Switchable I2C Real Time Clock Shield


This is a prototyped Arduino shield that is 5V and 3V switchable.  The real time clock (RTC) is a DS1307 running at 5V, with a backup battery to keep time while not plugged into another power source.  It connects with an Arduino or similar board via I2C, but using a voltage translation (level shifter) circuit using FETs (reference: Philips) to isolate the RTC chip that always runs at 5V from the Arduino CPU which can be running at either 5V or 3V.  This provides support for 3V Arduino format boards such as the Arduino Due which can be damaged if 5V is applied to its lines.  Jumpers are provided to select the voltage (red), the I2C lines used (D3/D2 or A5/A4), and whether 3.3K pull-ups are used on the microcontroller side of the circuit.  Note the RTC always has its pull-ups in place.

Note that due to USPS regulations, Lithium batteries cannot (without meeting specific conditions) be shipped via US airmail so my Digi-Key order that included the FETs and crystal was revised to eliminate the batteries.  These are available cheap in bulk from many distributors, but to save immediate costs including shipping I ended up purchasing a single one at the local drug store.  Next time I may use ground shipping for such items, but I also found a local electronics supplier that has a decent price.
 
The DS3107 chip was purchased overseas via eBay as it was available much cheaper than domestically.  Hint: look for free shipping.
Schematic


A different 3V RTC chip could also be used, such as a surface mount chip, and then the level shifting circuit (FET drain/source) needs to be reversed per the original circuit recommended by Philips Semiconductors because the low/high sides of the circuit are reversed when the RTC is running at 3V and the microcontroller is running at 5V.
For prototyping the FETs ordered are in package TO92-3.  I ordered two different FETs and ended up using the more expensive ones with a higher Vdss rating (200V).  A cheaper FET in SOT-23 packaging with a lower rating of 50V was also sourced but not tested.
Adafruit has a tutorial including an Arduino library for use with the DS1307.  I tested this library on the Arduino Leonardo and Duemillanove running at 5V.  For the 3V Due, I used simple raw I2C (Wire library) commands to talk to the DS1307.  Only SCL1/SDA1 worked for me on the Due (had to jumper these as the ProtoShield is pre-R3 and doesn't have dedicated SCL/SDA pins).



(I had meant to publish this article in February but due to some bad soldering on my part and challenges with the Due, this prototype wasn't working properly.  Took multiple re-visits to fix everything.  Now I am very glad it is working now.)