Integer top Real scaling block with optional output limiting.
This block converts an integer to a real and scales using linear interpolation.
By setting the #Limit_Out bit the output can be limited to the minimum and
maximum scale values.
Linear interpolation:
(#Raw - #Raw_Min)(#Scale_Max - #Scale_Min)
#Scaled= ------------------------------------------------------ + #Scale_Min
(#Raw_Max - #Raw_Min)
In
#Raw Int
#Raw_Min Int
#Raw_Max Int
#Scale_Min Real
#Raw_Max Real
OUT
# Scaleed Real
Network: 01 Convert integers to reals
L #Raw
ITD
DTR
T #_Raw_R
L #Raw_Min
ITD
DTR
T #_Raw_Min_R
L #Raw_Max
ITD
DTR
T #_Raw_Max_R
Network: 02 Calculation
// Raw - Raw_Min
L #_Raw_R
L #_Raw_Min_R
-R
T #_temp_real
// Scale_Max - Scale_Min
L #Scale_Max
L #Scale_Min
-R
//(Raw - Raw_Min) * (Scale_Max - Scale_Min)
L #_temp_real
*R
T #_temp_real
// Raw_Max - Raw_Min
L #_Raw_Max_R
L #_Raw_Min_R
-R
T #_temp_real2
//(Raw - Raw_Min) * (Scale_Max - Scale_Min) / (Raw_Max - Raw_Min)
L #_temp_real
L #_temp_real2
/R
//(Raw - Raw_Min) * (Scale_Max - Scale_Min) / (Raw_Max - Raw_Min) + Scale_Min
L #Scale_Min
+R
T #_Output
Network:03Turn on output for cascade
A #Always on bit
AN #Always on bit
SAVE
!--RELATED-POSTS-STARTS-->
No comments:
Post a Comment