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
PositionController.h
00001 #ifndef PositionController_H_ 00002 #define PositionController_H_ 00003 #include <cstdlib> 00004 #include <mbed.h> 00005 #include "EncoderCounter.h" 00006 #include "LowpassFilter.h" 00007 #include "ThreadFlag.h" 00008 #include "FastPWM.h" 00009 #include "Motion.h" 00010 00011 class PositionController 00012 { 00013 public: 00014 00015 PositionController(float counts_per_turn, float kn, float max_voltage, FastPWM& pwm, EncoderCounter& encoderCounter); 00016 00017 virtual ~PositionController(); 00018 00019 float getSpeedRPM(); 00020 float getSpeedRPS(); 00021 void setDesiredRotation(float desiredRotation); 00022 float getRotation(); 00023 void setFeedForwardGain(float kn); 00024 void setSpeedCntrlGain(float kp); 00025 void setPositionCntrlGain(float p); 00026 void setMaxVelocityRPS(float maxVelocityRPS); 00027 void setMaxVelocityRPM(float maxVelocityRPM); 00028 void setMaxAccelerationRPS(float maxAccelerationRPS); 00029 void setMaxAccelerationRPM(float maxAccelerationRPM); 00030 00031 private: 00032 00033 static const float TS; 00034 static const float LOWPASS_FILTER_FREQUENCY; 00035 static const float MIN_DUTY_CYCLE; 00036 static const float MAX_DUTY_CYCLE; 00037 00038 float counts_per_turn; 00039 float kn; 00040 float kp; 00041 float max_voltage; 00042 float max_speed; 00043 float p; 00044 00045 FastPWM& pwm; 00046 EncoderCounter& encoderCounter; 00047 short previousValueCounter; 00048 LowpassFilter speedFilter; 00049 float desiredSpeed; 00050 float actualSpeed; 00051 float initialRotation; 00052 float actualRotation; 00053 float desiredRotation; 00054 00055 Motion motion; 00056 00057 ThreadFlag threadFlag; 00058 Thread thread; 00059 Ticker ticker; 00060 00061 void run(); 00062 void sendThreadFlag(); 00063 }; 00064 00065 #endif /* PositionController_H_ */
Generated on Tue Jul 12 2022 21:20:55 by
1.7.2