Enable compression: When Enabled, this simulates RPM 'waves' that are common during cranking as each cylinder compresses. The effect will only be active below a set RPM value
+
+
Dynamic amplitude: When Enabled, the amplitude of the waves will change based on how far the RPM is below the compression RPM setting. If disabled, the wave amplitude will always be 100rpm
+
+
+
+
Configuration:
diff --git a/UI/renderer.js b/UI/renderer.js
index b61d14d..b196469 100644
--- a/UI/renderer.js
+++ b/UI/renderer.js
@@ -6,7 +6,7 @@ const ByteLengthParser = require('@serialport/parser-byte-length')
const {ipcRenderer} = require("electron")
var port = new serialport('/dev/tty-usbserial1', { autoOpen: false })
-const CONFIG_SIZE = 17;
+const CONFIG_SIZE = 18;
var onConnectIntervalConfig;
var onConnectIntervalWheels;
var isConnected=false;
@@ -236,6 +236,7 @@ function receiveConfig(data)
document.getElementById("compressionMode").value = data[12];
document.getElementById("compressionRPM").value = (((data[14] & 0xff) << 8) | (data[13] & 0xff));
document.getElementById("compressionOffset").value = (((data[16] & 0xff) << 8) | (data[15] & 0xff));
+ document.getElementById("compressionDynamic").value = data[17];
port.unpipe();
@@ -260,6 +261,7 @@ function sendConfig()
configBuffer[12] = parseInt(document.getElementById('compressionMode').value);
configBuffer.writeUInt16LE(parseInt(document.getElementById('compressionRPM').value), 13);
configBuffer.writeUInt16LE(parseInt(document.getElementById('compressionOffset').value), 15);
+ configBuffer[16] = document.getElementById('compressionDynamic').checked;
console.log("Sending full config: ", configBuffer);
@@ -568,6 +570,7 @@ function toggleCompression()
{
var state = document.getElementById('compressionEnable').checked
+ document.getElementById('compressionDynamic').disabled = !state
document.getElementById('compressionMode').disabled = !state
document.getElementById('compressionRPM').disabled = !state
document.getElementById('compressionOffset').disabled = !state
diff --git a/ardustim/ardustim/ardustim.ino b/ardustim/ardustim/ardustim.ino
index fcf1939..5540adf 100644
--- a/ardustim/ardustim/ardustim.ino
+++ b/ardustim/ardustim/ardustim.ino
@@ -330,7 +330,7 @@ void loop()
uint16_t calculateCompressionModifier()
{
- if( (currentStatus.rpm > config.compressionRPM) || (config.useCompression != true) ) { return 0; }
+ if( (currentStatus.base_rpm > config.compressionRPM) || (config.useCompression != true) ) { return 0; }
//if( currentStatus.base_rpm > 400 ) { return 0;}
uint16_t crankAngle = calculateCurrentCrankAngle();
@@ -359,6 +359,14 @@ uint16_t calculateCompressionModifier()
compressionModifier = pgm_read_byte(&sin_100_180[modAngle]);
break;
}
+
+ //RPM scaler - Varies the amplitude of the compression modifier based on how far below the compression RPM point we are. Eg:
+ //If the compression RPM value is 400
+ //At 300rpm the amplitude will be 75%
+ //At 200rpm the amplitude will be 50%
+ //At 100rpm the amplitude will be 25% etc
+ //Base RPM must be below 650 to prevent overflow
+ if(config.compressionDynamic && (currentStatus.base_rpm < 655U) ) { compressionModifier = (compressionModifier * currentStatus.base_rpm) / config.compressionRPM; }
return compressionModifier;
}
diff --git a/ardustim/ardustim/globals.h b/ardustim/ardustim/globals.h
index 0134827..f7deace 100644
--- a/ardustim/ardustim/globals.h
+++ b/ardustim/ardustim/globals.h
@@ -50,6 +50,7 @@ struct configTable
uint8_t compressionType = 0;
uint16_t compressionRPM = 400;
uint16_t compressionOffset = 0;
+ bool compressionDynamic = false;
} __attribute__ ((packed));
extern struct configTable config;