Hardware
Microcontroller Board
My platform is a self made board (two sided printed circuit board) with an Atmel AVR ATMEGA16 and L293D motor controller ICs. Here is a view of the assembled and soldered controller board. You may click on the pictures to get an enlarged view of the picture.
Here are pictures of the board before parts placement and soldering, first the component side,
second the solder side:
Features of this board are:
- 8 digital input/output ports (each equipped with an own ground line)
- 8 analog input ports (may also be configured as general purpose digital input/output ports, each equipped with an own ground line)
- 4 PWM controlled motor outputs with two L293DNE motor driver ICs
- Infrared remote control receiver SFH5110-38kHz (example: use of your television remote control with RC5, RC6 or REC80 code for commands to the µC board)
- Communication to a second identical board in SPI (serial peripheral interface) mode with slave select via RJ-45 modular cable connection (patch cable)
- Communication to up to 127 devices via I2C interface protocol implemented in software on any two digital ports (example: connect other µC boards or I2C devices such as ultrasonic distance sensors), see the I2C software library by Peter Fleury for integration in WinAVR GCC, especially the pure software implementation with "i2cmaster.h" and "i2cmaster.S"
- 8 bit µController ATMEGA16 (or pin compatible ATMEGA32 or ATMEGA8535)
- Up to 8 MHz internal RC oscillator clock or 16 MHz with optional quartz crystal resonator (not included in part list or placement view, insert "free flying" at two solder pads next to XTAL pins)
- Code may be written in C with WinAVR GCC (Gnu C-Compiler, free download) or in Assembler with AVR Studio (free download from Atmel web site)
- Code may be downloaded to the internal code-flash memory via the parallel port of your computer (see below the board "programmer"). For this you need an old fashioned legacy type PC with parallel printer port (they become pretty rare these days).
- During code download, the board must be powered. Either with an external source via the voltage regulator, or via the parallel port of the PC (the metal bridge J3 on the board "programmer" must be inserted). However, current supply via the parallel port of the PC is limited to a few mA. Therefore, the jumper JP1 on the board "ATMEGA16" must be opened to disconnect power supply for the L293DNE's during downloading, since they draw 20mA each even if inactive.
Figure Caption: µC board ATMEGA16 (older version not including all described features)
Figure Caption: Eagle board view (latest version including all features) of µController Board ATMEGA16
If you would like to build this board, you may download the file ATMEGA.zip containing all necessary files (eagle schematics and board, *.eps with mask pattern for PCB film, bill of material list, *.doc with mask pattern for printing, placement view, pin assignment, example program template.c {with board specific setup} and makefile for use with WinAVR etc.).
ATMEGA.zip
It's a two-sided board with half Euro Card format (100mm x 80mm). Two of these boards fit on one Euro Card format (100 mm x 160 mm). Therefore, I recommend to produce two of these board at a time. With the *.zip file I provide a combined mask pattern for a single UV exposure of two ATMEGA16 boards on one Euro Card format.
There are 38 via's on this board. I used a technique inserting a short wire into the vias and soldering them on both sides. Also take care that all devices on the top layer (such as electrolytic capacitors), whose pads are connected to top layer routing, must also be soldered on the top side.
Figure Caption: Pin assignment of the digital port of the board ATMEGA16
Figure Caption: Pin assignment of the analog port of the board ATMEGA16
Figure Caption: Pin assignment of the motor port of the board ATMEGA16
The software may be coded in C and compiled using the GNU Compiler Collection GCC under WinAVR (free download). You may use my files "template.c" and "makefile" contained in "ATMEGA.zip" for a quick start. The compiled code (intel hex format) is then loaded into the Atmel microcontrollers flash memory using the sp12 programming hardware (self-made board connected to the computer’s parallel interface named Ken’s Dongle after its creator Ken Huntington) and software (download available) developed by Steven Bolt, the founder of Pitronics in the Netherlands. A further programming software, which is compatible to the sp12 hardware, is provided under the name TwinAVR by Roland Walter (Berlin, Germany).
I designed a board named "programmer" on the basis of Steven Bolt's description, which fits to the pin assignment of the RJ-45 western modular jack of my µ-controller board "ATMEGA16".
Figure Caption: Eagle board view of board "programmer"
If you would like to build this board, you may download the file programmer.zip containing all necessary files (eagle schematics and board, *.eps for PCB film, bill of material list etc.).
programmer.zip
Sensor Board with 2-Axis Accelerometer for Measurement of Tilt Angle
For tilt angle measurement I am using a two-axis accelerometer sensor board (single sided SMD board) built with Freescale MMA2260D for x-axis and MMA1260D for z-axis with a bandwidth of 50Hz, which should be fast enough. Here is a picture of the sensor board:
Here is a picture of the sensor board before component placement and soldering:
The ICs from Freescale are for 5V operation, MMA2260D (x-axis, orientation towards the electric connectors) and MMA1260 (z-axis, orientaion towards the top). The range is ±2g on each axis. Output are two analog voltages between 0 and 5V (one for each axis). These outputs can be directly used on an analog input line of the µC board ATMEGA16. The electrical connectors fit to the standard fischertechnik 2.6mm-plugs. Here you see a picture of the board. The size of the board is 28 mm x 49 mm.
Figure Caption: SMD Board for 2-axis acceleration or tilt measurement. Isolation between 2.6 mm jacks and ground signal is achieved with a transparent tape
Figure Caption: Eagle board view of board "TiltXZ" with 2-axis acceleration sensor
If you would like to build this board, you may download the file TiltXZ.zip containing all necessary files (eagle schematics and board, *.eps for PCB film, etc.).
TiltXZ.zip
Rate Gyroscope for Measurement of Angular Velocity
However, the most important part for determining the tilt angle is the
rate gyro CRS03-02 (bandwidth 10 Hz) by Silicon Sensing / Atlantic Inertial Systems, see:
http://www.siliconsensing.com/CRS03packaged
The datasheet of CRS03 can be found here:
CRS03_Datasheet.pdf
On the right side is a picture of the used rate gyro. I am especially grateful to Eric Whitley from Silicon Sensing / BAE Systems for providing the sample for this project. This rate gyroscope proved to be very well suited for this kind of application. It gives a highly precise signal with very low noise which can be directly processed with AD conversion. Besides the Kalman filtering for bias control no other signal conditioning is required.
New Rate Gyroscopes by Silicon Sensing / Atlantic Inertial Systems providing SPI interface
The CRS03 with its analog output is doing a great job on my balancer. Nevertheless I was very curious on the new types offered by Silicon Sensing / Atlantic Intertial Systems which are accessed via SPI bus interface. So you do not need the ADC on the microcontroller anymore. Moreover, the gyro's internal ADC is with 12-bit conversion result much more precise than the 10-bit ADC of the Atmel AVR's. There are two new gyro types of special interest:
- The CRG20 is a surface-mounted all-digital gyro with great performance (max rate 300deg/s within specification, 400 deg/s monotonic). It can be provided on a 'breakout' board to ease evaluation. Further infos see here: http://www.siliconsensing.com/CRG20
- The DMU02 takes three of these new gyros, mounted orthogonally, and integrates these with a 3-axis accelerometer, thus providing a full 6-DOF capability in a single device. Further infos see here: http://www.siliconsensing.com/DMU02
Figure Caption: CRG20 evaluation board, the gyro is really small, connections have a pitch of 2 mm
Figure Caption: DMU02, dimensions are 1 cubic inch, connections have a pitch of 2 mm
Remote Control
The controller board contains an infrared receiver SFH5110-38 connected to one pin (INT2) of the microcontroller. This receiver demodulates 38-kHz-modulated infrared signals typically used by commercial infrared remote controls. I am using an Audio HiFi remote control with REC80 coding. Use the following link to my web page on how to use these remote controls (C-code and header files for download).
RemoteControl.html
If you want to use other sources, there is an application note named AVR410 with assembler code by ATMEL for decoding RC5 signal transmission. Peter Danninger provides a C-code for the same purpose on mikrocontroller.net. In future the remote control will be used to superimpose power or velocity to the two drive motors in the control equations. Then the drive direction (forward, backward, turning) and drive velocity can be controlled via infrared remote control.
Top of Page