Friday, December 28, 2012

Calunium: version 2

Calunium v2
Calunium version 2. Click on the image for an annotated version.

Features

  • ATmega1284P microcontroller with 128 KBytes flash memory, 16 KBytes SRAM and 4 KBytes EEPROM, SPI and I2C buses and 2 UARTS.
  • Shield-compatible with Arduino Uno revision 3, with extra I/O laid out to be compatible with Arduino Mega pins. Pin mapping is chosen for maximum compatibility with Uno.
  • Jumper-selectable 3.3 V or 5 V operation; selected voltage is available at the IOREF pin to enable shields to operate at the correct voltage.
  • I2C (SDA/SCL) mapped to dedicated SDA/SCL pins and the standard location used by the Arduino Mega but jumpers can be used to replace A4/A5 with SDA/SCL signals for compatibility with older Arduino shields.
  • Second UART (D1, D2) signals also mapped to corresponding location on Arduino Mega (TX1, RX1).
  • ISP header in standard location, allowing the Arduino ethernet/SD shield to be used.
  • D13 LED connected via FET to avoid loading D13.
  • Real-time clock (e.g, DS1307, DS1338, MCP7941x). Output square wave can be routed to D6 (INT2) or D15 (TOSC1, for input to timer/counter 2). Battery backup from CR2032 battery.
  • Micro-SD socket for additional data storage. Uses SPI bus (D11, D12, D13), chip select is D22. If card is fitted then 3.3 V operation is required.
  • Hope RFM12B radio module for communication. Uses SPI bus (D11, D12, D13), chip select is D14 and interrupt request is D6 (INT2, can be disconnected by removing a jumper). Requires 3.3 V operation; Calunium can be powered from 5 V provided that the RFM12B is not used.
  • Power from USB or FTDI connector.
  • Switches, connectors and USB socket located outside of the standard Arduino shield footprint so they do not interfere with shields and are accessible when shields are fitted.
  • Auxiliary power connector; connect your own voltage regulator or boost converter. 5 V from USB (FTDI and/or USB connector) and 3 V from RTC battery also available on the connector. For easy prototyping add your own power adaptor.
  • Auto-reset can be disabled by removing jumper.
  • Pads to fit LM61 temperature sensor.
  • Usable PCB-mounting holes.
  • JTAG header for debugging/programming.

Bootloader

Either the Optiboot or xboot bootloaders can be used. My preference is for xboot as explained in a previous blog post.

About the name

As Arduino is an Italian project, this project takes its name from the Roman name for Lancaster, Calunium, where the design of this clone originates.

Open source

Hardware
The Eagle PCB design files for Calunium are available on Github and are licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.

Software
Files to allow Calunium to be used with the Arduino 1.0 IDE are available on  Github and are licensed under the Gnu General Public License v2.

Peripherals pin mapping

PeripheralPinFunction
LED13
Temperature sensorA6
A7
Power
Output
Real-time clock*D6/D15Square-wave output/alarm
microSD card22Card select
RFM12B radio module6
14
Interrupt request
Select
* Also uses I2C bus (20, 21).
** Also uses SPI bus (11, 12, 13).

Microcontroller pin mapping

PinArduino Uno (Atmega328P)Calunium (Atmega1284P)Arduino Mega2560 (ATmega2560)
D0PD0 (PCINT16/RXD)PD0 (PCINT24/RXD0/T3)PE0 (RXD0/PCINT8)
D1PD1 (PCINT17/TXD)PD1 (PCINT25/TXD0)PE1 (TXD0)
D2PD2 (PCINT18/INT0)PD2 (PCINT26/RXD1/INT0)PE4 (OC3B/INT4)
D3PD3 (PCINT19/OC2B/INT1)PD3 (PCINT27/TXD1/INT1)PE5 (OC3C/INT5)
D4PD4 (PCINT20/XCK/T0)PB0 (PCINT8/XCK0/T0)PG5 (OC0B)
D5PD5 (PCINT21/OC0B/T1)PB1 (PCINT9/CLKO/T1)PE3 (OC3A)
D6PD6 (PCINT22/OC0A/AIN0)PB2 (PCINT10/INT2/AIN0)PH3 (OC4A)
D7PD7 (PCINT23/AIN1)PB3 (PCINT11/OC0A/AIN1)PH4 (OC4B)
D8PB0 (PCINT0/CLKO/ICP1)PD6 (PCINT30/OC2B/ICP)PH5 (OC4C)
D9PB1 (OC1A/PCINT1)PD5 (PCINT29/OC1A)PH6 (OC2B)
D10PB2 (SS/OC1B/PCINT2)PB4 (PCINT12/OC0B/SS)PB4 (OC2A/PCINT4)
D11PB3 (MOSI/OC2A/PCINT3)PB5 (PCINT13/ICP3/MOSI)PB5 (OC1A/PCINT5)
D12PB4 (MISO/PCINT4)PB6 (PCINT14/OC3A/MISO)PB6 (OC1B/PCINT6)
D13PB5 (SCK/PCINT5)PB7 (PCINT15/OC3B/SCK)PB7 (OC0A/PCINT7)
D14-PC7 (TOSC2/PCINT23)PJ1 (TXD3/PCINT10)
D15-PC6 (TOSC1/PCINT22)PJ0 (RXD3/PCINT9)
D16-PC5 (TDI/PCINT21)PH1 (TXD2)
D17-PC4 (TDO/PCINT20)PH0 (RXD2)
D18-PC3 (TMS/PCINT19)PD3 (TXD1/INT3)
D19-PC2 (TCK/PCINT18)PD2 (RXD1/INT2)
D20-PC1 (SDA/PCINT17)PD1 (SDA/INT1)
D21-PC0 (SCL/PCINT16)PD0 (SCL/INT0)
D22-PD4 (PCINT28/XCK1/OC1B)
D23-PD7 (OC2A/PCINT31)
A0PC0 (ADC0/PCINT8)PA7 (ADC1/PCINT7)PF0 (ADC0)
A1PC1 (ADC1/PCINT9)PA6 (ADC0/PCINT6)PF1 (ADC1)
A2PC2 (ADC2/PCINT10)PA5 (ADC2/PCINT5)PF2 (ADC2)
A3PC3 (ADC3/PCINT11)PA4 (ADC3/PCINT4)PF3 (ADC3)
A4PC4 (ADC4/PCINT12)PA3 (ADC4/PCINT3)PF4 (ADC4/TCK)
A5PC5 (ADC5/PCINT13)PA2 (ADC5/PCINT2)PF5 (ADC5/TMS)
A6PC6 (ADC6/PCINT14)PA1 (ADC6/PCINT1)PF6 (ADC6/TDO)
A7PC7 (ADC7/PCINT15)PA0 (ADC7/PCINT0)PF7 (ADC7/TDI)

Bill of materials

A bill of materials for Calunium v2 is available from Google docs.

Changes from Calunium v1

Summary of changes from Calunium v1.

Arduino 1.0 headers included
The revised Arduino headers have been included. This adds dedicated I2C connections and an IOREF pin whose purpose is to indicate the I/O voltage level.

Jumper-selectable 3.3 V or 5 V operation
The microcontroller supply voltage is easily selected by a single jumper setting.

Improved reset circuit
A reversed-biased diode has been added in parallel with the reset pull-up resistor to prevent overshoot of the reset signal which can cause erroneous behaviour.

Option to use surface-mount real-time clock
I've not been able to find a suitable alternative to the DS1307 which can operate at 3.3 V and which is available in a dual inline package. The alternatives are only available in SOIC8 or smaller packages. To support 3.3 V operation a combined DIP/SOIC8 footprint has been used.

Ceramic resonator option instead of crystal
The crystal footprint has been revised to allow a 3-pin ceramic oscillator to be fitted as an alternative to a crystal. Omit the 22 pF loading capacitors when using a ceramic oscillator.

Improved analogue power supply circuitry
Analogue power supply follows the advice given in the data sheet.

Temperature sensor now powered from logic output
The optional LM61 (or similar) temperature sensor is now powered from D7. This change has been made for low power operation; I had been fitting an LM61 to other shields instead of using one on Calunium so that it can be powered off when not needed.

V-USB removed
I've had no success with the V-USB interface so the necessary circuitry has been removed. If you have had any success please let me know how to make it work! The USB connector remains as a convenient 5 V power connector.

RFM12B shield for Raspberry Pi: Preliminary design

RFM12B shield for Raspberry Pi
Raspberry Pi interface to the RFM12B radio module, with integrated ISP programmer. The cut-out is to enable the PCB to fit inside the Multicomp Raspberry Pi case.

Current status

Earlier in the year I posted a design for a wireless gateway for the Raspberry Pi. It featured interfaces for the Hope RFM12 and XBee (or Ciseco XRF) radio modules. Also included was an in-circuit serial programming (ISP) programming interface for Atmel microcontrollers. I later refined the ISP interface to include some protection for the Raspberry Pi by adding a buffer and FET switch. I have not yet tried accessing the RFM12B directly from the Pi but other people have had problems, mainly it seems because of the time-critical interrupt handling. I'm sure this problem will eventually be solved once the Eve Alpha boards become widely available. Martin Harizanov solved this problem by adding an Atmel ATtiny microcontroller to bridge between the UART interface on the Pi and the SPI interface on the RFM12B. I bought a bare PCB that did this from the Open Energy Monitor shop. I tested the RFM12Pi Raspberry Pi Expansion board communicating with one of my Calunium v2 development boards, everything worked. Martin chose the ATtiny84 microcontroller which has just 512 bytes of RAM. I would like to have a solution which more closely mimics the Ciseco XRF module that I am currently using, which has a 240 byte buffer. One reason for needing a larger buffer is that the radio protocol I am using supports over the air firmware updates, with the new firmware sent in 128 byte blocks. If I am to implement something with 240 byte transmit and receive buffers I will need a microcontroller with more than 512 bytes of RAM.

Preliminary design

Based on my previous work and inspired by Martin Harizanov's implementation I have designed a RFM12B shield for the Raspberry Pi with integrated ISP interface. The microcontroller on this board is the popular ATmega328P, as used in the Arduino. Including the ISP interface has considerably increased the size of the PCB but this is a price I am willing to pay. The board is intended to be used as part of the AuroraWatchNet magnetometer network and the ability to remotely update the firmware will be very useful, especially since I can already perform over-the-air firmware upgrades on the battery-powered Calunium node. Surface-mount passive components could be used to reduce the PCB size but this would be contrary to my goal of making the AuroraWatchNet magnetometers easy to build for novice constructors.

The 74LVC244 buffer has two 4-bit line drivers, allowing two independent ISP interfaces to be included. The first is for the on-board ATmega328P microcontroller, the second is wired to a standard Atmel ISP header to allow an external microcontroller to be programmed. It means that the ATmega1284P used in the remote Calunium of the AuroraWatchNet magnetometers can be programmed initially, or recovered in the case of an over-the-air firmware upgrade mistake.

I hope to have some circuit boards made in January 2013 so if you spot any mistakes please let me know as soon as possible!

Open source

The Eagle PCB design files for the RFM12B/ISP shield for Raspberry Pi are available on Github and are licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.