VWS-7 Accelerometer
From VWSwiki
An accelerometer data collection system was flown (successfully!) on the VWS-7 balloon. This page provides information about the application and hardware, as well as access to the data.
Contents |
Cut to the chase!
A simple graphical view of acceleration data over 4-5 second intervals is available here. Note that the X axis represents vertical motion of the payload package due to the orientation of the iPhone within the package. Launch, burst, landing, and payload recovery from the tree are all clearly visible!
If you'd just like to obtain copies of the processed data to explore yourself, please jump down to the Getting Postprocessed Data section of this page.
Hardware
A first-generation iPhone was flown in the payload of VWS. The iPhone contains a 3-axis accelerometer, the LIS302DL by STMicroelectronics. A data sheet and application notes on this device are available from the part's manufacturer. The application notes in particular are fascinating reading; the device actually works by measuring capacitance changes of a few femtofarads as a tiny hunk of silicon moves around on the chip surface!
The iPhone programmer's access to the device is mediated through the operating system. As a result, some of the device's capabilities (+/- 8G scale and 400Hz sampling rate) are unavailable to the application developer. As it turns out, though, the sampling rate of up to 100 Hz proved sufficient. Since the resolution of the device is fairly low (each axis is reported using just eight bits of data), the +/- 2G measurement scale is ideal.
Software
The software run on the iPhone was modified from an example application provided by Apple as part of its iPhone Software Development Kit (SDK). Access to the accelerometer is frighteningly easy. Here are some code snippets (in Objective-C) that illustrate the process.
Initialize the accelerometer:
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)]; [[UIAccelerometer sharedAccelerometer] setDelegate:self];
Once the accelerometer has been initialized, a method will be called automatically. Here's the code I used:
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
// Log the data
fprintf(fp,"%d %f %f %f %f\n",sample++,acceleration.timestamp,acceleration.x, acceleration.y, acceleration.z);
// Update the accelerometer graph view
[graphView updateHistoryWithX:acceleration.x Y:acceleration.y Z:acceleration.z];
}
The "fprintf" statement above causes the collected data to be written to a data file. This file lives within the application space on the iPhone. After the flight, the iPhone was connected via cable to a development machine containing the SDK. From there, the data (a simple text file) was saved to the desktop.
Raw Data
The raw data file from the iPhone contains many lines. Each line has five columns, separated by spaces. Here are a few samples from the VWS-7 data file.
0 882.840705 -0.018169 -0.308866 -1.017442 1 882.861662 -0.018169 -0.308866 -0.981105 2 882.882607 -0.018169 -0.308866 -1.017442 3 882.904242 -0.036337 -0.308866 -1.090116 4 882.924813 -0.054506 -0.308866 -1.053779 5 882.945805 -0.036337 -0.308866 -1.017442 6 882.966745 -0.018169 -0.308866 -0.999273 7 882.988304 -0.036337 -0.327035 -1.035610 8 883.008978 0.018169 -0.327035 -1.035610 9 883.029884 -0.018169 -0.327035 -1.035610
- The first column contains the sample number. This is a sequentially-assigned number that starts at zero and increments by one for each sample recorded.
- The second column contains a timestamp value in seconds that can be used to compute the elapsed time between samples. For reasons unknown to the author, this value wraps around to zero after reaching approximately 3074.445. So, if the results of subtracting the previous sample timestamp from the current sample timestamp are negative, add 3074.445 to the result to get an approximately-true value.
- The third column contains the X-axis value. The X, Y, and Z axes make sense if you hold the iPhone vertically in front of you. NOTE, HOWEVER, that the iPhone flown in VWS-7 was installed sideways in the instrumentation package--so the X- and Y-axis data are reversed in our data. The number represents a G force, ranging from about -2 to +2 G. Don't be fooled by the floating-point numbers, though; there are only 256 discrete steps across the entire -2G to +2G range. In practice, though, this turns out to be plenty of resolution to see what's going on.
- The fourth column contains the Y-axis value; see previous comments on the X-axis values.
- The fifth and final column contains the Z-axis data.
If you would like to work with the raw data file, it is available for download. Be warned, though: it's huge and unwieldy; you probably actually want postprocessed data; keep reading for details.
Postprocessing
The raw data is difficult to work with. First of all, there's a lot of it: more than 600,000 lines for the VWS-7 flight and recovery. Common desktop applications like Excel choke on this much information. Second, there's some automated analysis that can be done to better understand the flight dynamics. As a result, Phil Wherry (AI4JF) wrote a postprocessing application to help reduce the data set to a manageable size.
Output from the postprocessing application looks like this:
PtCnt Elapsed AvgX AvgY AvgZ HiX HiY HiZ LowX LowY LowZ MaxG MaxX MaxY MaxZ MinG MinX MinY MinZ 500 10.628 0.051 -0.164 -0.915 2.326 2.307 2.307 -2.307 -1.853 -2.326 4.007 -2.307 2.307 -2.326 0.392 -0.055 0.073 -0.382 500 11.216 -0.229 -0.254 -0.967 0.036 0.091 0.000 -1.054 -0.709 -1.690 1.819 -0.600 -0.309 -1.690 0.469 -0.382 0.018 -0.273 500 11.883 -0.166 -0.068 -1.029 0.709 0.818 1.199 -1.308 -0.654 -2.326 2.480 -0.273 0.818 -2.326 0.122 -0.073 0.036 -0.091 500 10.924 0.925 -0.058 0.001 2.326 2.307 0.745 -0.182 -1.508 -0.890 3.278 2.326 2.307 0.109 0.160 -0.127 0.036 -0.091 500 11.339 0.944 -0.099 0.035 0.981 0.000 0.091 0.000 -0.200 -0.036 0.985 0.981 -0.073 0.055 0.844 0.836 -0.109 -0.036 500 11.342 0.945 -0.098 0.032 0.981 0.000 0.073 0.000 -0.127 -0.036 0.987 0.981 -0.109 0.018 0.916 0.908 -0.109 0.036 500 11.883 0.944 -0.098 0.033 0.963 0.000 0.055 0.000 -0.127 0.000 0.970 0.963 -0.109 0.036 0.915 0.908 -0.091 0.055 500 11.676 0.945 -0.098 0.032 0.999 0.036 0.091 0.000 -0.145 -0.109 1.003 0.999 0.036 -0.073 0.899 0.890 -0.127 0.018 500 10.926 0.945 -0.099 0.022 1.054 0.036 0.236 0.000 -0.236 -0.182 1.055 1.054 -0.018 -0.036 0.864 0.836 -0.218 0.036
The columns in this output are defined as follows:
- PtCnt: Contains the number of data points in this output line. The postprocessing application works by grouping sequential samples into bins of equal size, then reporting data in aggregate across the entire bin. Note that the last PtCnt value in a file is likely to be lower than the others, since the number of samples is unlikely to be evenly divisible by your selected bin size.
- Elapsed: The elapsed time in seconds covered by this data bin. Note that this can differ somewhat from one bin to the next due to the asynchronous way that the iPhone application is notified of motion events.
- AvgX: This is simply the average of all of the recorded X-axis values. Since averaging samples acts as a low-pass filter, it's important to note that large bin sizes will mask transient effects! Also remember that the iPhone in VWS-7 was installed sideways in the pay load, so X-axis data represents vertical acceleration.
- AvgY: The average of all recorded Y-axis values in the sample bin.
- AvgZ: The average of all recorded Z-axis values in the sample bin.
- HiX: The largest X-axis sample recorded in the sample bin.
- HiY: The largest Y-axis sample recorded in the sample bin.
- HiZ: The largest Z-axis sample recorded in the sample bin.
- LoX: The smallest X-axis sample recorded in the sample bin. This is often a negative acceleration rather than a small positive acceleration. Subtracting LoX from HiX will give you the dynamic range of accelerations encountered by the payload during the set of samples in the sample bin.
- LoY: The smallest Y-axis sample recorded in the sample bin.
- LoZ: The smallest Z-axis sample recorded in the sample bin.
- MaxG: This value is the maximum G-force recorded by the accelerometer using the samples in the bin. The G-force is calculated by computing the length of the vector from (0,0,0) to (X,Y,Z), so it accurately represents forces acting on more than one axis simultaneously. The value of MaxG is unsigned since it is a composite of motion on multiple axes. A direction vector could be calculated if desired using the MaxX, MaxY, and MaxZ components described below.
- MaxX: Contains the X-component of the sample that resulted in the largest G-force (as represented by MaxG). MaxX differs from HiX because MaxX, MaxY, and MaxZ are guaranteed to come from a single accelerometer sample--whereas HiX, HiY, and HiZ are independent.
- MaxY: Contains the Y-component of the sample that resulted in the largest G-force (as represented by MaxG).
- MaxZ: Contains the Z-component of the sample that resulted in the largest G-force (as represented by MaxG).
- MinG: This value is the minimum G-force recorded by the accelerometer using the samples in the bin. The G-force is calculated by computing the length of the vector from (0,0,0) to (X,Y,Z), so it accurately represents forces acting on more than one axis simultaneously. The value of MinG is unsigned since it is a composite of motion on multiple axes. A direction vector could be calculated if desired using the MinX, MinY, and MinZ components described below.
- MinX: Contains the X-component of the sample that resulted in the smallest G-force (as represented by MinG). MinX differs from LoX because MinX, MinY, and MinZ are guaranteed to come from a single accelerometer sample--whereas LoX, LoY, and LoZ are independent.
- MinY: Contains the Y-component of the sample that resulted in the smallest G-force (as represented by MinG).
- MinZ: Contains the Z-component of the sample that resulted in the smallest G-force (as represented by MinG).
The data file that results from a run of the postprocessing application should import easily into a spreadsheet application such as Excel.
The source code for the postprocessing application is available for those who would like to use it. It's written in C and should compile without problems on any modern platform with a C compiler. The code isn't especially pretty, but I think it's readable enough to understand and modify.
Getting Postprocessed Data
If you'd like to do your own analysis on the postprocessed data, it's available via a simple Web form. The data returned will be a text file conforming to the description above. As noted previously, the raw accelerometer data is also available, though most people will find the postprocessed version a lot easier to work with.
