ti bisogna il phaserunner

Dependencies:   mbed PID mbed-rtos

Committer:
beacon
Date:
Tue Jun 04 19:03:39 2019 +0000
Revision:
11:39bd79605827
Parent:
7:15e6fc689368
ti bisogna il phaserunner

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EpicG10 7:15e6fc689368 1
EpicG10 7:15e6fc689368 2
EpicG10 7:15e6fc689368 3 #ifndef ENCODER_H_
EpicG10 7:15e6fc689368 4 #define ENCODER_H_
EpicG10 7:15e6fc689368 5
EpicG10 7:15e6fc689368 6 #include <cstdlib>
EpicG10 7:15e6fc689368 7 #include "mbed.h"
EpicG10 7:15e6fc689368 8
EpicG10 7:15e6fc689368 9
EpicG10 7:15e6fc689368 10 /**
EpicG10 7:15e6fc689368 11 * This class implements a driver to read the quadrature
EpicG10 7:15e6fc689368 12 * encoder counter of the STM32 microcontroller.
EpicG10 7:15e6fc689368 13 */
EpicG10 7:15e6fc689368 14
EpicG10 7:15e6fc689368 15
EpicG10 7:15e6fc689368 16 class Encoder {
EpicG10 7:15e6fc689368 17
EpicG10 7:15e6fc689368 18 public:
EpicG10 7:15e6fc689368 19
EpicG10 7:15e6fc689368 20 Encoder(PinName& hallsensor);
EpicG10 7:15e6fc689368 21 virtual ~Encoder();
EpicG10 7:15e6fc689368 22 uint8_t reset(); // Reset pulse count to 49000, return 0 when not resetted or 1 when resetted
EpicG10 7:15e6fc689368 23 uint32_t read(); // Return Pulses 196000 pulses per Rotation(Pedals)
EpicG10 7:15e6fc689368 24 float readAngle(); // Return Angle in Radiants
EpicG10 7:15e6fc689368 25 float readFrequency(); // Return Drehzahl der pedale in rad/s
EpicG10 7:15e6fc689368 26 float readAcceleration(); // Return Acceleration of pedale in rad/s^2
EpicG10 7:15e6fc689368 27 float readRPM(); // Return Drehzahl in RPM
EpicG10 7:15e6fc689368 28 void ResetInterrupt();
EpicG10 7:15e6fc689368 29 operator short();
EpicG10 7:15e6fc689368 30
EpicG10 7:15e6fc689368 31
EpicG10 7:15e6fc689368 32 private:
EpicG10 7:15e6fc689368 33
EpicG10 7:15e6fc689368 34 TIM_TypeDef* TIM;
EpicG10 7:15e6fc689368 35 InterruptIn HallSensor;
EpicG10 7:15e6fc689368 36 PinName hallsensor;
EpicG10 7:15e6fc689368 37 Ticker ticker;
EpicG10 7:15e6fc689368 38 void calculateFrequency(); // Fucntion, which calculate the frequency every 5ms
EpicG10 7:15e6fc689368 39
EpicG10 7:15e6fc689368 40 const static float PI = 3.141592654;
EpicG10 7:15e6fc689368 41 const static float dt = 0.005; // 5ms
EpicG10 7:15e6fc689368 42 uint8_t resetOn;
EpicG10 7:15e6fc689368 43 float frequency;
EpicG10 7:15e6fc689368 44 float acceleration;
EpicG10 7:15e6fc689368 45
EpicG10 7:15e6fc689368 46 };
EpicG10 7:15e6fc689368 47
EpicG10 7:15e6fc689368 48 #endif /* ENCODER_COUNTER_H_ */