Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
hott_eam.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Sergey Krukowski <softsr@yahoo.de>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
27#ifndef HOTT_EAM_H
28#define HOTT_EAM_H
29
31#include "modules/imu/imu.h"
32#include "autopilot.h"
33#include "state.h"
34
35//Graupner #33620 Electric Air Module
36#define HOTT_TELEMETRY_EAM_SENSOR_ID 0x8E
37
39 int8_t start_byte; //#01 start int8_t
40 int8_t eam_sensor_id; //#02 EAM sensort id. constat value 0x8e
41 int8_t warning_beeps; //#03 1=A 2=B ... or 'A' - 0x40 = 1
42 // Q Min cell voltage sensor 1
43 // R Min Battery 1 voltage sensor 1
44 // J Max Battery 1 voltage sensor 1
45 // F Mim temperature sensor 1
46 // H Max temperature sensor 1
47 // S Min cell voltage sensor 2
48 // K Max cell voltage sensor 2
49 // G Min temperature sensor 2
50 // I Max temperature sensor 2
51 // W Max current
52 // V Max capacity mAh
53 // P Min main power voltage
54 // X Max main power voltage
55 // O Min altitude
56 // Z Max altitude
57 // C (negative) sink rate m/sec to high
58 // B (negative) sink rate m/3sec to high
59 // N climb rate m/sec to high
60 // M climb rate m/3sec to high
61
62 int8_t sensor_id; //#04 constant value 0xe0
63 int8_t alarm_invers1; //#05 alarm bitmask. Value is displayed inverted
64 //Bit# Alarm field
65 // 0 mAh
66 // 1 Battery 1
67 // 2 Battery 2
68 // 3 Temperature 1
69 // 4 Temperature 2
70 // 5 Altitude
71 // 6 Current
72 // 7 Main power voltage
73 int8_t alarm_invers2; //#06 alarm bitmask. Value is displayed inverted
74 //Bit# Alarm Field
75 // 0 m/s
76 // 1 m/3s
77 // 2 Altitude (duplicate?)
78 // 3 m/s (duplicate?)
79 // 4 m/3s (duplicate?)
80 // 5 unknown/unused
81 // 6 unknown/unused
82 // 7 "ON" sign/text msg active
83
84 int8_t cell1_L; //#07 cell 1 voltage lower value. 0.02V steps, 124=2.48V
91 int8_t cell1_H; //#14 cell 1 voltage high value. 0.02V steps, 124=2.48V
98
99 uint16_t batt1_voltage; //#21 #22 battery 1 voltage 0.02V steps
100
101 uint16_t batt2_voltage; //#23 #24 battery 2 voltage 0.02V steps
102
103 int8_t temp1; //#25 Temperature sensor 1. 0°=20, 26°=46
104 int8_t temp2; //#26 temperature sensor 2
105
106 uint16_t altitude; //#27 #28 Attitude lower value. unit: meters. Value of 500 = 0m
107
108 uint16_t current; //#29 #30 Current in 0.1 steps
109
110 uint16_t main_voltage; //#30 #31 Main power voltage (drive) in 0.1V steps
111
112 uint16_t batt_cap; //#32 #33 used battery capacity in 10mAh steps
113
114 uint16_t climbrate; //#34 #35 climb rate in 0.01m/s. Value of 30000 = 0.00 m/s
115
116 uint8_t climbrate3s; //#36 climbrate in m/3sec. Value of 120 = 0m/3sec
117
118 int8_t rpm_L; //#37 RPM. Steps: 10 U/min
120
121 int8_t electric_min; //#39 Electric minutes. Time does start, when motor current is > 3 A
123
124 int8_t speed_L; //#41 (air?) speed in km/h. Steps 1km/h
126
127 int8_t stop_byte; //#43 stop int8_t
128 //#44 CRC/Parity
129};
130
132{
133 memset(hott_eam_msg, 0, sizeof(struct HOTT_EAM_MSG));
134 hott_eam_msg->start_byte = 0x7C;
136 hott_eam_msg->sensor_id = 0xE0;
137 hott_eam_msg->stop_byte = 0x7D;
138}
139
141{
142 hott_eam_msg->batt1_voltage = electrical.vsupply * 5; // convert from V to steps of 0.2V
143 hott_eam_msg->batt2_voltage = electrical.vsupply * 5; // convert from V to steps of 0.2V
144 //hott_eam_msg->temp1 = 20 + imu.temperature / 10;
145 //hott_eam_msg->temp2 = 20 + imu.temperature / 10;
146 hott_eam_msg->altitude = (uint16_t)(500 + (stateGetPositionEnu_i()->z) / (1 << INT32_POS_FRAC));
147 hott_eam_msg->current = electrical.current * 10; // convert to deciA
148 hott_eam_msg->main_voltage = electrical.vsupply * 10; // convert to deciV
149 hott_eam_msg->batt_cap = 0;
151 hott_eam_msg->speed_L = speed_buf & 0xFF;
152 hott_eam_msg->speed_H = (speed_buf >> 8) & 0xFF;
153
154 hott_eam_msg->climbrate = (uint16_t)(30000 + (stateGetSpeedEnu_i()->z) * 100 / (1 << INT32_SPEED_FRAC));
155 hott_eam_msg->climbrate3s = (uint8_t)(120 + (stateGetSpeedEnu_i()->z) * 3 / (1 << INT32_SPEED_FRAC));
156
157 //display ON when motors are armed
159 hott_eam_msg->alarm_invers2 |= 0x80;
160 } else {
161 hott_eam_msg->alarm_invers2 &= 0x7f;
162 }
163}
164
165#endif /* HOTT_EAM_H */
bool autopilot_get_motors_on(void)
get motors status
Definition autopilot.c:295
Core autopilot interface common to all firmwares.
struct Electrical electrical
Definition electrical.c:92
Interface for electrical status: supply voltage, current, battery status, etc.
float current
current in A
Definition electrical.h:47
float vsupply
supply voltage in V
Definition electrical.h:45
#define INT32_POS_FRAC
#define INT32_SPEED_FRAC
int32_t z
Up.
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
Definition state.h:803
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Definition state.h:1013
static uint32_t stateGetHorizontalSpeedNorm_i(void)
Get norm of horizontal ground speed (int).
Definition state.h:1031
int8_t alarm_invers2
Definition hott_eam.h:73
uint16_t altitude
Definition hott_eam.h:106
int8_t stop_byte
Definition hott_eam.h:127
uint16_t climbrate
Definition hott_eam.h:114
int8_t speed_H
Definition hott_eam.h:125
int8_t speed_L
Definition hott_eam.h:124
int8_t temp2
Definition hott_eam.h:104
static void hott_update_eam_msg(struct HOTT_EAM_MSG *hott_eam_msg)
Definition hott_eam.h:140
int8_t cell3_H
Definition hott_eam.h:93
int8_t temp1
Definition hott_eam.h:103
int8_t cell7_L
Definition hott_eam.h:90
static void hott_init_eam_msg(struct HOTT_EAM_MSG *hott_eam_msg)
Definition hott_eam.h:131
int8_t cell6_L
Definition hott_eam.h:89
int8_t cell2_L
Definition hott_eam.h:85
int8_t cell1_L
Definition hott_eam.h:84
#define HOTT_TELEMETRY_EAM_SENSOR_ID
Definition hott_eam.h:36
int8_t cell1_H
Definition hott_eam.h:91
int8_t alarm_invers1
Definition hott_eam.h:63
uint16_t current
Definition hott_eam.h:108
int8_t cell5_H
Definition hott_eam.h:95
uint8_t climbrate3s
Definition hott_eam.h:116
int8_t sensor_id
Definition hott_eam.h:62
int8_t rpm_L
Definition hott_eam.h:118
int8_t cell4_H
Definition hott_eam.h:94
uint16_t batt2_voltage
Definition hott_eam.h:101
int8_t electric_min
Definition hott_eam.h:121
int8_t cell3_L
Definition hott_eam.h:86
int8_t eam_sensor_id
Definition hott_eam.h:40
int8_t warning_beeps
Definition hott_eam.h:41
int8_t cell6_H
Definition hott_eam.h:96
int8_t cell2_H
Definition hott_eam.h:92
int8_t cell7_H
Definition hott_eam.h:97
uint16_t batt1_voltage
Definition hott_eam.h:99
int8_t cell4_L
Definition hott_eam.h:87
int8_t rpm_H
Definition hott_eam.h:119
int8_t electric_sec
Definition hott_eam.h:122
int8_t cell5_L
Definition hott_eam.h:88
uint16_t batt_cap
Definition hott_eam.h:112
int8_t start_byte
Definition hott_eam.h:39
uint16_t main_voltage
Definition hott_eam.h:110
Inertial Measurement Unit interface.
uint16_t foo
Definition main_demo5.c:58
API to get/set the generic vehicle states.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.