瞬时风速风向改回1S风速风向
This commit is contained in:
parent
c68ab61d45
commit
3ca9afb94d
|
@ -549,7 +549,7 @@ void wind_task(void const * argument)
|
||||||
}
|
}
|
||||||
/// term_printf("x:%.2f y:%.2f win_speed %.2f m/s angle %.2f \r\n",av_speedx,av_speedy,av_speed,av_angle);
|
/// term_printf("x:%.2f y:%.2f win_speed %.2f m/s angle %.2f \r\n",av_speedx,av_speedy,av_speed,av_angle);
|
||||||
}
|
}
|
||||||
//瞬时风速风向
|
//算法求出的瞬时风速风向
|
||||||
weather_info.instantaneous_wind_direction = av_angle;
|
weather_info.instantaneous_wind_direction = av_angle;
|
||||||
weather_info.instantaneous_wind_speed = av_speed;
|
weather_info.instantaneous_wind_speed = av_speed;
|
||||||
///term_printf("win_speed %.2f \r\n",weather_info.wind_velocity);
|
///term_printf("win_speed %.2f \r\n",weather_info.wind_velocity);
|
||||||
|
@ -791,47 +791,53 @@ float linear_interpolation(float x) {
|
||||||
|
|
||||||
void my_update_mcs_param(float new_wind_speed, float new_wind_dirction)
|
void my_update_mcs_param(float new_wind_speed, float new_wind_dirction)
|
||||||
{
|
{
|
||||||
/// 三秒滑动平均
|
///// 三秒滑动平均
|
||||||
win_3s.speed_data[win_3s.index] = new_wind_speed;
|
// win_3s.speed_data[win_3s.index] = new_wind_speed;
|
||||||
win_3s.direction_data[win_3s.index] = new_wind_dirction;
|
// win_3s.direction_data[win_3s.index] = new_wind_dirction;
|
||||||
if(win_3s.count < 3)
|
// if(win_3s.count < 3)
|
||||||
{
|
// {
|
||||||
win_3s.count++;
|
// win_3s.count++;
|
||||||
}
|
// }
|
||||||
//计算三秒风速滑动平均值当作瞬时值
|
// //计算三秒风速滑动平均值当作瞬时值
|
||||||
win_3s.ave_speed_data = sum(win_3s.speed_data, win_3s.count) / win_3s.count;
|
// win_3s.ave_speed_data = sum(win_3s.speed_data, win_3s.count) / win_3s.count;
|
||||||
//计算三秒风向滑动平均值,风向滑动平均值需要过零算法
|
// //计算三秒风向滑动平均值,风向滑动平均值需要过零算法
|
||||||
float temp_sin_sum_3s = 0;
|
// float temp_sin_sum_3s = 0;
|
||||||
float temp_cos_sum_3s = 0;
|
// float temp_cos_sum_3s = 0;
|
||||||
for(int i = 0; i < win_3s.count; i++)
|
// for(int i = 0; i < win_3s.count; i++)
|
||||||
{
|
// {
|
||||||
temp_sin_sum_3s += sinf(win_3s.direction_data[i] * PI/180);
|
// temp_sin_sum_3s += sinf(win_3s.direction_data[i] * PI/180);
|
||||||
temp_cos_sum_3s += cosf(win_3s.direction_data[i] * PI/180);
|
// temp_cos_sum_3s += cosf(win_3s.direction_data[i] * PI/180);
|
||||||
}
|
// }
|
||||||
win_3s.ave_direction_data = atanf(temp_sin_sum_3s / (temp_cos_sum_3s + 0.00001)) * 180/PI;
|
// win_3s.ave_direction_data = atanf(temp_sin_sum_3s / (temp_cos_sum_3s + 0.00001)) * 180/PI;
|
||||||
// 不同象限不一样
|
// // 不同象限不一样
|
||||||
// 1象限真实角度=本身
|
// // 1象限真实角度=本身
|
||||||
// 2象限真实角度=+180
|
// // 2象限真实角度=+180
|
||||||
// 3象限真实角度=+180
|
// // 3象限真实角度=+180
|
||||||
// 4象限真实角度=+360
|
// // 4象限真实角度=+360
|
||||||
if((temp_sin_sum_3s > 0 && temp_cos_sum_3s < 0) || (temp_sin_sum_3s < 0 && temp_cos_sum_3s < 0))
|
// if((temp_sin_sum_3s > 0 && temp_cos_sum_3s < 0) || (temp_sin_sum_3s < 0 && temp_cos_sum_3s < 0))
|
||||||
{
|
// {
|
||||||
win_3s.ave_direction_data += 180;
|
// win_3s.ave_direction_data += 180;
|
||||||
}else if (temp_sin_sum_3s < 0 && temp_cos_sum_3s > 0)
|
// }else if (temp_sin_sum_3s < 0 && temp_cos_sum_3s > 0)
|
||||||
{
|
// {
|
||||||
win_3s.ave_direction_data += 360;
|
// win_3s.ave_direction_data += 360;
|
||||||
}
|
// }
|
||||||
g_stMcs_Para.instantaneous_wind_direction = win_3s.ave_direction_data;
|
// g_stMcs_Para.instantaneous_wind_direction = win_3s.ave_direction_data;
|
||||||
|
//
|
||||||
|
// /** 线性插值 **/
|
||||||
|
// /** win_3s.ave_speed_data[win_3s.index]为风速 **/
|
||||||
|
// /** win_3s.ave_direction_data[win_3s.index]为风向 **/
|
||||||
|
// /** 风向不要插值 **/
|
||||||
|
// /** 只用插值瞬时风速,10min便会是插值后的值 **/
|
||||||
|
// g_stMcs_Para.instantaneous_wind_speed = linear_interpolation(win_3s.ave_speed_data);
|
||||||
|
// /** 线性插值 **/
|
||||||
|
//// 更新索引
|
||||||
|
// win_3s.index = (win_3s.index + 1) % 3;
|
||||||
/** 线性插值 **/
|
/** 线性插值 **/
|
||||||
/** win_3s.ave_speed_data[win_3s.index]为风速 **/
|
|
||||||
/** win_3s.ave_direction_data[win_3s.index]为风向 **/
|
|
||||||
/** 风向不要插值 **/
|
/** 风向不要插值 **/
|
||||||
/** 只用插值瞬时风速,10min便会是插值后的值 **/
|
/** 只用插值瞬时风速,10min便会是插值后的值 **/
|
||||||
g_stMcs_Para.instantaneous_wind_speed = linear_interpolation(win_3s.ave_speed_data);
|
g_stMcs_Para.instantaneous_wind_speed = linear_interpolation(new_wind_speed);
|
||||||
/** 线性插值 **/
|
/** 线性插值 **/
|
||||||
// 更新索引
|
g_stMcs_Para.instantaneous_wind_direction = new_wind_dirction;
|
||||||
win_3s.index = (win_3s.index + 1) % 3;
|
|
||||||
|
|
||||||
|
|
||||||
/// 十分钟滑动平均值
|
/// 十分钟滑动平均值
|
||||||
|
|
Loading…
Reference in New Issue