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
- Committer:
- pmic
- Date:
- 2022-02-10
- Revision:
- 10:fe74e8909d3f
- Parent:
- 6:41dd03654c44
- Child:
- 29:335fb9b01ca7
File content as of revision 10:fe74e8909d3f:
#ifndef SpeedController_H_
#define SpeedController_H_
#include <cstdlib>
#include <mbed.h>
#include "EncoderCounter.h"
#include "LowpassFilter.h"
#include "ThreadFlag.h"
#include "FastPWM.h"
class SpeedController
{
public:
SpeedController(float counts_per_turn, float kn, float max_voltage, FastPWM& pwm, EncoderCounter& encoderCounter);
virtual ~SpeedController();
void setDesiredSpeedRPS(float desiredSpeed);
float getSpeedRPS();
float getSpeedRPM();
void setFeedForwardGain(float kn);
void setSpeedCntrlGain(float kp);
private:
void setDesiredSpeedRPM(float desiredSpeed);
static const float TS;
static const float LOWPASS_FILTER_FREQUENCY;
static const float MIN_DUTY_CYCLE;
static const float MAX_DUTY_CYCLE;
float counts_per_turn;
float kn;
float kp;
float max_voltage;
FastPWM& pwm;
EncoderCounter& encoderCounter;
short previousValueCounter;
LowpassFilter speedFilter;
float desiredSpeed;
float actualSpeed;
// float actualAngle;
ThreadFlag threadFlag;
Thread thread;
Ticker ticker;
void run();
void sendThreadFlag();
};
#endif /* SpeedController_H_ */
