[SOLVED] PT1000 sensor output flectional

Status
Not open for further replies.

Ranbeer Singh

Full Member level 5
Joined
Jul 30, 2015
Messages
259
Helped
22
Reputation
44
Reaction score
22
Trophy points
1,298
Location
Faridabad India
Activity points
3,266
PT1000 sensor output fluctuations

Hello experts

I made a temperature display with PT1000 sensor. Display last digit is not stable. To the best of my belief it is the factor of voltage fluctuations. Anticipation i am displaying it with some delay in my codes. But I think it is not stable like other temperature displays. It changes last decimal digit in every second or half of second. I am displaying in 00.0 format.
I want to know.... How to handle experts for this?
 
Last edited:

Try to use Kalman filter
Code:
void KalmanFloatCalc (KalmanFloatStructTypeDef * KalmanFloatStruct)
{
  KalmanFloatStruct->Result = KalmanFloatStruct->K * KalmanFloatStruct->Value;
  KalmanFloatStruct->Value = 1.0 - KalmanFloatStruct->K;
  KalmanFloatStruct->Previous *= KalmanFloatStruct->Value;
  KalmanFloatStruct->Result += KalmanFloatStruct->Previous;
  KalmanFloatStruct->Previous = KalmanFloatStruct->Result;
}
Code:
typedef struct
{
  float Result;               
  float Value;                 
  float Previous;       
  float K;                     
}KalmanFloatStructTypeDef;
 
Reactions: Okada

    Okada

    Points: 2
    Helpful Answer Positive Rating
It's looking good but how to use it? I have a float value only.

- - - Updated - - -

Can you explain me?
How it works?
 

Each time you launch KalmanFloatCalc function, the Result value coming closer to Value. As low you will choose K, as smooth will be this movement.
 
First you should define an instance:
Code:
KalmanFloatStructTypeDef KalmanStruct;

Then you full fill it with values:
Code:
KalmanStruct.Value = <you input value from ADC recalculated to temperature>
KalmanStruct.Previous = Value; // initial value to force it start closer to result
KalmanStruct.K = 0.1; // this you will have to choose yourself, 0.1 is a good value for 10 time averaging
Than you run the KalmanFloatCalc with parameter KalmanStruct at least 10 times and update the Value. You will see, how the Result will move to Value smoothly.
 
hello,


it is an exponential filter. I used it in 80 years on a PDP11 application Block Langage !
The filtering depends of the periode timing algorithem execution.

but with a less academic rule , as Easyrider83 presentation.

this excel sheet can show the result of filtering,
depending of K factor K=0.0 value is NEVER uddated K=1.0 Value is NOT filtered
and depend interval time of execution



View attachment Filtre_Exponentiel.zip


Code:
float TF,Kfilter,TNow,TOld;
int FirstPass=0;

....
  while(1)
  {
    M0=ADC_Read(0);
    TNow=(float)M0* 500.0/1024.0;   // 5V for 1024 pts  LM35 =10mV/°C so scale is 500°C
   if (FirstPass==0)
   {
    TOld=TNow;
    TF=TOld;
    FirstPass=1;
    }
    else
    {
     TF= ( TNow * Kfilter) + (1-Kfilter)*TOld;
     TOld=TF;
    }
    UART1_Write_CText(" ADC0 value = ");
    WordToStr(M0,CRam1);
    UART1_Write_Text(CRam1);
    UART1_Write(TAB);
    fltToa (TF, txt,2);
    UART1_Write_Text(txt);   UART1_Write(TAB);
    UART1_Write_CText(" Degres\r\n");
    Delay_ms(500);  // <- this delay is important for the filtering effect
    LD0=!LD0;
  }
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…