Glossary

What is Type conversion?

Explicit functions that move a value between types, such as INT_TO_REAL, REAL_TO_INT, TRUNC and TIME_TO_DINT.

The standard is strict: in most cases it does not convert implicitly and you must write the conversion yourself. It feels tedious but it prevents silent errors.

Mind the difference: TRUNC(3.9) is 3 because it cuts the fraction, while REAL_TO_INT(3.9) is 4 because it rounds. Picking the wrong one costs a whole step in position calculations.

Related terms

Integer division
Dividing two integers in ST gives an integer and the fraction is dropped, which is a common cause of an unexpected zero.
Analogue scaling
Turning the raw count from an input card into an engineering unit an operator understands: metres, bar or degrees.
Data type
The classification that fixes a variable size, value range and permitted operations: BOOL, INT, DINT, REAL, TIME and the rest.

All terms