[chronojump] raceAnalyzer. Triggers don't reset displacement count



commit 7bb6958cd406b77a44f092ee9472785dc432d391
Author: Xavier Padullés <x padulles gmail com>
Date:   Wed May 12 18:22:06 2021 +0200

    raceAnalyzer. Triggers don't reset displacement count

 arduino/raceAnalyzer/raceAnalyzer.ino | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/arduino/raceAnalyzer/raceAnalyzer.ino b/arduino/raceAnalyzer/raceAnalyzer.ino
index bd226022..c69f94fc 100644
--- a/arduino/raceAnalyzer/raceAnalyzer.ino
+++ b/arduino/raceAnalyzer/raceAnalyzer.ino
@@ -12,7 +12,7 @@
 Adafruit_ADS1115 loadCell;
 
 int rcaPin = 2;       //Pin associated to the RCA
-const int debounceTime = 100;  //Time that the RCA interruption will be deactivated after a change event
+const int debounceTime = 2;  //Time that the RCA interruption will be deactivated after a change event
 int encoderPinA = 3;  //Pin associated with the encoder interruption
 int encoderPinB = 4;
 volatile int encoderDisplacement = 0;
@@ -48,7 +48,7 @@ float metersPerPulse = 0.003003;      //Value for the manual race encoder
 int metersPerPulseAddress = 8;
 
 //Wether the sensor has to capture or not
-boolean capturing = true;
+boolean capturing = false;
 
 //Wether the encoder has reached the number of pulses per sample or not
 boolean procesSample = false;
@@ -125,6 +125,7 @@ void setup() {
 
   //Reading the initial state of the RCA
   lastRcaState = digitalRead(rcaPin);
+  rcaState = lastRcaState;
   //Using the rising flank of the A photocell we have a normal PPR.
   attachInterrupt(digitalPinToInterrupt(encoderPinA), changingA, RISING);
 
@@ -195,15 +196,14 @@ void loop() {
     Serial.write((byte*)&data, 9);
 
         //Printing in text mode
-//        Serial.println("");
 //        Serial.print(data.encoderDisplacement);
 //        Serial.print("\t");
 //        Serial.print(data.totalTime);
 //        Serial.print("\t");
-//        Serial.print(data.offsettedData);
-//        Serial.print("\t");
 //        Serial.println(data.sensor);
 //        Serial.print("\t");
+//        Serial.print(data.offsettedData);
+//        Serial.print("\t");
 //        Serial.println(elapsedTime);
 //        Serial.println(data[frameNumber].offsettedData);
 //        Serial.print(lastTriggerTime);
@@ -260,12 +260,12 @@ void changingRCA() {
   } else {        //Button released
     data.sensor = 1;
   }
-  data.encoderDisplacement = encoderDisplacement;
+
+    data.encoderDisplacement = 0;
 //  Serial.println("-------");
 //  Serial.print(data.encoderDisplacement);
 //  Serial.print("\tRCA\t");
 //  Serial.println(rcaState);
-  encoderDisplacement = 0;
   if(rcaState != lastRcaState) {
     procesSample = true;
     lastRcaState = rcaState;


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