Acceleration sensing USB interface using Atmega8 microcontroller

Contents

The TiltStick is a small acceleration sensing device in form of a USB stick. It’s using a two axis acceleration sensor to measure acceleration (caused e.g. by motion and tilt). The device is emulating a USB joystick and can thus be used in conjunction with any USB equipped host (e.g. a standard PC or the Nokia N8XX family) without any special drivers. The TiltStick is the successor of the Tilt Dongle for Palm OS.
prototype

The hardware

Two versions of the TiltStick have been designed based on different 2D accelerometer chips. The slightly smaller one is based on the Analog Devices XL203 (the XL202 may also be used). The bigger version is based on the Freescale MMA7261. The advantage of the freescale version is that a pin 3D chip exists. The hardware of the TiltStick is prepared to support the third axis.
The different accelerometers run at different voltages. Thus the ADI version runs at 5V and two zener diodes convert the voltages on the USB data pins to USB compatible 3.6V. The Freescale chip runs at max. 3.6V. This the supply voltage of the entire unit is reduced by two diodes to approx 3.6V. Thus no further conversion of the voltage on the USB data lines is required.
schematic
The current design V1.0 contains some design errors. Most important the USB data lines have to be swapped. This can easily be done by cutting the traces directly at the connector and replacing them with thin wires. Furthermore are the ADC6 and ADC7 pins used as GPIO. This doesn’t affect the ADI solution as this isn’t using those pins, but some changes are needed for the Freescale version. These aren’t documented yet as the current firmware doesn’t yet support the freescale chip. Finally the ADI version is missing a connection between PC3 and GND (can easily be fixed directly at the pin) which will allow future firmware versions to differ between the ADI and Freescale boards.

The USB interface

The USB interface of the TiltStick interface is based on a pure software implementation and uses two pins of the AVR (PB0 and PB2). This software implementation supports low speed USB only which is signalled to the PC by resistor R1. It is based upon the AVR-USB USB solution for the AVR family.

Device calibration

The accelerometers used on the TiltStick need to be calibrated in order to get accurate measurements in the range of -2G to +2G and to adjust the layout of the two axes to e.g. cope with the fact that the TiltStick may be oriented differently when attached to different host computers. Two ways for calibration exist:

PC assisted calibration

The PC assisted calibration is available for the Linux host platform only. It uses the caltool application included with the source archives. This application will the ask you to move the TiltStick in certain ways to calibrate. Just follow these instructions and you are done.

Self calibration

Since the caltool application is only available for Linux, the self calibration mode has been added to allow for easy calibration without a special software tool running on the host. To perform a self calibration perform the following simple steps:

  • Press and hold the calibration button (the one close to the USB connector) on the TiltStick for at least three seconds until the green LED turns off. The yellow calibration LED will then start blinking once a second to indicate that step one of the self calibration is in progress.
  • Hold the TiltStick “flat” and press the calibration button again within 15 seconds. The yellow LED will start flashing twice each second to indicate that this was successful and that the second step of the calibration is to be performed.
  • Tilt the TiltStick 90 degrees to the right and again press the calibration button within 15 seconds. The LED will start blinking three times each second.
  • Tilt the TiltStick 90 degrees down and once more press the calibration button within 15 seconds. The LED will start blinking four times each second.
  • Press the calibration button one last time within 15 seconds to permanently store the new calibration data inside the sticks internal eeprom memory. The yellow LED will stop flashing and the green LED will turn on again. Calibration is done!

You can interrupt the self calibration at any time by either pressing one of the fire buttons instead of the calibration button or by waiting 15 seconds for the self calibration to time out. The values in the eeprom will not be touched in this case.

Software

The TiltStick can be used in conjunction with any software that can be controlled using a simple two axis joystick with two fire buttons. However, the TiltStick is not a joystick and the user experience is most astonishing when being used with software that was specifically designed with the accelerometers in mind. The tiltstick_mass demo included with the downloads is such an application. It simulates a mass (the red circle) which is connected to two rubber bands (the yellow lines). If the TiltStick is attached and calibrated, the mass naturally follows the tiltsticks movements. E.g. tilting and shaking the computer with the attached TiltStick will make the mass move “downwards” or be shaken.
This demo software is also included with the Maemo download below.
For more detail: Acceleration sensing USB interface using Atmega8 microcontroller


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top