ti bisogna il phaserunner

Dependencies:   mbed PID mbed-rtos

Committer:
beacon
Date:
Tue Jun 04 19:03:39 2019 +0000
Revision:
11:39bd79605827
Parent:
9:56aed8c6779f
ti bisogna il phaserunner

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EpicG10 7:15e6fc689368 1 /**
EpicG10 7:15e6fc689368 2 * Steuert die 4 Phaserunner
EpicG10 7:15e6fc689368 3 */
EpicG10 7:15e6fc689368 4
EpicG10 7:15e6fc689368 5 #ifndef PA_REGLER_H
EpicG10 7:15e6fc689368 6 #define PA_REGLER_H
EpicG10 7:15e6fc689368 7
EpicG10 9:56aed8c6779f 8 #include "mbed.h"
EpicG10 7:15e6fc689368 9 #include "Phaserunner.h"
EpicG10 7:15e6fc689368 10 #include "Encoder.h"
EpicG10 8:1655d27152e6 11 #include "PID.h"
EpicG10 7:15e6fc689368 12
EpicG10 9:56aed8c6779f 13
EpicG10 9:56aed8c6779f 14 #define ERGO 0
EpicG10 9:56aed8c6779f 15 #define MOFA 1
EpicG10 9:56aed8c6779f 16 #define PEDELEC 2
EpicG10 9:56aed8c6779f 17
EpicG10 7:15e6fc689368 18 class Regler{
EpicG10 7:15e6fc689368 19 private:
EpicG10 7:15e6fc689368 20 //Alle Phaserunner
EpicG10 7:15e6fc689368 21 Phaserunner& vorderrad;
EpicG10 7:15e6fc689368 22 Phaserunner& hinterrad;
EpicG10 7:15e6fc689368 23 Phaserunner& linkspedal;
EpicG10 7:15e6fc689368 24 Phaserunner& rechtspedal;
EpicG10 7:15e6fc689368 25
EpicG10 9:56aed8c6779f 26 // Analog Outputs für Generatoren am Pedalen
EpicG10 9:56aed8c6779f 27 AnalogOut gegenmomentLinks;
EpicG10 9:56aed8c6779f 28 AnalogOut gegenmomentRechts;
EpicG10 9:56aed8c6779f 29
EpicG10 8:1655d27152e6 30 // PID Regler
EpicG10 9:56aed8c6779f 31 PID& pid;
EpicG10 8:1655d27152e6 32
EpicG10 7:15e6fc689368 33 //Encoder
EpicG10 7:15e6fc689368 34 Encoder& encoder;
EpicG10 7:15e6fc689368 35
EpicG10 7:15e6fc689368 36 //Drehmomentverhältnis
EpicG10 7:15e6fc689368 37 uint8_t torqueRatio;
EpicG10 7:15e6fc689368 38
EpicG10 7:15e6fc689368 39 //Verhältnis des Gegenmomentes
EpicG10 7:15e6fc689368 40 uint8_t recupRatio;
EpicG10 7:15e6fc689368 41
EpicG10 7:15e6fc689368 42 //Zeitliche Berechnung der Werte
EpicG10 7:15e6fc689368 43 void ReglerCalculate();
EpicG10 7:15e6fc689368 44
EpicG10 7:15e6fc689368 45 // Ticker
EpicG10 7:15e6fc689368 46 Ticker ticker;
EpicG10 7:15e6fc689368 47
EpicG10 8:1655d27152e6 48 // Ellipse Parameters
EpicG10 8:1655d27152e6 49 float a_,b_,beta_;
EpicG10 8:1655d27152e6 50
EpicG10 8:1655d27152e6 51 // Regler Parameters Pedale
EpicG10 8:1655d27152e6 52 float Kp_,Ki_,Ts_,setPoint_;
EpicG10 8:1655d27152e6 53
EpicG10 9:56aed8c6779f 54 // Betriebsmodus (0->Ergo, 1->Mofa, 2->Pedelec)
EpicG10 9:56aed8c6779f 55 uint8_t Modus_;
EpicG10 9:56aed8c6779f 56
EpicG10 9:56aed8c6779f 57 // Ergometer Stufe "(von 1 bis 10)"
EpicG10 8:1655d27152e6 58 float ErgoStufe_;
EpicG10 8:1655d27152e6 59
EpicG10 8:1655d27152e6 60 // Pedelec Values
EpicG10 9:56aed8c6779f 61 float PedStufe_, PedFactor_;
EpicG10 9:56aed8c6779f 62
EpicG10 9:56aed8c6779f 63 // AnalogOut Pins für gegenmomentsteuerung
EpicG10 9:56aed8c6779f 64 static const PinName GEG_LINKS_PIN = PA_4;
EpicG10 9:56aed8c6779f 65 static const PinName GEG_RECHTS_PIN = PA_5;
EpicG10 8:1655d27152e6 66
EpicG10 7:15e6fc689368 67 const static float PI = 3.14159265;
EpicG10 7:15e6fc689368 68
EpicG10 7:15e6fc689368 69
EpicG10 7:15e6fc689368 70 public:
EpicG10 7:15e6fc689368 71 /**
EpicG10 7:15e6fc689368 72 * Erstellt einen Regler für alle Phaserunner
EpicG10 7:15e6fc689368 73 * @param vorderrad
EpicG10 7:15e6fc689368 74 * @param hinterrad
EpicG10 7:15e6fc689368 75 * @param linkspedal
EpicG10 7:15e6fc689368 76 * @param rechtspedal
EpicG10 7:15e6fc689368 77 * @param encoder
EpicG10 7:15e6fc689368 78 */
EpicG10 7:15e6fc689368 79 Regler(Phaserunner& vorderrad, Phaserunner& hinterrad, Phaserunner& linkspedal, Phaserunner& rechtspedal, Encoder& encoder);
EpicG10 7:15e6fc689368 80
EpicG10 7:15e6fc689368 81 /**
EpicG10 7:15e6fc689368 82 * Regelt die Phaserunner auf eine bestimmte Geschwindigkeit.
EpicG10 7:15e6fc689368 83 * @param speed Geschwindigkeit in km/h
EpicG10 7:15e6fc689368 84 */
EpicG10 7:15e6fc689368 85 void setSpeed(uint8_t speed);
EpicG10 7:15e6fc689368 86
EpicG10 7:15e6fc689368 87 /**
EpicG10 7:15e6fc689368 88 * Setzt das Drehmomentverhältnis zwischen Vorderrad und Hinterrad.
EpicG10 7:15e6fc689368 89 * @param torqueRatio: Drehmoment des Hinterrades in %. Das Drehmoment auf dem Vorderrad ist dann 100% - torqueRatio.
EpicG10 7:15e6fc689368 90 */
EpicG10 7:15e6fc689368 91 void setTorqueProportion(uint8_t torqueRatio);
EpicG10 7:15e6fc689368 92
EpicG10 7:15e6fc689368 93 /**
EpicG10 7:15e6fc689368 94 * Setzt das Verhältnis des Gegenmomentes zwischen Vorderrad und Hinterrad.
EpicG10 7:15e6fc689368 95 * @param torqueRatio: Gegenmoment des Hinterrades in %. Das Gegenmoment auf dem Vorderrad ist dann 100% - torqueRatio.
EpicG10 7:15e6fc689368 96 */
EpicG10 7:15e6fc689368 97 void setRecuperationProportion(uint8_t recupRatio);
EpicG10 7:15e6fc689368 98
EpicG10 7:15e6fc689368 99 /**
EpicG10 7:15e6fc689368 100 * Setzt das Drehmoment auf beide Phaserunner.
EpicG10 7:15e6fc689368 101 * @param torque Drehmoment in Prozent
EpicG10 7:15e6fc689368 102 */
EpicG10 7:15e6fc689368 103 void setTorqueMotors(uint8_t torque);
EpicG10 7:15e6fc689368 104
EpicG10 7:15e6fc689368 105 /**
EpicG10 7:15e6fc689368 106 * Setzt das Drehmoment auf beide Phaserunner.
EpicG10 7:15e6fc689368 107 * @param torque Drehmoment in Prozent
EpicG10 7:15e6fc689368 108 */
EpicG10 7:15e6fc689368 109 void setTorquePedals(uint8_t torque);
EpicG10 7:15e6fc689368 110
EpicG10 7:15e6fc689368 111 /**
EpicG10 9:56aed8c6779f 112 * Setzt das Nullpunkt der Pedalen.
EpicG10 9:56aed8c6779f 113 *
EpicG10 9:56aed8c6779f 114 */
EpicG10 9:56aed8c6779f 115 void setZero();
EpicG10 9:56aed8c6779f 116
EpicG10 9:56aed8c6779f 117 /**
EpicG10 7:15e6fc689368 118 * Setzt die Rekuperation der Motoren
EpicG10 7:15e6fc689368 119 * @param recuperation
EpicG10 7:15e6fc689368 120 */
EpicG10 7:15e6fc689368 121 void setRecuperationMotors(uint8_t recuperation);
EpicG10 7:15e6fc689368 122
EpicG10 7:15e6fc689368 123 /**
EpicG10 7:15e6fc689368 124 * Setzt die Rekuperation der Pedale
EpicG10 7:15e6fc689368 125 * @param recuperation
EpicG10 7:15e6fc689368 126 */
EpicG10 7:15e6fc689368 127 void setRecuperationPedals(uint8_t recuperation);
EpicG10 8:1655d27152e6 128
EpicG10 8:1655d27152e6 129 /**
EpicG10 8:1655d27152e6 130 * Setzt die Ellipse Parameters
EpicG10 8:1655d27152e6 131 * @param a
EpicG10 8:1655d27152e6 132 * @param b
EpicG10 8:1655d27152e6 133 * @param beta
EpicG10 8:1655d27152e6 134 */
EpicG10 8:1655d27152e6 135 void setEllipseParameters(float a, float b, float beta);
EpicG10 8:1655d27152e6 136
EpicG10 8:1655d27152e6 137 /**
EpicG10 8:1655d27152e6 138 * Setzt die PI Regler Parameters
EpicG10 8:1655d27152e6 139 * @param Kp
EpicG10 8:1655d27152e6 140 * @param Ki
EpicG10 8:1655d27152e6 141 * @param Ts in s
EpicG10 8:1655d27152e6 142 */
EpicG10 8:1655d27152e6 143 void setReglerParameters(float Kp, float Ki, float Ts);
EpicG10 8:1655d27152e6 144
EpicG10 8:1655d27152e6 145 /**
EpicG10 8:1655d27152e6 146 * Setzt die PI Regler Setpoint
EpicG10 8:1655d27152e6 147 * @param SetPoint
EpicG10 8:1655d27152e6 148 */
EpicG10 8:1655d27152e6 149 void setReglerSetPoint(float Setpoint);
EpicG10 8:1655d27152e6 150
EpicG10 8:1655d27152e6 151 /**
EpicG10 8:1655d27152e6 152 * Setzt die Ergometer schwirichkeit Stufe
EpicG10 8:1655d27152e6 153 * @param ErgoStufe
EpicG10 8:1655d27152e6 154 */
EpicG10 8:1655d27152e6 155 void setErgoStufe(float ErgoStufe);
EpicG10 8:1655d27152e6 156
EpicG10 8:1655d27152e6 157 /**
EpicG10 8:1655d27152e6 158 * Setzt die Pedelec schwirichkeit Stufe
EpicG10 8:1655d27152e6 159 * @param ErgoStufe
EpicG10 8:1655d27152e6 160 */
EpicG10 8:1655d27152e6 161 void setPedStufe(float PedStufe);
EpicG10 8:1655d27152e6 162
EpicG10 8:1655d27152e6 163 /**
EpicG10 8:1655d27152e6 164 * Setzt die Pedelec Factor
EpicG10 8:1655d27152e6 165 * @param PedFactor
EpicG10 8:1655d27152e6 166 */
EpicG10 8:1655d27152e6 167 void setPedFactor(float PedFactor);
EpicG10 9:56aed8c6779f 168
EpicG10 9:56aed8c6779f 169 /**
EpicG10 9:56aed8c6779f 170 * Setzt die Modus
EpicG10 9:56aed8c6779f 171 * @param Modus
EpicG10 9:56aed8c6779f 172 */
EpicG10 9:56aed8c6779f 173 void setModus(float Modus);
EpicG10 7:15e6fc689368 174 };
EpicG10 7:15e6fc689368 175
EpicG10 7:15e6fc689368 176 #endif //PA_REGLER_H
EpicG10 7:15e6fc689368 177