00001 /* FreeEMS - the open source engine management system 00002 00003 Copyright 2008, 2009 Fred Cooke 00004 00005 This file is part of the FreeEMS project. 00006 00007 FreeEMS software is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 FreeEMS software is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ 00019 00020 We ask that if you make any changes to this file you email them upstream to 00021 us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! 00022 00023 Thank you for choosing FreeEMS to run your engine! */ 00024 00025 00045 /* Header file multiple inclusion protection courtesy eclipse Header Template */ 00046 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */ 00047 #ifndef FILE_FIXED_CONFIGS_H_SEEN 00048 #define FILE_FIXED_CONFIGS_H_SEEN 00049 00050 00051 00060 typedef struct { 00061 /* Pre configured value settings for the sensor inputs */ 00062 unsigned short presetIAT; 00063 unsigned short presetCHT; 00064 unsigned short presetTPS; 00065 unsigned short presetEGO; 00066 unsigned short presetBRV; 00067 unsigned short presetMAP; 00068 unsigned short presetAAP; 00069 unsigned short presetMAT; 00070 unsigned short presetEGO2; 00071 unsigned short presetIAP; 00072 unsigned short presetBPW; /* Base Pulse Width */ 00073 unsigned short presetAF; /* Air Flow */ 00074 } sensorPreset; 00075 00076 #define SENSOR_PRESETS_SIZE sizeof(sensorPreset) 00077 00078 00079 typedef struct { 00080 /* Sensor related settings */ 00081 unsigned short TPSClosedMAP; 00082 unsigned short TPSOpenMAP; 00083 00084 /* Sensor input conditioning settings */ 00085 /* These are used to calculate MAP, EGO and TPS from ADC readings. */ 00086 00087 /* For MAP, default to MPX4250A 260kPa - 8kPa = 252kPa See the link for the transfer function*/ 00088 unsigned short MAPMinimum; /* 0 kPa usually. */ 00089 unsigned short MAPRange; /* 10000, 11500, 25000, 30000, 40000 etc (/100 for kPa) */ 00090 00091 /* For AAP, default to MPX4100A 107.5kPa - 14kPa = 93.5kPa See the link for the transfer function */ 00092 unsigned short AAPMinimum; /* 0 kPa usually. */ 00093 unsigned short AAPRange; /* 10000, 11500, 25000, 30000, 40000 etc (/100 for kPa) */ 00094 00095 /* Default to Innovate LC-1 on lambda 0.5 - 1.5 for 0-5V range (lambda range = 1.0) */ 00096 unsigned short EGOMinimum; /* 0.5 lambda ? (0.5 x 32768 = 16384) */ 00097 unsigned short EGORange; /* 1.5 lambda ? ((1.5 - 0.5) x 32768 = 32768 (max 49152)) */ 00098 00099 /* 0 - 24.5 Volt measurement with 10k and 39k resistors */ 00100 /* http://www.google.com/search?hl=en&safe=off&q=5+*+(39000+%2B+10000)+%2F+10000&btnG=Search */ 00101 unsigned short BRVMinimum; /* 0 Volts usually. */ 00102 unsigned short BRVRange; /* 24.5 Volts for 10k and 39k resistors on a 12v vehicle */ 00103 00104 /* Default to 25% of voltage = closed (0%) */ 00105 /* 75% of voltage = open (100%) */ 00106 unsigned short TPSMinimumADC; /* *should* be zero, but often isn't, this value corresponds to 0% TPS */ 00107 unsigned short TPSMaximumADC; /* */ 00108 // unsigned short TPSADCRange; // ?? 100% = how many ADCs ? 00109 /*efine TPS_MINIMUM 0 ** = 0.00% For clarity ONLY, always zero. */ 00110 #define TPS_RANGE_MAX 64000 /* = 100.00% */ 00111 } sensorRange; 00112 00113 #define SENSOR_RANGES_SIZE sizeof(sensorRange) 00114 00115 00116 typedef struct { 00117 /* Fuel injection settings TODO duplication from original temp code below!! */ 00118 unsigned short perCylinderVolume; /* 500cc = 0.5l 0.5 * 32768 = pcv, so divide by 32768 go get litres */ 00119 unsigned short stoichiometricAFR; /* 34 for hydrogen, all others less, figure is 14.7 * 1024, divide by 1024 to get AFR */ 00120 unsigned short injectorFlow; /* Injector flow of 240cc/min / 60 is 4ml/second is multiplied by 1024, so divide by 1024 for ml/second, divide by 1000 for litres/second */ 00121 unsigned short densityOfFuelAtSTP; /* 703gm/litre for Octane. 32 * fuel density = number, divide by 32 for the real figure */ 00122 /* Setting variables (must be inited with useful values) */ 00123 unsigned short capacityOfAirPerCombustionEvent; /* How much air it swallows per power producing event */ 00124 unsigned short perPrimaryInjectorChannelFlowRate; /* How much fuel flows per minute per channel */ 00125 unsigned short perSecondaryInjectorChannelFlowRate; /* How much fuel flows per minute per channel */ 00126 unsigned char ports; /* How many groups of injectors we are firing */ 00127 unsigned char coils; /* How many coils we are firing */ 00128 unsigned char combustionEventsPerEngineCycle; /* How many power producing events per engine cycle */ 00129 unsigned char revolutionsPerEngineCycle; /* Rotary = 1, 2 Stroke = 1, 4 Stroke = 2 */ 00130 unsigned char primaryTeeth; /* How many teeth are on the crank signal including the missing ones if any (eg. 36-1 primary = 36 not 35) */ 00131 unsigned char missingTeeth; /* Number sequentially removed from primary teeth (eg. 36-1 missing = 1) */ 00132 } engineSetting; 00133 00134 #define ENGINE_SETTINGS_SIZE sizeof(engineSetting) 00135 00136 00137 typedef struct { 00138 /* Serial settings */ 00139 unsigned short baudDivisor; /* 22 = (40MHz / (16*115.2kHz)) = 21.7013889 */ 00140 unsigned char networkAddress; /* Default = 1, Default for PC = 10 */ 00141 } serialSetting; 00142 00143 #define SERIAL_SETTINGS_SIZE sizeof(serialSetting) 00144 00145 00146 typedef struct { 00147 /* Tacho settings */ 00148 unsigned char tachoTickFactor; 00149 unsigned short tachoTotalFactor; 00150 } tachoSetting; 00151 00152 #define TACHO_SETTINGS_SIZE sizeof(tachoSetting) 00153 00154 00155 typedef struct { 00156 unsigned short readingTimeout; /* How often an ADC reading MUST occur */ 00157 } sensorSetting; 00158 00159 #define SENSOR_SETTINGS_SIZE sizeof(sensorSetting) 00160 00161 00162 #define userTextFieldArrayLength1 1024 - (ENGINE_SETTINGS_SIZE + SERIAL_SETTINGS_SIZE + TACHO_SETTINGS_SIZE + 2) 00163 00173 typedef struct { 00174 00175 engineSetting engineSettings; 00176 00177 serialSetting serialSettings; 00178 00179 tachoSetting tachoSettings; 00180 00181 /* Settings variables : 0 = false */ 00182 unsigned short coreSettingsA; /* Each bit represents the state of some core setting, masks below and above where the same one is used */ 00183 /* Bit masks for coreSettingsA */ // TODO needs a rename, as does coreStatusA 00184 //#define COREA1 BIT1_16 /* 1 */ 00185 #define PRIMARY_POLARITY BIT2_16 /* 2 1 = high teeth 0 = low teeth */ 00186 #define SECONDARY_POLARITY BIT3_16 /* 3 1 = high teeth 0 = low teeth */ 00187 //#define COREA4 BIT4_16 /* 4 */ 00188 //#define FUEL_CUT BIT5_16 /* 5 Remove injection completely */ 00189 //#define HARD_SPARK_CUT BIT6_16 /* 6 Remove ignition completely */ 00190 //#define SOFT_SPARK_CUT BIT7_16 /* 7 Remove ignition events round robin style */ 00191 //#define SPARK_RETARD BIT8_16 /* 8 Retard ignition in RPM dependent way */ 00192 #define STAGED_ON BIT9_16 /* 9 Whether we are firing the staged injectors */ 00193 #define STAGED_START BIT10_16 /* 10 1 = Fixed start 0 = Scheduled start */ 00194 #define STAGED_END BIT11_16 /* 11 1 = Fixed end 0 = Scheduled end */ 00195 //#define COREA12 BIT12_16 /* 12 */ 00196 //#define COREA13 BIT13_16 /* 13 */ 00197 //#define COREA14 BIT14_16 /* 14 */ 00198 //#define COREA15 BIT15_16 /* 15 */ 00199 //#define COREA16 BIT16_16 /* 16 */ 00200 00201 unsigned char userTextField[userTextFieldArrayLength1]; /* "Place your personal notes here!!" */ 00202 } fixedConfig1; 00203 00204 #define FIXED_CONFIG1_SIZE sizeof(fixedConfig1) 00205 00206 00207 #define userTextFieldArrayLength2 1024 - (SENSOR_RANGES_SIZE + SENSOR_PRESETS_SIZE + SENSOR_SETTINGS_SIZE) 00208 00210 typedef struct { 00211 00212 sensorRange sensorRanges; 00213 00214 sensorPreset sensorPresets; 00215 00216 sensorSetting sensorSettings; 00217 00218 /* User text field for noting which installation the unit is from etc. */ 00219 unsigned char userTextField2[userTextFieldArrayLength2]; /* "Place your personal notes here!!" */ 00220 } fixedConfig2; 00221 00222 #define FIXED_CONFIG2_SIZE sizeof(fixedConfig2) 00223 00224 00225 #else 00226 /* let us know if we are being untidy with headers */ 00227 #warning "Header file FIXED_CONFIGS_H seen before, sort it out!" 00228 /* end of the wrapper ifdef from the very top */ 00229 #endif