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