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_1;
20 public class AltosRecordTM extends AltosRecord {
30 public int ground_accel;
31 public int ground_pres;
32 public int accel_plus_g;
33 public int accel_minus_g;
35 public int flight_accel;
36 public int flight_vel;
37 public int flight_pres;
40 * Values for our MP3H6115A pressure sensor
42 * From the data sheet:
44 * Pressure range: 15-115 kPa
45 * Voltage at 115kPa: 2.82
46 * Output scale: 27mV/kPa
49 * 27 mV/kPa * 2047 / 3300 counts/mV = 16.75 counts/kPa
50 * 2.82V * 2047 / 3.3 counts/V = 1749 counts/115 kPa
53 static final double counts_per_kPa = 27 * 2047 / 3300;
54 static final double counts_at_101_3kPa = 1674.0;
57 barometer_to_pressure(double count)
59 return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0;
62 public double pressure() {
65 return barometer_to_pressure(pres);
68 public double ground_pressure() {
69 if (ground_pres == MISSING)
71 return barometer_to_pressure(ground_pres);
74 public double battery_voltage() {
77 return AltosConvert.cc_battery_to_voltage(batt);
80 public double main_voltage() {
83 return AltosConvert.cc_ignitor_to_voltage(main);
86 public double drogue_voltage() {
87 if (drogue == MISSING)
89 return AltosConvert.cc_ignitor_to_voltage(drogue);
92 /* Value for the CC1111 built-in temperature sensor
93 * Output voltage at 0°C = 0.755V
94 * Coefficient = 0.00247V/°C
95 * Reference voltage = 1.25V
97 * temp = ((value / 32767) * 1.25 - 0.755) / 0.00247
98 * = (value - 19791.268) / 32768 * 1.25 / 0.00247
102 thermometer_to_temperature(double thermo)
104 return (thermo - 19791.268) / 32728.0 * 1.25 / 0.00247;
107 public double temperature() {
110 return thermometer_to_temperature(temp);
113 double accel_counts_per_mss() {
114 double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2;
116 return counts_per_g / 9.80665;
119 public double acceleration() {
120 if (ground_accel == MISSING || accel == MISSING)
122 return (ground_accel - accel) / accel_counts_per_mss();
125 public void copy(AltosRecordTM old) {
128 version = old.version;
129 callsign = old.callsign;
142 flight_accel = old.flight_accel;
143 ground_accel = old.ground_accel;
144 flight_vel = old.flight_vel;
145 flight_pres = old.flight_pres;
146 ground_pres = old.ground_pres;
147 accel_plus_g = old.accel_plus_g;
148 accel_minus_g = old.accel_minus_g;
151 public AltosRecordTM clone() {
152 return new AltosRecordTM(this);
155 void make_missing() {
163 flight_accel = MISSING;
164 flight_vel = MISSING;
165 flight_pres = MISSING;
167 ground_accel = MISSING;
168 ground_pres = MISSING;
169 accel_plus_g = MISSING;
170 accel_minus_g = MISSING;
173 public AltosRecordTM(AltosRecord old) {
178 public AltosRecordTM(AltosRecordTM old) {
182 public AltosRecordTM() {