Fast ADC readings ok, to verify timing and settling time
This commit is contained in:
@@ -16,7 +16,7 @@ lib_deps =
|
||||
hideakitai/DebugLog@^0.8.4
|
||||
board_build.flash_size = 4MB
|
||||
board_build.partitions = default.csv
|
||||
monitor_speed = 115200
|
||||
monitor_speed = 921600
|
||||
build_type = release
|
||||
|
||||
[env:esp32-devtest-debug]
|
||||
@@ -27,7 +27,7 @@ lib_deps =
|
||||
hideakitai/DebugLog@^0.8.4
|
||||
board_build.flash_size = 4MB
|
||||
board_build.partitions = default.csv
|
||||
monitor_speed = 115200
|
||||
monitor_speed = 921600
|
||||
build_type = debug
|
||||
build_flags =
|
||||
-O0
|
||||
|
||||
@@ -18,13 +18,16 @@ static uint32_t count = 0;
|
||||
#define PAUSE_LONG_MIN 5000
|
||||
#define PAUSE_LONG_MAX PAUSE_LONG_MIN*100
|
||||
|
||||
#define RPM_MIN 800
|
||||
#define RPM_MAX 5500
|
||||
|
||||
void clearScreen(){
|
||||
Serial.print("\033[2J"); // clear screen
|
||||
Serial.print("\033[H"); // cursor home
|
||||
Serial.flush();
|
||||
}
|
||||
|
||||
static double filtered = 0;
|
||||
static double filtered_rpm = 0;
|
||||
|
||||
static const std::map<const uint32_t, const char *> pin2Name = {
|
||||
{PIN_TRIG_A12P, "HIGH_PIN_TRIG_A12P"},
|
||||
@@ -54,7 +57,7 @@ static timerStatus stsA = {
|
||||
void setup()
|
||||
{
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.begin(921600);
|
||||
delay(1000);
|
||||
LOG_ATTACH_SERIAL(Serial);
|
||||
|
||||
@@ -94,11 +97,11 @@ void loop()
|
||||
stsA.soft_start = false;
|
||||
}
|
||||
|
||||
double new_val = (float)(map(analogRead(FREQ_POT), 0, 4096, PAUSE_LONG_MIN, PAUSE_LONG_MAX));
|
||||
filtered = filtered + 0.1 * (new_val - filtered);
|
||||
stsA.pause_long_us = (uint32_t)filtered;
|
||||
double new_rpm = (double)(map(analogRead(FREQ_POT), 0, 4096, RPM_MIN, RPM_MAX));
|
||||
filtered_rpm = filtered_rpm + 0.1 * (new_rpm - filtered_rpm);
|
||||
stsA.pause_long_us = (uint32_t)(60000000.0f / filtered_rpm / 2.0f);
|
||||
LOG_INFO("Spark Delay uS: ", stsA.spark_delay_us, "\tSoft Start: ", stsA.soft_start ? "TRUE" : "FALSE");
|
||||
LOG_INFO("Pause: ", (uint32_t)(stsA.pause_long_us / 1000), "ms");
|
||||
LOG_INFO("Engine Rpm: ", (uint32_t)(filtered_rpm));
|
||||
LOG_INFO("Coil Pulse: ", stsA.coil_pulse_us, "us");
|
||||
LOG_INFO("Spark Pulse: ", stsA.spark_pulse_us, "us");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user