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: MODSERIAL mbed EMG_Input QEI biquadFilter
Motor/motor.h
- Committer:
- kbruil
- Date:
- 2016-10-28
- Revision:
- 10:27fdd43f3b85
- Parent:
- 9:19dafcb4a098
File content as of revision 10:27fdd43f3b85:
#include "mbed.h" #include "QEI.h" #include "BiQuad.h" #ifndef M_PI #define M_PI 3.141592653589793238462643383279502884L // Pi #endif class motor { private: PwmOut pwm; // pwm port DigitalOut dir; // direction port QEI sense; // encoder BiQuad bq1, bq2; // Declare biquads for filtering D BiQuadChain bqc; // Declare biquad chains for filtering D double integral; double olderr; double P, I, D; bool flip; public: motor(PinName p_pwm, PinName p_dir, PinName p_senseA, PinName p_senseB, double p, double i, double d, bool flipped); void setSpeed(float val); double getPosition(void); void PID(double setpoint, double dt); ~motor(); };