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-10
- Revision:
- 9:d7eb815cb057
- Parent:
- 8:10ae7bc88d6e
- Child:
- 10:370851e6e132
File content as of revision 9:d7eb815cb057:
#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);
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;
//int state;
float _offset, MechPosition, dir, test_pos, vel_old, out_old;
};
class PositionSensorSPI: public PositionSensor{
public:
PositionSensorSPI(int CPR, float offset);
virtual float GetMechPosition();
virtual float GetElecPosition();
virtual float GetMechVelocity();
virtual void ZeroPosition();
private:
float _offset, MechPosition, MechOffset;
int _CPR, rotations, old_counts;
SPI *spi;
DigitalOut *cs;
};
#endif