Method of controlling combustion engine timing
TECHNICAL FIELD 
     The present invention relates to controlling the ignition timing of an internal combustion engine to maintain stable engine idle speeds. 
     BACKGROUND ART 
     Generally, it is desirable for an internal combustion engine to maintain a stable idle speed. By maintaining a stable idle speed, stalling of the engine due to load, or torque, variations can be minimized. 
     The prior art teaches many methods of idle speed control. For example, U.S. Pat. No. 4,719,573, issued to Kissel et al., discloses a method for idle speed control for an engine equipped with a fuel/air mixture means and an air bypass means. The spark advance is temporarily changed in response to idle speed changes due to changing engine load, either by retarding or advancing the spark advance value. Thus, the idle speed is moved to the targeted value and held there until the air bypass system has a chance to respond. As the air bypass valve is properly positioned, the spark advance is changed back to a steady state value, allowing the idle speed actuator valve or motor to operate in a stable manner without the undesirable effects of slow response. 
     U.S. Pat. No. 4,696,272, issued to Kato et al., discloses an ignition timing control method for internal combustion engines. The method is adapted to control the timing of the ignition of a mixture being supplied to the engine and includes the steps of retarding a determined ignition timing value by a predetermined amount when the engine is in a predetermined idling region and the engine temperature exceeds a predetermined value, and setting a desired idling speed in response to operating conditions of the engine. The method also includes the steps of calculating a correction value by multiplying the difference between a desired idle speed and an actual engine speed by a predetermined coefficient, and correcting the ignition timing value retarded by the predetermined amount by the correction value thus calculated. 
     U.S. Pat. No. 4,509,477, issued to Takao et al., discloses a method and apparatus for idle operation control of internal combustion engines. The control of the rotational speed of the engine to a predetermined value during idle operation is performed by detecting an engine rotational speed variation characteristic, detecting an engine torque variation characteristic and detecting a phase difference between the two characteristics on the basis of the engine rotational speed. An engine torque variation condition is determined at the present moment on the basis of the torque variation characteristic data and the phase difference data and an engine operation parameter, such as ignition timing, is then corrected in a direction to minimize the engine torque variation. 
     Other patents related to controlling the idle speed of an internal combustion engine include U.S. Pat. No. Re. 33,027, issued to Danno et al., U.S. Pat. No. 5,033,432, issued to Ohuchi et al., U.S. Pat. No. 5,024,197, issued to Nakamura, U.S. Pat. No. 5,016,180, issued to Fujisawa, U.S. Pat. No. 4,933,863, issued to Okano et al., U.S. Pat. No. 4,890,592, issued to Furuyama et al., U.S. Pat. No. 4,883,034, issued to Yashiki et al., U.S. Pat. No. 4,879,656, issued to Quigley et al., U.S. Pat. No. 4,676,211, issued to Kiuchi et al. and U.S. Pat. No. 4,552,109, issued to Boccadoro et al. 
     Previous strategies, however, utilized only one or two fixed values of spark retard, restricting the degrees of freedom of these strategies and only crudely approximating the complex behavior of spark advance as a function of speed and load. 
     SUMMARY OF THE INVENTION 
     It is an object of the present invention to maintain the idle speed of an internal combustion engine. 
     It is an additional object of the present invention to maintain the idle speed of an internal combustion engine utilizing an idle feedback spark control system. 
     It is yet a further object of the present invention to maintain the idle speed of an internal combustion engine by compensating for load disturbances utilizing a torque-based calculation of the required spark advance. 
     In carrying out the above objects and other objects and features of the present invention, a method is provided for maintaining the speed of a spark-ignited internal combustion engine operating at a desired idle speed to compensate for engine speed variations caused by torque disturbances. The engine is controlled according to a control strategy by an electronic controller having a memory. The method comprises the step of determining a desired final spark advance utilizing an actual idle speed and the desired idle speed expressed as an RPM error ratio to linearize the control strategy. In the preferred embodiment, the RPM error ratio is equivalent to the torque disturbance and the operating engine torque, expressed as a torque ratio. The torque ratio represents the amount of torque correction required to compensate for the torque disturbance. 
     The strategy of the present invention, to control engine RPM through spark advance adjustments, is intuitively understandable, but the task of accomplishing it is complicated by two non-linearities. First, the relationship between spark advance and torque is non-linear. Second, the relationship between and engine RPM error and torque is also non-linear. 
     The benefits accruing to the present invention are numerous, since the strategy takes advantage of a torque ratio formulation. First, the present invention linearizes the relationship between RPM error and torque, so as to ensure the requested torque is accurately delivered. Second, the desired torque compensation is correct regardless of engine operating conditions, such as engine RPM and load. Lastly, the strategy of the present invention is calibratable with one parameter, which effectively defines the amount of torque the strategy will supply on demand. The operating spark which supplies its reserve of torque is calculated without additional calibration efforts. 
     The above objects and other objects, features and advantages of the present invention will be readily appreciated by one of ordinary skill in the art from the following detailed description of the best mode for carrying out the invention when taken in connection with the accompanying drawings. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram of a controller for use with the present invention; 
     FIG. 2 is a high level flow chart illustrating the method of the present invention for use with the controller shown in FIG. 1; 
     FIG. 3 is a graphical illustration of a function which relates spark offset from MBT to a torque ratio; 
     FIG. 4 is a graphical illustration of the negative inverse of the function shown in FIG. 3; 
     FIG. 5 is a graphical representation of the determination of the torque ratio supplied by the engine; 
     FIG. 6 is a flow chart illustrating the determination of a desired reserve torque ratio; 
     FIGS. 7a-7e are flow charts illustrating the determination of a spark state; 
     FIGS. 8a-8b illustrate the flow chart for the determination of a reserved torque ratio; 
     FIG. 9 is a flow chart illustrating the determination of a torque correction required for maintaining the desired idle speed of the engine; and 
     FIG. 10 is a flow chart illustrating the determination of an idle spark which will provide the amount of torque correction. 
    
    
     BEST MODE FOR CARRYING OUT THE INVENTION 
     As shown in FIG. 1, air and fuel are supplied to an engine 12, which has an RPM output and a torque output applied to a transmission 14. The engine 12 and the transmission 14 are coupled to an electronic control module 16. Preferably, the control module 16 receives data relating to operation of the engine 12 and the transmission 14 from a plurality of sensors not specifically illustrated and accordingly executes the combustion engine timing strategy of the present invention, as described in greater detail below. 
     Referring now to FIG. 2, there is shown a high level flow chart illustrating the method of controlling combustion engine timing of the present invention, which implements a torque-based feedback spark at idle. In the preferred embodiment, the feedback spark strategy is a closed-loop control strategy which operates during engine idle and attempts to maintain a desired engine idle RPM by increasing and decreasing engine torque through spark advance adjustments. A spark advance adjustment is the preferred adjustment due to the speed with which such an adjustment can be effected. Once the torque disturbance is rejected through a spark adjustment, desired idle speed can be maintained by modifying air charge. For example, desired idle speed can be maintained by increasing air charge and retarding spark advance. Thus, as the air charge is varied, a spark advance adjustment is made in preparation for a subsequent torque disturbance. 
     More specifically, the electronic control module 16 reacts to an RPM error from the desired idle RPM with an adjustment to spark advance. Idle RPM control is thus accomplished in conjunction with the normal idle speed control and fuel strategies executed by the electronic control module 16, which need not be discussed in detail for purposes of the present invention. The present invention utilizes spark advance to maintain engine idle speed during torque variations, since spark advance is the quickest responding output of the electronic control module 16 which directly affects engine output torque. 
     The following is a glossary of abbreviations for terms utilized throughout this disclosure: 
     AM=air mass flow 
     AM DES  =air mass flow at the desired engine idle RPM 
     AM CAL  =air mass flow increase due to the calibrated load imposed on the system 
     AM LDD  =AM needed to maintain N CAL  with an applied torque, T LD   
     AM NLD  =needed to maintain N CAL  without an applied torque, T LD   
     APT=at part throttle; -1=closed throttle; 0=part throttle; 1=wide open throttle 
     BG TMR  =background loop time 
     DND SUP  =delayed neutral/drive flag; 0=neutral and 1=drive 
     DSD RPM  =idle speed control desired RPM 
     DR BS  =base desired engine speed in drive 
     FBS --  ENT COMP  =entry into feedback spark state complete 
     FBS --  ENT TC  =time constant which paces the entry into feedback spark 
     FBS --  ENT OK  =OK to begin entry into feedback spark state 
     FBS --  EX COMP  =exit from feedback spark state complete 
     FBS --  EX OK  =OK to begin exit from feedback spark state 
     FKEXIT=filter constant which paces exit from feedback spark 
     FUNC=function which calculates the torque ratio at which an engine is operating from the SPK.sub.Δ  from SPK MBT  ; shown in FIG. 3 
     INVFUNC=function which returns a spark retard (°) from SPK MBT  as a function of desired torque ratio; shown in FIG. 4 
     ISC FLG  =ISC mode indicator flag; -1=dashpot mode, 0=dashpot preposition mode: 1=closed-loop RPM control mode; and 2=lockout entry to RPM control 
     K=constant of proportionality relating air mass flow, torque and RPM 
     K SPK  =proportional gain applied to control error 
     LAST --  LD MBT  =load from the last pass corrected to the value the load would have at SPK MBT . 
     MIN MPH  =minimum speed to enter closed-loop RPM control 
     N=engine RPM 
     N ACT  =actual engine RPM under current operating conditions 
     N CAL  =the RPM at which the calibration load (AM CAL ) test was conducted 
     N DES  =desired idle RPM 
     N LDD  =RPM when engine is loaded with torque, T LD  ; N NLD  =N CAL  during calibration test 
     N NLD  =RPM when engine is not loaded with torque, T LD  ; N NLD  =N CAL  during calibration test 
     NU BS  =base desired engine speed in neutral 
     SPK=calculated spark 
     SPK --  ABS LIM  =an absolute spark limit which preferably is not exceeded 
     SPK CTRL  =threshold above base DSD RPM  below which spark feedback can be entered 
     SPK.sub.Δ =spark delta offset from SPK MBT  which was calculated via the torque ratio calculations; equals SPK MBT  -SPK --  ABS LIM   
     SPK --  FBS GAIN  =feedback spark control proportional gain term; normally calibrated to &#34;1&#34; in order to exactly compensate for torque disturbances; unitless 
     SPK --  FLEX LIM  =desirable spark limit which may be exceeded briefly when torque is required by a strategy, such as feedback spark or engine torque oscillation modulation. 
     SPK --  LOAD RES  =desired torque (expressed as load) which the feedback spark calculation can supply to compensate for a torque disturbance to the engine, unitless 
     SPK MBT  =the spark advance required for maximum brake torque 
     SPK ST  =defines the use of feedback spark; 0=feedback spark is not being used; 1=transitioning into feedback spark; 2=using the feedback spark calculation, and 3=transitioning out of feedback spark 
     SPK TMR  =timer used to pace the transition into feedback spark 
     T=engine torque 
     SPK TAR  =throttle angle rate of change 
     T ACT  =actual engine torque under current operating conditions 
     TP=instantaneous throttle position 
     TP LST  =previous A/D reading of TP 
     TR AV  =the ratio of torque available for use by advancing spark 
     TR COR  =the amount of torque ratio correction which reflects and compensates for a torque disturbance; added by advancing spark 
     TR.sub.Δ =when torque ratio change is less than TR.sub.Δ  then entry to or exit from feedback spark is complete 
     T DES  =engine torque at desired RPM 
     T LD  =calculated torque of an applied load 
     T LDD  =total torque supplied by the engine when it is loaded with a test load. T LDD  =T NLD  +T LD   
     T NLD  =total torque supplied by the engine before it is loaded with a test load (T LD ) 
     TR ENG  =torque ratio supplied by the engine 
     TR RES  =a reserve of torque which is created by retarding spark below SPK MBT   
     TR --  RES LAST  =last pass value of TR RES   
     tr --  res DES  =desired reserve torque ratio 
     tr --  flex=torque ratio at the flexible spark limit 
     V --  MODE setup  =1=use normal spark for VIP operating mode 
     VS BAR  =filtered vehicle speed 
     It should be noted that terms appearing in this disclosure and in the drawing figures as &#34;lower case&#34; represent temporary variables whose values are stored in miscellaneous temporary registers in the electronic control module 16, whereas terms appearing as &#34;upper case&#34; represent variables whose values are stored in permanent registers in the electronic control module 16. 
     Referring now to FIGS. 3 and 4, the present invention preferably utilizes a pair of functions, labelled as FUNC and INVFUNC, respectively, which relate a spark that is offset, or retarded, from the value required for maximum brake torque (hereinafter &#34;MBT spark&#34;) and a torque ratio. The existence of this kind of a relationship allows the present invention to compensate for load disturbances imposed on the engine at idle via a torque ratio-based calculation, which in turn, allows a direct calculation of the required spark advance. 
     Preferably, the strategy is based on actual mapping data obtained from a calibration procedure with the data being entered in Table I, shown below, which is preferably store d in a ROM memory of the electronic control module 16. 
     
                       TABLE I                                                     
______________________________________                                    
       DEG.  TORQUE                                                       
       BTDC  RATIO                                                        
______________________________________                                    
        0    1.00                                                         
        5    0.99                                                         
       10    0.95                                                         
       15    0.88                                                         
       20    0.80                                                         
       25    0.71                                                         
       30    0.62                                                         
       35    0.52                                                         
______________________________________                                    
 
    
     With reference now to FIG. 3, the input, shown along the horizontal axis, is the amount the spark is retarded from MBT spark, measured in degrees (°). The output, shown along the vertical axis, is the ratio of delivered engine torque at a particular spark advance to the engine torque delivered when the engine is operating at MBT spark. In other words, when the engine is operating at MBT spark, the torque ratio is 1.0 and when the operating point is retarded from MBT spark, the resulting torque ratio will be a dimensionless fractional value, such as 0.80 or 0.90. 
     The spark/torque function table values shown above in Table I were obtained from engine mapping data and represent typical numbers for a given engine design. To obtain these numbers, for example, an engine was operated at a desired idle speed and a particular air charge (i.e. load), and the spark advance was set at MBT spark (SPK MBT ). The brake torque and the friction torque were observed and recorded at these initial conditions. Next, the spark advance value was retarded by a predetermined amount (SPK x ), such as five degrees (5°), and the brake torque and the friction torque were observed and recorded again. This process was repeated a number of times, resulting in Table I. 
     It should be noted that the indicated torque is a combination of brake torque and friction torque. From the indicated torque values, the torque ratio can be calculated as follows: ##EQU1## 
     Referring now to FIG. 4, there is graphically illustrated another function, labelled as INVFUNC, which also relates spark and torque ratio. It can be seen that the function shown in FIG. 4 is a &#34;mirror image&#34;, or a negative inverse, of the function shown graphically in FIG. 3. Similarly, a table of values, shown below in Table II, which represents INVFUNC, is stored in the ROM memory of the electronic control module system 16: 
     
                       TABLE II                                                    
______________________________________                                    
       DEG.  TORQUE                                                       
       BTDC  RATIO                                                        
______________________________________                                    
         0   1.00                                                         
        -5   0.99                                                         
       -10   0.95                                                         
       -15   0.88                                                         
       -20   0.80                                                         
       -25   0.71                                                         
       -30   0.62                                                         
       -35   0.52                                                         
______________________________________                                    
 
    
     The derivation of the relationships which express engine behavior via torque ratios will be reviewed first, followed by a detailed explanation of the determination of the spark required to maintain a desired idle speed. 
     The strategy of the present invention is utilized to determine the torque ratio to be supplied by the engine (TR ENG ) to maintain a desired idle speed. As described in greater detail below, TR ENG  is converted to a spark advance utilizing INVFUNC and adding that spark advance to the MBT spark value. TR ENG  is determined from the torque ratio available (TR AV ), torque ratio reserve (TR RES ) and a torque ratio correction (TR COR ), such that: 
     
         TR.sub.ENG =TR.sub.AV -TR.sub.RES +TR.sub.COR              (2) 
    
     This relationship is shown graphically in FIG. 5. 
     TR AV , the ratio of torque available for use, is the torque ratio supplied if the engine were operating at the MBT or absolute spark limit. TR RES  is a reserve of torque preferably expressed as a torque ratio, which is created by retarding the spark advance below MBT. This reserve of torque is made available to the control system 10, shown in FIG. 1, to compensate for torque disturbances and is essentially the only calibratable part of the strategy. The desired torque to be held in reserve by operating retarded from MBT is calibrated through the parameter SPK --  LOAD RES . TR COR  is the amount of torque, expressed at a torque ratio, which reflects a torque disturbance as measured by an engine RPM error. This torque compensates for the torque disturbance and is supplied by the engine as a result of advancing the spark value. 
     It is possible to relate engine work rate to the energy contained in the air fuel mixture and, therefore, to air flow rate. Work rate can also be expressed via torque and RPM and the two measures can be fundamentally related through a constant of proportionality: 
     
         N*T=K*AM                                                   (3) 
    
     Since the present invention utilizes a ratio approach, it will be seen that K drops out of the equations and does not need to have a specific value. A useful restatement of this relationship is: ##EQU2## 
     As shown in FIG. 3, FUNC references MBT spark. It is therefore necessary to know the amount of torque ratio lost and hence the amount of torque ratio available, since other parts of the spark calculation request less than MBT spark: 
     
         SPK.sub.Δ =SPK.sub.MBT -SPK.sub.- ABS.sub.LIM        (5) 
    
     Using FUNC directly: 
     
         TR.sub.AV =FUNC(SPK.sub.Δ)                           (6) 
    
     In order to have the ability to add torque to compensate for a torque disturbance, a torque reserve is designed in and is always available. It is preferable to define this reserve as a fixed value of torque. If, however, torque is not measurable in the control module strategies, it can be determined from air mass flow and RPM and the reserve will be created by retarding spark. To determine the torque amount, a procedure is recommended where a calibrator operates the engine at a normal idle, noting air mass and RPM. The calibrator then applies a load which is representative of the desired load rejection. The engine is allowed to stabilize to the same RPM with the load applied and the new air mass is noted. The increase in air mass is calibrated as AM CAL  and the RPM at which the test was conducted is calibrated as N CAL . The derivation of the air mass flow and RPM based torque ratio follows. From equation (4), ##EQU3## Subtracting equation (7) from equation (8), ##EQU4## By definition, 
     
         AM.sub.CAL =AM.sub.LDD -AM.sub.NLD                         (10) 
    
     and 
     
         T.sub.LD =T.sub.LDD -T.sub.NLD                             (11) 
    
     For the calibration exercise described above, it can be stated that, 
     
         N.sub.CAL =N .sub.LDD =N.sub.NLD                           (12) 
    
     T LD , a calibrated constant, is then obtained by combining equations (9) through (12), ##EQU5## The torque reserve ratio, TR RES , can be defined as ##EQU6## Utilizing equation (7) and equation (13), ##EQU7## wherein the numerator has become a constant and the denominator varies with operating conditions. Rearranging, it can be seen that ##EQU8## 
     In this context, the ability to supply a torque correction implies the ability to infer a torque ratio of a system load from an RPM drop. From equation (4), ##EQU9## 
     It should be noted that air mass flow is defined to be the same in equations (17) and (18) in order to relate them to each other. As an aside, air mass flow should not change during RPM dips, providing that sonic flow is maintained across the throttle plate. 
     By definition, ##EQU10## Substituting equations (17) and (18) into equation (19), it can be seen that ##EQU11## Reducing equation (20), the torque ratio correction can be expressed as ##EQU12## 
     A useable torque ratio equation can be obtained by substituting equations (6), (16) and (21) into equation (2), resulting in the following equation: ##EQU13## Even though it should not be necessary, K SPK  is introduced as a proportional gain term for calibration purposes. 
     The idle spark value, i.e. the spark advance corresponding to TR ENG , can be obtained from INVFUNC: 
     
         SPK=SPK.sub.MBT +INVFUNC(TR.sub.ENG)                       (23) 
    
     Thus, the strategy of the present invention preferably implements the relationships expressed in equations (22) and (23). There are two benefits from this approach. The present invention linearizes the proportional controller, which allows for the delivery of the right amount of spark correction regardless of operating conditions. Specifically, it prevents overcorrection under some operating conditions, which leads to idle oscillations, and under-correction under other conditions, which lead to large RPM dips when torque loads are applied to the engine at idle. The linearization comes from the formulation of the control parameter N (i.e. engine speed) into {1-N ACT  /N DES  }, which is linear, rather than the traditional {N DES  -N ACT  }, which is nonlinear. The present invention also incorporates a correction for the nonlinear relationship between spark advance and torque ratio. 
     A second benefit of the formulation of the present invention is that it allows the calibrator to calibrate a desired level of load (i.e. torque) rejection. The present invention calculates the appropriate spark retard under all operating conditions, ensuring that adequate load rejection occurs under all operating conditions. At the same time, excessive load rejection capability is prevented. Excessive load rejection capability results from excessive spark retard, which increases fuel consumption and decreases idle quality. 
     Referring now to FIGS. 6-10, there are shown flow charts illustrating the determination of the idle spark of equation (23). FIG. 6 illustrates the determination of the desired reserve torque ratio. In order to have the ability to add torque to compensate for a torque disturbance, the present invention utilizes a torque reserve which is always available. As previously stated, this torque reserve is preferably defined as a fixed value of torque. If, however, the control module 16 does not execute strategies for measuring torque, air charge (AC) can be utilized instead of torque, since they are directly proportional to each other. Torque or air charge can be expressed as equivalent dimensionless ratios referred herein as a torque ratio: ##EQU14## It should be appreciated that when a ratio is used, many simplifications result. 
     In the preferred embodiment, the calibration of the torque reserve remains substantially constant for all speed-load combinations and is created by retarding spark. To determine the desired amount of torque reserve, the preferred procedure is to operate the engine at a normal idle and record the load and engine RPM. An external torque disturbance can then be applied which is representative of the load rejection desired. Next, the engine is allowed to stabilize to the RPM as before and the desired increase in torque required to maintain this RPM is determined. This increase in load is calibrated by SPK --  LOAD RES . Of course, the amount of spark retard required to provide an appreciable load rejection may require a very large spark retard at idle. As a result, feedback spark may be utilized primarily for stabilizing the idle speed. 
     Thus, at step 100 in FIG. 6, the desired reserve torque ratio is determined utilizing the desired torque (expressed as load) and load corrected to its equivalent value at MBT (i.e. LAST --  LD MBT ). 
     Referring now to FIGS. 7aa-7e, there are shown flow charts illustrating the determination of spark state (SPK ST ), which defines the use of feedback spark in the present invention. In the preferred embodiment, there are four (4) spark states. SPK ST  #0 corresponds to no feedback spark being utilized. SPK ST  #1 corresponds to a transition into feedback spark. SPK ST  #2 corresponds to utilization of feedback spark calculation and SPK ST  #3 corresponds to a transition out of feedback spark, as described in greater detail hereinbelow. 
     Referring now to FIG. 7a, a flow chart is shown illustrating entry into SPK ST  #0, which marks the completion of the transition from feedback spark, as represented by the variable FBS --  EX COMP . At step 202, the control module 16 determines whether or not the absolute value of the difference between the last pass value of torque reserve (TR --  RES LST ) and the present torque ratio reserve (TR --  RES), is less than TR.sub.Δ, a predetermined calibration constant which represents a deviation from the torque ratio reserve and which controls entry into feedback spark state #2. Based on that determination, the control module 16 accordingly sets the value of FBS --  EX COMP  at steps 204 or 206. 
     Referring now to FIG. 7b, there is shown a flow chart illustrating the entry conditions to SPK ST  #1, which marks a transition into feedback spark calculation. To enter SPK ST  #1, certain conditions are preferably satisfied for transition into feedback spark calculations, as represented by the variable (FBS --  ENT OK ). At steps 208 and 210, the control module 16 considers whether the transmission is in a drive gear (DND SUP  =1) or neutral (DND SUP  =0) and determines whether the difference between the desired idle speed control RPM (DSD RPM ) and a base desired engine speed (DR BS  for drive, NUBASE for neutral) exceeds the value of the variable SPK CTRL , which represents a threshold above DSD RPM  below which spark feedback can be entered. At step 212, the control module 16 determines the state of ISC FLG , a flag which indicates the air flow control mode. As a result of those determinations, the control module 16 sets the value of FBS --  ENT OK  at steps 214 or 216, with a value of &#34;1&#34; indicating a transition into SPK ST  #1. 
     Referring now to FIG. 7c, there is shown a flow chart illustrating the entry conditions to SPK ST  #2, the spark state corresponding to use of feedback spark calculation. At step 218, the control module 16 compares the value of SPK TMR , a timer used to pace the transition into feedback spark, to a predetermined calibration time constant (FBS --  ENT TC ) which paces the entry into feedback spark. The control module 16 may also perform the comparison previously described at step 202 above. Based on at least one of these comparisons, the control module 16 sets the value of FBS --  ENT COMP  accordingly at steps 220 or 222, with a value of &#34;1&#34; indicating entry into feedback spark state 2 is allowed. 
     Referring now to FIG. 7d, a flow chart illustrates the entry conditions to SPK ST  #3 (i.e. begin transition out of feedback spark calculations or out of entry mode). In setting the value of the feedback spark exit variable (FBS --  EX OK ) at steps 226 or 228, the control module 16 at step 224 determines whether the variable APT has a non-negative value and, if APT has a negative value, compares the filtered vehicle speed (VS BAR ) to a calibration constant (MIN MPH ) which represents the maximum vehicle speed allowed to remain in closed-loop RPM control. Preferably, this calibration constant applies to systems having a vehicle speed sensor (VSS), and is set below the speed at which a vehicle having an automatic transmission rolls along in a drive gear without application of the brakes. The effect is to prevent entry into RPM control during parking lot maneuvers. A typical value for MIN MPH  is about 3 MPH. 
     Referring now to FIG. 7e, there is shown a flow chart illustrating the spark state transition logic. As shown, a new spark state is determined based on the present spark state and the value of the various feedback entry and exit variables which were determined with references FIGS. 7a-7d. 
     At step 230, if feedback spark is not being used and the entry conditions to spark state 1 are satisfied, the control module sets the current spark state to &#34;1&#34; and the value of SPK TMR  to &#34;0&#34; at step 232. If the controller is transitioning into feedback spark (i.e. SPK ST  =1) and the feedback exit conditions are satisfied at step 234, SPK ST  is set to &#34;3&#34; and the spark timer is allowed to run at step 236. 
     With continuing reference to FIG. 7e, a step 238, if the control module 16 is transitioning into feedback spark and the entry transition to feedback spark is complete, the control module 16 begins using feedback spark calculation (i.e. SPK ST  =2) and the spark timer is allowed to run at step 240. 
     At step 242, if feedback spark calculations are being utilized and the feedback spark exit conditions are satisfied, the spark state is set to &#34;3&#34; and the spark timer is allowed to run at step 244. If, however, the control module 16 is transitioning out of feedback spark and the feedback spark entry conditions have been satisfied at step 246, the control module sets the spark state to a value of &#34;1&#34; and the spark timer is set to &#34;0&#34; at step 248. 
     At step 250, if the control module 16 is transitioning out of feedback spark and the feedback spark exit conditions are satisfied, the spark state is set to &#34;0&#34; and the spark timer is allowed to run at step 252. If some other combination of spark state value and feedback spark entry/exit value exists, the spark state remains unchanged and the spark timer is allowed to run as a default at step 254. 
     Referring now to FIGS. 8a-8b, determination of the reserve torque ratio will now be discussed. As shown, the reserve torque ratio routine utilizes information previously determined in the desired reserve torque ratio and spark state routines. At step 302, the control module 16 determines whether the MBT spark is greater than SPK --  ABS LIM , which represents the absolute spark value limit due to detonation, torque limitation or base spark requirements. If the MBT spark exceeds the limit, at step 304 the control module 16 determines an available torque ratio, TR AV , and a flex torque ratio tr --  flex, utilizing FUNC (shown in FIG. 3). If MBT spark does not exceed the limit, at step 306 the control module 16 determines whether the MBT spark exceeds SPK --  FLEX LIM . If the MBT spark does exceed the flexible limit, at step 308 the control module 16 sets the value of the absolute torque ratio to &#34;1&#34; and determines tr --  flex utilizing FUNC and control flow jumps to step 312. If the tests at steps 302 and 306 both fail, the control module sets TR AV  and tr --  flex both to a value of &#34;1&#34; at step 310. 
     With continuing reference to FIG. 8a, at step 312 a base torque ratio reserve (tr --  res BS ) is determined utilizing the available torque ratio and the flexible torque ratio. At step 314, the control module 16 selects the larger of the existing and desired torque reserve ratios by comparing this base torque ratio reserve With tr --  res DES  and accordingly setting the value of tr --  res at step 316 or 318. 
     Referring now to FIG. 8b, at step 320, the control module 16 determines the change in throttle position. If the throttle position change is negative, SPK TAR  is set to zero and the previous throttle position is set to the instantaneous throttle position at step 322. If the change in throttle position is zero or positive, however, SPK TAR  is determined at step 324 utilizing the equation shown. The factor &#34;9.57&#34; is the conversion from analog-to-digital counts into degrees of rotation. At steps 328, 332, 336 and 338, the control module 16 determines the torque ratio reserve which is available to compensate for a torque disturbance, based on the determination of the spark state at steps 326, 330 and 334, respectively. Preferably, the value of FKEXIT determined at step 336 is clipped to value between FKEXIT MIN  and &#34;1&#34;. Thus, upon entry into SPK ST  #1, TR RES  is preferably ramped exponentially from a value of tr --  flex to a value of tr --  res, utilizing a rolling average routine. TR RES  remains at the latter value until the strategy exits via SPK ST  #3 to SPK ST  #0, at which time TR RES  decays to a value of tr --  flex at a rate based on the throttle angle rate. Generally, the greater the throttle rate, the faster the decay. 
     Referring now to FIG. 9, there is shown a flow chart illustrating the determination of the torque correction TR COR . As shown, this routine utilizes information from the spark state routines. If the bit flag V --  MODE SETUP  equals &#34;0&#34; (step 402), the control module calculates tr --  cor based on the desired idle speed RPM (DSD RPM ), the actual engine RPM (N) and a feedback spark control proportional gain term (SPK --  FBS GAIN ). If the controller is transitioning into feedback spark (step 408), the control module 16 determines the amount torque correction utilizing a rolling average based on tr --  cor and FBS --  ENT TC  at step 410. If, however, the controller is currently utilizing feedback spark (step 412), the control module 16 sets the torque correction equal to the value of tr --  cor at step 414. The amount of torque correction is set to &#34;0&#34; if the spark state is equal to &#34;0&#34; or &#34;3&#34; at step 416. 
     Referring now to FIG. 10, there is shown a flow chart illustrating the determination of the idle spark, that is, the spark advance which corresponds to the amount of torque correction for maintaining the desired idle speed. As illustrated, the idle spark routine utilizes information from the reserve torque ratio and the torque correction routines. At step 502, the control module 16 determines the torque ratio to be supplied by the engine (TR ENG ) utilizing TR AV , TR RES  and TR COR . As previously discussed, TR AV  is the torque ratio available calculated from the absolute spark limit, TR RES  is the torque ratio reserve created by retarding spark below MBT and TR COR  is the torque ratio correction required to respond to an RPM error. 
     At step 504, the control module 16 determines a spark feedback value (i.e SPK FB ) based on MBT spark and INVFUNC (shown in FIG. 4). This spark feedback value is then compared to a minimum spark feedback value (SPK MIN ) at step 506. Based on that comparison, the control module 16 sets the value of the idle spark at step 508 or 510. The spark advance is then accordingly adjusted, and the engine produces the torque ratio required to maintain the desired idle speed. 
     It is to be understood, of course, that while the form of the invention described above constitutes the preferred embodiment of the invention, the preceding description is not intended to illustrate all possible forms thereof. It is also to be understood that the words used are words of description, rather than limitation, and that various changes may be made without departing from the spirit and scope of the invention, which should be construed according to the following claims.