Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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
30
#include "
subsystems/electrical.h
"
31
#include "
subsystems/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
38
struct
HOTT_EAM_MSG
{
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
85
int8_t
cell2_L
;
//#08
86
int8_t
cell3_L
;
//#09
87
int8_t
cell4_L
;
//#10
88
int8_t
cell5_L
;
//#11
89
int8_t
cell6_L
;
//#12
90
int8_t
cell7_L
;
//#13
91
int8_t
cell1_H
;
//#14 cell 1 voltage high value. 0.02V steps, 124=2.48V
92
int8_t
cell2_H
;
//#15
93
int8_t
cell3_H
;
//#16
94
int8_t
cell4_H
;
//#17
95
int8_t
cell5_H
;
//#18
96
int8_t
cell6_H
;
//#19
97
int8_t
cell7_H
;
//#20
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
119
int8_t
rpm_H
;
//#38
120
121
int8_t
electric_min
;
//#39 Electric minutes. Time does start, when motor current is > 3 A
122
int8_t
electric_sec
;
//#40
123
124
int8_t
speed_L
;
//#41 (air?) speed in km/h. Steps 1km/h
125
int8_t
speed_H
;
//#42
126
127
int8_t
stop_byte
;
//#43 stop int8_t
128
//#44 CRC/Parity
129
};
130
131
static
void
hott_init_eam_msg
(
struct
HOTT_EAM_MSG
*hott_eam_msg)
132
{
133
memset(hott_eam_msg, 0,
sizeof
(
struct
HOTT_EAM_MSG
));
134
hott_eam_msg->
start_byte
= 0x7C;
135
hott_eam_msg->
eam_sensor_id
=
HOTT_TELEMETRY_EAM_SENSOR_ID
;
136
hott_eam_msg->
sensor_id
= 0xE0;
137
hott_eam_msg->
stop_byte
= 0x7D;
138
}
139
140
static
void
hott_update_eam_msg
(
struct
HOTT_EAM_MSG
*hott_eam_msg)
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;
150
uint16_t
speed_buf = (
uint16_t
)(
stateGetHorizontalSpeedNorm_i
() * 36 / 10 / (1 <<
INT32_SPEED_FRAC
));
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
158
if
(
autopilot_get_motors_on
()) {
159
hott_eam_msg->
alarm_invers2
|= 0x80;
160
}
else
{
161
hott_eam_msg->
alarm_invers2
&= 0x7f;
162
}
163
}
164
165
#endif
/* HOTT_EAM_H */
autopilot_get_motors_on
bool autopilot_get_motors_on(void)
get motors status
Definition:
autopilot.c:212
HOTT_EAM_MSG::cell4_H
int8_t cell4_H
Definition:
hott_eam.h:94
electrical.h
HOTT_EAM_MSG::electric_sec
int8_t electric_sec
Definition:
hott_eam.h:122
uint16_t
unsigned short uint16_t
Definition:
types.h:16
HOTT_EAM_MSG::cell4_L
int8_t cell4_L
Definition:
hott_eam.h:87
HOTT_EAM_MSG::cell1_H
int8_t cell1_H
Definition:
hott_eam.h:91
HOTT_EAM_MSG::alarm_invers1
int8_t alarm_invers1
Definition:
hott_eam.h:63
HOTT_EAM_MSG::cell5_L
int8_t cell5_L
Definition:
hott_eam.h:88
HOTT_EAM_MSG::speed_H
int8_t speed_H
Definition:
hott_eam.h:125
INT32_SPEED_FRAC
#define INT32_SPEED_FRAC
Definition:
pprz_algebra_int.h:73
HOTT_EAM_MSG::cell1_L
int8_t cell1_L
Definition:
hott_eam.h:84
HOTT_TELEMETRY_EAM_SENSOR_ID
#define HOTT_TELEMETRY_EAM_SENSOR_ID
Definition:
hott_eam.h:36
HOTT_EAM_MSG::cell7_H
int8_t cell7_H
Definition:
hott_eam.h:97
stateGetPositionEnu_i
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
Definition:
state.h:674
HOTT_EAM_MSG::cell6_H
int8_t cell6_H
Definition:
hott_eam.h:96
HOTT_EAM_MSG::speed_L
int8_t speed_L
Definition:
hott_eam.h:124
HOTT_EAM_MSG::current
uint16_t current
Definition:
hott_eam.h:108
Electrical::vsupply
float vsupply
supply voltage in V
Definition:
electrical.h:45
HOTT_EAM_MSG::cell6_L
int8_t cell6_L
Definition:
hott_eam.h:89
HOTT_EAM_MSG::start_byte
int8_t start_byte
Definition:
hott_eam.h:39
HOTT_EAM_MSG::climbrate
uint16_t climbrate
Definition:
hott_eam.h:114
HOTT_EAM_MSG::temp1
int8_t temp1
Definition:
hott_eam.h:103
imu.h
HOTT_EAM_MSG::batt2_voltage
uint16_t batt2_voltage
Definition:
hott_eam.h:101
HOTT_EAM_MSG::eam_sensor_id
int8_t eam_sensor_id
Definition:
hott_eam.h:40
stateGetSpeedEnu_i
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Definition:
state.h:872
hott_update_eam_msg
static void hott_update_eam_msg(struct HOTT_EAM_MSG *hott_eam_msg)
Definition:
hott_eam.h:140
HOTT_EAM_MSG::warning_beeps
int8_t warning_beeps
Definition:
hott_eam.h:41
HOTT_EAM_MSG::main_voltage
uint16_t main_voltage
Definition:
hott_eam.h:110
HOTT_EAM_MSG::temp2
int8_t temp2
Definition:
hott_eam.h:104
HOTT_EAM_MSG::cell2_L
int8_t cell2_L
Definition:
hott_eam.h:85
HOTT_EAM_MSG::rpm_L
int8_t rpm_L
Definition:
hott_eam.h:118
uint8_t
unsigned char uint8_t
Definition:
types.h:14
autopilot.h
HOTT_EAM_MSG::cell3_L
int8_t cell3_L
Definition:
hott_eam.h:86
HOTT_EAM_MSG::cell7_L
int8_t cell7_L
Definition:
hott_eam.h:90
HOTT_EAM_MSG::rpm_H
int8_t rpm_H
Definition:
hott_eam.h:119
HOTT_EAM_MSG
Definition:
hott_eam.h:38
HOTT_EAM_MSG::batt1_voltage
uint16_t batt1_voltage
Definition:
hott_eam.h:99
HOTT_EAM_MSG::cell2_H
int8_t cell2_H
Definition:
hott_eam.h:92
HOTT_EAM_MSG::electric_min
int8_t electric_min
Definition:
hott_eam.h:121
HOTT_EAM_MSG::altitude
uint16_t altitude
Definition:
hott_eam.h:106
HOTT_EAM_MSG::batt_cap
uint16_t batt_cap
Definition:
hott_eam.h:112
int8_t
signed char int8_t
Definition:
types.h:15
HOTT_EAM_MSG::climbrate3s
uint8_t climbrate3s
Definition:
hott_eam.h:116
hott_init_eam_msg
static void hott_init_eam_msg(struct HOTT_EAM_MSG *hott_eam_msg)
Definition:
hott_eam.h:131
HOTT_EAM_MSG::cell5_H
int8_t cell5_H
Definition:
hott_eam.h:95
stateGetHorizontalSpeedNorm_i
static uint32_t stateGetHorizontalSpeedNorm_i(void)
Get norm of horizontal ground speed (int).
Definition:
state.h:890
HOTT_EAM_MSG::stop_byte
int8_t stop_byte
Definition:
hott_eam.h:127
HOTT_EAM_MSG::cell3_H
int8_t cell3_H
Definition:
hott_eam.h:93
EnuCoor_i::z
int32_t z
Up.
Definition:
pprz_geodetic_int.h:80
electrical
struct Electrical electrical
Definition:
electrical.c:66
state.h
HOTT_EAM_MSG::sensor_id
int8_t sensor_id
Definition:
hott_eam.h:62
HOTT_EAM_MSG::alarm_invers2
int8_t alarm_invers2
Definition:
hott_eam.h:73
INT32_POS_FRAC
#define INT32_POS_FRAC
Definition:
pprz_algebra_int.h:68
Electrical::current
float current
current in A
Definition:
electrical.h:46
sw
airborne
modules
hott
hott_eam.h
Generated on Tue Feb 1 2022 13:51:15 for Paparazzi UAS by
1.8.17