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.
PositionSensor/PositionSensor.h
- Committer:
- benkatz
- Date:
- 2016-05-12
- Revision:
- 10:370851e6e132
- Parent:
- 9:d7eb815cb057
- Child:
- 11:c83b18d41e54
File content as of revision 10:370851e6e132:
#ifndef POSITIONSENSOR_H
#define POSITIONSENSOR_H
class PositionSensor {
public:
virtual float GetMechPosition() {return 0.0f;}
virtual float GetElecPosition() {return 0.0f;}
virtual float GetMechVelocity() {return 0.0f;}
};
class PositionSensorEncoder: public PositionSensor {
public:
PositionSensorEncoder(int CPR, float offset, int ppairs);
virtual float GetMechPosition();
virtual float GetElecPosition();
virtual float GetMechVelocity();
virtual float GetElecVelocity();
private:
InterruptIn *ZPulse;
DigitalIn *ZSense;
//DigitalOut *ZTest;
virtual void ZeroEncoderCount(void);
virtual void ZeroEncoderCountDown(void);
int _CPR, flag, rotations, _ppairs;
//int state;
float _offset, MechPosition, dir, test_pos, vel_old, out_old;
};
class PositionSensorSPI: public PositionSensor{
public:
PositionSensorSPI(int CPR, float offset, int ppairs);
virtual float GetMechPosition();
virtual float GetElecPosition();
virtual float GetMechVelocity();
virtual void ZeroPosition();
private:
float _offset, MechPosition, MechOffset;
int _CPR, rotations, old_counts, _ppairs;
SPI *spi;
DigitalOut *cs;
};
#endif