Configuration = 'Dual Table v.0.10' RAM = { #PUBLIC ;******************************************************************************* ;* MegaSquirt RAM Variables ;******************************************************************************* ; ; RAM Variables - Ordered List for RS232 realtime download - ; delivered in one packet. ; ;=============================================================================== ; First 19 must have their order maintained for compatibility with ; original Configurator. secl byte ; low seconds - from 0 to 255, then rollover squirt byte ; Event variable bit field for Injector Firing engine byte ; Variable bit-field to hold engine current status barometer byte = 101T ; ADC Raw Barometer Reading - count (0 - 255) ;------------------------------------------------------------------------------- ; Raw ADC Counts ; This block must remain in exactly this order as it is dictated by the ; hardware configuration. See DoADC and schematic. map byte = 70T ; Manifold Absolute Pressure mat byte = $BB ; Manifold Air Temperature clt byte = $BB ; Coolant Temperature TPS byte = $BB ; Throttle Position Sensor batt byte = $BB ; Battery Voltage EGO byte = $BB ; Exhaust Gas Oxygen ;------------------------------------------------------------------------------- EGOcorr byte = 100T ; Oxygen Sensor Correction AirCorr byte = 100T ; Air Density Correction lookup - percent warmcor byte = 100T ; Total Warmup Correction - percent rpm byte ; Computed engine RPM - rpm/100 pw1 byte ; injector squirt time in 1/10 millisec (0 to 25.5 millisec) - applied TPSaccel byte ; Acceleration enrichment - percent barocor byte = 100T ; Barometer Lookup Correction - percent GammaE byte = 100T ; Total Gamma Enrichments - percent vecurr byte = 100T ; Current VE value from lookup table - percent pw2 byte ; the other pw comparison (injector #2) vecurr2 byte = 0 Pg_Offset byte = 0 #PRIVATE ;------------------------------------------------------------------------------- ; Pulse width stuff. pwcalc1 byte ; Computed injector 1 pulse width - move into variable PW1 at pulse time pwcalc2 byte ; Computed injector 2 pulse width pwrun1 byte ; Pulsewidth timing variable - from 0 to 25.4ms pwrun2 byte ;------------------------------------------------------------------------------- ; Actual engine parameters in engineering units. kpa byte ; MAP value in kPa coolant byte ; Coolant temperature in Degrees F plus 40 (allows -40 degress to fit in ubyte) throttle byte ; Throttle position in percent. GET RID OF THIS, use tuning sw. ;------------------------------------------------------------------------------- ; Engine RPM -> RPM = 12000/(ncyl * (rpmph - rpmpl)) rpmph byte ; High part of RPM Period rpmpl byte ; Low part of RPM Period rpmch byte ; Counter for high part of RPM rpmcl byte ; Counter for low part of RPM ;---------------------------------------------------------------------------- ; Previous raw ADC values for computing derivatives. Must correspond ; exactly to the block above starting with "map". lmap byte ; Manifold Absolute Pressure ADC last Reading lmat byte ; Manifold Air Temp ADC last Reading lclt byte ; Coolant Temperature ADC last Reading lTPS byte ; Throttle Position Sensor ADC last Reading lbatt byte ; Battery Voltage ADC last Reading lEGO byte ; Last EGO ADC reading ;---------------------------------------------------------------------------- ; Global Time Clock mms byte ; 0.0001 second update variable ms byte ; 0.001 second increment hs byte ; 0.01 second increment ts byte ; 0.1 second increment sech byte ; high seconds - rollover at 65536 secs (1110.933 minutes, 18.51 hours) TPSaclk byte ; TPS enrichment timer clock in 0.1 second resolution EGOcount byte ; Counter value for EGO step - incremented every ignition pulse asecount byte ; Counter value for after-start enrichment counter - every ignition pulse igncount byte ; Ignition pulse counter altcount byte ; used for offsetting the VE and enrichments for table 2 TPSaclkcmp byte ; Comparison value for TPS acceleration time - from lookup table TPSfuelcut byte = 100T ; TPS Fuel Cut (percent) ;---------------------------------------------------------------------------- ; SCI parameters/variables txcnt byte ; SCI transmitter count (incremented) txgoal byte ; SCI number of bytes to transmit txmode byte ; Transmit mode flag rxoffset byte ; offset placeholder when receiving VE/constants vis. SCI ;---------------------------------------------------------------------------- adsel byte ; ADC Selector Variable last_TPS byte = $FF ; TPS reading updated every 0.1 seconds last_MAP byte = $FF ; MAP reading updated at 0.01 seconds ;---------------------------------------------------------------------------- ; Routines for integer math - storage variables INTACC1 byte(4) INTACC2 byte(4) SPVAL byte(4) ;---------------------------------------------------------------------------- ; Variables for Flash burner ;---------------------------------------------------------------------------- burnSrc byte(2) ; 2-byte address of RAM source data. burnDst byte(2) ; 2-byte address of FLASH destination. burnCount byte ; 1-byte count of bytes to store. ;burnBlk byte(2) ; 2-byte offset of block being erased or written. ;burnLast byte(2) ; 2-byte end of block address ms_temp_sp byte(2) ; 2-byte to store return address ;---------------------------------------------------------------------------- ; Extra "registers" tmp1 byte tmp2 byte tmp3 byte tmp4 byte tmp5 byte tmp6 byte tmp7 byte tmp8 byte tmp9 byte tmp10 byte tmp11 byte tmp12 byte tmp13 byte tmp14 byte tmp15 byte tmp16 byte tmp17 byte tmp18 byte tmp19 byte tmp20 byte tmp21 byte ; used in burner routine ; ;------------------------------------------------------------------------------- ; Various other stuff, don't put it low or you'll waste zero page space. mmsrun byte = 0 load byte ;------------------------------------------------------------------------------- ; Boost controller data bcDC byte = 0 ; Current pwm "duty cycle" (255=100%) MAPdot byte = 0 } RAM_FLASH = { #ORG $E000 ;------------------------------------------------------------------------------- ; Flash Configuration Variables here - variables can be downloaded by pcc or clc. ;------------------------------------------------------------------------------- ; VETABLE and Constants ; VE byte(64) = { ; 64 bytes for VE Table 18T, 18T, 18T, 18T, 18T, 18T, 18T, 18T, ; VE (0,n) 22T, 25T, 30T, 32T, 35T, 35T, 35T, 35T, ; VE (1,n) 35T, 35T, 35T, 35T, 35T, 35T, 35T, 35T, ; VE (2,n) 50T, 50T, 50T, 50T, 50T, 50T, 50T, 50T, ; VE (3,n) 50T, 50T, 50T, 50T, 50T, 50T, 50T, 50T, ; VE (4,n) 50T, 50T, 50T, 50T, 50T, 50T, 50T, 50T, ; VE (5,n) 65T, 65T, 65T, 65T, 65T, 65T, 65T, 65T, ; VE (6,n) 80T, 80T, 80T, 80T, 80T, 80T, 80T, 90T ; VE (7,n) } ;============================================================================== ; 64 byte boundary ;============================================================================== CWU byte = 100T ; Crank Enrichment at -40 F CWH byte = 025T ; Crank Enrichment at 170 F AWEV byte = 020T ; After-start Warmup Percent enrichment add-on value AWC byte = 250T ; After-start number of cycles WWU byte(10) = { ; Warmup bins(fn temp) 120T, ; -40 F 120T, ; -20 F 115T, ; 0 F 115T, ; 20 F 115T, ; 40 F 110T, ; 60 F 105T, ; 80 F 100T, ; 100 F 100T, ; 130 F 100T ; 160 F } TPSAQ byte(4) = { ; TPS acceleration amount (fn TPSDOT) in 0.1 ms units 13T, ; TPSdot = 0.1 v/ms 30T, ; TPSdot = 0.4 40T, ; TPSdot = 0.8 40T ; TPSdot = 1.5 } TPSacold byte = 2T ; Cold acceleration amount (at -40 degrees) in 0.1 ms units TPSthresh byte = 6T ; Accel TPS DOT threshold TPSASYNC byte = 10T ; ***** TPS Acceleration clock value TPSDQ byte = 20T ; Deacceleration fuel cut EGOtemp byte = 200T ; Coolant Temperature where EGO is active EGOcountcmp byte = 32T ; Counter value where EGO step is to occur EGOdelta byte = 1T ; EGO Percent step size for rich/lean EGOlimit byte = 10T ; Upper/Lower EGO rail limit (egocorr is inside 100 +/- Limit) REQ_FUEL byte = 70T ; Fuel constant DIVIDER byte = 2T ; IRQ divide factor for pulse ;------------------------------------------------------------------------------- ; Alternate is an 8 bit variable, but only 1 bit is used in PCC/MT 1.xx ; if alternate = 0 then, as default, both injectors are driven off table 1 ; ; Each injector can be ; not driven ; from table 1 ; from table 2 ; from both tables ; ; Alternate ; bit 0 ; controlled by MS or MT for simul/alternate mode ; 0 = both Inj's controlled by 'standard' table the rest of the byte is ignored ; 1 = additional modes activated ; ; bits 1&2 ; 00 = injector 1 not driven ; 01 = driven from table 1 ; 10 = driven from table 2 ; 11 = driven from both tables ; ; bits 3&4 ; 00 = injector 2 not driven ; 01 = driven from table 1 ; 10 = driven from table 2 ; 11 = driven from both tables ; ; bit 5 ; 0 = GammaE not applied to Inj 1 ; 1 = GammaE applied to Inj 1 ; ; bit 6 ; 0 = GammaE not applied to Inj 2 ; 1 = GammaE applied to Inj 2 ; ; bit 7 - not used ;------------------------------------------------------------------------------- Alternate byte = 1T ; used to offset the VE calcs InjOpen byte = 10T ; Injector Open Time InjOCFuel byte = 0T ; PW-correlated amount of fuel injected during injector open INJPWM1 byte = 30T ; Bank 1 - Injector PWM duty cycle at current limit INJPWMT1 byte = 255T ; Bank 1 - Injector PWM mmillisec time at which to activate. BATTFAC byte = 12T ; Battery Gamma Factor ;------------------------------------------------------------------------------- ; Constant for RPM = 12,000/ncyl - downloaded constant rpmk byte(2) = { $05, $DC } ; ; VE table RPM Bins for 2-D interpolation RPMRANGEVE byte(8) = { 5T, 10T, 15T, 20T, 28T, 36T, 44T, 52T } ; VE Table MAP Pressure Bins for 2_D interp. KPARANGEVE byte(8) = { 20T, 30T, 40T, 50T, 60T, 75T, 90T, 100T } ;------------------------------------------------------------------------------- ; CONFIG11: ; Bit 0-1 = MAP Type ; 00 = MPX4115AP ; 01 = MPX4250AP ; 10 = User-defined ; 11 = User-Defined ; Bit 2 = Engine Stroke ; 0 = Four Stroke ; 1 = Two Stroke ; Bit 3 = Injection Type ; 0 = Port Injection ; 1 = Throttle Body ; Bit 4-7 = Number of Cylinders ; 0000 = 1 cylinder ; 0001 = 2 cylinders ; 0010 = 3 cylinders ; 0011 = 4 cylinders ; 0100 = 5 cylinder ; 0101 = 6 cylinders ; 0110 = 7 cylinders ; 0111 = 8 cylinders ; 1000 = 9 cylinders ; 1001 = 10 cylinders ; 1010 = 11 cylinders ; 1011 = 12 cylinders Config11 byte = %00111000 ; Configuration for PC Configurator - placeholder only ;------------------------------------------------------------------------------- ; CONFIG12: ; Bit 0-1 = COOL Sensor Type ; 00 = GM ; 01 = User-defined ; 10 = User-defined ; 11 = User-Defined ; Bit 2-3 = MAT Sensor Type ; 00 = GM ; 01 = Undefined ; 10 = Undefined ; 11 = Undefined ; Bit 4-7 = Number of Injectors ; 0000 = 1 Injector ; 0001 = 2 Injectors ; 0010 = 3 Injectors ; 0011 = 4 Injectors ; 0100 = 5 Injectors ; 0101 = 6 Injectors ; 0110 = 7 Injectors ; 0111 = 8 Injectors ; 1000 = 9 Injectors ; 1001 = 10 Injectors ; 1010 = 11 Injectors ; 1011 = 12 Injectors Config12 byte = %00110000 ;------------------------------------------------------------------------------- ; ; CONFIG13 Bit Definitions ; CONFIG13: ; Bit 0 = Odd-fire averaging ; 0 = Normal ; 1 = Odd-Fire ; Bit 1 = O2 Sensor Type ; 0 = Narrow-band (single wire 14.7 stoch) ; 1 = DIY-WB (Stoch = 2.5V, reverse slope) ; Bit 2 = Control Stategy ; 0 = Speed-Density ; 1 = Alpha-N ; Bit 3 = Baro correction ; 0 = Disable ; 1 = Enable Config13 byte = %00001000 ;------------------------------------------------------------------------------- PRIMEP byte = 20T ; Priming pulse in 1/10ths ms EGOrpm byte = 12T ; EGO disabled below this rpm (* 100rpm) FASTIDLE byte = 185T ; Fast Idle Temperature O2targetV byte = 26T ; target voltage (in adc counts) for lamda sensor Spare_1 byte(5) = { $AA, $AA, $AA, $AA, $AA } ;============================================================================== ; 128 byte boundary ;============================================================================== ; VETABLE 2 and Constants ; VE_2 byte(64) = { ; 64 bytes for VE Table 2 18T, 18T, 18T, 18T, 18T, 18T, 18T, 18T, ; VE (0,n) 22T, 25T, 30T, 32T, 35T, 35T, 35T, 35T, ; VE (1,n) 35T, 35T, 35T, 35T, 35T, 35T, 35T, 35T, ; VE (2,n) 50T, 50T, 50T, 50T, 50T, 50T, 50T, 50T, ; VE (3,n) 50T, 50T, 50T, 50T, 50T, 50T, 50T, 50T, ; VE (4,n) 50T, 50T, 50T, 50T, 50T, 50T, 50T, 50T, ; VE (5,n) 65T, 65T, 65T, 65T, 65T, 65T, 65T, 65T, ; VE (6,n) 80T, 80T, 80T, 80T, 80T, 80T, 80T, 90T ; VE (7,n) } ;============================================================================== ; 64 byte boundary ;============================================================================== CWU_2 byte = 100T ; Crank Enrichment at -40 F - not used yet CWH_2 byte = 025T ; Crank Enrichment at 170 F - not used yet AWEV_2 byte = 020T ; After-start Warmup Percent enrichment add-on value - not used yet AWC_2 byte = 250T ; After-start number of cycles - not used yet WWU_2 byte(10) = { ; Warmup bins(fn temp) - not used yet 120T, ; -40 F 120T, ; -20 F 115T, ; 0 F 115T, ; 20 F 115T, ; 40 F 110T, ; 60 F 105T, ; 80 F 100T, ; 100 F 100T, ; 130 F 100T ; 160 F } TPSAQ_2 byte(4) = { ; TPS acceleration amount (fn TPSDOT) in 0.1 ms units 13T, ; TPSdot = 0.1 v/ms 30T, ; TPSdot = 0.4 40T, ; TPSdot = 0.8 40T ; TPSdot = 1.5 } TPSacold_2 byte = 2T ; Cold acceleration amount (at -40 degrees) in 0.1 ms units TPSthresh_2 byte = 6T ; Accel TPS DOT threshold TPSASYNC_2 byte = 10T ; ***** TPS Acceleration clock value TPSDQ_2 byte = 20T ; Deacceleration fuel cut EGOtemp_2 byte = 200T ; Coolant Temperature where EGO is active - not used yet EGOcountcmp_2 byte = 32T ; Counter value where EGO step is to occur - not used yet EGOdelta_2 byte = 1T ; EGO Percent step size for rich/lean - not used yet EGOlimit_2 byte = 10T ; Upper/Lower EGO rail limit (egocorr is inside 100 +/- Limit) - not used yet REQ_FUEL_2 byte = 155T ; Fuel constant DIVIDER_2 byte = 4T ; IRQ divide factor for pulse Alternate_2 byte = 1T ; Not used InjOpen_2 byte = 10T ; Injector Open Time InjOCFuel_2 byte = 0T ; PW-correlated amount of fuel injected during injector open INJPWM2 byte = 30T ; Bank 2 - Injector PWM duty cycle at current limit INJPWMT2 byte = 255T ; Bank 2 - Injector PWM mmillisec time at which to activate. BATTFAC_2 byte = 12T ; Battery Gamma Factor ;------------------------------------------------------------------------------- ; Constant for RPM = 12,000/ncyl - downloaded constant rpmk_2 byte(2) = { $05, $DC } ; ; VE table RPM Bins for 2-D interpolation RPMRANGEVE_2 byte(8) = { 5T, 10T, 15T, 20T, 28T, 36T, 44T, 52T } ; VE Table MAP Pressure Bins for 2_D interp. KPARANGEVE_2 byte(8) = { 20T, 30T, 40T, 50T, 60T, 75T, 90T, 100T } ;------------------------------------------------------------------------------- config21 byte = %00000000 config22 byte = %00000000 ;------------------------------------------------------------------------------- ; ; CONFIG23 Bit Definitions ; CONFIG23: ; Bit 0 = ; Bit 1 = ; Bit 2 = Control Strategy for INJ 2 ; 0 = Speed-Density ; 1 = Alpha-N ;------------------------------------------------------------------------------- config23 byte = %00000000 PRIMEP_2 byte = 10T ; Priming pulse in 1/10ths ms - not used yet EGOrpm_2 byte = 11T ; EGO disabled below this rpm (* 100rpm) - not used yet FASTIDLE_2 byte = 185T ; Fast Idle Temperature - not used yet O2targetV_2 byte = 26T ; target voltage (in adc counts) for lamda sensor - not used yet revLimit byte = 67T ; Rev limit ; Nitrous switch parameters. minN2Otemp byte = 160T ; Coolant temperature below which N2O is disabled. lowN2ORPM byte = 035T ; RPM below which N2O is disabled. highN2ORPM byte = 066T ; RPM above which N2O is disabled. Crankrpm byte = 003T ; rpm, below which, the engine is cranking ; after today's discussion re. the 125byte return from V that would mean that ; these last three bytes would not be available to MT ??? Hmmm have to think ;============================================================================== ; 128 byte - Flash Page boundary ;============================================================================== } FLASH = { ; This is used to set the bin coolant range for WWU WWUrange byte(10) = { 0T, 20T, 40T, 60T, 80T, 100T, 120T, 140T, 170T, 200T } TPSdotrate byte(4) = { 5T, ; 0.1 volts delta 20T, ; 0.4 volt 40T, ; 0.8 volt 77T ; 1.5 volt } bcPgain byte = 100T ; Proportional gain bcDgain byte = 100T ; Derivative gain bcTPS byte(4) = { ; TPS bins for boost controller set point interpolation. ; Barring tuner support, suck these out of your throttlefactor.inc ; Percentages are just my outta the hat values. 25T, ; ADC 0% throttle 57T, ; 15 108T, ; 40 225T ; ADC 100 } bcSPV byte(4) = { ; Set point values corresponding to each throttle bin. 90T, ; kPa at 0% throttle 100T, ; kPa 15 167T, ; kPa 40 167T ; kPa at 100 } REVNUM byte = 01T ; revision number, Bruce uses 1x & 2x, we'll use 0.1 }