[chronojump/michrolab: 49/57] Added calculations for inertial mode. TODO: Add it in the interface




commit 8b2d1e80408f729ba29c0c3cc0ebf61f6f20d30a
Author: Xavier Padullés <testing chronojump org>
Date:   Sat May 21 12:55:25 2022 +0200

    Added calculations for inertial mode. TODO: Add it in the interface

 arduino/ForceSensorTFT/ForceSensorTFT.ino | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/arduino/ForceSensorTFT/ForceSensorTFT.ino b/arduino/ForceSensorTFT/ForceSensorTFT.ino
index 8a0e73c95..e105a3170 100644
--- a/arduino/ForceSensorTFT/ForceSensorTFT.ino
+++ b/arduino/ForceSensorTFT/ForceSensorTFT.ino
@@ -45,6 +45,7 @@ String version = "0.7";
 Encoder encoder(8, 9);
 IntervalTimer encoderTimer;
 long position = 0;
+bool inertialMode = false;
 long lastEncoderPosition;
 long lastSamplePosition = 0;
 int encoderBuffer[20];
@@ -1417,7 +1418,9 @@ void getEncoderDynamics()
   if (sampleDuration >= 1000)
   {
     lastSampleTime = totalTime;
+    
     long position = encoder.read();
+    if (inertialMode) position = - abs(position);
     measured = (float)(position - lastSamplePosition) * 1000 / (sampleDuration);
     //measured = position;
     //if (measured != 0) Serial.println(measured);
@@ -1427,12 +1430,12 @@ void getEncoderDynamics()
       if (position >= minRom) {
         encoderPhase = 1;
         localMax = position;
-        //Serial.println("CONcentric");
+        Serial.println("Start in CONcentric");
       }
       else if (position <= -minRom) {
         encoderPhase = 1;
         localMax = position;
-        //Serial.println("ECCentric");
+        Serial.println("Start in ECCentric");
       }
     }
 
@@ -1474,7 +1477,7 @@ void startEncoderCapture()
   encoderPhase = 0;
   localMax = 0;
   position = 0;
-  lastSamplePosition;
+  lastSamplePosition = 0;
   lastSampleTime = 0;
   startPhasePosition = 0;
   startPhaseTime = 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]