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.
CURRENT_CONTROL.h
00001 #ifndef __CURRENT_CONTROL_H__ 00002 #define __CURRENT_CONTROL_H__ 00003 00004 #include "mbed.h" 00005 #include "PID.h" 00006 00007 00008 00009 class LPF 00010 {public: 00011 float output, outputLast; 00012 00013 LPF(float samplingTime); 00014 float filter(float input, float cutOff); 00015 00016 private: 00017 float Ts; 00018 }; 00019 00020 00021 class CURRENT_CONTROL 00022 { 00023 public: 00024 typedef enum { 00025 PWM1, 00026 PWM2 00027 } PWMIndex; 00028 00029 CURRENT_CONTROL(PinName curChannel, PinName PwmChannel1, PinName PwmChannel2, PWMIndex pwmIndex, float Kp, float Ki, float Kd, float samplingTime); 00030 float saturation(float input, float limit_H, float limit_L); 00031 void Control(float curRef, float speed); 00032 void SetParams(float Analog2Cur, float angSpeed2Backemf, float voltage2DutyRatio); 00033 00034 //functions for test//////// 00035 void ChangePwmPeriod(float microSeconds); 00036 void SetPWMDuty(float ratio); 00037 float GetAnalogIn(void); 00038 float GetCurrent(void); 00039 ////////////////////////// 00040 PWMIndex pwmIndex_; 00041 PID pid; 00042 PwmOut MotorPlus; 00043 PwmOut MotorMinus; 00044 float controlOutput; 00045 00046 float currentOffset; 00047 float curFeedBack; 00048 00049 AnalogIn currentAnalogIn; 00050 float analogInValue; 00051 00052 float analog2Cur; 00053 float Kw; 00054 float voltage2Duty; 00055 LPF lpFilter; 00056 00057 00058 private: 00059 00060 float Ts; 00061 00062 00063 }; 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 #endif
Generated on Thu Jul 28 2022 05:07:40 by
