Spaces:
Running
Running
File size: 4,480 Bytes
96a5049 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
#ifndef STRUCTURES_H
#define STRUCTURES_H
#include <Arduino.h>
#include <WebServer.h>
#include <Ticker.h>
#include <Preferences.h>
struct CylinderState {
unsigned long lastSparkTime;
bool isInjecting;
uint8_t pin;
float advance;
float detonationLevel;
};
struct EngineError {
bool detonationError;
bool temperatureError;
bool mapError;
bool lambdaError;
bool throttleError;
uint8_t errorCode;
};
struct EngineData {
float rpm;
float map;
float temp;
float lambda;
float detonationLevel1;
float detonationLevel2;
float combinedDetonationLevel;
};
struct ThrottleConfig {
float minPosition;
float maxPosition;
float idlePosition;
float speedPulseRatio;
float ignitionMap[16][16];
};
struct ThrottleLearnData {
float idlePositions[16];
uint16_t idleSamples[16];
float detonationHistory1[10];
float detonationHistory2[10];
int detonationHistoryIndex1;
int detonationHistoryIndex2;
};
struct ThrottleDiagnostics {
bool isCalibrated;
bool isStuck;
bool isOverloaded;
float current;
float voltage;
float detonationCorrection;
};
struct IgnitionMap {
float advance[16][16];
float rpmAxis[16];
float loadAxis[16];
float detonationMap[16][16];
float lambdaMap[16][16];
};
struct LearningData {
float advanceCorrections[16][16];
uint32_t samples[16][16];
float detonationHistory[100];
uint8_t detonationIndex;
};
struct EngineConfig {
float idleRPM;
float idleRPMCold;
float warmupTemp;
float maxRPM;
float minRPM;
float maxAdvance;
float minAdvance;
float maxInjection;
float minInjection;
float detonationThreshold;
float learningRate;
float maxDetonationCorrection;
};
// Структура для хранения конфигурации
struct ConfigData {
uint8_t version;
// Базовые таблицы
float fuelTable[16][16]; // Базовая таблица топливоподачи
float ignitionTable[16][16]; // Базовая таблица УОЗ
// Таблицы обучения
float fuelLearning[16][16]; // Таблица коррекции топливоподачи
float ignitionLearning[16][16]; // Таблица коррекции УОЗ
// Константы впрыска
float injectionTimeMin;
float injectionTimeMax;
float injectionPressure;
float injectorFlow;
float injectorDeadtime;
float injectorVoltage;
float injectorCorrection;
float startInjectionTime;
float startRpmThreshold;
// Лямбда
float lambdaTarget;
float lambdaCorrectionMin;
float lambdaCorrectionMax;
float lambdaCorrectionStep;
// Холостой ход
float idleRpmMin;
float idleRpmMax;
float idleAdvanceMin;
float idleAdvanceMax;
float idleAdvanceStep;
float idleAdvanceInterval;
float idleTargetRpm; // Целевые обороты ХХ
float idleKp; // Коэффициент P для ПИД
float idleKi; // Коэффициент I для ПИД
float idleKd; // Коэффициент D для ПИД
// Коррекции
bool tempCorrectionEnabled;
bool lambdaCorrectionEnabled;
bool idleAdvanceLearningEnabled;
bool throttleAdaptationEnabled;
bool hotEngineCorrectionEnabled;
bool accelPumpEnabled;
// Зажигание
String ignitionType;
int coilCount;
float sparkDuration;
float maxAdvance;
float minAdvance;
float mechanicalAdvance;
float dwellTime;
// Температура
float coldStartTemp;
float hotEngineTemp;
uint32_t checksum;
};
// Настройки РХХ
struct IdleSettings {
float targetRPM;
float valveMinPosition;
float valveMaxPosition;
float rpmTolerance;
float kp;
float ki;
float kd;
};
// Системные настройки
struct SystemSettings {
uint32_t version;
IdleSettings idle;
float minAdvance;
float maxAdvance;
float injectionTimeMin;
float injectionTimeMax;
float idleRpmMin;
float idleRpmMax;
};
// Данные обучения
struct LearningData2 {
float fuelCorrections[16][16];
float ignitionCorrections[16][16];
uint32_t cellHits[16][16];
uint32_t version;
};
#endif |