diff options
Diffstat (limited to 'ao-tools')
| -rw-r--r-- | ao-tools/ao-view/aoview_state.c | 8 | ||||
| -rw-r--r-- | ao-tools/lib/cc-convert.c | 11 |
2 files changed, 14 insertions, 5 deletions
diff --git a/ao-tools/ao-view/aoview_state.c b/ao-tools/ao-view/aoview_state.c index 838899a7..505bcddc 100644 --- a/ao-tools/ao-view/aoview_state.c +++ b/ao-tools/ao-view/aoview_state.c @@ -127,10 +127,10 @@ aoview_state_derive(struct cc_telem *data, struct aostate *state) accel_counts_per_mss = ((data->accel_minus_g - data->accel_plus_g) / 2.0) / 9.80665; state->acceleration = (data->ground_accel - data->flight_accel) / accel_counts_per_mss; state->speed = data->flight_vel / (accel_counts_per_mss * 100.0); - state->temperature = ((data->temp / 32767.0 * 3.3) - 0.5) / 0.01; - state->drogue_sense = data->drogue / 32767.0 * 15.0; - state->main_sense = data->main / 32767.0 * 15.0; - state->battery = data->batt / 32767.0 * 5.0; + state->temperature = cc_thermometer_to_temperature(data->temp); + state->drogue_sense = cc_ignitor_to_voltage(data->drogue); + state->main_sense = cc_ignitor_to_voltage(data->main); + state->battery = cc_battery_to_voltage(data->batt); if (!strcmp(data->state, "pad")) { if (data->gps.gps_locked && data->gps.nsat >= 4) { state->npad++; diff --git a/ao-tools/lib/cc-convert.c b/ao-tools/lib/cc-convert.c index ac6962ba..8d6876a0 100644 --- a/ao-tools/lib/cc-convert.c +++ b/ao-tools/lib/cc-convert.c @@ -213,10 +213,19 @@ cc_accelerometer_to_acceleration(double accel, double ground_accel) return (ground_accel - accel) / count_per_mss; } +/* Value for the CC1111 built-in temperature sensor + * Output voltage at 0°C = 0.755V + * Coefficient = 0.00247V/°C + * Reference voltage = 1.25V + * + * temp = ((value / 32767) * 1.25 - 0.755) / 0.00247 + * = (value - 19791.268) / 32768 * 1.25 / 0.00247 + */ + double cc_thermometer_to_temperature(double thermo) { - return ((thermo / 32767 * 3.3) - 0.5) / 0.01; + return (thermo - 19791.268) / 32728.0 * 1.25 / 0.00247; } double |
