Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo Motordriver SDFileSystem
HallEffectEncoder.h
- Committer:
- baguetteboys
- Date:
- 2020-04-30
- Revision:
- 6:889949e44d1e
- Parent:
- 4:067fefe01204
File content as of revision 6:889949e44d1e:
#ifndef HALL_EFFECT_ENCODER_H
#define HALL_EFFECT_ENCODER_H
#include "mbed.h"
class HallEffectEncoder {
public:
//CTOR
HallEffectEncoder(PinName pin, float update_speed);
//PUBLIC API
float getDist(); // get the distance //WIP has Wheel Diameter encoded
float getSpeed(); // get the speed of the wheel
int getCount(); // get the count of the encoder
void reset(); // reset the count to 0
private:
/* Encoder Input */
InterruptIn _encoder; // Input Pin
void callback_transition(); // Pole transitions callback
/* Speed Update Ticker */
float ticker_update_speed; // Update Period
Ticker _speed_ticker;
void updateSpeed(); // Updates the speed of the wheel
/* Internals */
int count; // Transitions count
float speed; // Speed is in cm / s
};
#endif