For example, if you use Step7 to program, The analog input is a word and designated PIWxxx ;xxx=word address
The analog output is PQWxxx
The word addresses is defined in the hardware configuration.
usually, the analog value inside the PLC is in a range (example: from 0 to 27648) which corresponds the physical value (example: 4-20mA), Where 0->4mA and 27648->4mA
You have to scale your output or input with the value inside the PLC.
Example:
you have a level sensor from 0 to 100m
You then need to scale the range (0 - 27648) with the physical value (0 - 100m)
Then you use scissors multiplication to get the value as follows:
Physical -> PLC
0m -> 0
100m -> 27648
Ym -> X
then Y=(X * 100)/27648
Where: X is the input from PIWxxx
Y is the distance in meters