Hi, I have been performing some scaling recently and had trouble finding the equations to perform the tasks I needed.
I found these on another forum:
Typical scaling formulas:
For analog inputs:
Eng_Out = (Raw_In-Min_Raw)*((Max_Eng-Min_Eng)/(Max_Raw-Min_Raw))+Eng_Min
For analog outputs:
Raw_Out = (Eng_In-Min_Eng)*((Max_Raw-Min_Raw)/(Max_Eng-Min_Eng))+Min_Raw
Subsequently I managed to transpose this equation so that I could perform a calibration function for low level (i.e. scaled output should be 0) in the PLC when it is not 0. The output from the equation (Error) needs to be added to the Raw Minimum that is used in the scale instruction. The upper value (100%) should be calibrated first with a move analog input to Max Raw instruction.
I am pretty sure I would have used too many parentheses...I am always extra careful with my equations.
(Error) x = ((((ScaledMax-ScaledMin)/-ScaledMin)*Actual Raw) - (((ScaledMax-ScaledMin)/-ScaledMin)*Min Raw) - Max Raw + Min Raw)/(ScaledMax/-ScaledMin)
The equation below may be easier to use if the scaled max 100 and scaled min -25 are fixed and will never be changed, it is the one I am using for tank level. It obviously uses less instructions/data file.
(Error) x = (5*Actual Raw - 5*Min Raw - Max Raw + Min Raw)/4
Hope this could be useful for someone.
I found these on another forum:
Typical scaling formulas:
For analog inputs:
Eng_Out = (Raw_In-Min_Raw)*((Max_Eng-Min_Eng)/(Max_Raw-Min_Raw))+Eng_Min
For analog outputs:
Raw_Out = (Eng_In-Min_Eng)*((Max_Raw-Min_Raw)/(Max_Eng-Min_Eng))+Min_Raw
Subsequently I managed to transpose this equation so that I could perform a calibration function for low level (i.e. scaled output should be 0) in the PLC when it is not 0. The output from the equation (Error) needs to be added to the Raw Minimum that is used in the scale instruction. The upper value (100%) should be calibrated first with a move analog input to Max Raw instruction.
I am pretty sure I would have used too many parentheses...I am always extra careful with my equations.
(Error) x = ((((ScaledMax-ScaledMin)/-ScaledMin)*Actual Raw) - (((ScaledMax-ScaledMin)/-ScaledMin)*Min Raw) - Max Raw + Min Raw)/(ScaledMax/-ScaledMin)
The equation below may be easier to use if the scaled max 100 and scaled min -25 are fixed and will never be changed, it is the one I am using for tank level. It obviously uses less instructions/data file.
(Error) x = (5*Actual Raw - 5*Min Raw - Max Raw + Min Raw)/4
Hope this could be useful for someone.