Serial Accelerometer Dongle - MMA7361
Reward Points: 0
Availability: 446
20 or more $22.00
Description: The Serial Accelerometer Dongle is a 3 axis accelerometer up to +/-6g with a simple serial interface. The Serial Accelerometer Dongle has a variable baud rate, a factory reset command, and a complete triple axis measurement system based on the MMA7361 sensor from Freescale. Power is gained from any RS232 port (including USB-to-RS232 converters) so no external power supply is needed. The new version replaces the onboard PIC with an ATMega328 . The board has software configurable settings to select between 2 different sensing ranges (+/- 1.5 and 6g).
The board outputs real-time accelerations from 9600 to 57600bps using visible ASCII characters. It is compatible with any RS232 Comm port in conjunction with any terminal program (Hyperterminal, VB Programs, or anything else that can read the comm port). It works fine with USB-RS232 converters.
Quick-start Guide
To start using your Serial Accelerometer Dongle you'll need to have a terminal program installed, and a USB cable and Serial-USB Converter. Plug the dongle into the USB cable using the Serial-USB Converter, and plug the USB cable into a computer. One great thing about the dongle is that it takes power from the Serial port, so no external power supply is needed! Once you've plugged the dongle into the computer, open a terminal program and create a serial port connection. The serial port settings should be configured for 38400bps, 8 data bits, 1 stop bit and no parity bits.
If the serial connection has been established a configuration menu will be displayed in the terminal window. The user is presented with six options which allow for calibrating the device, changing the configuration settings, or exiting the menu. The default calibration uses the recommended settings from the MMA7361 datasheet, but calibrating the device may give more accurate readings. The default configuration settings are:
- Gravity Output Mode (accelerometer data will be displayed as the G value for the axis)
- 50 Hz Output Frequency (Data will be sent from the dongle at 50 Hz)
- +/-1.5G Range
- 38400bps for the Baud Rate
If the selection is to exit the menu the dongle will start displaying data according the the configuration parameters. This is referred to as 'Running Mode.' If Running Mode is entered with the default settings, G values for the X,Y and Z axis will be displayed at 50 Hz, with a newline separating each reading. The dongle will exit Running Mode and go back to the configuration menu if any key is entered on the serial port (Note: your terminal window must be the active window in order for the dongle to detect the key press).
Hardware Notes
The Serial Accelerometer has only 2 main components: the ATmega328 microprocessor and the MMA7361 accelerometer. It is important to point out that the ATmega328 is the same microprocessor used on the Arduino platform, and is preloaded with the Arduino serial bootloader for easier reprogramming.
The dongle is takes power from the serial port that it's connected to, and regulates the 5V down to 3.3V for the boards power. There is also a level shifter that converts the RS232 voltage levels from the serial port to 3.3V for the microcontroller serial port.
There are 2 LEDs and a reset button on the Serial Accelerometer dongle. The LEDs are labeled as PWR and STAT, for power and status. The power LED comes on if the dongle is powered. There are several different states for the status LED: when the dongle is first powered on the status LED stays off until the device in initialized. Once the dongle has initialized and entered the configuration menu the status LED turns on. The status LED stays on until the dongle exits the configuration menu and enters Run Mode. While in Run Mode, the status LED toggles from On to Off, or Off to On, every time a new data set is sent to the serial port.
The dongle has 2 header groups, there is a 5 pin header which provides access to 3.3V, ground, and the analog output values for each axis from the MMA7361; there is also a 6 pin ISP header for reprogramming the ATmega328. While the microprocessor can be programmed using the Arduino Bootloader over the serial port the user also has the option of reprogramming the device using the ISP header.
Default Settings and Factory Reset
The serial accelerometer has 5 settings that affect the devices operation and can be configured by the user. The settings are used to calibrate the accelerometer, set the baud rate, set the output frequency of the data, select the output mode and select the range of the accelerometer. More information on each of the settings is available in the 'Configuration Menu' section of the wiki. The default settings are as follows:
- CALIBRATION: The typical values noted in the MMA7361 datasheet are used for the default calibration.
- OUTPUT MODE: Gravity
- OUTPUT FREQUENCY: 50 Hz
- BAUD RATE: 38400 bps
- RANGE: +/- 1.5g
If for some reason the device gets into an unknown state (i.e. the baud rate is mistakenly changed and you can't find the correct one), a factory reset can be applied to restore the default settings. To apply the factory reset, locate the exposed test pad on the bottom of the serial accelerometer dongle. Use a wire or a paper clip to connect the test point to ground, and power up the board (if the board is already powered up, just press the reset button while the test point is shorted to ground). If the board is powered up with the test point shorted, the dongle will enter test mode and restore the default settings. When the factory reset is applied the status LED will start blinking immediately at start-up, rather than staying on. After applying the factory reset, remove the short from the test point to ground and reset the board. You can now use the 38400 baud rate to reach the configuration menu again.
Interfacing
The default baud rate settings for the Serial Accelerometer Dongle are 38400bps, 8 data bits, 1 stop bit and no parity
Interfacing with the Serial Accelerometer Dongle is achieved using an RS232 Serial connection. Commands are sent to the dongle using simple simple ASCII characters. Unless the binary output mode is being used, the data from the dongle is also ASCII formatted. The easiest way to connect to the dongle is to use a terminal program. If the default settings haven't been altered, but sure to connect to the dongle using 38400-8-N-1 for the serial port settings. Flow control must be disabled in order for the device to function properly. To start interfacing with the dongle, just plug it in and open a terminal program with the specified settings and the configuration menu for the device will be displayed in the terminal window. If it doesn't show up after a second or two, try pressing the reset button on the dongle. If that doesn't work, ensure that the correct port has been selected in the terminal program, and that the serial port settings have been set properly.
Configuration Menu
--- Serial Accelerometer Dongle MMA7361 ---
Firmware Version 6.0Select a menu item to continue:
[1] Calibrate (Current Calibration Values: 1525, 1629, 1619)
[2] Output Mode (Gravity Values)
[3] Output Frequency (10 Hz)
[4] Sensor Range (+/- 1.5g)
[5] Baud Rate (115200)
[x] Exit
Selection:
The Serial Accelerometer Dongle only has two modes: configuration and run. When the device is first powered up it goes into configuration mode and the configuration menu will be displayed. The configuration menu allows the user to customize the settings, calibrate the accelerometer or enter run mode. The configuration menu allows the user to set the baud rate, set the output frequency of the data, select the output mode and select the range of the accelerometer. The current configuration settings are displayed following the menu labels for each setting. All of the calibration and configuration settings are saved in EEPROM, so they will be maintained even if the dongle is powered off or reset. If the baud rate is changed, the new baud rate setting will be used immediately as well as the next time the dongle is powered up! To exit the configuration menu and enter run mode, where the accelerometer data will be displayed, can be achieved by pressing the 'x' key. While in run mode, configuration mode can be reached at any time by pressing any key (or sending a character to the serial port).
Calibration
The dongle comes calibrated to the typical values recommended in the MMA7361 datasheet, however further accuracy can be attained by manually calibrating the device. Press '1' while in configuration mode to calibrate the device. Instructions will be displayed in the terminal window that lead the user through the calibration process.
Calibration Menu (Press X at any time to Exit)
For each axis you will be prompted to find the maximum and minimum values.
Simply rotate the serial accelerometer until you find the appropriate value and
press a key (any key except x) to register the value
Calibrate X Axis
Find Maximum X Value:
X: 500
Essentially there are 2 steps for each axis: finding the maximum and minimum static readings. When prompted simply rotate the device along the specified axis until the maximum or minimum reading is found. Once the proper threshold has been found, press enter/return to move onto the next step.
The calibration settings are only used if the G Values output mode is selected. If only the raw display modes are to be used calibration can be bypassed. The calibration values are saved to EEPROM and restored at power-up, so the device does not have to be calibrated every time it is turned on. The device does need to be calibrated, though, if the accelerometer range is changed. If the range is changed and the device is not calibrated, the G Values will be incorrect.
Output Mode Selection
There are three available output modes for the Serial Accelerometer Dongle: G Value, Raw ADC Data in Ascii and Raw ADC Data in Binary. The output mode determines how the data will be presented in the terminal window. Pressing '2' from the configuration menu will allow the output mode to be selected. Each output mode has a different limit on it's maximum output frequency. If the output mode is changed and the current output frequency exceeds the frequency limit of the new mode, the output frequency will be lowered to the maximum output frequency of the current mode.
Select the desired output mode
[1] Gravity Values
[2] Raw Values
[3] Raw Values in Binary Format
All of the output modes draw their values from the Analog to Digital Converter (ADC) of the ATmega328. A continuous averaging filter is applied to free running ADC readings so that the value reported to the terminal window is always an average of the previous 4 readings. The output frequency of all modes is limited to 250 Hz in part to allow for each axis to update 4 times before displaying another reading.
Gravity Output Mode
The Gravity Output Mode will display the current G value for each axis. The G value is calculated using the voltage read from the MMA7361 and the current mode setting. If the device has been calibrated, the calibration values are also used to approximate a more accuarate value for the G value. Otherwise the default values from the datasheet are used to calculate the ratio of voltage to mG. This is a sample of the G ouput.
0.22 0.18 1.01
0.23 0.16 0.98
0.24 0.17 0.98
0.24 0.17 0.99
0.22 0.18 1.02
The output will always show one character preceding the decimal point, and two characters following the decimal point with a tab character separating the X/Y values and the Y/Z values. A newline character and a carriage return character follow the Z value. The order of axis values is X, Y, Z. Calculating the G values of the axis requires the use of floating point arithmetic, which limits the output speed for the Gravity Output Mode. Here is a table which illustrates the maximum output frequencies allowed for the mode based on the current baud rate.
Baud Rate | Maximum Output Frequency (hz) |
---|---|
4800 | 25 |
9600 | 45 |
14400 | 66 |
19200 | 83 |
38400 | 125 |
57600 | 142 |
115200 | 166 |
Raw ADC in ASCII Output Mode
The Raw ADC in ASCII output mode simply displays the ADC count value for each axis using Ascii characters. The maximum value that can be read by the ADC is 1023, while the minimum value is 0. Find out about how to convert the ADC value to a voltage by reading the Analog to Digital Converter section of the ATmega328 datasheet, or by reading this tutorial on the SparkFun website. You can also find out how to convert the voltage to a G value by reading the MMA7361 datasheet, which can be downloaded at the top of this document. Here's a sample of the output from the Serial Accelerometer while in Raw ADC in ASCII Output Mode.
0711 0525 0559
0520 0560 0711
0711 0520 0558
0522 0559 0711
0709 0524 0561
The output shows the ADC values of the X, Y then Z axis, with a tab character between the X/Y values and the Y/Z values. There are newline and carriage return characters which follow the Z axis values. Each value will always consist of four characters. The output rate is somewhat limited by the number of characters that must be displayed. The following table illustrates the maximum output frequency for each baud rate.
Baud Rate | Maximum Output Frequency (hz) |
---|---|
4800 | 27 |
9600 | 58 |
14400 | 76 |
19200 | 111 |
38400 | 200 |
57600 | 250 |
115200 | 250 |
Raw ADC in Binary Output Mode
Raw ADC in Binary Output Mode is the same as the Raw ADC in Ascii mode, except that the values are sent as binary characters through the serial port rather than Ascii characters. While this means that the values can't be deciphered by glancing at them in a terminal window, binary values are much easier to parse and interpret if a program is being used to interpret the data (like python, processing, etc.). Here's an example of the output for this mode.
#xw$#;w$#yx$#ww$#x$#yx$#xx$#<y$#yx$#xx$
#=x$#xx$#xx$#=<y$#xx$#vw$#=<w$#wx$#[y$#?!
Not very pretty! But it doesn't matter, it's still pretty useful. The output does have some formatting: each value set starts with a '#' character and ends with a '$' character. Between the start and end character there are 6 bytes, 2 bytes that represent the ADC value for each axis (X, Y followed by Z). The ADC values are sent to the serial port with the MSB first, then the LSB. A generalized output would look something like this:
['#'][High X Byte][Low X Byte][High Y Byte][Low Y Byte][High Z Byte][Low Z Byte]['$']
Notice that there is no spacing between any of the values, and there is no carriage return. Because there are so few bytes sent in this output mode the device can achieve a higher output frequency at lower baud rates! Here's the maximum output frequencies for each baud rate while in Raw ADC Values in Binary mode.
Baud Rate | Maximum Output Frequency (hz) |
---|---|
4800 | 47 |
9600 | 90 |
14400 | 125 |
19200 | 166 |
38400 | 250 |
57600 | 250 |
115200 | 250 |
Output Frequency Selection
The Output Frequency Selection menu allows the frequency at which data sets (the X, Y and Z value) will be sent to the serial port. To enter this menu, press '3' from the configuration menu. The Output Frequency menu will present instructions on how to increase or decrease the output frequency. Use the 'i' and 'd' keys to increase or decrease the output frequency. To exit the menu, press 'x.' The new setting will be saved, and if the device is powered off this setting will be recalled the next time it is powered on. Remember, each output mode has a limit on the output frequency, and the limit changes depending on the baud rate. If a frequency value is selected that exceeds these limitations the device will automatically lower the output frequency to match the output frequency limit of the current configuration. The output frequency may also be over-ridden if the baud rate is lowered. This will only occur if the new baud rate setting has a maximum output rate for the current mode that is lower than the current output rate.
Set the desired output frequency. Press [i] to increase and [d] to decrease.
Press [x] to exit
Frequency range is limited automatically by the output mode and baud rate
Output Frequency: 10
Notes on how the maximum values were determined (link to another wiki)
Sensor Range
The MMA7361 has two different ranges, +/-1.5G and +/-6G. The Sensor Range menu allows the range of the sensor to be configured. Press '4' to enter the Sensor Range menu. Changing the sensor range will over-ride any user calibration values, so the device should be re-calibrated any time this setting is modified. From the Sensor Range menu, press '1' to select +/-1.5G mode, or press '2' to select +/-6g mode. Any other key will exit the menu without modifying the setting.
Select the desired accelerometer range.
[1] +/- 1.5g
[2] +/- 6.0g
Baud Rate
The Baud Rate menu will allow you to change the baud rate for the Serial Accelerometer Dongle. To access the menu, press '5' from the configuration menu. The menu presents a list of the supported baud rates.
Select the desired baud rate.
[1] 4800
[2] 9600
[3] 14400
[4] 19200
[5] 38400
[6] 57600
[7] 115200
The default baud rate for the dongle is 38400bps. To change the baud rate, just select the number corresponding to the desired rate. The baud rate will be changed immediately and will also be saved to EEPROM. In order to read the data from the device you will need to change the baud rate of the terminal program. If the device gets into an unknown baud rate, the default baud rate can be recovered by issuing a factory reset. Read the section 'Default Settings and Factory Reset' for more information.
Run Mode
While in Run Mode the dongle will display the X, Y and Z axis values continuously until the user issues a command to exit Run Mode. The values will be displayed according to the configuration settings chosen in the configuration menu. New accelerometer values will be displayed at the rate specified by the Output Frequency setting. The values will be displayed according to the selected Output Mode, and the values will be limited by the selected Sensor Range.
To enter Run Mode, press 'x' from the configuration menu. To exit Run Mode and and enter the configuration menu, just press any key.
Dimensions: 1.3 x 1.25" (33.2 x 31.7 mm)
Documents:
Write a review
Your Name:Your Review: Note: HTML is not translated!
Rating: Bad Good
Enter the code in the box below: