diff include/VirtualClock.h @ 149:134bff10e561 ClockSync

Added simple one-variable one-measurement Kalman filter, Pid controller(which output is not used). Virtual clock is now much more precise and reactive for period. Still it is lagging behind a bit on the overall offset.
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 21 Sep 2015 03:12:21 +0100
parents 44d07fa9bd03
children ebbfb154351a
line wrap: on
line diff
--- a/include/VirtualClock.h	Mon Sep 21 03:11:32 2015 +0100
+++ b/include/VirtualClock.h	Mon Sep 21 03:12:21 2015 +0100
@@ -4,6 +4,8 @@
 #include "math.h"
 #include "stats.hpp"
 #include "Clock.h"
+#include "IirFilter.h"
+#include "Kalman.h"
 #ifdef USE_JUCE
 #else
 #include <BeagleRT.h>
@@ -13,14 +15,19 @@
 private:
 	myClock_t startTime;
 	myClock_t startTimeOffset;
-	myClock_t lastSync;
+	myClock_t lastSyncTime;
+//	myClock_t lastSyncEstimatedTime;
+	double lastSyncEstimatedTime;
 	bool firstRun;
 	double elapsedPeriods;
 	double elapsedPeriodsOffset;
+	double blockPeriod;
 	double period;
 	MovingAverage<double> movingAverage;
+	IirFilter iir;
+	KalmanOne kalman;
 public:
-	void init();
+	void init(float initialValueUs);
 	VirtualClock();
 /**
 	Call this method at regular intervals to sync che virtual clock