STIMA
3
platformio
stima_v3
i2c-wind
src
i2c-wind-config.h
1
2
/*********************************************************************
3
Copyright (C) 2022 Marco Baldinetti <m.baldinetti@digiteco.it>
4
authors:
5
Paolo patruno <p.patruno@iperbole.bologna.it>
6
Marco Baldinetti <m.baldinetti@digiteco.it>
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License as
10
published by the Free Software Foundation; either version 2 of
11
the License, or (at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
20
**********************************************************************/
21
22
#ifndef _I2C_WIND_CONFIG_H
23
#define _I2C_WIND_CONFIG_H
24
25
#include <sensors_config.h>
26
27
/*********************************************************************
28
* MODULE
29
*********************************************************************/
34
#define MODULE_MAIN_VERSION (3)
35
40
#define MODULE_MINOR_VERSION (18)
41
46
#define MODULE_CONFIGURATION_VERSION (1)
47
52
#define MODULE_TYPE (STIMA_MODULE_TYPE_WIND)
53
54
/*********************************************************************
55
* CONFIGURATION
56
*********************************************************************/
61
#define CONFIGURATION_DEFAULT_IS_ONESHOT (false)
62
67
#define CONFIGURATION_DEFAULT_I2C_ADDRESS (I2C_WIND_DEFAULT_ADDRESS)
68
73
#define CONFIGURATION_RESET_PIN (8)
74
75
#if (USE_SENSOR_DES || USE_SENSOR_DED)
80
#define WIND_POWER_PIN (5)
81
86
#define WIND_DIRECTION_ANALOG_PIN (A0)
87
92
#define WIND_SPEED_DIGITAL_PIN (3)
93
94
#define ADC_VOLTAGE_MAX (5000.0)
95
#define ADC_VOLTAGE_MIN (0.0)
96
97
#define ADC_MAX (1023.0)
98
#define ADC_MIN (0.0)
99
100
#define WIND_DIRECTION_VOLTAGE_MAX (4500.0)
101
#define WIND_DIRECTION_VOLTAGE_MIN (500.0)
102
103
#define WIND_DIRECTION_ERROR_VOLTAGE_MAX (50.0)
104
#define WIND_DIRECTION_ERROR_VOLTAGE_MIN (50.0)
105
106
#define WIND_DIRECTION_MAX (360.0)
107
#define WIND_DIRECTION_MIN (0.0)
108
109
#define WIND_SPEED_HZ_MAX (250.0)
110
#define WIND_SPEED_HZ_MIN (0.0)
111
#define WIND_SPEED_HZ_TURN (1.0)
112
113
#define WIND_SPEED_MAX (50.0)
114
#define WIND_SPEED_MIN (0.0)
115
116
#define CONFIGURATION_DEFAULT_ADC_VOLTAGE_OFFSET_1 (0.0)
117
#define CONFIGURATION_DEFAULT_ADC_VOLTAGE_OFFSET_2 (1.0)
118
#define CONFIGURATION_DEFAULT_ADC_VOLTAGE_MIN (WIND_DIRECTION_VOLTAGE_MIN)
119
#define CONFIGURATION_DEFAULT_ADC_VOLTAGE_MAX (WIND_DIRECTION_VOLTAGE_MAX)
120
121
#endif
122
123
#if (USE_SENSOR_GWS)
124
#define WIND_POWER_PIN (4)
125
126
#define WIND_DIRECTION_MAX (360.0)
127
#define WIND_DIRECTION_MIN (0.0)
128
129
#define WIND_SPEED_MAX (60.0)
130
#define WIND_SPEED_MIN (0.0)
131
132
#define GWS_SERIAL_BAUD (9600)
133
#define GWS_SERIAL_TIMEOUT_MS (0)
134
135
#define UART_RX_BUFFER_LENGTH (41)
136
#endif
137
#define
SDCARD_CHIP_SELECT_PIN
7
142
147
#define SPI_SPEED SD_SCK_MHZ(4)
148
153
#define I2C_MAX_TIME (180)
154
155
/*********************************************************************
156
* POWER DOWN
157
*********************************************************************/
162
#define USE_POWER_DOWN (true)
163
168
#define DEBOUNCING_POWER_DOWN_TIME_MS (10)
169
174
#define USE_TIMER_1 (true)
175
176
/*********************************************************************
177
* WATCHDOG
178
*********************************************************************/
187
#define WDT_TIMER (WDTO_8S)
188
189
/*********************************************************************
190
* WIND SENSORS
191
*********************************************************************/
192
193
#if (USE_SENSOR_DES || USE_SENSOR_DED)
198
#define SENSORS_ACQ_TIME_MS (2000)
199
200
#define SENSORS_SAMPLE_TIME_MS (SENSORS_ACQ_TIME_MS * 3)
201
#define SENSORS_WARMUP_TIME_MS (SENSORS_SAMPLE_TIME_MS / 2)
202
#endif
203
204
#if (USE_SENSOR_GWS)
205
// for 644pa
206
//#define SENSORS_SAMPLE_TIME_MS (2000)
207
// for 1284p
208
#define SENSORS_SAMPLE_TIME_MS (1000)
209
#endif
210
215
#define WMO_REPORT_SAMPLES_TIME (10)
216
221
#define WMO_REPORT_SAMPLES_COUNT (size_t)((WMO_REPORT_SAMPLES_TIME*1000Lu*60Lu)/SENSORS_SAMPLE_TIME_MS)
222
227
#define RMAP_REPORT_SAMPLE_ERROR_MAX_PERC (10.)
228
233
#define LONG_GUST_SAMPLES_TIME (60)
234
235
240
#define LONG_GUST_SAMPLES_COUNT (size_t)((LONG_GUST_SAMPLES_TIME*1000Lu)/SENSORS_SAMPLE_TIME_MS)
241
242
247
#define GWS_ERROR_COUNT_MAX (10)
248
249
// wind class definition
250
#define WIND_CLASS_1_MAX (1.0)
251
#define WIND_CLASS_2_MAX (2.0)
252
#define WIND_CLASS_3_MAX (4.0)
253
#define WIND_CLASS_4_MAX (7.0)
254
#define WIND_CLASS_5_MAX (10.0)
255
260
#if (USE_SENSOR_DES)
261
#define CALM_WIND_MAX_MS (0.3)
262
#endif
263
264
#if (USE_SENSOR_GWS)
265
#define CALM_WIND_MAX_MS (0.1)
266
#endif
267
272
/*********************************************************************
273
* SENSORS
274
*********************************************************************/
275
280
#define USE_SENSORS_COUNT (USE_SENSOR_DED + USE_SENSOR_DES + USE_SENSOR_GWS)
281
282
#if (USE_SENSORS_COUNT == 0)
283
#error No sensor used. Are you sure? If not, enable it in RmapConfig/sensors_config.h
284
#endif
285
286
/*********************************************************************
287
* TIMER1
288
*********************************************************************/
293
#if (USE_SENSOR_DES || USE_SENSOR_DED)
294
#define TIMER1_INTERRUPT_TIME_MS (SENSORS_ACQ_TIME_MS / 2)
295
#endif
296
297
#if (USE_SENSOR_GWS)
298
#define TIMER1_INTERRUPT_TIME_MS (SENSORS_SAMPLE_TIME_MS)
299
#endif
300
305
#if (F_CPU == 8000000L)
306
#define TIMER1_OVERFLOW_TIME_MS (8388)
307
#elif (F_CPU == 16000000L)
308
#define TIMER1_OVERFLOW_TIME_MS (4194)
309
#endif
310
315
#define TIMER1_TCNT1_VALUE ((uint16_t)(0xFFFF - (float)(1.0 * 0xFFFF * TIMER1_INTERRUPT_TIME_MS / TIMER1_OVERFLOW_TIME_MS)))
316
321
#define TIMER_COUNTER_VALUE_MAX_MS (SENSORS_SAMPLE_TIME_MS)
322
323
/*********************************************************************
324
* TASKS
325
*********************************************************************/
330
#define WIND_SETUP_DELAY_MS (100)
331
336
#define WIND_POWER_ON_DELAY_MS (5000)
337
338
347
#define WIND_POWER_RESPONSE_DELAY_MS (200)
348
353
#define WIND_READ_DELAY_MS (2)
354
359
#define WIND_READ_COUNT (10)
360
365
#define TRANSACTION_TIMEOUT_MS (5000)
366
367
368
#endif
SDCARD_CHIP_SELECT_PIN
#define SDCARD_CHIP_SELECT_PIN
Chip select for SDcard SPI.
Definition:
i2c-leaf-config.h:103
Generated by
1.9.1