CCHS GGHC: CCHS element14 group
Over the last couple of weeks, the electronic design for our microcontroller-based electronics experimenter's instrument has been completed, I've completed the PCB layout and sent the CAM files off to the PCB fab, we've sorted out the BOM lists, and we've ordered a whole bunch of components from our friends at element14 and Digi-Key. We've sourced essentially all our components from element14 and Digi-Key... but these vendors aren't the only vendors that sell the components needed... these are almost all very common components available from many suppliers.

Above: The PCB layout of the main board.
Right now, tentatively, its working title is the ArduinoLab. (I'm considering calling it the Mystik Spiral project... because we're thinking of changing the name.
)
So, I thought that now, while we're waiting for the delivery people to bring our PCBs after the Easter holiday, might be a good time to look at the electronics designed by Marc Alexander and myself, and go over how it all works.
Microcontroller
At the heart of it all we have a microcontroller... the Atmel ATmega328. This is undoubtedly a familiar microcontroller to many readers. It is, of course, the same AVR microcontroller used as the basis of the Arduino system, in most cases. This widely available, popular microcontroller is surrounded by several other core components of the microcontroller system on the system's main "motherboard".

To give us the most flexibility when it comes to packaging up the finished PCBs into an enclosure, and because I'm using the free "light" license for Eagle, which limits the PCB dimensions, our best option actually turned out to be dividing up this system across several PCBs, instead of putting it all on a single monolithic PCB. We'll take a look at these peripheral PCBs in a moment.
The AVR is running at a clock frequency of 16 MHz... the same most Arduino devices. This board is intended to be fully compatible with the Arduino system - the Arduino bootloader and the Arduino IDE - for easy programming and software development. And of course, just like Arduino, everything is open-source too, for hackability, repairability, and expandability, as well as for the educational value of open-source. We're writing firmware for the device based on the Arduino system, running on top of the Arduino bootloader, so the firmware is easy to understand and easy to change.
Because this board is almost entirely based on compact surfact-mount components, a QFN-32 version of the ATmega328 ATmega328 is used. This has the added advantage that it gives us a couple of extra I/O pins - the AVR's 7th and 8th analog inputs. These inputs are present on the chip die, but they are not broken out to pins on the DIP version of the chip.
Included on the motherboard is the popular FT232RL USB virtual-UART IC, just like on the Arduino Duemilanove, providing USB connectivity for programming and communications with your PC. We've also included a reset button for the AVR, too. A USB mini-B connector is used for the USB interface on this board instead of the traditional USB 'B' connector, which is excessively tall and bulky.
For even more expandability, flexibility and hackability, I've also added some pads surrounding the AVR, in a standard Arduino "Shield" footprint. This provides lots of exciting hacker-friendly potential for expansion and access into the microcontroller pins!
Power Supply
So, basically, it's just like an Arduino, right? Well, not exactly. There are some further features we've implemented in this case, whilst still maintaining a high degree of Arduino compatibility.
To start with, we need some portable power. I've included a 3.6 V lithium-ion AA cell on the board, for convenient wireless power and portable operation, with no wall-warts, power cables or batteries dangling off. A Microchip MCP73831 Li-ion charge management IC is used to charge the cell from power supplied by a USB host device, or a 5 V mains power supply (a plugpack or wall-wart) with a USB connector. There is no need to remove the battery and plug it into a battery charger - you simply plug it into a USB host, and it charges the battery. User friendly, no-fuss, uninterrupted portable power that just works - just like your laptop or cellphone.
The lithium cell's nominal 3.6 V is stepped up to 5 V using a Texas Instruments TPS61202 buck/boost converter IC. This allows us to run the microcontroller's positive supply rail at 5 V, which is a common, familiar choice for most Arduino-like devices, and gives us a little more flexibility than a 3.3 V supply rail. One small disadvantage of this device, however, is that it is a very small QFN-10 SMD package. Probably going to have to bust out a stereomicroscope for this one.
Since the MCP73831, the FT232RL and the TPS61202 are only available as surface-mount devices, we could really make use of the extra 2 ADC channels on the ATmega328 ATmega328, and we need to fit a relatively large amount of electronics onto a relatively small PCB, we have decided to make the system's motherboard almost entirely built from SMD components. For realistic electronic engineering projects today, with nontrivial devices, one needs to learn to stop worrying and love surface-mount technology, because you just can't get many interesting and valuable ICs in DIP packages.

Graphical Display
Next up, we've got the LCD display. Here, we've decided to step up a little from our traditional choice of the common HD44780 character displays, and we've chosen a nice little 128 x 64 graphical LCD based on the common KS0108 chipset, with white images on a blue backlit background. In fact, with a little shopping around in Asia, we've found that these graphical LCDs are no more expensive than similar 20x4 HD44780 alphanumeric LCD display modules. But we don't have very many spare pins to play with on our AVR... so how are we going to wire up this LCD display, with its 8-bit data bus and several extra control lines compared to a traditional HD44780? In order to do more with less microcontroller pins, I've used a cascaded pair of cheap and readily available CD4094 8-bit shift registers (or HEF4094 HEF4094... or whatever. You could use any 4094 from one of the different digital logic families), to let us latch the data and instructions out to the LCD display in a serial fashion, using relatively few microcontroller pins.

We're going to write some modified KS0108 libraries which are compatible with existing Arduino libraries for KS0108 displays, so they can be plugged into existing programs, but which drive the LCD via the shift registers. This is relatively slow, but saves many microcontroller pins for other uses.
The KS0108 128x64 LCD displays we are using are essentially the same as those used for ladyada's delightful MONOCHRON clock. This gives you a good idea of what they look like:

(This image belongs to Limor Fried and Adafruit Industries. Used in good faith. Thanks!)
Lots of interesting peripherals
A header footprint for a Digi XBee 802.15.4 module (or any compatible 3.3 V serial module, such as those GPS, Bluetooth and RF communications "bee" modules available from Seeed Studios) and a corresponding 3.3 V regulator are also available on the board, as is a piezo buzzer for audible feedback to the user. We've also got a digitally-controlled adjustable DC voltage output. MOSFET Q1 is switched by the microcontroller, and the resulting PWM waveform is smoothed out with the big-ass capacitor C2. Shunt resistor R11 lets us use the AVR's ADC inputs to measure the current flowing in the output circuit. This simple low-current power supply is really convenient for all kinds of electronics and physics experiments. Suppose that we want to measure the V-I curve of a diode. Well, over a certain range at least. We can program the system appropriately, attach the diode, and sweep the positive bias voltage from 0 to 5 volts while we're measuring the current flowing, and we can send the result to a plot on the graphics LCD! (Well, theoretically at least. I haven't tested this yet.)
Analog Data Acquisition
We've also got a couple of potentiometers for analog input from the user, as well as a couple of terminals for analog voltage measurements from external circuits or devices. To make sure that nothing gets blown up by students who are experimenting, these analog input ports are attenuated in a 4:1 ratio by voltage dividers, and clamped with 5.6 V zener diodes, making these inputs nicely hardened to prevent damage to the unit. The main 5 V rail is also clamped to 5.6 V by a 5 W zener diode to make sure that the ICs cannot be damaged if an excessive voltage is applied to the 5 V rail. Because the ADC inputs are attenuated in 4:1 ratio, the maximum analog voltage that can be measured by these analog inputs is approximately 20 V. One of these digital inputs is connected to both a digital input on the AVR and an ADC input, so we can do things like pulse counting and digital data recording in the digital domain, as well as the measurement of analog signals. Lots of possibilities for experiments and educational activities!
Lots of buttons to push
We've also got some other bits and pieces, on the peripheral PCBs. We've got a set of six pushbutton switches, for user input, control and navigation through the software menu system displayed on the LCD. These six pushbuttons are connected through a string of resistors, forming a voltage divider with an output voltage that changes as different buttons are pressed. By reading this voltage with of the the AVR's ADC inputs, we can receive input from a whole bunch of pushbuttons using only a single microcontroller pin. This simple pushbutton pad is on its own little PCB - and this design is one that I suspect will probably have future value for all kinds of different microcontroller and Arduino projects. This board is connected back to the main board using three wires - the 5 V rail, ground, and the analog output. Since the component density is not especially high on this board and no specialised components are used, common through-hole components are used exclusively on this board, and it is a single-sided board, making it relatively simple even for beginners to solder together, adding another aspect of potential educational value.

Digital Outputs
The final one of the three PCBs in this system contains three digital open-collector transistor outputs, and an output for analog waveform synthesis. The main reason that a separate PCB was used here is because of the limitations on board dimensions in the free-as-in-free-beer "Light" edition of CADsoft Eagle, which I used to lay out the PCBs. Three of the AVR's PWM-capable output pins are bought out to three BJTs, with 1 k pull-up resistors that be switched on and off, allowing either digital outputs or true open-collector outputs. 1N5819 1N5819 diodes are used in the pull-up part of the circuit for protection of the circuit, preventing the 5 V rail from being pulled up too high if the pull-up switch is closed and an excessively large voltage is applied to the output. An 18 ohm resistor is included in the emitter to protect the transistor from overcurrent, and a 1N4004 diode is connected to the output to protect the transistor from back-EMF from an inductive load.

Analog Synthesiser
One of these PWM output channels also has a second function - it is also used for analog waveform synthesis. An input PWM signal is filtered through a second-order low-pass RC filter, creating an analog waveform. A second-order Chebyshev LC filter might have a bit sharper transfer function here, but resistors are much cheaper and smaller than inductors, as a rough general rule, and the RC filtering gives good enough performance characteristics for our purposes. To synthesis sinusoidal waveforms, for example, a sine lookup table will be pre-computed and incorporated into the microcontroller firmware, avoiding the relatively computationally intensive task of calculating sines in realtime.

The analog output is then buffered with a voltage follower, an Burr-Brown OPA340 rail-to-rail opamp. A rail-to-rail opamp is really valuable here, since we only have a unipolar 5 V power supply. An AC coupling capacitor can be switched into the circuit to remove any DC offset - or bypassed if some DC component is actually desired. Another toggle switch is used on the output side in order to choose between either the analog synthesis output or the transistor output. Hopefully these features, along with other hardening and protection measures in the circuit, make this device fairly hard to break electrically. Like the pushbutton input panel, the nature of the components on this board and the density of these components did not justify the use of surface-mount components, and it uses only through-hole components, making it easy to assemble, even for beginners.
I've included portions of our hardware schematics in this post... but of course the entire thing is open-source. If you want to get the whole lot, in full, glorious high-resolution, feel free to check out the contents of my repository for this project over on GitHub - you'll find everything there. If you're not familar with git (and GitHub) it's a great thing to learn - it's not just for greybeard programmers.
Happy Hacking,
Luke Weston,
Connected Community Hackerspace, Melbourne, Australia.
http://hackmelbourne.org