From: Keith Packard Date: Mon, 20 Feb 2017 01:36:04 +0000 (-0800) Subject: altoslib: Add TeleMini v3 support X-Git-Tag: 1.7~105 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=1029a6e4a61b20698e00e29fc0c8c3877f1e7b0f altoslib: Add TeleMini v3 support eeprom, telemetry and monitor idle. This is just like TeleMini v2, except the ADC ranges are all difference as the voltage dividers are different and the ADC itself has a different range. Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 288f43ce..0b413287 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -219,7 +219,23 @@ public class AltosConvert { return AltosLib.MISSING; } - static double tele_mini_voltage(int sensor) { + static double tele_mini_3_adc(int raw) { + return raw / 4095.0; + } + + static public double tele_mini_3_battery_voltage(int v_batt) { + if (v_batt != AltosLib.MISSING) + return 3.3 * tele_mini_3_adc(v_batt) * (5.6 + 10.0) / 10.0; + return AltosLib.MISSING; + } + + static double tele_mini_3_pyro_voltage(int raw) { + if (raw != AltosLib.MISSING) + return 3.3 * tele_mini_3_adc(raw) * (100.0 + 27.0) / 27.0; + return AltosLib.MISSING; + } + + static double tele_mini_2_voltage(int sensor) { double supply = 3.3; return sensor / 32767.0 * supply * 127/27; diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index c9598254..36b5961b 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -82,7 +82,8 @@ public class AltosEepromChunk { case AltosLib.AO_LOG_FORMAT_TELEMETRUM: eeprom = new AltosEepromMetrum2(this, offset); break; - case AltosLib.AO_LOG_FORMAT_TELEMINI: + case AltosLib.AO_LOG_FORMAT_TELEMINI2: + case AltosLib.AO_LOG_FORMAT_TELEMINI3: case AltosLib.AO_LOG_FORMAT_EASYMINI: eeprom = new AltosEepromMini(this, offset); break; diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index 957c826a..baeec730 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -101,7 +101,8 @@ public class AltosEepromFile extends AltosStateIterable { case AltosLib.AO_LOG_FORMAT_TELEMETRUM: body = new AltosEepromIterable(AltosEepromMetrum2.read(input)); break; - case AltosLib.AO_LOG_FORMAT_TELEMINI: + case AltosLib.AO_LOG_FORMAT_TELEMINI2: + case AltosLib.AO_LOG_FORMAT_TELEMINI3: case AltosLib.AO_LOG_FORMAT_EASYMINI: body = new AltosEepromIterable(AltosEepromMini.read(input)); break; diff --git a/altoslib/AltosEepromMini.java b/altoslib/AltosEepromMini.java index dc51e591..04155071 100644 --- a/altoslib/AltosEepromMini.java +++ b/altoslib/AltosEepromMini.java @@ -42,11 +42,24 @@ public class AltosEepromMini extends AltosEeprom { public int sense_m() { return data16(8); } public int v_batt() { return data16(10); } - double voltage(AltosState state, int sensor) { + private double battery_voltage(AltosState state, int sensor) { if (state.log_format == AltosLib.AO_LOG_FORMAT_EASYMINI) return AltosConvert.easy_mini_voltage(sensor, state.serial); - else - return AltosConvert.tele_mini_voltage(sensor); + if (state.log_format == AltosLib.AO_LOG_FORMAT_TELEMINI2) + return AltosConvert.tele_mini_2_voltage(sensor); + if (state.log_format == AltosLib.AO_LOG_FORMAT_TELEMINI3) + return AltosConvert.tele_mini_3_battery_voltage(sensor); + return -1; + } + + private double pyro_voltage(AltosState state, int sensor) { + if (state.log_format == AltosLib.AO_LOG_FORMAT_EASYMINI) + return AltosConvert.easy_mini_voltage(sensor, state.serial); + if (state.log_format == AltosLib.AO_LOG_FORMAT_TELEMINI2) + return AltosConvert.tele_mini_2_voltage(sensor); + if (state.log_format == AltosLib.AO_LOG_FORMAT_TELEMINI3) + return AltosConvert.tele_mini_3_pyro_voltage(sensor); + return -1; } public void update_state(AltosState state) { @@ -62,9 +75,9 @@ public class AltosEepromMini extends AltosEeprom { break; case AltosLib.AO_LOG_SENSOR: state.set_ms5607(pres(), temp()); - state.set_apogee_voltage(voltage(state, sense_a())); - state.set_main_voltage(voltage(state, sense_m())); - state.set_battery_voltage(voltage(state, v_batt())); + state.set_apogee_voltage(pyro_voltage(state, sense_a())); + state.set_main_voltage(pyro_voltage(state, sense_m())); + state.set_battery_voltage(battery_voltage(state, v_batt())); break; } } diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 8871e9cc..5c6f57e0 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -38,8 +38,9 @@ class AltosIdler { static final int idle_sensor_metrum = 11; static final int idle_sensor_mega = 12; static final int idle_sensor_emini = 13; - static final int idle_sensor_tmini = 14; + static final int idle_sensor_tmini2 = 14; static final int idle_sensor_tgps = 15; + static final int idle_sensor_tmini3 = 16; public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException, AltosUnknownProduct { for (int idler : idlers) { @@ -72,12 +73,15 @@ class AltosIdler { case idle_sensor_emini: AltosSensorEMini.update_state(state, link, config_data); break; - case idle_sensor_tmini: + case idle_sensor_tmini2: AltosSensorTMini.update_state(state, link, config_data); break; case idle_sensor_tgps: AltosSensorTGPS.update_state(state, link, config_data); break; + case idle_sensor_tmini3: + AltosSensorTMini3.update_state(state, link, config_data); + break; } if (idle != null) idle.update_state(state); @@ -108,7 +112,11 @@ public class AltosIdleFetch implements AltosStateUpdate { new AltosIdler("TeleMini-v2", AltosIdler.idle_ms5607, - AltosIdler.idle_sensor_tmini), + AltosIdler.idle_sensor_tmini2), + + new AltosIdler("TeleMini-v3", + AltosIdler.idle_ms5607, + AltosIdler.idle_sensor_tmini3), new AltosIdler("TeleMetrum-v1", AltosIdler.idle_gps, diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index cfa1fa27..aec2c692 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -332,9 +332,11 @@ public class AltosLib { public static final int AO_LOG_FORMAT_TELEMEGA_OLD = 5; public static final int AO_LOG_FORMAT_EASYMINI = 6; public static final int AO_LOG_FORMAT_TELEMETRUM = 7; - public static final int AO_LOG_FORMAT_TELEMINI = 8; + public static final int AO_LOG_FORMAT_TELEMINI2 = 8; public static final int AO_LOG_FORMAT_TELEGPS = 9; public static final int AO_LOG_FORMAT_TELEMEGA = 10; + public static final int AO_LOG_FORMAT_DETHERM = 11; + public static final int AO_LOG_FORMAT_TELEMINI3 = 12; public static final int AO_LOG_FORMAT_NONE = 127; public static boolean isspace(int c) { diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java deleted file mode 100644 index 073144d4..00000000 --- a/altoslib/AltosSensorTMini.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package org.altusmetrum.altoslib_11; - -import java.util.concurrent.TimeoutException; - -public class AltosSensorTMini { - public int tick; - public int apogee; - public int main; - public int batt; - - static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException { - try { - AltosSensorTMini sensor_tmini = new AltosSensorTMini(link); - - if (sensor_tmini == null) - return; - state.set_battery_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.batt)); - state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.apogee)); - state.set_main_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.main)); - - } catch (TimeoutException te) { - } - } - - public AltosSensorTMini(AltosLink link) throws InterruptedException, TimeoutException { - String[] items = link.adc(); - for (int i = 0; i < items.length;) { - if (items[i].equals("tick:")) { - tick = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("apogee:")) { - apogee = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("main:")) { - main = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("batt:")) { - batt = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - i++; - } - } -} - diff --git a/altoslib/AltosSensorTMini2.java b/altoslib/AltosSensorTMini2.java new file mode 100644 index 00000000..7e00abd0 --- /dev/null +++ b/altoslib/AltosSensorTMini2.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_11; + +import java.util.concurrent.TimeoutException; + +public class AltosSensorTMini2 { + public int tick; + public int apogee; + public int main; + public int batt; + + static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException { + try { + AltosSensorTMini2 sensor_tmini = new AltosSensorTMini2(link); + + if (sensor_tmini == null) + return; + state.set_battery_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.batt)); + state.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.apogee)); + state.set_main_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.main)); + + } catch (TimeoutException te) { + } + } + + public AltosSensorTMini2(AltosLink link) throws InterruptedException, TimeoutException { + String[] items = link.adc(); + for (int i = 0; i < items.length;) { + if (items[i].equals("tick:")) { + tick = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("apogee:")) { + apogee = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("main:")) { + main = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("batt:")) { + batt = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + i++; + } + } +} + diff --git a/altoslib/AltosSensorTMini3.java b/altoslib/AltosSensorTMini3.java new file mode 100644 index 00000000..19d514d7 --- /dev/null +++ b/altoslib/AltosSensorTMini3.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_11; + +import java.util.concurrent.TimeoutException; + +public class AltosSensorTMini3 { + public int tick; + public int apogee; + public int main; + public int batt; + + static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException { + try { + AltosSensorTMini3 sensor_tmini = new AltosSensorTMini3(link); + + if (sensor_tmini == null) + return; + state.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(sensor_tmini.batt)); + state.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sensor_tmini.apogee)); + state.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sensor_tmini.main)); + + } catch (TimeoutException te) { + } + } + + public AltosSensorTMini3(AltosLink link) throws InterruptedException, TimeoutException { + String[] items = link.adc(); + for (int i = 0; i < items.length;) { + if (items[i].equals("tick:")) { + tick = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("apogee:")) { + apogee = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("main:")) { + main = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("batt:")) { + batt = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + i++; + } + } +} + diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 0caefcd6..f830bf35 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -67,7 +67,8 @@ public abstract class AltosTelemetry implements AltosStateUpdate { final static int packet_type_mega_data = 0x09; final static int packet_type_metrum_sensor = 0x0a; final static int packet_type_metrum_data = 0x0b; - final static int packet_type_mini = 0x10; + final static int packet_type_mini2 = 0x10; + final static int packet_type_mini3 = 0x11; static AltosTelemetry parse_hex(String hex) throws ParseException, AltosCRCException { AltosTelemetry telem = null; diff --git a/altoslib/AltosTelemetryMini.java b/altoslib/AltosTelemetryMini.java deleted file mode 100644 index 74adb052..00000000 --- a/altoslib/AltosTelemetryMini.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package org.altusmetrum.altoslib_11; - - -public class AltosTelemetryMini extends AltosTelemetryStandard { - int state; - - int v_batt; - int sense_a; - int sense_m; - - int pres; - int temp; - - int acceleration; - int speed; - int height; - - int ground_pres; - - public AltosTelemetryMini(int[] bytes) { - super(bytes); - - state = int8(5); - - v_batt = int16(6); - sense_a = int16(8); - sense_m = int16(10); - - pres = int32(12); - temp = int16(16); - - acceleration = int16(18); - speed = int16(20); - height = int16(22); - - ground_pres = int32(24); - } - - public void update_state(AltosState state) { - super.update_state(state); - - state.set_state(this.state); - - state.set_battery_voltage(AltosConvert.tele_mini_voltage(v_batt)); - state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sense_a)); - state.set_main_voltage(AltosConvert.tele_mini_voltage(sense_m)); - - state.set_ground_pressure(ground_pres); - - state.set_pressure(pres); - state.set_temperature(temp/100.0); - - state.set_kalman(height, speed/16.0, acceleration/16.0); - } -} diff --git a/altoslib/AltosTelemetryMini2.java b/altoslib/AltosTelemetryMini2.java new file mode 100644 index 00000000..50ec504d --- /dev/null +++ b/altoslib/AltosTelemetryMini2.java @@ -0,0 +1,73 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_11; + + +public class AltosTelemetryMini2 extends AltosTelemetryStandard { + int state; + + int v_batt; + int sense_a; + int sense_m; + + int pres; + int temp; + + int acceleration; + int speed; + int height; + + int ground_pres; + + public AltosTelemetryMini2(int[] bytes) { + super(bytes); + + state = int8(5); + + v_batt = int16(6); + sense_a = int16(8); + sense_m = int16(10); + + pres = int32(12); + temp = int16(16); + + acceleration = int16(18); + speed = int16(20); + height = int16(22); + + ground_pres = int32(24); + } + + public void update_state(AltosState state) { + super.update_state(state); + + state.set_state(this.state); + + state.set_battery_voltage(AltosConvert.tele_mini_2_voltage(v_batt)); + state.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sense_a)); + state.set_main_voltage(AltosConvert.tele_mini_2_voltage(sense_m)); + + state.set_ground_pressure(ground_pres); + + state.set_pressure(pres); + state.set_temperature(temp/100.0); + + state.set_kalman(height, speed/16.0, acceleration/16.0); + } +} diff --git a/altoslib/AltosTelemetryMini3.java b/altoslib/AltosTelemetryMini3.java new file mode 100644 index 00000000..21f8c485 --- /dev/null +++ b/altoslib/AltosTelemetryMini3.java @@ -0,0 +1,76 @@ +/* + * Copyright © 2017 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_11; + + +public class AltosTelemetryMini3 extends AltosTelemetryStandard { + + int state; + + int v_batt; + int sense_a; + int sense_m; + + int pres; + int temp; + + int acceleration; + int speed; + int height_16; + + int ground_pres; + + public AltosTelemetryMini3(int[] bytes) { + super(bytes); + + state = int8(5); + + v_batt = int16(6); + sense_a = int16(8); + sense_m = int16(10); + + pres = int32(12); + temp = int16(16); + + acceleration = int16(18); + speed = int16(20); + height_16 = int16(22); + + ground_pres = int32(24); + } + + public void update_state(AltosState state) { + super.update_state(state); + + state.set_state(this.state); + + state.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(v_batt)); + + state.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_a)); + state.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_m)); + + state.set_pressure(pres); + state.set_temperature(temp/100.0); + + state.set_kalman(extend_height(state, height_16), + speed/16.0, acceleration/16.0); + + state.set_ground_pressure(ground_pres); + } +} diff --git a/altoslib/AltosTelemetryStandard.java b/altoslib/AltosTelemetryStandard.java index 4f0d7130..35d315c7 100644 --- a/altoslib/AltosTelemetryStandard.java +++ b/altoslib/AltosTelemetryStandard.java @@ -84,8 +84,11 @@ public abstract class AltosTelemetryStandard extends AltosTelemetry { case packet_type_metrum_data: telem = new AltosTelemetryMetrumData(bytes); break; - case packet_type_mini: - telem = new AltosTelemetryMini(bytes); + case packet_type_mini2: + telem = new AltosTelemetryMini2(bytes); + break; + case packet_type_mini3: + telem = new AltosTelemetryMini3(bytes); break; default: telem = new AltosTelemetryRaw(bytes); diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 2a9eb9c9..3af12c99 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -88,7 +88,8 @@ altoslib_JAVA = \ AltosSensorMM.java \ AltosSensorEMini.java \ AltosSensorTM.java \ - AltosSensorTMini.java \ + AltosSensorTMini2.java \ + AltosSensorTMini3.java \ AltosSensorMega.java \ AltosSensorMetrum.java \ AltosSensorTGPS.java \ @@ -105,7 +106,8 @@ altoslib_JAVA = \ AltosTelemetryMap.java \ AltosTelemetryMegaSensor.java \ AltosTelemetryMegaData.java \ - AltosTelemetryMini.java \ + AltosTelemetryMini2.java \ + AltosTelemetryMini3.java \ AltosTelemetryMetrumSensor.java \ AltosTelemetryMetrumData.java \ AltosTelemetryReader.java \