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: LSM9DS1 RangeFinder FastPWM
Dependents: PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board ... more
SpeedController.h@29:335fb9b01ca7, 2022-05-13 (annotated)
- Committer:
- pmic
- Date:
- Fri May 13 20:53:33 2022 +0000
- Revision:
- 29:335fb9b01ca7
- Parent:
- 10:fe74e8909d3f
Motion integrated into SpeedController and PositionController class
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pmic | 3:8b42e643b294 | 1 | #ifndef SpeedController_H_ |
| pmic | 3:8b42e643b294 | 2 | #define SpeedController_H_ |
| pmic | 3:8b42e643b294 | 3 | #include <cstdlib> |
| pmic | 3:8b42e643b294 | 4 | #include <mbed.h> |
| pmic | 3:8b42e643b294 | 5 | #include "EncoderCounter.h" |
| pmic | 3:8b42e643b294 | 6 | #include "LowpassFilter.h" |
| pmic | 3:8b42e643b294 | 7 | #include "ThreadFlag.h" |
| pmic | 5:6cd242a61e4c | 8 | #include "FastPWM.h" |
| pmic | 29:335fb9b01ca7 | 9 | #include "Motion.h" |
| pmic | 3:8b42e643b294 | 10 | |
| pmic | 3:8b42e643b294 | 11 | class SpeedController |
| pmic | 3:8b42e643b294 | 12 | { |
| pmic | 3:8b42e643b294 | 13 | public: |
| pmic | 3:8b42e643b294 | 14 | |
| pmic | 6:41dd03654c44 | 15 | SpeedController(float counts_per_turn, float kn, float max_voltage, FastPWM& pwm, EncoderCounter& encoderCounter); |
| pmic | 3:8b42e643b294 | 16 | |
| pmic | 3:8b42e643b294 | 17 | virtual ~SpeedController(); |
| pmic | 3:8b42e643b294 | 18 | |
| pmic | 4:9c003c402033 | 19 | void setDesiredSpeedRPS(float desiredSpeed); |
| pmic | 4:9c003c402033 | 20 | float getSpeedRPS(); |
| pmic | 10:fe74e8909d3f | 21 | float getSpeedRPM(); |
| pmic | 10:fe74e8909d3f | 22 | void setFeedForwardGain(float kn); |
| pmic | 10:fe74e8909d3f | 23 | void setSpeedCntrlGain(float kp); |
| pmic | 29:335fb9b01ca7 | 24 | void setMaxVelocityRPS(float maxVelocityRPS); |
| pmic | 29:335fb9b01ca7 | 25 | void setMaxVelocityRPM(float maxVelocityRPM); |
| pmic | 29:335fb9b01ca7 | 26 | void setMaxAccelerationRPS(float maxAccelerationRPS); |
| pmic | 29:335fb9b01ca7 | 27 | void setMaxAccelerationRPM(float maxAccelerationRPM); |
| pmic | 3:8b42e643b294 | 28 | |
| pmic | 3:8b42e643b294 | 29 | private: |
| pmic | 3:8b42e643b294 | 30 | |
| pmic | 10:fe74e8909d3f | 31 | void setDesiredSpeedRPM(float desiredSpeed); |
| pmic | 10:fe74e8909d3f | 32 | |
| pmic | 6:41dd03654c44 | 33 | static const float TS; |
| pmic | 3:8b42e643b294 | 34 | static const float LOWPASS_FILTER_FREQUENCY; |
| pmic | 3:8b42e643b294 | 35 | static const float MIN_DUTY_CYCLE; |
| pmic | 3:8b42e643b294 | 36 | static const float MAX_DUTY_CYCLE; |
| pmic | 3:8b42e643b294 | 37 | |
| pmic | 6:41dd03654c44 | 38 | float counts_per_turn; |
| pmic | 6:41dd03654c44 | 39 | float kn; |
| pmic | 6:41dd03654c44 | 40 | float kp; |
| pmic | 6:41dd03654c44 | 41 | float max_voltage; |
| pmic | 4:9c003c402033 | 42 | |
| pmic | 5:6cd242a61e4c | 43 | FastPWM& pwm; |
| pmic | 3:8b42e643b294 | 44 | EncoderCounter& encoderCounter; |
| pmic | 3:8b42e643b294 | 45 | short previousValueCounter; |
| pmic | 3:8b42e643b294 | 46 | LowpassFilter speedFilter; |
| pmic | 3:8b42e643b294 | 47 | float desiredSpeed; |
| pmic | 3:8b42e643b294 | 48 | float actualSpeed; |
| pmic | 4:9c003c402033 | 49 | // float actualAngle; |
| pmic | 29:335fb9b01ca7 | 50 | |
| pmic | 29:335fb9b01ca7 | 51 | Motion motion; |
| pmic | 3:8b42e643b294 | 52 | |
| pmic | 3:8b42e643b294 | 53 | ThreadFlag threadFlag; |
| pmic | 3:8b42e643b294 | 54 | Thread thread; |
| pmic | 3:8b42e643b294 | 55 | Ticker ticker; |
| pmic | 3:8b42e643b294 | 56 | |
| pmic | 6:41dd03654c44 | 57 | void run(); |
| pmic | 3:8b42e643b294 | 58 | void sendThreadFlag(); |
| pmic | 3:8b42e643b294 | 59 | }; |
| pmic | 3:8b42e643b294 | 60 | |
| pmic | 3:8b42e643b294 | 61 | #endif /* SpeedController_H_ */ |
