hh

Dependencies:   FastPWM3

Committer:
benkatz
Date:
Wed Apr 13 04:09:56 2016 +0000
Revision:
8:10ae7bc88d6e
Parent:
7:dc5f27756e02
Child:
9:d7eb815cb057
Multi-turn mechanical position, MA700 position sensing over SPI.  Placeholder torque controller for cogging/ripple compensation;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benkatz 0:4e1c4df6aabd 1 #ifndef POSITIONSENSOR_H
benkatz 0:4e1c4df6aabd 2 #define POSITIONSENSOR_H
benkatz 0:4e1c4df6aabd 3 class PositionSensor {
benkatz 0:4e1c4df6aabd 4 public:
benkatz 0:4e1c4df6aabd 5 virtual float GetMechPosition() {return 0.0f;}
benkatz 0:4e1c4df6aabd 6 virtual float GetElecPosition() {return 0.0f;}
benkatz 0:4e1c4df6aabd 7 };
benkatz 0:4e1c4df6aabd 8
benkatz 0:4e1c4df6aabd 9
benkatz 0:4e1c4df6aabd 10 class PositionSensorEncoder: public PositionSensor {
benkatz 0:4e1c4df6aabd 11 public:
benkatz 0:4e1c4df6aabd 12 PositionSensorEncoder(int CPR, float offset);
benkatz 0:4e1c4df6aabd 13 virtual float GetMechPosition();
benkatz 0:4e1c4df6aabd 14 virtual float GetElecPosition();
benkatz 3:6a0015d88d06 15 virtual float GetMechVelocity();
benkatz 3:6a0015d88d06 16 virtual float GetElecVelocity();
benkatz 0:4e1c4df6aabd 17 private:
benkatz 0:4e1c4df6aabd 18 InterruptIn *ZPulse;
benkatz 0:4e1c4df6aabd 19 DigitalIn *ZSense;
benkatz 1:b8bceb4daed5 20 //DigitalOut *ZTest;
benkatz 0:4e1c4df6aabd 21 virtual void ZeroEncoderCount(void);
benkatz 7:dc5f27756e02 22 virtual void ZeroEncoderCountDown(void);
benkatz 7:dc5f27756e02 23 int _CPR, flag, rotations;
benkatz 1:b8bceb4daed5 24 //int state;
benkatz 7:dc5f27756e02 25 float _offset, MechPosition, dir, test_pos;
benkatz 0:4e1c4df6aabd 26 };
benkatz 0:4e1c4df6aabd 27
benkatz 8:10ae7bc88d6e 28 class PositionSensorSPI: public PositionSensor{
benkatz 8:10ae7bc88d6e 29 public:
benkatz 8:10ae7bc88d6e 30 PositionSensorSPI(int CPR, float offset);
benkatz 8:10ae7bc88d6e 31 virtual float GetMechPosition();
benkatz 8:10ae7bc88d6e 32 virtual float GetElecPosition();
benkatz 8:10ae7bc88d6e 33 private:
benkatz 8:10ae7bc88d6e 34 float _offset, MechPosition;
benkatz 8:10ae7bc88d6e 35 int _CPR, rotations, old_counts;
benkatz 8:10ae7bc88d6e 36 SPI *spi;
benkatz 8:10ae7bc88d6e 37 DigitalOut *cs;
benkatz 8:10ae7bc88d6e 38 };
benkatz 0:4e1c4df6aabd 39 #endif