Ajout d'une fonction pour mesurer la vitesse du moteur

master
xctd692 9 years ago
parent f28134bcd7
commit 3fa09f41be

@ -57,6 +57,10 @@ int lastError = 0;
int sumError = 0; int sumError = 0;
int StartRoutine=0; int StartRoutine=0;
float OldTime = 0;
float Oldencoder0Pos = 0;
float MySpeed = 0;
//Integral term min/max (random value and not yet tested/verified) //Integral term min/max (random value and not yet tested/verified)
int iMax = 100; int iMax = 100;
int iMin = 0; int iMin = 0;
@ -158,6 +162,12 @@ void Fstart(){
} }
void Speed(){
MySpeed = (Oldencoder0Pos - encoder0Pos) / ( OldTime - millis());
OldTime = millis();
Oldencoder0Pos = encoder0Pos;
}
void docalc() { void docalc() {
if (millis() - previousMillis > interval) if (millis() - previousMillis > interval)

Loading…
Cancel
Save