Question
Floating point error not working.
Dear ST Hello,
I have a big problem with floating point calculations,
I am trying to implement the IIR filter to filter a current but the result is Zero.
Sometimes the watch expression window shows me 0 but the input filter is not zero.
/* Get the HImax */
HimaxCurrentCons = HAL_ADC_GetValue(&hadc2);
/* Get LSM current */
l_u16AdcCurrent = HAL_ADC_GetValue(&hadc1);
/* Filter the current LSM */
Input[0] = (float_t)1E6;//l_u16AdcCurrent;
filter_out = FilterCoefInput[0] * Input[0];
for (int i = 6; i > 0; i--)
{
/* adding the ai * xi i=7..1 */
filter_out = filter_out + (FilterCoefInput[i] * Input[i]);
/* Shifting the register input */
Input[i] = Input[i - 1];
}
for (int j = 6; j > 0; j--)
{
/* Adding the bj * yj j = 6..1 */
filter_out = filter_out + (FilterCoefOutput[j] * Output[j-1]);
/* Shifting the register output */
Output[j] = Output[j - 1];
}
Output[0] = filter_out;
/* Current compute */
LsmCurrent = (300.0/2559) * filter_out;Thank in advance,
S.tarik