fig1 shows a diagram of a single stage crude oil electrostatic desalting mechanism 1000 of the present invention . the desalting mechanism 1000 of the present invention includes a crude oil supply 10 for storing crude oil . the crude oil supply 10 is connected to a controllable pump 70 which is connected to an optional controllable fluid mixer 80 . the optional controllable fluid mixer 80 allows an emulsion of crude oil 10 , wash water 20 , and acid additive 30 to be created prior to heating based upon the specific characteristics of the crude oil supply 10 to be desalted . the optional controllable fluid mixer 80 , if necessary to process the crude oil supply 10 , is controlled by the controller 110 to create and maintain the proper emulsion mix of crude oil 10 , wash water 20 , and acid additive 30 . following either the controllable pump 70 or the optional controllable fluid mixer 80 is a controllable flow control valve ( fcv ) 120 . the controllable flow control valve 120 and the controllable pump 70 work in conjunction under command of the controller 110 to control and maintain the crude oil feed rate and pressure . the crude oil 10 or crude oil emulsion created via optional controllable fluid mixer 80 is then heated to a desired processing temperature by the heater 130 which is controlled by controller 110 . the desalting mechanism 1000 of the present invention also includes a wash water supply 20 and an acid additive supply 30 . in the embodiment of fig1 , as is preferred , the acid additive 30 is mixed with the wash water 20 by the controllable fluid mixer 40 before the crude oil / wash water emulsion is formed . alternatively , the acid additive 30 could be mixed with the wash water 20 and crude oil 10 during the emulsion creation or after water - oil emulsion creation or with the crude oil 10 itself . the fluid mixer 40 is controlled by the controller 110 to create and maintain the proper solution mixture of acid additive 30 and wash water 20 . the acid additive 30 can be selected from the group consisting of oxalic acid , citric acid , glycolic acid , gluconic acid , c . sub . 2 - c . sub . 4 alpha - hydroxy acids , malic acid , lactic acid , poly - hydroxy carboxylic acids , thioglycolic acid , chloroacetic acid , polymeric forms of the above hydroxyacids , poly - glycolic esters , glycolate ethers , and ammonium salt and alkali metal salts of these hydroxyacids , and mixtures thereof . after mixing the solution of acid additive 30 and wash water 20 with the controllable fluid mixer 40 , the resulting solution is input to a controllable flow control valve 90 which is used to allow samples of the mixed acid additive 30 and wash water 20 solution to be measured at a measurement station 200 . measurements made on the solution samples would include but not be limited to solution ph , solution impurity levels , and percentage of acid additive 30 to wash water 20 . this information is sent to the controller 110 . after mixing the solution of acid additive 30 and wash water 20 with the controllable fluid mixer 40 , the resulting solution is also input to a controllable pump 50 whose output is connected to a controllable flow control valve 60 . the controllable pump 50 and the flow control valve 60 work in conjunction under the command of the controller 110 to control and maintain the wash water / acid solution feed rate and pressure . in the embodiment of fig1 , the controllable flow control valve 60 is shown to be a three - way valve to allow for emulsion creation with the crude oil supply 10 via the optional controllable fluid mixer 80 , the optional controllable fluid mixer 140 , or both . like the optional controllable fluid mixer 80 , the optional controllable fluid mixer 140 , if necessary to process the crude oil supply 10 , is controlled by the controller 110 to create and maintain the proper emulsion mix of crude oil 10 , wash water 20 , and acid additive 30 . the controllable flow control valve 60 also allows for the acid additive 30 and wash water 20 solution to be presented to the optional controllable fluid mixer 80 and optional controllable fluid mixer 140 at the same or different flow rates when both mixer devices are used in the desalting process . following the optional controllable fluid mixer 140 , the emulsion passes through a pressure control valve 160 before entering the electrostatic desalter 170 . the electrostatic desalter 170 includes a liquid level sensor ( ls ) 210 used to measure the aqueous level in the electrostatic desalter 170 . in the embodiment of fig1 , the measurement output of the liquid level sensor 210 is routed to the controller 110 . the controller 110 uses the liquid level measurement data to control the controllable flow control valve 220 to drain the effluent from the electrostatic desalter 170 and control the aqueous layer and emulsion layer within the electrostatic desalter 170 . alternatively , the liquid level sensor 210 output may be directly connected to a level control valve instead of the controllable flow control valve 220 to drain the effluent . the controllable flow control valve 220 is also configured to allow samples of the effluent solution to be measured at a measurement station 200 . measurements made on the solution samples would include but not be limited to solution ph , solution impurity levels , temperature , and amount of residual oil present in the effluent . this information is sent to the controller 110 . the electrical power supply 150 provides the voltage necessary to create the electric field necessary for electrostatic coalescence in the electrostatic desalter 170 . the controller 110 controls the electrical power supply 150 output . the electrical power supply 150 output may be static ( i . e . constant voltage with a current limit ) or , preferably , able to change key parameters to enhance the desalting operation . the electrical power supply 150 under the control of the controller 110 would preferably be able to alter its &# 39 ; output to include but not be limited to changes in the voltage level applied to the electrostatic desalter 170 , the voltage waveform applied to the electrostatic desalter 170 , current limits ( if any ) on the electrical power supply 150 , or any combination thereof . the desalted crude output of the electrostatic desalter 170 passes through a pressure control valve 180 and a controllable flow control valve 190 . the controllable flow control valve 190 has two outputs to direct the desalted crude oil . under control of the controller 110 , the controllable flow control valve 190 controls and maintains the flow rate of desalted crude oil to the remaining refinery operations . additionally , under control of the controller 110 , the controllable flow control valve 190 can also direct samples of the desalted crude to the measurement station 200 . measurements made on the solution samples would include but not be limited to impurity levels , temperature , residual acid additive 30 and wash water 20 solution , etc . this information is sent to the controller 110 . in the embodiment of fig1 , the controller 110 collects measurements from process points including but not limited to the various points described herein to evaluate the efficiency of the desalting mechanism 1000 . the measurement points can be divided into two data types : intra - process data and product data . intra - process data include factors that have an impact in the results of the final product , but are not measurements of the final product . product data are measurements of the final product . in the embodiment of fig1 , the controller 110 collects measurements from a number of intra - process data points including but not limited to the following : the crude oil supply 10 feed rate through the flow control valve 120 the temperature , viscosity , and density of the crude oil supply 10 or , optionally , the emulsion created by mixing the crude oil supply with a solution comprising the acid additive 30 or acid additive 30 and wash water 20 through the controllable heater 130 . the acid additive 30 and wash water 20 feed rate through the controllable flow control valve 60 . the characteristics of the solution mixture of acid additive 30 and wash water 20 through the controllable flow control valve 90 and measurement station 200 . specific measurements may include but not be limited to the percentage of acid additive in the solution , other impurities present either in the wash water 20 or acid additive 30 , etc . the electrostatic desalter 170 water level and emulsion layer through the liquid level sensor 210 . the characteristics of the electrostatic desalter 170 effluent through the controllable flow control valve 220 and the measurement station 200 . the characteristics of the electrostatic desalter 170 electric field through the electrical power supply 150 . specific measurements may include but not be limited to peak voltage , peak current , rms current , rms voltage , current limit , etc . the intra - process measurements made under the control of the controller 110 are made at random or , preferably , regular intervals while processing the crude supply 10 . if the desalting process includes a customer specification for any intra - process measurement , each applicable measurement is compared to the specification to determine if the sample is within the customer required limits . if the specification is not met , immediate corrective action is taken as per the customers &# 39 ; requirement . the intra - process data measurements made under the control of the controller 110 are used under the present invention to compute statistical quantifiers for use by the controller 110 to signal potential problems with and control the electrostatic desalter mechanism 1000 . the data measurements are classified as either binary or continuous . examples of a binary data set include a pass or fail criteria . continuous data includes measurements such as temperature , pressure , voltage , etc . in the embodiment of fig1 , the controller 110 collects measurements of the desalted crude oil output product through the controllable flow control valve 190 and the measurement station 200 . the product measurements made under the control of the controller 110 are made at random or , preferably , regular intervals . if the desalting process includes a customer specification for any measurement either individually or in combination with others , each applicable measurement is compared to the specification to determine if the sample is within the customer required limits . if the specification is not met , immediate corrective action is taken per the customers &# 39 ; requirements . the product data measurements made under the control of the controller 110 are also used under the present invention to compute statistical quantifiers for use by the controller 110 to signal potential problems with and control the electrostatic desalter mechanism 1000 . the product data measurements are classified as either binary or continuous in the same manner as the intra - process data measurements . based upon the type of crude oil being processed , the controller 110 can adjust various factors of the desalting operation including but not limited to the following : the crude oil supply 10 feed rate through the controllable pump 70 and controllable flow control valve 120 the temperature of the crude oil supply 10 or , optionally , the emulsion created by mixing the crude oil supply 10 with a solution comprising the acid additive 30 and / or wash water 20 through the controllable heater 130 . the solution mixture of acid additive 30 and wash water 20 through the controllable fluid mixer 40 . the flow rate of the solution mixture of acid additive 30 and wash water 20 through the controllable pump 50 and controllable flow control valve 60 . the emulsion formation through optional controllable fluid mixer 80 and / or optional controllable fluid mixer 140 . the electrostatic desalter 170 electric field through the controllable electrical power supply 150 . control of the electrostatic desalter water level and emulsion layers through the liquid level sensor 210 , the controllable flow control valve 220 , and the controllable flow control valve 190 . as different crude oils are processed by the desalting mechanism 1000 , the characteristics necessary to efficiently desalt the crude oil will require some adjustment . additionally , differences in electrostatic desalter 170 characteristics , wash water supply 20 purity , etc . between different desalting mechanisms 1000 require the storage of different control settings . the memory / data storage 100 function of the desalting mechanism 1000 allows the controller to access and update , if required , the control settings required to efficiently process various types of crude oil supplies 10 . fig2 shows a diagram of a typical first stage dehydration followed by a second stage electrostatic desalting mechanism 2000 of the present invention . the desalting mechanism 2000 of the present invention includes a crude oil supply 2010 for storing crude oil . the crude oil supply 2010 is connected to a controllable pump 2070 whose output is connected to a controllable flow control valve ( fcv ) 2120 . the controllable flow control valve 2120 and the controllable pump 2070 work in conjunction under command of the controller 2110 to control and maintain the crude oil feed rate and pressure . the crude oil 2010 is then heated to a desired processing temperature by the heater 2130 which is controlled by controller 2110 . in the embodiment of fig2 , the heated crude oil passes through a pressure control valve 2160 before entering the dehydration mechanism 2310 . the dehydration mechanism 2310 is designed to remove high salinity water from the crude oil supply 2010 . the dehydration process relies on establishing a varying high voltage electric field in the oil phase of the dehydration mechanism 2310 . due to the action of the imposed electric field , the droplets are agitated causing the drops to coalesce into droplets of sufficient size to migrate via gravity to the lower water phase of the dehydration mechanism 2310 . the dehydration mechanism 2310 includes a liquid level sensor ( ls ) 2340 used to measure the water level in the dehydration mechanism 2310 . in the embodiment of fig2 , the measurement output of the liquid level sensor 2340 is routed to the controller 2110 . the controller 2110 uses the liquid level measurement data to control the controllable flow control valve 2330 to drain the waste water from the dehydration mechanism 2310 and control the water layer and oil layer within the dehydration mechanism 2310 . alternatively , the liquid level sensor 2340 output may be directly connected to a level control valve instead of the controllable flow control valve 2330 to drain the waste water . the controllable flow control valve 2330 is also configured to allow samples of the effluent solution to be measured at a measurement station 2200 . measurements made on the solution samples would include but not be limited to solution ph , solution impurity levels , temperature , and amount of residual oil present in the waste water . this information is sent to the controller 2110 . the electrical power supply 2300 provides the voltage necessary to create the electric field necessary for water coalescence in the dehydration mechanism 2310 . the controller 2110 controls the electrical power supply 2300 output . the electrical power supply 2300 output may be static ( i . e . constant voltage with a current limit ) or , preferably , able to change key parameters to enhance the dehydration operation . the electrical power supply 2300 under the control of the controller 2110 would preferably be able to alter its &# 39 ; output to include but not be limited to changes in the voltage level applied to the dehydration mechanism 2310 , the voltage waveform applied to the dehydrator , current limits ( if any ) on the electrical power supply 2300 , or any combination thereof . the crude output of the dehydration mechanism 2310 passes through a pressure control valve 2320 on its way to the controllable fluid mixer 2350 . the controllable fluid mixer 2350 allows an emulsion of crude oil 2010 , wash water 2020 , and acid additive 2030 to be created based upon the specific characteristics of the crude oil supply 2010 to be desalted . the controllable fluid mixer 2350 is controlled by the controller 2110 to create and maintain the proper emulsion mix of crude oil 2010 , wash water 2020 , and acid additive 2030 . the desalting mechanism 2000 of the present invention also includes a wash water supply 2020 and a acid additive supply 2030 . in the embodiment of fig2 , as is preferred , the acid additive 2030 is mixed with the wash water 2020 by the controllable fluid mixer 2040 before the crude oil / wash water emulsion is formed . alternatively , the acid additive 2030 could be mixed with the wash water 2020 and crude oil 2010 during the emulsion creation or after emulsion creation or with the crude oil 2010 itself . the fluid mixer 2040 is controlled by the controller 2110 to create and maintain the proper solution mixture of acid additive 2030 and wash water 2020 . the acid additive 2030 can be selected from the group consisting of oxalic acid , citric acid , glycolic acid , gluconic acid , c . sub . 2 - c . sub . 4 alpha - hydroxy acids , malic acid , lactic acid , poly - hydroxy carboxylic acids , thioglycolic acid , chloroacetic acid , polymeric forms of the above hydroxyacids , poly - glycolic esters , glycolate ethers , and ammonium salt and alkali metal salts of these hydroxyacids , and mixtures thereof . after mixing the solution of acid additive 2030 and wash water 2020 with the controllable fluid mixer 2040 , the resulting solution is input to a controllable flow control valve 2090 which is used to allow samples of the mixed acid additive 2030 and wash water 2020 solution to be measured at a measurement station 2200 . measurements made on the solution samples would include but not be limited to solution ph , solution impurity levels , and percentage of acid additive 2030 to wash water 2020 . this information is sent to the controller 2110 . after mixing the solution of acid additive 2030 and wash water 2020 with the controllable fluid mixer 2040 , the resulting solution is also input to a controllable pump 2050 whose output is connected to a controllable flow control valve 2060 . the controllable pump 2050 and the flow control valve 2060 work in conjunction under the command of the controller 2110 to control and maintain the wash water / acid solution feed rate and pressure . the output of the flow control valve 2060 is an input to the controllable fluid mixer 2350 where the emulsion of crude oil 2010 , wash water 2020 , and acid additive 2030 is formed . after mixing the crude oil 2010 , acid additive 2030 , and wash water 2020 in the controllable fluid mixer 2350 , the resulting emulsion passes through a controllable flow control valve 2360 before entering the electrostatic desalter 2170 . the controllable flow control valve 2360 , under command of the controller 2110 , controls the flow rate of the crude oil emulsion into the electrostatic desalter 2170 as well as allowing samples of the emulsion to be directed to the measurement station 2200 . measurements made on the solution samples would include but not be limited to impurity levels , temperature , amount of acid additive 2030 and wash water 2020 solution , etc . this information is sent to the controller 2110 . the electrostatic desalter 2170 includes a liquid level sensor ( ls ) 2210 used to measure the aqueous level in the electrostatic desalter 2170 . in the embodiment of fig2 , the measurement output of the liquid level sensor 2210 is routed to the controller 2110 . the controller 2110 uses the liquid level measurement data to control the controllable flow control valve 2220 to drain the effluent from the electrostatic desalter 2170 and control the aqueous layer and emulsion layer within the electrostatic desalter 2170 . alternatively , the liquid level sensor 2210 output may be directly connected to a level control valve instead of the controllable flow control valve 2220 to drain the effluent . the controllable flow control valve 2220 is also configured to allow samples of the effluent solution to be measured at a measurement station 2200 . measurements made on the solution samples would include but not be limited to solution ph , solution impurity levels , temperature , and amount of residual oil present in the effluent . this information is sent to the controller 2110 . the electrical power supply 2150 provides the voltage necessary to create the electric field necessary for electrostatic coalescence in the electrostatic desalter 2170 . the controller 2110 controls the electrical power supply 2150 output . the electrical power supply 2150 output may be static ( i . e . constant voltage with a current limit ) or , preferably , able to change key parameters to enhance the desalting operation . the electrical power supply 2150 under the control of the controller 2110 would preferably be able to alter its &# 39 ; output to include but not be limited to changes in the voltage level applied to the electrostatic desalter 2170 , the voltage waveform applied to the electrostatic desalter 2170 , current limits ( if any ) on the electrical power supply 2150 , or any combination thereof . the desalted crude output of the electrostatic desalter 2170 passes through a pressure control valve 2180 and a controllable flow control valve 2190 . the controllable flow control valve 2190 has two outputs to direct the desalted crude oil . under control of the controller 2110 , the controllable flow control valve 2190 controls and maintains the flow rate of desalted crude oil to the remaining refinery operations . additionally , under control of the controller 2110 , the controllable flow control valve 2190 can also direct samples of the desalted crude to the measurement station 2200 . measurements made on the solution samples would include but not be limited to impurity levels , temperature , residual acid additive 2030 and wash water 2020 solution , etc . this information is sent to the controller 2110 . in the embodiment of fig2 , the controller 2110 takes measurements including but not limited to the various points described herein to evaluate the efficiency of the desalting mechanism 2000 . the measurement points can be divided into two data types : intra - process data and product data . intra - process data include factors that have an impact in the results of the final product , but are not measurements of the final product . product data are measurements of the final product . in the embodiment of fig2 , the controller 2110 collects measurements from a number of intra - process data points including but not limited to the following : the crude oil supply 2010 feed rate through the flow control valve 2120 . the temperature , viscosity , and density of the crude oil supply 2010 through the controllable heater 2130 . the dehydration mechanism 2310 water level and emulsion layer through the liquid level sensor 2340 . the characteristics of the dehydration mechanism 2310 waste water through the controllable flow control valve 2330 and the measurement station 2200 . the characteristics of the dehydration mechanism 2310 electric field through the electrical power supply 2300 . the acid additive 2030 and wash water 2020 feed rate through the controllable flow control valve 2060 . the characteristics of the solution mixture of acid additive 2030 and wash water 2020 through the controllable flow control valve 2090 and measurement station 2200 . the characteristics of the wash water 2020 / acid additive 2030 / crude oil 2010 emulsion through the controllable flow control valve 2360 and measurement station 2200 . the electrostatic desalter 2170 water level and emulsion layer through the liquid level sensor 2210 . the characteristics of the electrostatic desalter 2170 effluent through the controllable flow control valve 2220 and the measurement station 2200 . the characteristics of the electrostatic desalter 2170 electric field through the electrical power supply 2150 . the intra - process measurements made under the control of the controller 2110 are made at random or , preferably , regular intervals while processing the crude supply 2010 . if the desalting process includes a customer specification for any intra - process measurement , each applicable measurement is compared to the specification to determine if the sample is within the customer required limits . if the specification is not met , immediate corrective action is taken as per the customers &# 39 ; requirement . the intra - process data measurements made under the control of the controller 2110 are used under the present invention to compute statistical quantifiers for use by the controller 2110 to signal potential problems with and control the electrostatic desalter mechanism 2000 . the data measurements are classified as either binary or continuous . examples of a binary data set include a pass or fail criteria . continuous data includes measurements such as temperature , pressure , voltage , etc . in the embodiment of fig2 , the controller 2110 collects measurements of the desalted crude oil output product through the controllable flow control valve 2190 and the measurement station 2200 . the product measurements made under the control of the controller 2110 are made at random or , preferably , regular intervals . if the desalting process includes a customer specification for any measurement either individually or in combination with others , each applicable measurement is compared to the specification to determine if the sample is within the customer required limits . if the specification is not met , immediate corrective action is taken per the customers &# 39 ; requirements . the product data measurements made under the control of the controller 2110 are also used under the present invention to compute statistical quantifiers for use by the controller 2110 to signal potential problems with and control the electrostatic desalter mechanism 2000 . the product data measurements are classified as either binary or continuous in the same manner as the intra - process data measurements . based upon the type of crude oil being processed , the controller 2110 can adjust various factors of the desalting operation including but not limited to the following : the crude oil supply 2010 feed rate through the controllable pump 2070 and controllable flow control valve 2120 the temperature of the crude oil supply 2010 through the controllable heater 2130 . control of the dehydration mechanism 2310 water level and oil layers through the liquid level sensor 2340 , the controllable flow control valve 2330 , and the controllable flow control valve 2360 . the dehydration mechanism 2310 electric field through the controllable power supply 2300 . the solution mixture of acid additive 2030 and wash water 2020 through the controllable fluid mixer 2040 . the flow rate of the solution mixture of acid additive 2030 and wash water 2020 through the controllable pump 2050 and controllable flow control valve 2060 . the electrostatic desalter 2170 electric field through the controllable electrical power supply 2150 . control of the electrostatic desalter 2170 water level and emulsion layers through the liquid level sensor 2210 , the controllable flow control valve 2220 , and the controllable flow control valve 2190 . as different crude oils are processed by the desalting mechanism 2000 , the characteristics necessary to efficiently desalt the crude oil will require some adjustment . additionally , differences in dehydration mechanism 2310 characteristics , electrostatic desalter 2170 characteristics , wash water supply 2020 purity , etc between different desalting mechanisms 2000 require the storage of different control settings . the memory / data storage 2100 function of the desalting mechanism 2000 allows the controller to access and update , if required , the control settings required to efficiently process various types of crude oil supplies 2010 . fig3 shows a diagram of a typical two stage electrostatic desalting mechanism 3000 of the present invention . the desalting mechanism 3000 of the present invention includes a crude oil supply 3010 for storing crude oil . the crude oil supply 3010 is connected to a controllable pump 3070 whose output is connected to a controllable flow control valve ( fcv ) 3120 . the controllable flow control valve 3120 and the controllable pump 3070 work in conjunction under command of the controller 3110 to control and maintain the crude oil feed rate and pressure . the crude oil 3010 is heated to a desired processing temperature by the heater 3130 which is controlled by controller 3110 . in the embodiment of fig3 , the heated crude oil is mixed with recycled effluent from the electrostatic desalter 3170 to create an emulsion mix of the crude oil supply 3010 and recycled effluent from the electrostatic desalter 3170 via the controllable fluid mixer 3380 . use of an effluent recycle as indicated in fig3 is well - known in the art . the crude oil / effluent recycle emulsion passes through a pressure control valve 3160 before entering the electrostatic desalter 3310 . the electrostatic desalter 3310 includes a liquid level sensor ( ls ) 3340 used to measure the aqueous level in the electrostatic desalter 3310 . in the embodiment of fig3 , the measurement output of the liquid level sensor 3340 is routed to the controller 3110 . the controller 3110 uses the liquid level measurement data to control the controllable flow control valve 3330 to drain the waste effluent from the electrostatic desalter 3310 and control the aqueous layer and emulsion layer within the electrostatic desalter 3310 . alternatively , the liquid level sensor 3340 output may be directly connected to a level control valve instead of the controllable flow control valve 3330 to drain the waste effluent . the controllable flow control valve 3330 is also configured to allow samples of the waste effluent solution to be measured at a measurement station 3200 . measurements made on the solution samples would include but not be limited to solution ph , solution impurity levels , temperature , and amount of residual oil present in the waste effluent . this information is sent to the controller 3110 . the electrical power supply 3300 provides the voltage necessary to create the electric field necessary for electrostatic coalescence in the electrostatic desalter 3310 . the controller 3110 controls the electrical power supply 3300 output . the electrical power supply 3300 output may be static ( i . e . constant voltage with a current limit ) or , preferably , able to change key parameters to enhance the electrostatic coalescence operation . the electrical power supply 3300 under the control of the controller 3110 would preferably be able to alter its &# 39 ; output to include but not be limited to changes in the voltage level applied to the electrostatic desalter 3310 , the voltage waveform applied to the desalter , current limits ( if any ) on the electrical power supply 3300 , or any combination thereof . the crude output of the electrostatic desalter 3310 passes through a pressure control valve 3320 on its way to the controllable fluid mixer 3350 . the controllable fluid mixer 3350 allows a second emulsion of electrostatic desalter 3310 output , wash water 3020 , and acid additive 3030 to be created based upon the specific characteristics of the crude oil supply 3010 to be desalted . the controllable fluid mixer 3350 is controlled by the controller 3110 to create and maintain the proper emulsion mix of crude oil 3010 , wash water 3020 , and acid additive 3030 . the desalting mechanism 3000 of the present invention also includes a wash water supply 3020 and an acid additive supply 3030 . in the embodiment of fig3 , as is preferred , the acid additive 3030 is mixed with the wash water 3020 by the controllable fluid mixer 3040 before the crude oil / wash water emulsion is formed . alternatively , the acid additive 3030 could be mixed with the wash water 3020 and crude oil 3010 during the emulsion creation or after emulsion creation or with the crude oil 3010 itself . the fluid mixer 3040 is controlled by the controller 3110 to create and maintain the proper solution mixture of acid additive 3030 and wash water 3020 . the acid additive 3030 can be selected from the group consisting of oxalic acid , citric acid , glycolic acid , gluconic acid , c . sub . 2 - c . sub . 4 alpha - hydroxy acids , malic acid , lactic acid , poly - hydroxy carboxylic acids , thioglycolic acid , chloroacetic acid , polymeric forms of the above hydroxyacids , poly - glycolic esters , glycolate ethers , and ammonium salt and alkali metal salts of these hydroxyacids , and mixtures thereof . after mixing the solution of acid additive 3030 and wash water 3020 with the controllable fluid mixer 3040 , the resulting solution is input to a controllable flow control valve 3090 which is used to allow samples of the mixed acid additive 3030 and wash water 3020 solution to be measured at a measurement station 3200 . measurements made on the solution samples would include but not be limited to solution ph , solution impurity levels , and percentage of acid additive 3030 to wash water 3020 . this information is sent to the controller 3110 . after mixing the solution of acid additive 3030 and wash water 3020 with the controllable fluid mixer 3040 , the resulting solution is also input to a controllable pump 3050 whose output is connected to a controllable flow control valve 3060 . the controllable pump 3050 and the flow control valve 3060 work in conjunction under the command of the controller 3110 to control and maintain the wash water / acid solution feed rate and pressure . the output of the flow control valve 3060 is an input to the controllable fluid mixer 3350 where the second emulsion of electrostatic desalter 3310 output , wash water 3020 , and acid additive 3030 is formed . after mixing the second emulsion in the controllable fluid mixer 3350 , the second emulsion passes through a controllable flow control valve 3360 before entering the electrostatic desalter 3170 . the controllable flow control valve 3360 , under command of the controller 3110 , controls the flow rate of the second emulsion into the electrostatic desalter 3170 as well as allowing samples of the emulsion to be directed to the measurement station 3200 . measurements made on the solution samples would include but not be limited to impurity levels , temperature , amount of acid additive 3030 and wash water 3020 solution , etc . this information is sent to the controller 3110 . the electrostatic desalter 3170 includes a liquid level sensor ( ls ) 3210 used to measure the aqueous level in the electrostatic desalter 3170 . in the embodiment of fig3 , the measurement output of the liquid level sensor 3210 is routed to the controller 3110 . the controller 3110 uses the liquid level measurement data to control the controllable flow control valve 3220 to recycle the effluent from the electrostatic desalter 3170 and control the aqueous layer and emulsion layer within the electrostatic desalter 3170 . alternatively , the liquid level sensor 3210 output may be directly connected to a level control valve instead of the controllable flow control valve 3220 to recycle the effluent . the controllable flow control valve 3220 along with the controllable pump 3370 , under command of the controller 3110 , control and maintain the recycled effluent flow rate and pressure to the controllable mixer 3380 . the controllable flow control valve 3220 is also configured to allow samples of the effluent solution to be measured at a measurement station 3200 . measurements made on the solution samples would include but not be limited to solution ph , solution impurity levels , temperature , and amount of residual oil present in the effluent . this information is sent to the controller 3110 . the electrical power supply 3150 provides the voltage necessary to create the electric field necessary for electrostatic coalescence in the electrostatic desalter 3170 . the controller 3110 controls the electrical power supply 3150 output . the electrical power supply 3150 output may be static ( i . e . constant voltage with a current limit ) or , preferably , able to change key parameters to enhance the desalting operation . the electrical power supply 3150 under the control of the controller 3110 would preferably be able to alter its &# 39 ; output to include but not be limited to changes in the voltage level applied to the electrostatic desalter 3170 , the voltage waveform applied to the electrostatic desalter 3170 , current limits ( if any ) on the electrical power supply 3150 , or any combination thereof . the desalted crude output of the electrostatic desalter 3170 passes through a pressure control valve 3180 and a controllable flow control valve 3190 . the controllable flow control valve 3190 has two outputs to direct the desalted crude oil . under control of the controller 3110 , the controllable flow control valve 3190 controls and maintains the flow rate of desalted crude oil to the remaining refinery operations . additionally , under control of the controller 3110 , the controllable flow control valve 3190 can also direct samples of the desalted crude to the measurement station 3200 . measurements made on the solution samples would include but not be limited to impurity levels , temperature , residual acid additive 3030 and wash water 3020 solution , etc . this information is sent to the controller 3110 . in the embodiment of fig3 , the controller 3110 takes measurements including but not limited to the various points described herein to evaluate the efficiency of the desalting mechanism 3000 . the measurement points can be divided into two data types : intra - process data and product data . intra - process data include factors that have an impact in the results of the final product , but are not measurements of the final product . product data are measurements of the final product . in the embodiment of fig3 , the controller 3110 collects measurements from a number of intra - process data points including but not limited to the following : the crude oil supply 3010 feed rate through the flow control valve 3120 . the temperature , viscosity , and density of the crude oil supply 3010 through the controllable heater 3130 . the electrostatic desalter 3310 water level and emulsion layer through the liquid level sensor 3340 . the characteristics of the electrostatic desalter 3310 effluent through the controllable flow control valve 3330 and the measurement station 3200 . the characteristics of the electrostatic desalter 3310 electric field through the electrical power supply 3300 . the acid additive 3030 and wash water 3020 feed rate through the controllable flow control valve 3060 . the characteristics of the solution mixture of acid additive 3030 and wash water 3020 through the controllable flow control valve 3090 and measurement station 3200 . the characteristics of the wash water 3020 / acid additive 3030 / crude oil 3010 emulsion through the controllable flow control valve 3360 and measurement station 3200 . the electrostatic desalter 3170 water level and emulsion layer through the liquid level sensor 3210 . the characteristics of the electrostatic desalter 3170 effluent through the controllable flow control valve 3220 and the measurement station 3200 . the characteristics of the electrostatic desalter 3170 electric field through the electrical power supply 3150 . the intra - process measurements made under the control of the controller 3110 are made at random or , preferably , regular intervals while processing the crude supply 3010 . if the desalting process includes a customer specification for any intra - process measurement , each applicable measurement is compared to the specification to determine if the sample is within the customer required limits . if the specification is not met , immediate corrective action is taken as per the customers &# 39 ; requirement . the intra - process data measurements made under the control of the controller 3110 are used under the present invention to compute statistical quantifiers for use by the controller 3110 to signal potential problems with and control the electrostatic desalter mechanism 3000 . the data measurements are classified as either binary or continuous . examples of a binary data set include a pass or fail criteria . continuous data includes measurements such as temperature , pressure , voltage , etc . in the embodiment of fig3 , the controller 3110 collects measurements of the desalted crude oil output product through the controllable flow control valve 3190 and the measurement station 3200 . the product measurements made under the control of the controller 3110 are made at random or , preferably , regular intervals . if the desalting process includes a customer specification for any measurement either individually or in combination with others , each applicable measurement is compared to the specification to determine if the sample is within the customer required limits . if the specification is not met , immediate corrective action is taken per the customers &# 39 ; requirements . the product data measurements made under the control of the controller 3110 are also used under the present invention to compute statistical quantifiers for use by the controller 3110 to signal potential problems with and control the electrostatic desalter mechanism 3000 . the product data measurements are classified as either binary or continuous in the same manner as the intra - process data measurements . based upon the type of crude oil being processed , the controller 3110 can adjust various factors of the desalting operation including but not limited to the following : the crude oil supply 3010 feed rate through the controllable pump 3070 and controllable flow control valve 3120 the temperature of the crude oil supply 3010 through the controllable heater 3130 . control of the electrostatic desalter 3310 aqueous level and emulsion layers through the liquid level sensor 3340 , the controllable flow control valve 3330 , and the controllable flow control valve 3360 . the electrostatic desalter 3310 electric field through the controllable power supply 3300 . the solution mixture of acid additive 3030 and wash water 3020 through the controllable fluid mixer 3040 . the flow rate of the solution mixture of acid additive 3030 and wash water 3020 through the controllable pump 3050 and controllable flow control valve 3060 . the first emulsion formation of crude oil supply 3010 and recycled effluent from electrostatic desalter 3170 through controllable flow control valve 3220 , controllable pump 3370 , and controllable fluid mixer 3380 . the second emulsion formation through controllable fluid mixer 3350 . the electrostatic desalter 3170 electric field through the controllable electrical power supply 3150 . control of the electrostatic desalter 3170 water level and emulsion layers through the liquid level sensor 3210 , the controllable flow control valve 3220 , and the controllable flow control valve 3190 . as different crude oils are processed by the desalting mechanism 3000 , the characteristics necessary to efficiently desalt the crude oil will require some adjustment . additionally , differences in electrostatic desalter 3310 and 3170 characteristics , wash water supply 3020 purity , etc between different desalting mechanisms 3000 require the storage of different control settings . the memory / data storage 3100 function of the desalting mechanism 3000 allows the controller to access and update , if required , the control settings required to efficiently process various types of crude oil supplies 3010 . preferably , the control settings are determined based upon maximizing the economic benefit for the desalting the crude oil supply 3010 . fig4 shows a process flow diagram of one embodiment of the control algorithm 4000 of the present invention for a typical crude oil desalting operation . the intra - process data is measured in step 4010 . the intra - process data may include but not be limited to the crude oil feed rate , the crude oil temperature , viscosity , and density , the characteristics of the electrostatic desalter effluent , the electrostatic desalter water level and emulsion layer , the characteristics of the electrostatic desalter electric field , the acid additive feed rate , the wash water feed rate , the characteristics of the wash water / acid additive / crude oil emulsion , et al . during step 4010 , the intra - process data may be measured at random or , preferably , regular intervals such that the measurements cover the frequency of potential sources of variation . as the intra - process data is collected , it is compared to any applicable specification or customer requirement in step 4020 . decision step 4030 determines whether or not the applicable intra - process data met the customer requirements . if not , a human operator is notified in step 4040 . in step 4050 , the repair / reaction plan is implemented to repair the failed sensor , piece of equipment , etc . that caused the intra - process data measurement 4010 to fail . after the repair / reaction plan of step 4050 has been executed , the intra - process data is measured again in step 4010 . if the decision step 4030 results in all applicable intra - process data measurements meeting the customer requirements , then the intra - process data is separated into their applicable measurement subsets to form a subgroup and the number of data points in each subset subgroup is compared to the appropriate subgroup size , n , in step 4060 . as an example , if we assume that the crude oil flow rate , crude oil temperature , and electrostatic desalter water level are all measured in step 4010 , then there will be a crude oil flow rate data subset , a crude oil temperature data subset , and an electrostatic desalter water level data subset . step 4060 compares the number of data samples in each subset subgroup to the required number of samples , n , needed for each subset subgroup . each subset subgroup may have a different requirement for the number of samples , n . if , in step 4060 , the number of data points in a subset subgroup is less than the number , n , that is required , then the intra - process data is measured again in step 4010 . if , in step 4060 , the number of subset subgroup data points equals the required number of samples , n , then the subgroup statistics are computed in step 4070 . the statistics computed in step 4070 are made on continuous data and depend upon the number of samples in the subset subgroup . preferably , the intra - process measurements collected in step 4010 are continuous . if the number of subset subgroup samples is one , there is no calculation to be made in step 4070 . if the number of subset subgroup samples is greater than one , there are three calculations that may be made . the subset subgroup sample mean is computed as where m a is the sample mean of subset subgroup number a , x i represents the individual subset subgroup measurement values , and n is the number of samples that make up the subset subgroup . the subset subgroup sample standard deviation is computed as where σ a is the sample standard deviation of subset subgroup a , m a is the sample mean of subset subgroup number a , x i represents the individual subset subgroup measurement values , and n is the number of samples that make up the subset subgroup . the subset subgroup range is computed as where r a is the range of the subset subgroup a and { x i } represents the set of subset subgroup measurement values . decision step 4080 compares the number of subset subgroups to the required number of subgroups , n , needed for each subset . if , in step 4080 , the number of subset subgroups is less than the number , n , that is required , then the intra - process data is measured again in step 4010 for a new subset subgroup . if , in step 4080 , the number of subset subgroups equals the required number of subgroups , n , then the subset statistics are computed in step 4090 . the computations made in step 4090 depend upon whether or not the intra - process measurement data collected in step 4010 is binary or continuous and the number of subset subgroup samples taken . if , the data measured in step 4010 is binary ( i . e . pass / fail , above or below a threshold value , et al ), the subset computations to be made in step 4090 can be based upon either the number of discrete events ( i . e . number of values above a threshold per subset subgroup ) or the fraction of discrete events ( i . e . number of values above a threshold divided by the number of subset subgroup samples ). for tracking and controlling the number of discrete events , the average threshold crossing count ( atc ) for the subset is computed as where atc is the average threshold crossing count for the subset , tc i is the threshold crossing count for each subset subgroup , and n is the number of subset subgroups . the average subgroup threshold crossing ratio is computed as where astc is the average subgroup threshold crossing ratio , tc i is the threshold crossing count for each subset subgroup , and n i is the number of samples that make up the particular subset subgroup . the upper and lower control limits are computed as where ul atc is the average threshold crossing count upper limit , ll atc is the average threshold crossing count lower limit , atc is the average threshold crossing count for the subset , and astc is the average subgroup threshold crossing ratio . for tracking and controlling the fraction of discrete events , the average subgroup threshold crossing ratio ( astc ) is computed as above along with the upper and lower control limits as where ul astc is the average subgroup threshold crossing ratio upper limit , ll astc is the average subgroup threshold crossing ratio lower limit , and astc is the average subgroup threshold crossing ratio . an advantage of using astc over atc for binary data tracking and control is that astc allows for a variable sample number , n , for each subgroup while atc assumes a constant number of samples . if , the intra - process data measured in step 4010 is continuous , the subset computations to be made in step 4090 may vary based upon the number of subset subgroup data samples , n . if the number of subset subgroup data samples is one ( 1 ), then the subset average value is computed as where am 1 is the one sample subset average , x i represents the individual subset subgroup measurement values , and n is the number of subset subgroups . the one sample subgroup range is computed as sr i =| x i − x i − 1 | for i = 2 to n where sr i is the range between the i and ( i − 1 ) data value and x i represents the individual subset subgroup measurement values . the subset average range is computed as where ar 1 is one sample subset average range , sr i represents the subset subgroup ranges , and n is the number of subset subgroups . the upper and lower control limits for the one sample subset average ( am 1 ) and the one sample subset average range ( ar 1 ) are computed as where ar 1 is the one sample subset average range , ul am1 is the one sample subset average upper limit , ll am1 is the one sample subset average lower limit , ul ar1 is the one sample subset average range upper limit , ll ar1 is the one sample subset average range lower limit , the constant d 3 is zero , and the values e 2 and d 4 computed as 2 . 660 and 3 . 267 , respectively , based upon the theoretical distribution of range values between two samples . if the range , sr i , were computed using more individual sample values and / or the intra - process data measurements collected in step 4010 are not normally distributed , then the values of d 3 , e 2 , and d 4 may be different . if , the data measured in step 4010 is continuous and the number of subset subgroup data samples , n , is greater than one ( 1 ), then the subset average value is computed as where am is the subset average , m a is the sample mean of subset subgroup number a computed in step 4070 , and n is the number of subset subgroups . the subset average range is computed as where ar is the subset average range , r a is the range of the subset subgroup number a computed in step 4070 , and n is the number of subset subgroups . the subset average standard deviation is computed as where aσ is the subset average standard deviation , σ a is the sample standard deviation of subset subgroup number a computed in step 4070 , and n is the number of subset subgroups . the upper and lower control limits for the subset average ( am ) and the subset average range ( ar ) when the subset average range is used for tracking and control are computed as where am is the subset average , ar is the subset average range , ul am is the subset average upper limit , ll am is the subset average lower limit , ul ar is the subset average range upper limit , ll ar is the subset average range lower limit , and a 2 , d 3 , and d 4 are constants that vary based upon the number of subset subgroup samples , n . table i , below , provides values for a 2 , d 3 , and d 4 for subset subgroup sample sizes from 2 to 25 assuming that the intra - process data measurements collected in step 4010 are normally distributed . control limit values for a 2 , d 3 , and d 4 the upper and lower control limits for the subset average ( am ) and the subset average standard deviation ( aσ ) when the subset average standard deviation is used for tracking and control are computed as where am is the subset average , aσ is the subset average standard deviation , ul ams is the subset average upper limit , ll ams is the subset average lower limit , ul aσ is the subset average standard deviation upper limit , ll aσ is the subset average standard deviation lower limit , and a 3 , b 3 , and b 4 are constants that vary based upon the number of subset subgroup samples , n . table ii , below , provides values for a 3 , b 3 , and b 4 for subset subgroup sample sizes from 2 to 25 assuming that the intra - process data measurements collected in step 4010 are normally distributed . after the subset statistics are computed in step 4090 , the subset subgroup statistics computed in step 4070 and the subset statistics computed in step 4090 are compared to a set of criteria in step 4100 that are designed to provide evidence of statistical instability in the intra - process data measurements collected in step 4010 . preferably , the indicators of statistical instability provide warnings of adverse process conditions before the process produces intra - process measurements or product that fails the customer specifications . if the intra - process data measured in step 4010 for a given subset is binary , the calculations made in steps 4070 and 4090 for the subset subgroup threshold crossing counts ( tc i ), subset average threshold crossing count ( atc ), the subset average threshold crossing count upper limit ( ul atc ), and the subset average threshold crossing count lower limit ( ll atc ) and / or the subset subgroup fractional threshold crossing counts the average subgroup threshold crossing ratio ( astc ), the average subgroup threshold crossing ratio upper limit ( ul astc ), and the average subgroup threshold crossing ratio lower limit ( ll astc ) are compared in step 4100 . if the intra - process data measured in step 4010 for a given subset is continuous and the number of subset subgroup data samples , n , is one ( 1 ), then the intra - process data measurements , x i , made in step 4010 and the calculations made in step 4090 for the one sample subset average ( am 1 ), the one sample subset average upper limit ( ul am1 ), and the one sample subset average lower limit ( ll am1 ) are compared in step 4100 . additionally , the calculations made in step 4090 for the one sample subgroup range ( sr i ), the one sample subset average range ( ar 1 ), the one sample subset average range upper limit ( ul ar1 ), and the one sample subset average range lower limit ( ll ar1 ) are compared in step 4100 . if the intra - process data measured in step 4010 for a given subset is continuous and the number of subset subgroup data samples , n , is greater than one , then either the calculations made using range in step 4070 and step 4090 or the calculations made using the standard deviation in step 4070 and step 4090 are used for comparison in step 4100 . the choice of which calculation set ( range or standard deviation ) can be made based upon the number of subset subgroup samples , n . preferably , the standard deviation calculation set will be used if the number of subset subgroup samples is greater than or equal to 10 . if the range calculations are used in step 4100 , then the calculations made in step 4070 and step 4090 for the subset subgroup sample means ( m a ), the subset average ( am ), the subset average upper limit ( ul am ), and the subset average lower limit ( ll am ) are compared . additionally , the calculations made in step 4070 and step 4090 for the subset subgroup ranges ( r a ), the subset average range ( ar ), the subset average range upper limit ( ul ar ), and the subset average range lower limit ( ll ar ) are compared in step 4100 . if the standard deviation calculations are used in step 4100 , then the calculations made in step 4070 and step 4090 for the subset subgroup sample means ( m a ), the subset average ( am ), the subset average upper limit ( ul ams ), and the subset average lower limit ( ll ams ) are compared . additionally , the calculations made in step 4070 and step 4090 for the subset subgroup sample standard deviation ( σ a ), the subset average standard deviation ( aσ ), the subset average standard deviation upper limit ( ll aσ ), and the subset average standard deviation lower limit ( ul aσ ) are compared in step 4100 . for each calculation set ( such as m a , am , ul am , and ll am ), the subset subgroup computations ( such as m a ) are compared in order ( i . e . 1 thru n sequentially ) in step 4100 with the corresponding subset average , upper limit , and lower limit . intra - process data measurements collected in step 4010 that are binary have only one calculation set ( either threshold crossing counts or threshold crossing count ratios ) while continuous data have two sets ( either mean and range or mean and standard deviation ) for criteria comparison . the criteria to be applied in step 4100 to provide evidence of potential instability may include , but not be limited to , one or more of the following : one or more subset subgroup computations are greater than the corresponding subset average upper limit or less than the corresponding subset average lower limit . for instance , if any m a value is greater than ul am or less than ll am . n b consecutive subset subgroup computations exist between the mean and the upper limit or the mean and the lower limit . for instance , if n b was chosen to be 8 , this criteria would be breached if there were 8 or more consecutive m a values greater than am and less than ul am or less than am and greater than ll am . n b must be less than or equal to the number of subgroups , n . n t consecutive subset subgroup computations continually increase or continually decrease . for instance , if n t was chosen to be 5 , this criteria would be breached if m n t − 5 & lt ; m n t − 4 & lt ; m n t − 3 & lt ; m n t − 2 & lt ; m n t − 1 & lt ; m n t or m n t − 5 & gt ; m n t − 4 & gt ; m n t − 3 & gt ; m n t − 2 & gt ; m n t − 1 & gt ; m n t . n t must be less than or equal to the number of subgroups , n . n a consecutive subset subgroup computations alternate in direction ; increasing then decreasing . for instance , if n a was chosen to be 10 , this criteria would be breached if ; m n a − 9 & gt ; m n a − 8 & lt ; m n a − 7 & gt ; m n a − 6 & lt ; m n a − 5 & gt ; m n a − 4 & lt ; m n a − 3 & gt ; m n a − 2 & lt ; m n a − 1 & gt ; m n a m n a − 9 & lt ; m n a − 8 & gt ; m n a − 7 & lt ; m n a − 6 & gt ; m n a − 5 & lt ; m n a − 4 & gt ; m n a − 3 & lt ; m n a − 2 & gt ; m n a − 1 & lt ; m n a n a must be less than or equal to the number of subgroups , n . x out of y consecutive subset subgroup computations lie in a band between the upper limit and a statistically improbable point below the upper limit or a band between the lower limit and a statistically improbably point above the lower limit such that all of the x points lie in the same band . for instance , if x was chosen to be 2 , y was chosen to be 3 , and the band limits were from the limit boundaries and halfway between the limit boundaries and the subset mean , this criteria would be breached if either of the following conditions were true ; y must be less than or equal to the number of subgroups , n . other criteria may also be applied to the subset subgroup and subset computations in step 4100 to provide statistical indicators of process instability . decision step 4110 determines whether or not the subset subgroup and subset statistics indicate any potential problems with the intra - process functions of the crude oil desalter . if any of the subset comparisons conducted in step 4100 do not meet the chosen criteria , the subset ( s ) failing the comparisons indicate there may be a problem with one or more elements of the oil desalting process even though the product being produced and / or the intra - process data measurements are within spec . if any of the subset comparisons conducted in step 4100 do not meet the chosen criteria , decision step 4110 directs that a human operator is notified indicating a potential problem with one or more elements of the oil desalting process . in step 4120 , the human operator is provided with the data and information indicating the possible problem and a new set of subset subgroup and subset data is collected . if all subset comparisons conducted in step 4100 meet the chosen criteria , there is no indicated problem and a new set of subset subgroup and subset data is collected . the oil desalting process product data is measured in step 4170 . the product data may include but not be limited to the desalted crude oil salt content , basic sediments and water content of the desalted crude oil , the temperature of the desalted crude oil , the density of the desalted crude oil , the viscosity of the desalted crude oil , et al . during step 4170 , the product data may be measured at random or , preferably , regular intervals such that the measurements cover the frequency of potential sources of variation . as the product data is collected , it is compared to any application specification or customer requirement in step 4180 . decision step 4190 determines whether or not the measured product data met the customer requirements . if not , a human operator is notified in step 4150 . in step 4160 , the failed product plan is implemented per the customers requirements based upon the failed measurements . the output of step 4160 is input to step 4140 along with the failed data points for further analysis and action . step 4140 will compute adjustments to one or more controllable parameters of the oil desalter as well as implement automated reaction functions based upon the product failure which may include a quarantine of the suspect product produced since the last known good product , implementation of on - line repair procedures , statistical analysis to estimate the failure root cause , or , in case of catastrophic failure , automated process shutdown . if the decision step 4190 results in all applicable product data measurements meeting the customer requirements , then the product data is separated into their applicable product measurement subsets to form a product subgroup and the number of data points in each product subset subgroup is compared to the appropriate product subgroup size , n , in step 4200 . as an example , if we assume that the salt content in the desalted crude oil , desalted crude oil temperature , and basic sediments and water content of the desalted crude oil are all measured in step 4170 , then there will be a salt content in the desalted crude oil data subset , a desalted crude oil temperature data subset , and a basic sediments and water content data subset . step 4200 compares the number of data samples in each product subset subgroup to the required number of samples , n , needed for each product subset subgroup . each product subset subgroup may have a different requirement for the number of samples , n . if , in step 4200 , the number of data points in a product subset subgroup is less than the number , n , that is required , then the product data is measured again in step 4170 . if , in step 4200 , the number of product subset subgroup data points equals the required number of samples , n , then the subgroup statistics are computed in step 4210 . the statistics computed in step 4210 are made on continuous data and depend upon the number of samples in the product subset subgroup . preferably , the product measurements collected in step 4170 are continuous . if the number of product subset subgroup samples is one , there is no calculation to be made in step 4210 . if the number of product subset subgroup samples is greater than one , there are three calculations that may be made . the product subset subgroup sample mean is computed as where pm a is the sample mean of product subset subgroup number a , y i represents the individual product subset subgroup measurement values , and n is the number of samples that make up the product subset subgroup . the product subset subgroup sample standard deviation is computed as where pσ a is the sample standard deviation of product subset subgroup a , pm a is the sample mean of product subset subgroup number a , y i represents the individual product subset subgroup measurement values , and n is the number of samples that make up the product subset subgroup . the product subset subgroup range is computed as where pr a is the range of the product subset subgroup a and { y i } represents the set of product subset subgroup measurement values . decision step 4220 compares the number of product subset subgroups to the required number of subgroups , n , needed for each product subset . if , in step 4220 , the number of product subset subgroups is less than the number , n , that is required , then the product data is measured again in step 4170 for a new subset subgroup . if , in step 4220 , the number of product subset , subgroups equals the required number of subgroups , n , then the product subset statistics are computed in step 4230 . the computations made in step 4230 depend upon whether or not the product measurement data collected in step 4170 is binary or continuous and the number of subset subgroup samples taken . if , the data measured in step 4170 is binary ( i . e . pass / fail , above or below a threshold value , et al ), the subset computations to be made in step 4230 can be based upon either the number of discrete events ( i . e . number of values above a threshold per subset subgroup ) or the fraction of discrete events ( i . e . number of values above a threshold divided by the number of subset subgroup samples ). for tracking and controlling the number of discrete events , the average threshold crossing count ( patc ) for the product subset is computed as where patc is the average threshold crossing count for the product subset , ptc i is the threshold crossing count for each product subset subgroup , and n is the number of product subset subgroups . the average product subgroup threshold crossing ratio is computed as where pastc is the average product subgroup threshold crossing ratio , ptc i is the threshold crossing count for each product subset subgroup , and n i is the number of samples that make up the particular product subset subgroup . the upper and lower control limits are computed as where ul patc is the average product threshold crossing count upper limit , ll patc is the average product threshold crossing count lower limit , patc is the average threshold crossing count for the product subset , and pastc is the average product subgroup threshold crossing ratio . for tracking and controlling the fraction of discrete events , the average product subgroup threshold crossing ratio ( pastc ) is computed as above along with the upper and lower control limits as where ul pastc is the average product subgroup threshold crossing ratio upper limit , ll pastc is the average product subgroup threshold crossing ratio lower limit , and pastc is the average product subgroup threshold crossing ratio . an advantage of using pastc over patc for binary data tracking and control is that pastc allows for a variable sample number , n , for each subgroup while patc assumes a constant number of samples . if , the product data measured in step 4170 is continuous , the product subset computations to be made in step 4230 may vary based upon the number of product subset subgroup data samples , n . if the number of product subset subgroup data samples is one ( 1 ), then the product subset average value is computed as where pam 1 is the one sample product subset average , y i represents the individual product subset subgroup measurement values , and n is the number of product subset subgroups . the one sample product subgroup range is computed as psr i =| y i − y i − 1 | for i = 2 to n where psr i is the range between the i and ( i − 1 ) data value and y i represents the individual product subset subgroup measurement values . the product subset average range is computed as where par 1 is one sample product subset average range , psr i represents the product subset subgroup ranges , and n is the number of product subset subgroups . the upper and lower control limits for the one sample product subset average ( pam 1 ) and the one sample product subset average range ( par 1 ) are computed as where par 1 is the one sample product subset average range , ul pam1 is the one sample product subset average upper limit , ll pam1 is the one sample product subset average lower limit , ul par1 is the one sample product subset average range upper limit , ll par1 is the one sample product subset average range lower limit , the constant d 3 is zero , and the values e 2 and d 4 are computed as 2 . 660 and 3 . 267 , respectively , based upon the theoretical distribution of range values between two samples . if the range , psr i , were computed using more individual sample values and / or the product data measurements collected in step 4170 are not normally distributed , then the values of d 3 , e 2 , and d 4 may be different . if , the product data measured in step 4170 is continuous and the number of subset subgroup data samples , n , is greater than one ( 1 ), then the product subset average value is computed as where pam is the product subset average , pm a is the sample mean of product subset subgroup number a computed in step 4210 , and n is the number of product subset subgroups . the product subset average range is computed as where par is the product subset average range , pr a is the range of the product subset subgroup number a computed in step 4210 , and n is the number of product subset subgroups . the product subset average standard deviation is computed as where paσ is the product subset average standard deviation , pσ a is the sample standard deviation of product subset subgroup number a computed in step 4210 , and n is the number of product subset subgroups . the upper and lower control limits for the product subset average ( pam ) and the product subset average range ( par ) when the product subset average range is used for tracking and control are computed as where pam is the product subset average , par is the product subset average range , ul pam is the product subset average upper limit , ll pam is the product subset average lower limit , ul par is the product subset average range upper limit , ll par is the product subset average range lower limit , and a 2 , d 3 , and d 4 are constants that vary based upon the number of product subset subgroup samples , n . table i provides values for a 2 , d 3 , and d 4 for product subset subgroup sample sizes from 2 to 25 assuming that the product data measurements collected in step 4170 are normally distributed . the upper and lower control limits for the product subset average ( pam ) and the product subset average standard deviation ( paσ ) when the product subset average standard deviation is used for tracking and control are computed as where pam is the product subset average , paσ is the product subset average standard deviation , ul pams is the product subset average upper limit , ll pams is the product subset average lower limit , ul paσ is the product subset average standard deviation upper limit , ll paσ is the product subset average standard deviation lower limit , and a 3 , b 3 , and b 4 are constants that vary based upon the number of subset subgroup samples , n . table ii provides values for a 3 , b 3 , and b 4 for product subset subgroup sample sizes from 2 to 25 assuming that the product data measurements collected in step 4170 are normally distributed . after the product subset statistics are computed in step 4230 , the product subset subgroup statistics computed in step 4210 and the product subset statistics computed in step 4230 are compared to a set of criteria in step 4240 that are designed to provide evidence of statistical instability in the product data measurements collected in step 4170 . preferably , the indicators of statistical instability provide warnings of adverse process conditions before the process produces product that fails the customer specifications . if the product data measured in step 4170 for a given product subset is binary , the calculations made in steps 4210 and 4230 for the product subset subgroup threshold crossing counts ( ptc i ), product subset average threshold crossing count ( patc ), the product subset average threshold crossing count upper limit ( ul patc ), and the product subset average threshold crossing count lower limit ( ll patc ) and / or the product subset subgroup fractional threshold crossing counts the average product subgroup threshold crossing ratio ( pastc ), the average product subgroup threshold crossing ratio upper limit ( ul pastc ), and the average subgroup threshold crossing ratio lower limit ( ll pastc ) are compared in step 4240 . if the product data measured in step 4170 for a given product subset is continuous and the number of product subset subgroup data samples , n , is one ( 1 ), then the product data measurements , y i , made in step 4170 and the calculations made in step 4230 for the one sample product subset average ( pam 1 ), the one sample product subset average upper limit ( ul pam1 ), and the one sample product subset average lower limit ( ll pam1 ) are compared in step 4240 . additionally , the calculations made in step 4230 for the one sample product subgroup range ( psr i ), the one sample product subset average range ( par 1 ), the one sample product subset average range upper limit ( ul par1 ), and the one sample product subset average range lower limit ( ll par1 ) are compared in step 4240 . if the product data measured in step 4170 for a given product subset is continuous and the number of product subset subgroup data samples , n , is greater than one , then either the calculations made using range in step 4210 and step 4230 or the calculations made using the standard deviation in step 4210 and step 4230 are used for comparison in step 4240 . the choice of which calculation set ( range or standard deviation ) can be made based upon the number of product subset subgroup samples , n . preferably , the standard deviation calculation set will be used if the number of product subset subgroup samples is greater than or equal to 10 . if the range calculations are used in step 4240 , then the calculations made in step 4210 and step 4230 for the product subset subgroup sample means ( pm a ), the product subset average ( pam ), the product subset average upper limit ( ul pam ), and the product subset average lower limit ( ll pam ) are compared . additionally , the calculations made in step 4210 and step 4230 for the product subset subgroup ranges ( pr a ), the product subset average range ( par ), the product subset average range upper limit ( ul par ), and the product subset average range lower limit ( ll par ) are compared in step 4240 . if the standard deviation calculations are used in step 4240 , then the calculations made in step 4210 and step 4230 for the for the product subset subgroup sample means ( pm a ), the product subset average ( pam ), the product subset average upper limit ( ul pams ), and the product subset average lower limit ( ll pams ) are compared . additionally , the calculations made in step 4210 and step 4230 for the product subset subgroup sample standard deviation ( pσ a ), the product subset average standard deviation ( paσ ), the product subset average standard deviation upper limit ( ll paσ ), and the product subset average standard deviation lower limit ( ul paσ ) are compared in step 4240 . for each calculation set ( such as pm a , pam , ul pam , and ll pam ), the product subset subgroup computations ( such as pm a ) are compared in order ( i . e . 1 thru n sequentially ) in step 4240 with the corresponding product subset average , upper limit , and lower limit . product data measurements collected in step 4170 that are binary have only one calculation set ( either threshold crossing counts or threshold crossing count ratios ) while continuous data have two sets ( either mean and range or mean and standard deviation ) for criteria comparison . the criteria to be applied in step 4240 to provide evidence of potential instability may include , but not be limited to , the same or similar criteria identified for step 4100 . decision step 4250 determines whether or not the product subset subgroup and product subset statistics indicate any potential problems with the product output of the crude oil desalter . if any of the product subset comparisons conducted in step 4240 do not meet the chosen criteria , the product subset ( s ) failing the comparisons indicate there may be a problem with one or more elements of the oil desalting process even though the product being produced and / or the intra - process data measurements are still within specification . if any of the product subset comparisons conducted in step 4240 do not meet the chosen criteria , decision step 4250 will direct the control flow to step 4140 to compute the necessary variable adjustments necessary to bring the product measurements back within statistical stability . if the all of the product subset comparisons conducted in step 4240 , meet the criteria chosen , decision step 4250 will direct the control flow step 4260 to compute the process capability . process capability is computed in step 4260 on product subsets that are continuous , the product subset subgroups contain more than one ( 1 ) sample , and the underlying product subset subgroup measurements collected in step 4170 for each product subset have a customer specification ( upper limit , lower limit , or both ). for each product subset meeting these criteria that also used the range calculation set in step 4230 , the product subset process standard deviation estimate is computed as where par is the product subset average range computed in step 4230 , pσ pr is the product subset process standard deviation estimate based upon product subset range , and d 2 is a constant that varies based upon the number of product subset subgroup samples , n . if the product subset used the standard deviation calculation set in step 4230 , the product subset process standard deviation estimate is computed as where paσ is the product subset average standard deviation computed in step 4230 , pσ pσ is the product subset process standard deviation estimate based upon product subset standard deviation , and c 4 is a constant that varies based upon the number of product subset subgroup samples , n . table iii , below , provides values for d 2 and c 4 for product subset subgroup sample sizes from 2 to 25 assuming that the product data measurements collected in step 4170 are normally distributed . after the product subset process standard deviation estimates are computed in step 4260 , the process capacity is estimated in step 4260 based upon computing a z value for the product subset relative to the specification limits . for a unilateral or one - sided specification limit , the product subset z value for normally distributed product data is computed as where z sssl is the product subset z value for a single - sided specification limit , sl represents the product subset specification limit , pam is the product subset average computed in step 4230 , and pσ is the product subset process standard deviation estimate based either on range or standard deviation computed in step 4260 . for a bilateral or two - sided specification limit , the product subset z values for normally distributed product data are computed as where z usl is the product subset z value for the upper specification limit , z lsl is the product subset z value for the lower specification limit , usl represents the product subset upper specification limit , lsl presents the product subset lower specification limit , pam is the product subset average computed in step 4230 , and pσ is the product subset process standard deviation estimate based either on range or standard deviation computed in step 4260 . after the z values are computed for each product subset in step 4260 , an estimate for probability of producing in specification product can be computed through an iterative calculation using the z values or saving a z value table in memory . the use of z value statistics for estimating probability is well known in the art . step 4140 computes the adjustments to be made to the controllable parameters of the oil desalter . the adjustments include , but are not limited to , the crude oil feed rate , the crude oil temperature , the wash water feed rate , the wash water and additive solution mix , the temperature of the oil / wash water emulsion , the electrostatic desalter water level , the addition rate of acid additive , and the electric field generated within the electrostatic desalter either individually or in combination . in one embodiment of the present invention , the computations in step 4140 consider the intra - process subset subgroup statistics computed in step 4070 , the intra - process subset statistics computed in step 4090 , the comparison results of the intra - process subset subgroup and subset statistics in step 4100 , the product subset subgroup statistics computed in step 4210 , the product subset statistics computed in step 4230 , and the comparison results of the product subset subgroup and subset statistics in step 4240 . if the product subset and product subset subgroup comparison of step 4240 was determined to be within the control criteria in decision step 4250 , the process capability computations of step 4260 are also considered in step 4140 . in the embodiment of the present invention , the variables may be adjusted to maintain process control ( for instance , an adjustment to a parameter to bring an intra - process measurement within statistical stability ) or to maximize the oil desalter &# 39 ; s economic benefit . as an example , if the process capability for the oil desalter was estimated to produce within specification product 99 . 9999 % of the time given a set of parameter settings , it may make economic sense to increase the crude oil flow rate such that the oil desalter process capability is reduced to producing within specification product 99 . 99 % while simultaneously increasing the product output for a given period of time . step 4130 receives the adjustments computed in step 4140 to the controllable parameters of the oil desalter and implements these adjustments . following the implementation of the adjustments in step 4130 , a new set of product subset subgroup and product subset data is measured in step 4170 . fig5 shows a process diagram 5000 of one embodiment of the method of the present invention for a typical crude oil electrostatic desalting operation implementing automated control . the desalting process is set to an initial state in step 5100 based upon the characteristics of the configuration of the desalting operation and the characteristics of the crude oil to be desalted . an acid additive is mixed with wash water or directly with the crude oil in step 5200 . an emulsion of crude oil , wash water , and acid additive is created in step 5300 . the emulsion is resolved into a hydrocarbon or oil phase and an aqueous or water phase in step 5400 . the intra - process characteristics of the desalting operation that may or may not be dependent upon desalting configuration are measured along with characteristics of the desalted crude oil in step 5500 . tracking and control statistics are computed in step 5600 on the intra - process characteristics and desalted crude oil characteristics measured in step 5500 . an optional estimate of the probability of producing desalted crude oil that is within customer specification is computed in step 5700 . characteristics of the desalting operation to include but are not limited to one or more of the following may be varied in step 5800 to maximize the economic benefit of the desalting operation based upon the measurements in step 5500 , the statistics computed in step 5600 , and the optional probability estimate in step 5700 : the crude oil feed rate , the crude oil temperature , the electric field characteristics of the dehydration / desalter mechanisms , the wash water flow rate , the crude oil emulsion formation , control of the dehydration / desalter water levels and emulsion layers , the acid additive type and addition rate , and the effluent recycle ( as appropriate ). the above embodiments are merely preferred and the scope of the invention defined by the claims below .