DRV8323RS Version

Dependencies:   mbed-dev-f303 FastPWM3

Committer:
benkatz
Date:
Mon Oct 31 16:48:16 2016 +0000
Revision:
14:80ce59119d93
Parent:
13:a3fa0a31b114
Child:
20:bf9ea5125d52
Misc. changes.  Finally fixed transforms (turns out B and C current measurements were accidentally swapped)

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 9:d7eb815cb057 7 virtual float GetMechVelocity() {return 0.0f;}
benkatz 13:a3fa0a31b114 8 virtual float GetElecVelocity() {return 0.0f;}
benkatz 0:4e1c4df6aabd 9 };
benkatz 0:4e1c4df6aabd 10
benkatz 0:4e1c4df6aabd 11
benkatz 0:4e1c4df6aabd 12 class PositionSensorEncoder: public PositionSensor {
benkatz 0:4e1c4df6aabd 13 public:
benkatz 10:370851e6e132 14 PositionSensorEncoder(int CPR, float offset, int ppairs);
benkatz 0:4e1c4df6aabd 15 virtual float GetMechPosition();
benkatz 0:4e1c4df6aabd 16 virtual float GetElecPosition();
benkatz 3:6a0015d88d06 17 virtual float GetMechVelocity();
benkatz 3:6a0015d88d06 18 virtual float GetElecVelocity();
benkatz 0:4e1c4df6aabd 19 private:
benkatz 0:4e1c4df6aabd 20 InterruptIn *ZPulse;
benkatz 0:4e1c4df6aabd 21 DigitalIn *ZSense;
benkatz 1:b8bceb4daed5 22 //DigitalOut *ZTest;
benkatz 0:4e1c4df6aabd 23 virtual void ZeroEncoderCount(void);
benkatz 7:dc5f27756e02 24 virtual void ZeroEncoderCountDown(void);
benkatz 10:370851e6e132 25 int _CPR, flag, rotations, _ppairs;
benkatz 1:b8bceb4daed5 26 //int state;
benkatz 9:d7eb815cb057 27 float _offset, MechPosition, dir, test_pos, vel_old, out_old;
benkatz 0:4e1c4df6aabd 28 };
benkatz 0:4e1c4df6aabd 29
benkatz 14:80ce59119d93 30 class PositionSensorMA700: public PositionSensor{
benkatz 8:10ae7bc88d6e 31 public:
benkatz 14:80ce59119d93 32 PositionSensorMA700(int CPR, float offset, int ppairs);
benkatz 8:10ae7bc88d6e 33 virtual float GetMechPosition();
benkatz 8:10ae7bc88d6e 34 virtual float GetElecPosition();
benkatz 9:d7eb815cb057 35 virtual float GetMechVelocity();
benkatz 11:c83b18d41e54 36 virtual int GetRawPosition();
benkatz 9:d7eb815cb057 37 virtual void ZeroPosition();
benkatz 8:10ae7bc88d6e 38 private:
benkatz 9:d7eb815cb057 39 float _offset, MechPosition, MechOffset;
benkatz 10:370851e6e132 40 int _CPR, rotations, old_counts, _ppairs;
benkatz 8:10ae7bc88d6e 41 SPI *spi;
benkatz 8:10ae7bc88d6e 42 DigitalOut *cs;
benkatz 8:10ae7bc88d6e 43 };
benkatz 14:80ce59119d93 44
benkatz 14:80ce59119d93 45 class PositionSensorAM5147: public PositionSensor{
benkatz 14:80ce59119d93 46 public:
benkatz 14:80ce59119d93 47 PositionSensorAM5147(int CPR, float offset, int ppairs);
benkatz 14:80ce59119d93 48 virtual float GetMechPosition();
benkatz 14:80ce59119d93 49 virtual float GetElecPosition();
benkatz 14:80ce59119d93 50 virtual float GetMechVelocity();
benkatz 14:80ce59119d93 51 virtual int GetRawPosition();
benkatz 14:80ce59119d93 52 virtual void ZeroPosition();
benkatz 14:80ce59119d93 53 private:
benkatz 14:80ce59119d93 54 float _offset, MechPosition, MechOffset;
benkatz 14:80ce59119d93 55 int _CPR, rotations, old_counts, _ppairs;
benkatz 14:80ce59119d93 56 SPI *spi;
benkatz 14:80ce59119d93 57 DigitalOut *cs;
benkatz 14:80ce59119d93 58 int readAngleCmd;
benkatz 14:80ce59119d93 59
benkatz 14:80ce59119d93 60 };
benkatz 0:4e1c4df6aabd 61 #endif