[chronojump] Better error message if need more oscillations on IM calculation



commit 6ddf97738eeb2bd9b6a830e2935d70d0369a811b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 27 13:40:20 2014 +0200

    Better error message if need more oscillations on IM calculation

 encoder/inertia-momentum.R |   11 +++++++++++
 src/gui/encoder.cs         |    2 +-
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/encoder/inertia-momentum.R b/encoder/inertia-momentum.R
index 79145fe..b71da0f 100644
--- a/encoder/inertia-momentum.R
+++ b/encoder/inertia-momentum.R
@@ -37,32 +37,43 @@
 
 calculate <- function (displacement, mass, length)
 {
+       print("at inertia-momentum.R calculate")
+
        #cumulative movement of the encoder
        x <- cumsum(displacement)
+       print(c("x",x))
 
        #time in milliseconds
        t <- seq(1,length(displacement))
+       print(c("t",t))
 
        #all the information about local maximums and minimums and crossings
        ex <- extrema(x)
+       print(c("ex",ex))
 
        #times where the maximums are found in milliseconds
        tmax <- rowMeans(ex$maxindex)
+       print(c("tmax",tmax))
 
        #the last maximum is discarded
        tmax <- tmax[1:(length(tmax)-1)]
+       print(c("tmax",tmax))
 
        #Periods of the oscillations
        T <- diff(tmax[1:length(tmax)])
+       print(c("T",T))
 
        #Coefficients of a Logarithmic regression
        logT <- lm( log(T) ~ I(log(tmax[1:(length(tmax)-1)])))
+       print(c("logT",logT))
 
        #The final period of the oscillation in seconds
        finalT <- exp(logT$coefficients[1] + logT$coefficients[2]*log(tmax[length(tmax)]))/1000
+       print(c("finalT",finalT))
 
        #Inertia momentum using the pendulus formula
        I <- ( (finalT / (2 * pi))^2 ) * mass * 9.81 * length - (mass * length^2)
+       print(c("I",I))
 
        return(as.numeric(I))
 }
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 7edf680..a039698 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4595,7 +4595,7 @@ Log.Write(" AT ANALYZE 2 ");
                                Log.WriteLine("imResultText = |" + imResultText + "|");
 
                                if(imResultText == "NA" || imResultText == "")
-                                       encoder_configuration_win.Button_encoder_capture_inertial_do_ended 
(0, "Error capturing");
+                                       encoder_configuration_win.Button_encoder_capture_inertial_do_ended 
(0, "Error capturing. Maybe need more oscillations.");
                                else {
                                        //script calculates Kg*m^2 -> GUI needs Kg*cm^2
                                        encoder_configuration_win.Button_encoder_capture_inertial_do_ended (


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