Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures 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 
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
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 
131 static void hott_init_eam_msg(struct HOTT_EAM_MSG* hott_eam_msg) {
132  memset(hott_eam_msg, 0, sizeof(struct HOTT_EAM_MSG));
133  hott_eam_msg->start_byte = 0x7C;
135  hott_eam_msg->sensor_id = 0xE0;
136  hott_eam_msg->stop_byte = 0x7D;
137 }
138 
139 static void hott_update_eam_msg(struct HOTT_EAM_MSG* hott_eam_msg) {
140 
141  hott_eam_msg->batt1_voltage = electrical.vsupply;
142  hott_eam_msg->batt2_voltage = electrical.vsupply;
143  //hott_eam_msg->temp1 = 20 + imu.temperature / 10;
144  //hott_eam_msg->temp2 = 20 + imu.temperature / 10;
145  hott_eam_msg->altitude = (uint16_t)(500 + (stateGetPositionEnu_i()->z) / (1 << INT32_POS_FRAC));
146  hott_eam_msg->current = electrical.current / 100;
147  hott_eam_msg->main_voltage = electrical.vsupply;
148  hott_eam_msg->batt_cap = 0;
149  uint16_t speed_buf = (uint16_t)(*stateGetHorizontalSpeedNorm_i() * 36 / 10 / (1 << INT32_SPEED_FRAC));
150  hott_eam_msg->speed_L = speed_buf && 0xFF;
151  hott_eam_msg->speed_H = (speed_buf >> 8) && 0xFF;
152 
153  hott_eam_msg->climbrate = (uint16_t)(30000 + (stateGetSpeedEnu_i()->z) * 100 / (1 << INT32_SPEED_FRAC));
154  hott_eam_msg->climbrate3s = (uint8_t)(120 + (stateGetSpeedEnu_i()->z) * 3 / (1 << INT32_SPEED_FRAC));
155 
156  //display ON when motors are armed
157  if (autopilot_motors_on) {
158  hott_eam_msg->alarm_invers2 |= 0x80;
159  } else {
160  hott_eam_msg->alarm_invers2 &= 0x7f;
161  }
162 }
163 
164 #endif /* HOTT_EAM_H */
unsigned short uint16_t
Definition: types.h:16
int8_t electric_min
Definition: hott_eam.h:121
int8_t sensor_id
Definition: hott_eam.h:62
int8_t alarm_invers2
Definition: hott_eam.h:73
#define INT32_POS_FRAC
bool_t autopilot_motors_on
Definition: autopilot.c:54
int8_t electric_sec
Definition: hott_eam.h:122
uint16_t batt1_voltage
Definition: hott_eam.h:99
int8_t cell7_H
Definition: hott_eam.h:97
uint16_t main_voltage
Definition: hott_eam.h:110
uint16_t vsupply
supply voltage in decivolts
Definition: electrical.h:48
uint16_t altitude
Definition: hott_eam.h:106
static int32_t * stateGetHorizontalSpeedNorm_i(void)
Get norm of horizontal ground speed (int).
Definition: state.h:819
int8_t cell3_L
Definition: hott_eam.h:86
int8_t temp2
Definition: hott_eam.h:104
int8_t cell1_L
Definition: hott_eam.h:84
uint16_t climbrate
Definition: hott_eam.h:114
int32_t z
Up.
int8_t cell5_L
Definition: hott_eam.h:88
static void hott_update_eam_msg(struct HOTT_EAM_MSG *hott_eam_msg)
Definition: hott_eam.h:139
Interface for electrical status: supply voltage, current, battery status, etc.
int8_t cell7_L
Definition: hott_eam.h:90
int8_t start_byte
Definition: hott_eam.h:39
int8_t rpm_H
Definition: hott_eam.h:119
int8_t speed_H
Definition: hott_eam.h:125
int8_t temp1
Definition: hott_eam.h:103
int8_t cell2_L
Definition: hott_eam.h:85
uint16_t batt2_voltage
Definition: hott_eam.h:101
int8_t cell2_H
Definition: hott_eam.h:92
uint16_t current
Definition: hott_eam.h:108
int8_t cell4_L
Definition: hott_eam.h:87
Inertial Measurement Unit interface.
int8_t cell4_H
Definition: hott_eam.h:94
#define HOTT_TELEMETRY_EAM_SENSOR_ID
Definition: hott_eam.h:36
uint16_t batt_cap
Definition: hott_eam.h:112
int32_t current
current in milliamps
Definition: electrical.h:49
uint8_t climbrate3s
Definition: hott_eam.h:116
int8_t cell1_H
Definition: hott_eam.h:91
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
int8_t rpm_L
Definition: hott_eam.h:118
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Definition: state.h:805
int8_t eam_sensor_id
Definition: hott_eam.h:40
int8_t stop_byte
Definition: hott_eam.h:127
struct Electrical electrical
int8_t cell6_L
Definition: hott_eam.h:89
int8_t cell6_H
Definition: hott_eam.h:96
#define INT32_SPEED_FRAC
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
Definition: state.h:637
signed char int8_t
Definition: types.h:15
int8_t alarm_invers1
Definition: hott_eam.h:63
static void hott_init_eam_msg(struct HOTT_EAM_MSG *hott_eam_msg)
Definition: hott_eam.h:131
int8_t speed_L
Definition: hott_eam.h:124
int8_t warning_beeps
Definition: hott_eam.h:41
int8_t cell3_H
Definition: hott_eam.h:93
int8_t cell5_H
Definition: hott_eam.h:95