# BlenderPID_PIDSPCalc ## Initialization - Initialize variables - Set up slew rate limits - Configure timer variables ## Beverage Type Detection ### Sugar Beverage - Calculate syrup percentage based on Brix #### First Production Mode - Formula: $gActualSyrupPerc = \frac{ProductBrix + ProdBrixOffset + gFirstProdExtraBrix}{gActualSyrupBrix}$ - Add extra Brix for first production #### Normal Production Mode - Formula: $gActualSyrupPerc = \frac{ProductBrix + ProdBrixOffset + gBrixTrackingCorr}{gActualSyrupBrix}$ - Apply Brix tracking correction ### Diet Beverage - Calculate syrup percentage based on ratio #### First Production Mode - Formula: $gActualSyrupPerc = \frac{1}{Ratio + 1} + gFirstProdDietExtraSyr$ - Add extra syrup (1.2% more) #### Normal Production Mode - Formula: $gActualSyrupPerc = \frac{1}{Ratio + 1}$ ### Water Recipe - Set water percentage to 100% - Set syrup percentage to 0% ## Ratio Calculations - Water percentage: $gActualWaterPerc = 1 - gActualSyrupPerc$ - Mixing ratio: $gActualRatioM = \frac{gActualWaterPerc}{gActualSyrupPerc}$ - Volumetric ratio: $gActualSPRatioVol = \frac{gActualRatioM \times gActualSyrupDens}{gH2ODensity}$ ## Production Mode Operations ### CO2 Equilibrium Pressure Calculation - Calculate pressure based on CO2 volumes - Add safety margin (0.3 bar) - Set tank pressure setpoints ### Production Setpoint Management - Apply production speed limits - Handle first production special conditions - Apply slew rate limiting for smooth changes ### Water Flow Control - Formula: $gSPH2O = \frac{gActualProdSP}{gActualSPRatioVol + 1.0} \times gActualSPRatioVol$ - Handle water-only recipes ### Critical Blending Detection - Monitor blending error magnitude - Monitor flow deviation percentage - Enable tracking mode if critical ### Syrup Flow Control - Track water flow in critical conditions - Calculate reference setpoint - Apply blend error correction - Formula: $gSPSYR = (gSyrSPRef + gSyrSPTemp) \times gActualSyrupDens$ ## CO2 and Gas Control ### CO2 Temperature Compensation - Calculate temperature-based compensation - Account for deaeration effect ### Oxygen Content Calculation - Calculate water O2 content - Calculate syrup O2 content - Calculate product O2 content: $gProductO2 = \frac{gActualRatioM \times gDeairWaterO2 + gSyrupO2}{gActualRatioM + 1}$ ### CO2 Injection Control - Calculate CO2 volumes setpoint - Apply corrections based on flow - Formula: $gSPCO2 = gCO2SPRef + gCO2SPTemp$ - First production: $gActualSPCO2 = (CO2Vols - gDeairCO2Comp) \times gFirstProdExtraCO2Fact \times CO2Fact \times (1 - \frac{ProductBrix}{100.0})$ ### Secondary Gas Injection - Calculate second gas volumes if enabled - Formula: $gActualSPGAS2 = GAS2Vols \times GAS2Fact \times (1 - \frac{ProductBrix}{100.0})$ - Set to zero if disabled ## Tank Level Control ### Syrup Tank - Set level based on operation mode - Use slew limiting for transitions - Handle CIP mode conditions ### Deaeration Tank - Set level based on operation mode - Handle startup conditions - Control deaeration effectiveness ### Storage Tank - Set level based on target level - Apply slew rate limiting ## Temperature Control ### Product Chiller Mode - Set water and product temperature equal - Match recipe temperature setpoint ### Water Chiller Mode - Compensate for syrup temperature - Formula: $gSPH2OTemperature = SPProdTemp - \frac{gCpSyrup \times (gMeterSyrTemp - SPProdTemp) \times gActualSyrupDens}{gCpH2O}$ ### CIP Mode - Set appropriate temperature for cleaning