2024-07-05 03:52:43 +00:00
|
|
|
|
#ifndef _ANEMOMETER__H_
|
|
|
|
|
#define _ANEMOMETER__H_
|
|
|
|
|
|
|
|
|
|
#include "adc.h"
|
|
|
|
|
#include "dma.h"
|
|
|
|
|
#include "i2c.h"
|
|
|
|
|
#include "usart.h"
|
|
|
|
|
#include "tim.h"
|
|
|
|
|
#include "gpio.h"
|
|
|
|
|
#include "stdio.h"
|
|
|
|
|
#include "string.h"
|
|
|
|
|
#include "math.h"
|
|
|
|
|
|
|
|
|
|
#include "arr_tool.h"
|
|
|
|
|
|
|
|
|
|
#include "FreeRTOS.h"
|
|
|
|
|
#include "cmsis_os.h"
|
|
|
|
|
|
|
|
|
|
#include "arm_math.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 延时REV_MUTE_DELAY us启动ADC采集数据
|
|
|
|
|
// 最大风速30m/s 2.5M 采样率 延时260uS
|
|
|
|
|
#define REV_MUTE_DELAY_US 260
|
|
|
|
|
// adc 采样率
|
|
|
|
|
// 5 5M
|
|
|
|
|
// 4 4M
|
|
|
|
|
// 3 3M
|
|
|
|
|
#define ADC_SAMP_RATE_MHz ((float32_t)2.5)
|
|
|
|
|
|
|
|
|
|
// 驱动方波频率
|
|
|
|
|
#define DRIVE_FREQ_MHz ((float32_t)0.2)
|
|
|
|
|
|
|
|
|
|
// 驱动方波个数 实际个数 DRIVE_NUM+1
|
|
|
|
|
|
|
|
|
|
#define DRIVE_NUM 2
|
|
|
|
|
|
|
|
|
|
// 传播距离 风速计算公式中的L参数
|
|
|
|
|
#define DISTANCE ((float32_t)120000.0)
|
|
|
|
|
// 富奥通结构 L = 118946
|
|
|
|
|
// #define DISTANCE 118946
|
|
|
|
|
|
|
|
|
|
// x方向
|
|
|
|
|
#define WIND_DIRECTION_X 0x00
|
|
|
|
|
// y方向
|
|
|
|
|
#define WIND_DIRECTION_Y 0x01
|
|
|
|
|
|
|
|
|
|
// adc 采集buf长度
|
|
|
|
|
#define ADC_VAL_LEN 1024
|
|
|
|
|
|
|
|
|
|
extern int16_t adc_val[ADC_VAL_LEN];
|
|
|
|
|
extern int16_t adc_val1[ADC_VAL_LEN];
|
|
|
|
|
|
2024-07-19 03:55:34 +00:00
|
|
|
|
//滑动平均值结构体
|
2024-07-20 07:59:17 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
float speed_data[3]; // 存储数据点的数组
|
|
|
|
|
float direction_data[3]; // 存储数据点的数组
|
|
|
|
|
int index; // 指向队列头部的索引(实际上是最近添加的元素)
|
|
|
|
|
int count; // 当前队列中的元素数量
|
|
|
|
|
} SlidingWindow_3s;
|
2024-07-19 03:55:34 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
float speed_data[60]; // 存储数据点的数组
|
|
|
|
|
float direction_data[60]; // 存储数据点的数组
|
|
|
|
|
int index; // 指向队列头部的索引(实际上是最近添加的元素)
|
|
|
|
|
int count; // 当前队列中的元素数量
|
2024-07-20 07:59:17 +00:00
|
|
|
|
} SlidingWindow_1mim;
|
|
|
|
|
typedef struct {
|
2024-07-22 02:24:58 +00:00
|
|
|
|
float speed_data[600]; // 存储数据点的数组
|
2024-08-09 03:03:03 +00:00
|
|
|
|
float direction_data[600]; // 存储数据点的数组
|
|
|
|
|
float ave_speed_data[600]; // 存储数据点平均值的数组
|
|
|
|
|
float ave_direction_data[600]; // 存储数据点平均值的数组
|
2024-07-20 07:59:17 +00:00
|
|
|
|
int index; // 指向队列头部的索引(实际上是最近添加的元素)
|
|
|
|
|
int count; // 当前队列中的元素数量
|
|
|
|
|
} SlidingWindow_10min;
|
2024-07-19 03:55:34 +00:00
|
|
|
|
|
2024-07-05 03:52:43 +00:00
|
|
|
|
#pragma pack(push,1)
|
|
|
|
|
typedef struct __weather_param
|
|
|
|
|
{
|
|
|
|
|
float32_t wind_velocity_x;
|
|
|
|
|
// 校准dtof 偏差
|
|
|
|
|
//float32_t wind_velocity_x_dtof_offset;
|
|
|
|
|
|
|
|
|
|
float32_t wind_velocity_y;
|
|
|
|
|
//float32_t wind_velocity_y_offset;
|
|
|
|
|
// 风速
|
|
|
|
|
float32_t wind_velocity;
|
|
|
|
|
// 超声波传播速度
|
|
|
|
|
float32_t wind_c;
|
|
|
|
|
// 风向
|
|
|
|
|
float32_t wind_angle;
|
|
|
|
|
// 温度
|
|
|
|
|
float32_t temperature;
|
|
|
|
|
// 湿度
|
|
|
|
|
float32_t humidity;
|
|
|
|
|
// 降雨量
|
|
|
|
|
float32_t precipitation;
|
|
|
|
|
|
|
|
|
|
} Weather_param;
|
|
|
|
|
extern Weather_param weather_info;
|
|
|
|
|
|
|
|
|
|
typedef struct _mcs_para{
|
|
|
|
|
float32_t min_wind_direction; /* 最小风向 */
|
|
|
|
|
float32_t average_wind_direction;/* 平均风向 */
|
|
|
|
|
float32_t max_wind_direction; /* 最大风向 */
|
|
|
|
|
float32_t min_wind_speed; /* 最小风速 */
|
|
|
|
|
float32_t average_wind_speed; /* 平均风速 */
|
|
|
|
|
float32_t max_wind_speed; /* 最大风速 */
|
|
|
|
|
float32_t temperature; /* 环境温度 */
|
|
|
|
|
float32_t humidity; /* 环境湿度 */
|
|
|
|
|
float32_t pressure; /* 压强 */
|
|
|
|
|
float32_t precipitation; /* 雨量 */
|
|
|
|
|
float32_t precipitation_intensity;/* 光辐射 */
|
|
|
|
|
}mcs_para;
|
|
|
|
|
extern mcs_para g_stMcs_Para;
|
2024-11-18 08:48:30 +00:00
|
|
|
|
|
|
|
|
|
typedef struct _error_log{
|
|
|
|
|
uint16_t tof_error_NS:1; /* 接受南北信号(tofy,tofx<0)很小 */
|
|
|
|
|
uint16_t tof_error_WE:1; /* 接受东西信号(tofy,tofx<0)很小 */
|
|
|
|
|
uint16_t error_2:1; /* 保留 */
|
|
|
|
|
uint16_t error_3:1; /* 保留 */
|
|
|
|
|
uint16_t error_4:1; /* 保留 */
|
|
|
|
|
uint16_t error_5:1; /* 保留 */
|
|
|
|
|
uint16_t error_6:1; /* 保留 */
|
|
|
|
|
uint16_t error_7:1; /* 保留 */
|
|
|
|
|
uint16_t error_8:1; /* 保留 */
|
|
|
|
|
uint16_t error_9:1; /* 保留 */
|
|
|
|
|
uint16_t error_10:1; /* 保留 */
|
|
|
|
|
uint16_t error_11:1; /* 保留 */
|
|
|
|
|
uint16_t error_12:1; /* 保留 */
|
|
|
|
|
uint16_t error_13:1; /* 保留 */
|
|
|
|
|
uint16_t error_14:1; /* 保留 */
|
|
|
|
|
uint16_t error_15:1; /* 保留 */
|
|
|
|
|
}error_log;
|
|
|
|
|
extern error_log g_error_log;
|
2024-07-05 03:52:43 +00:00
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
// 切换通道
|
|
|
|
|
void change_channel(uint32_t channel);
|
|
|
|
|
|
|
|
|
|
// 采集一次数据
|
|
|
|
|
void play_one_measure(int16_t* result_data,uint32_t len);
|
|
|
|
|
|
|
|
|
|
// 通过采集的数据计算 风速 风向
|
|
|
|
|
void calculate_param(Weather_param *parm ,uint32_t direction , int16_t *adc_buf1,int16_t *adc_buf2,uint32_t len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void wind_task(void const * argument);
|
2024-07-12 09:30:01 +00:00
|
|
|
|
void tem_hum_update_task(void const * argument);
|
2024-07-17 02:58:39 +00:00
|
|
|
|
void wind_update_task(void const * argument);
|
2024-08-06 07:33:33 +00:00
|
|
|
|
void my_update_mcs_param(float new_wind_speed, float new_wind_dirction);
|
2024-07-05 03:52:43 +00:00
|
|
|
|
|
|
|
|
|
#endif
|