// ****** Motor with friction ***** HS-Esslingen *******//
float wMachine;
float tqInrUnLimDes;
float tqInrLim;
float tqInr;
float wRotor;
float tqFric;
float pwrMax_C = 20000;
float tqMax_C = 100;
float tqFric_C = 2;
float moi_C = 0.02;
unsigned long oldMillis;
int gridTimeMsec = 10;
float gridTimeSec = 0.01;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if (millis() >= oldMillis) {
if (millis()>1500) tqInrUnLimDes = 100;
if (millis()>2000) tqInrUnLimDes = 0;
tqInrLim = min(tqMax_C,pwrMax_C /max(0.1,wRotor));
tqInr = min(tqInrLim,tqInrUnLimDes);
tqFric = max(-1,min(1,wRotor))*tqFric_C;
wRotor= wRotor + (tqInr-tqFric) * gridTimeSec/moi_C;
oldMillis = oldMillis + gridTimeMsec;
Serial.print(tqInr*10);
Serial.print(" , ");
Serial.println(wRotor);
} // end of grid
} // end of void