micro-ELC
TachometerJEncoder.h
Go to the documentation of this file.
1#ifndef TACHOMETER_JENCODER_H
2#define TACHOMETER_JENCODER_H
3#include "JEncoder/JEncoder.h" //from JMotor library
4#include "Measurement.h"
5#include <Arduino.h>
6#include <RunningAverage.h>
12private:
13 float vel = 0;
14 RunningAverage smoother;
15
16public:
17 JEncoder& encoder;
23 TachometerJEncoder(JEncoder& _encoder, uint16_t numSavedForSmoothing = 0)
24 : smoother(numSavedForSmoothing + 1)
25 , encoder(_encoder)
26 {
27 }
28
30 {
31 return smoother.getAverage();
32 }
33 void run()
34 {
35 encoder.run();
36 smoother.addValue(encoder.getVel());
37 }
38};
39#endif
Defines an interface for measuring the frequency, rotational speed, or voltage of a generator to use ...
Definition: Measurement.h:6
This class measures the speed of a generator using a tachometer.
Definition: TachometerJEncoder.h:11
void run()
call this in loop() since some forms of measurement may need to be constantly polled
Definition: TachometerJEncoder.h:33
JEncoder & encoder
Definition: TachometerJEncoder.h:17
float getMeasurement()
Use this method to get the most recent measurement on the speed of the generator.
Definition: TachometerJEncoder.h:29
TachometerJEncoder(JEncoder &_encoder, uint16_t numSavedForSmoothing=0)
This class measures the speed of a generator using any JEncoder from the JMotor library.
Definition: TachometerJEncoder.h:23