10.4
Data Type Conversion Functions
The Data Type Conversion functions are used to change a data item from one number
type to another. Many programming instructions, such as math functions, must be used
with data of one type.
•
Convert data to BDC-4
•
Convert data to signed integer
•
Convert data to double-precision integer
•
Convert data to Real
•
Convert data to Word
•
Round a Real number toward zero (TRUN)
10.4.1
Data Type Conversion Functions Convert
Signed Integer Data to BCD-4
The Convert to BCD-4 function outputs the four-digit BCD equivalent of signed integer
data. The original data is not changed by this function.
Data can be converted to BCD format to drive BCD-encoded LED displays or presets to
external devices such as high-speed counters.
When the function receives power flow, it performs the conversion, making the result
available via output Q. The function passes power flow when power is received, unless
the specified conversion would result in a value that is outside the range 0 to 9999.
Value to be converted
OK
Enable
INT
_
TO
BCD4
IN
Output
Q
10.4.1.1
Parameters of the Convert to BCD-4 Function
Input/
Output
Choices
Description
enable
flow
When the function is enabled, the conversion is
performed.
IN
I, Q, M, T, G, R, AI, AQ,
constant
IN contains a reference for the integer value to
be converted to BCD-4.
OK
flow, none
The OK output is energized when the function is
performed without error.
Q
I, Q, M, T, G, R, AI, AQ
Output Q contains the BCD-4 form of the original
value in IN.
10.4.1.2
Example
In the example, whenever input %I0002 is set and no errors exist, the integer at input
location %I0017 through %I0032 is converted to four BCD digits, and the result is stored
in memory locations %Q0033 through %Q0048. Coil %Q1432 is used to check for
successful conversion.
156
GFK-1503E
VersaMax PLC User Manual
For public disclosure
Summary of Contents for VersaMax PLC
Page 16: ...Notes 16 GFK 1503E VersaMax PLC User Manual For public disclosure ...
Page 38: ...Notes 38 GFK 1503E VersaMax PLC User Manual For public disclosure ...
Page 50: ...Notes 50 GFK 1503E VersaMax PLC User Manual For public disclosure ...
Page 92: ...Notes 92 GFK 1503E VersaMax PLC User Manual For public disclosure ...
Page 112: ...Notes 112 GFK 1503E VersaMax PLC User Manual For public disclosure ...
Page 224: ...Notes 224 GFK 1503E VersaMax PLC User Manual For public disclosure ...
Page 292: ...Notes 292 GFK 1503E VersaMax PLC User Manual For public disclosure ...
Page 316: ...Notes 316 GFK 1503E VersaMax PLC User Manual For public disclosure ...
Page 317: ......