/* * rte_wx.c * * Created on: 26.01.2019 * Author: mateusz */ #include #include #include "main.h" #include "misc_config.h" #ifndef RTE_WX_PROBLEMS_MAX_THRESHOLD #define RTE_WX_PROBLEMS_MAX_THRESHOLD 20 #endif /** * A little word of explanataion: * -> rte_wx_temperature_external_xxxxxx - these are default temperature readings provided * by a sensor of choice. It might be dallas, modbus-rtu or other * * -> rte_wx_temperature_inernal_xxxxx - this is always a temperature measured by inernal pressure and/or * humidity sensor. The intension here is to monitor how hot the * controller internally * */ float rte_wx_temperature_average_external_valid = 0.0f; //= WIND_AVERAGE_LEN - 1) { rte_wx_problems_wind_buffers++; } // go through wind speed buffer and checks if it contains the same value for (i = 0; i < WIND_AVERAGE_LEN - 1; i++) { if (rte_wx_windspeed[i] != rte_wx_windspeed[i + 1]) { break; } // break the loop if the windspeed is zero anywhere, not to reset // periodically if wind sensor is not connected. if (rte_wx_windspeed[i] == 0) { break; } } // check if an end of the buffer has been reached if (i >= WIND_AVERAGE_LEN - 1) { rte_wx_problems_wind_buffers++; } // check if average wind speed is different from zero and the same than gusts if (rte_wx_average_windspeed != 0 && (rte_wx_average_windspeed == rte_wx_max_windspeed)) { // if so a wind sensor had been blocked by icing very rapidly // before next DMA interrupt so rte_wx_windspeed is also // not updated at all rte_wx_problems_wind_values++; } // check if wind direction equals exactly north (zero degrees) if (rte_wx_average_winddirection == 0) { // open wind direction input (anemometer disconnected) gives // a reading of about 6 do 8 degrees. If it is stuck on zero // the U->f converted or its reference clock generator // might not work at all rte_wx_problems_wind_values++; } else { rte_wx_problems_wind_values = 0; } if (rte_wx_problems_wind_values > RTE_WX_PROBLEMS_MAX_THRESHOLD) { looks_good = 0; } if (rte_wx_problems_wind_buffers > RTE_WX_PROBLEMS_MAX_THRESHOLD * 3) { looks_good = 0; } return looks_good; }