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: mbed PID mbed-rtos
Regler.h
00001 /** 00002 * Steuert die 4 Phaserunner 00003 */ 00004 00005 #ifndef PA_REGLER_H 00006 #define PA_REGLER_H 00007 00008 #include "mbed.h" 00009 #include "Phaserunner.h" 00010 #include "Encoder.h" 00011 #include "PID.h" 00012 00013 00014 #define ERGO 0 00015 #define MOFA 1 00016 #define PEDELEC 2 00017 00018 class Regler{ 00019 private: 00020 //Alle Phaserunner 00021 Phaserunner& vorderrad; 00022 Phaserunner& hinterrad; 00023 Phaserunner& linkspedal; 00024 Phaserunner& rechtspedal; 00025 00026 // Analog Outputs für Generatoren am Pedalen 00027 AnalogOut gegenmomentLinks; 00028 AnalogOut gegenmomentRechts; 00029 00030 // PID Regler 00031 PID& pid; 00032 00033 //Encoder 00034 Encoder& encoder; 00035 00036 //Drehmomentverhältnis 00037 uint8_t torqueRatio; 00038 00039 //Verhältnis des Gegenmomentes 00040 uint8_t recupRatio; 00041 00042 //Zeitliche Berechnung der Werte 00043 void ReglerCalculate(); 00044 00045 // Ticker 00046 Ticker ticker; 00047 00048 // Ellipse Parameters 00049 float a_,b_,beta_; 00050 00051 // Regler Parameters Pedale 00052 float Kp_,Ki_,Ts_,setPoint_; 00053 00054 // Betriebsmodus (0->Ergo, 1->Mofa, 2->Pedelec) 00055 uint8_t Modus_; 00056 00057 // Ergometer Stufe "(von 1 bis 10)" 00058 float ErgoStufe_; 00059 00060 // Pedelec Values 00061 float PedStufe_, PedFactor_; 00062 00063 // AnalogOut Pins für gegenmomentsteuerung 00064 static const PinName GEG_LINKS_PIN = PA_4; 00065 static const PinName GEG_RECHTS_PIN = PA_5; 00066 00067 const static float PI = 3.14159265; 00068 00069 00070 public: 00071 /** 00072 * Erstellt einen Regler für alle Phaserunner 00073 * @param vorderrad 00074 * @param hinterrad 00075 * @param linkspedal 00076 * @param rechtspedal 00077 * @param encoder 00078 */ 00079 Regler(Phaserunner& vorderrad, Phaserunner& hinterrad, Phaserunner& linkspedal, Phaserunner& rechtspedal, Encoder& encoder); 00080 00081 /** 00082 * Regelt die Phaserunner auf eine bestimmte Geschwindigkeit. 00083 * @param speed Geschwindigkeit in km/h 00084 */ 00085 void setSpeed(uint8_t speed); 00086 00087 /** 00088 * Setzt das Drehmomentverhältnis zwischen Vorderrad und Hinterrad. 00089 * @param torqueRatio: Drehmoment des Hinterrades in %. Das Drehmoment auf dem Vorderrad ist dann 100% - torqueRatio. 00090 */ 00091 void setTorqueProportion(uint8_t torqueRatio); 00092 00093 /** 00094 * Setzt das Verhältnis des Gegenmomentes zwischen Vorderrad und Hinterrad. 00095 * @param torqueRatio: Gegenmoment des Hinterrades in %. Das Gegenmoment auf dem Vorderrad ist dann 100% - torqueRatio. 00096 */ 00097 void setRecuperationProportion(uint8_t recupRatio); 00098 00099 /** 00100 * Setzt das Drehmoment auf beide Phaserunner. 00101 * @param torque Drehmoment in Prozent 00102 */ 00103 void setTorqueMotors(uint8_t torque); 00104 00105 /** 00106 * Setzt das Drehmoment auf beide Phaserunner. 00107 * @param torque Drehmoment in Prozent 00108 */ 00109 void setTorquePedals(uint8_t torque); 00110 00111 /** 00112 * Setzt das Nullpunkt der Pedalen. 00113 * 00114 */ 00115 void setZero(); 00116 00117 /** 00118 * Setzt die Rekuperation der Motoren 00119 * @param recuperation 00120 */ 00121 void setRecuperationMotors(uint8_t recuperation); 00122 00123 /** 00124 * Setzt die Rekuperation der Pedale 00125 * @param recuperation 00126 */ 00127 void setRecuperationPedals(uint8_t recuperation); 00128 00129 /** 00130 * Setzt die Ellipse Parameters 00131 * @param a 00132 * @param b 00133 * @param beta 00134 */ 00135 void setEllipseParameters(float a, float b, float beta); 00136 00137 /** 00138 * Setzt die PI Regler Parameters 00139 * @param Kp 00140 * @param Ki 00141 * @param Ts in s 00142 */ 00143 void setReglerParameters(float Kp, float Ki, float Ts); 00144 00145 /** 00146 * Setzt die PI Regler Setpoint 00147 * @param SetPoint 00148 */ 00149 void setReglerSetPoint(float Setpoint); 00150 00151 /** 00152 * Setzt die Ergometer schwirichkeit Stufe 00153 * @param ErgoStufe 00154 */ 00155 void setErgoStufe(float ErgoStufe); 00156 00157 /** 00158 * Setzt die Pedelec schwirichkeit Stufe 00159 * @param ErgoStufe 00160 */ 00161 void setPedStufe(float PedStufe); 00162 00163 /** 00164 * Setzt die Pedelec Factor 00165 * @param PedFactor 00166 */ 00167 void setPedFactor(float PedFactor); 00168 00169 /** 00170 * Setzt die Modus 00171 * @param Modus 00172 */ 00173 void setModus(float Modus); 00174 }; 00175 00176 #endif //PA_REGLER_H 00177
Generated on Mon Aug 1 2022 09:49:43 by
