 			{
 				if (current_magnet == 0)
 				{
-					for (int i = RPM_SMOOTHING_LENGTH - 1; i > 0; i--)
+					if ((rpm > 300) && (now - revolution_time) * 1.1 > revolution_time_history[0]) // Allow 10% change in RPM
 					{
-						revolution_time_history[i] = revolution_time_history[i - 1];
+						for (int i = RPM_SMOOTHING_LENGTH - 1; i > 0; i--)
+						{
+							revolution_time_history[i] = revolution_time_history[i - 1];
+						}
+						revolution_time_history[0] = now - revolution_time;
+						revolution_time = now;
 					}
-					revolution_time_history[0] = now - revolution_time;
-					revolution_time = now;
+					else
+					{
+						for (int i = RPM_SMOOTHING_LENGTH - 1; i > 0; i--)
+						{
+							revolution_time_history[i] = revolution_time_history[i - 1];
+						}
+						revolution_time_history[0] = now - revolution_time;
+						revolution_time = now;
+					}
+
 				}
 				angle_delta = estimated_crank_angle - (true_crank_angle[current_magnet] * 10);
 				estimated_crank_angle = true_crank_angle[current_magnet] * 10;

volatile uint32_t rpm;
volatile uint32_t angular_frequency; // In 0.1 degrees / second
volatile int32_t delta_time_history[DELTA_TIME_HISTORY_LENGTH];
volatile int32_t magnet_start_time = 0;
volatile int32_t magnet_time_delta = 0;
volatile int32_t revolution_time = 0;


// #define EXTRA_TRACE

//#define Serial SerialUSB

#define TFT_UPDATE_INTERVAL 250000
#define FLYWHEEL_MAGNET_SENSOR_PIN 6 // Port PC23 on SAM3
#define IGNITION_OUT_PIN 7
#define NTC_PIN 0
#define PRE_IGITION_SLOPE_DEFAULT 10.0 // Degrees @ 1600 rpm. These two combined gives 25 deg + BIAS @ 1600 rpm
