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.
include/motor.hpp@23:112c0be5a7f3, 2013-11-19 (annotated)
- Committer:
- calamaridudeman
- Date:
- Tue Nov 19 19:07:35 2013 +0000
- Revision:
- 23:112c0be5a7f3
- Child:
- 26:53b793b7a82f
fixed all the java-esque code to be cpp, have bezier and geometry code working solid
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
calamaridudeman | 23:112c0be5a7f3 | 1 | #include "mbed.h" |
calamaridudeman | 23:112c0be5a7f3 | 2 | #include "QEI.h" |
calamaridudeman | 23:112c0be5a7f3 | 3 | |
calamaridudeman | 23:112c0be5a7f3 | 4 | #ifndef MOTOR_HPP |
calamaridudeman | 23:112c0be5a7f3 | 5 | #define MOTOR_HPP |
calamaridudeman | 23:112c0be5a7f3 | 6 | |
calamaridudeman | 23:112c0be5a7f3 | 7 | class Motor { |
calamaridudeman | 23:112c0be5a7f3 | 8 | |
calamaridudeman | 23:112c0be5a7f3 | 9 | public: |
calamaridudeman | 23:112c0be5a7f3 | 10 | Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, PinName encA, PinName encB); |
calamaridudeman | 23:112c0be5a7f3 | 11 | |
calamaridudeman | 23:112c0be5a7f3 | 12 | void start(); |
calamaridudeman | 23:112c0be5a7f3 | 13 | void stop(); |
calamaridudeman | 23:112c0be5a7f3 | 14 | void setTorque(float t); |
calamaridudeman | 23:112c0be5a7f3 | 15 | void Control(); |
calamaridudeman | 23:112c0be5a7f3 | 16 | float getMotorPos(); |
calamaridudeman | 23:112c0be5a7f3 | 17 | float getCurrent(); |
calamaridudeman | 23:112c0be5a7f3 | 18 | static float filterLowPass(float old, float currentIn, float alphar); |
calamaridudeman | 23:112c0be5a7f3 | 19 | void setPos(float pos); |
calamaridudeman | 23:112c0be5a7f3 | 20 | void setVel(float vel); |
calamaridudeman | 23:112c0be5a7f3 | 21 | void setPosVel(float pos, float vel); |
calamaridudeman | 23:112c0be5a7f3 | 22 | void zero(); |
calamaridudeman | 23:112c0be5a7f3 | 23 | |
calamaridudeman | 23:112c0be5a7f3 | 24 | float kp; |
calamaridudeman | 23:112c0be5a7f3 | 25 | float kd; |
calamaridudeman | 23:112c0be5a7f3 | 26 | |
calamaridudeman | 23:112c0be5a7f3 | 27 | private: |
calamaridudeman | 23:112c0be5a7f3 | 28 | Ticker t; |
calamaridudeman | 23:112c0be5a7f3 | 29 | AnalogIn aIn; |
calamaridudeman | 23:112c0be5a7f3 | 30 | DigitalOut Forward; |
calamaridudeman | 23:112c0be5a7f3 | 31 | DigitalOut Backward; |
calamaridudeman | 23:112c0be5a7f3 | 32 | PwmOut pwmOut; |
calamaridudeman | 23:112c0be5a7f3 | 33 | QEI encoder; |
calamaridudeman | 23:112c0be5a7f3 | 34 | |
calamaridudeman | 23:112c0be5a7f3 | 35 | float speed; |
calamaridudeman | 23:112c0be5a7f3 | 36 | float freq; |
calamaridudeman | 23:112c0be5a7f3 | 37 | float pos; |
calamaridudeman | 23:112c0be5a7f3 | 38 | float angle; |
calamaridudeman | 23:112c0be5a7f3 | 39 | float voltage; |
calamaridudeman | 23:112c0be5a7f3 | 40 | int mode; |
calamaridudeman | 23:112c0be5a7f3 | 41 | |
calamaridudeman | 23:112c0be5a7f3 | 42 | float dAngularVelocity; |
calamaridudeman | 23:112c0be5a7f3 | 43 | float dAngle; |
calamaridudeman | 23:112c0be5a7f3 | 44 | float dTorque; |
calamaridudeman | 23:112c0be5a7f3 | 45 | }; |
calamaridudeman | 23:112c0be5a7f3 | 46 | |
calamaridudeman | 23:112c0be5a7f3 | 47 | #endif |