2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.AltosLib;
20 public class AltosRecordTM extends AltosRecord {
28 public int ground_accel;
29 public int ground_pres;
30 public int accel_plus_g;
31 public int accel_minus_g;
33 public int flight_accel;
34 public int flight_vel;
35 public int flight_pres;
38 * Values for our MP3H6115A pressure sensor
40 * From the data sheet:
42 * Pressure range: 15-115 kPa
43 * Voltage at 115kPa: 2.82
44 * Output scale: 27mV/kPa
47 * 27 mV/kPa * 2047 / 3300 counts/mV = 16.75 counts/kPa
48 * 2.82V * 2047 / 3.3 counts/V = 1749 counts/115 kPa
51 static final double counts_per_kPa = 27 * 2047 / 3300;
52 static final double counts_at_101_3kPa = 1674.0;
55 barometer_to_pressure(double count)
57 return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0;
60 public double raw_pressure() {
63 return barometer_to_pressure(pres);
66 public double filtered_pressure() {
67 if (flight_pres == MISSING)
69 return barometer_to_pressure(flight_pres);
72 public double ground_pressure() {
73 if (ground_pres == MISSING)
75 return barometer_to_pressure(ground_pres);
78 public double battery_voltage() {
81 return AltosConvert.cc_battery_to_voltage(batt);
84 public double main_voltage() {
87 return AltosConvert.cc_ignitor_to_voltage(main);
90 public double drogue_voltage() {
91 if (drogue == MISSING)
93 return AltosConvert.cc_ignitor_to_voltage(drogue);
96 /* Value for the CC1111 built-in temperature sensor
97 * Output voltage at 0°C = 0.755V
98 * Coefficient = 0.00247V/°C
99 * Reference voltage = 1.25V
101 * temp = ((value / 32767) * 1.25 - 0.755) / 0.00247
102 * = (value - 19791.268) / 32768 * 1.25 / 0.00247
106 thermometer_to_temperature(double thermo)
108 return (thermo - 19791.268) / 32728.0 * 1.25 / 0.00247;
111 public double temperature() {
114 return thermometer_to_temperature(temp);
117 double accel_counts_per_mss() {
118 double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2;
120 return counts_per_g / 9.80665;
123 public double acceleration() {
124 if (acceleration != MISSING)
127 if (ground_accel == MISSING || accel == MISSING)
129 return (ground_accel - accel) / accel_counts_per_mss();
132 public double accel_speed() {
133 if (speed != MISSING)
135 if (flight_vel == MISSING)
137 return flight_vel / (accel_counts_per_mss() * 100.0);
140 public void copy(AltosRecordTM old) {
143 version = old.version;
144 callsign = old.callsign;
157 flight_accel = old.flight_accel;
158 ground_accel = old.ground_accel;
159 flight_vel = old.flight_vel;
160 flight_pres = old.flight_pres;
161 ground_pres = old.ground_pres;
162 accel_plus_g = old.accel_plus_g;
163 accel_minus_g = old.accel_minus_g;
166 public AltosRecordTM clone() {
167 AltosRecordTM n = (AltosRecordTM) super.clone();
172 void make_missing() {
190 public AltosRecordTM(AltosRecord old) {
195 public AltosRecordTM() {