Created class doesn't work

Hello,
I tried to create a class which should compute the rpm of a shaft by using a Kalman filter and a Hall-Effect sensor.

I created the object k1 before void setup():

//Kalman
Kalman k1;




void drehzahlMessen()
{
  umlaufzeit=(millis()-lasttime);
  lasttime=millis();
}


void setup() {


  pinMode(A0,INPUT);           //Matrixtastatur
  pinMode(18,OUTPUT);          //Signal Vor
  pinMode(17,OUTPUT);          //Signal Rückwärts
  pinMode(19,INPUT);           //Taster Rückwärts
  pinMode(0,INPUT);            //Taster Vor
  pinMode(1,INPUT);            //Taster Stopp
  pinMode(2,INPUT);            //Hallsensor
  pinMode(3,INPUT);            //Not aus
  pinMode(7,OUTPUT);           //LCD DB7 
  pinMode(8,OUTPUT);           //DB6
  pinMode(9,OUTPUT);           //DB5

but I received this error: 'Kalman' does not name a type

Kalman.h:

#ifdef Kalman_h
#define Kalman_h
#include "Arduino.h"

class Kalman
{
 private:
  float Xk1;  //Vorhergesagter nächster Zustand
  float Pk1;  //Vorhergesager Fehler
  float Kk;   //Kalman Gain
  float Xk;   //aktueller Zustand
  float Pk;   //aktueller Fehler
  float Q;  //Kovarianz des Systems
  float H;  //Kovarianz der Messung
  float messung;
 public:
   Kalman();
   void drehzahlUpdate(float drehzahl);
   void setQ(float Q);
   void setH(float H);
   float aktdrehzahl();
};
#endif

Kalman.cpp:

#include "Arduino.h"
#include "Kalman.h"

Kalman::Kalman()
{
 Q=0;
 H=0;
 Xk1=0;
 Pk1=0;
 Kk=0;
 Xk=0;
 Pk=0;
}
void Kalman::setQ(float Q1)
{
 Q=Q1; 
}
void Kalman::setH(float H1)
{
 H=H1; 
}
void Kalman::drehzahlUpdate(float drehzahl)
{
 messung=drehzahl; 
}
float Kalman::aktdrehzahl()
{
  Xk1=Xk;
  Pk1=Pk+Q;
  Kk=Pk1/(Pk1+H);
  Xk=Kk*(messung-Xk1)+Xk1;
  Pk=(1-Kk)*Pk1;
  return Xk;
}

I can't find any mistake in the code. Can you help me?
I have searched the net for hours and couldn't find anything useful

but I received this error: 'Kalman' does not name a type

Why do you think it does? You have not included the Kalman.h file in your sketch, so the compiler is right.

I included the Kalman.h
I didn't post the whole sketch,because I didn't want to overload this tread.
Currently I am not at home, but when I'm at home I will post the whole sketch.

dave48859:
Kalman.h:

#ifdef Kalman_h

#define Kalman_h

An include guard typically uses #ifndef, not #ifdef, because you want the file to be included only if it hasn't been included already.

Thanks very much!
Now it works :slight_smile: :slight_smile: