BOOL_TO_INT (Boolean to Integer Conversion)
Converts FALSE to 0 and TRUE to 1 for numeric operations.
The BOOL_TO_INT function converts a boolean value to an integer: FALSE becomes 0 and TRUE becomes 1. This conversion is useful for accumulating boolean conditions into numeric values, creating status codes from individual bits, and using boolean signals in arithmetic calculations.
Parameters
Inputs
| Name | Type | Description |
|---|---|---|
| IN | BOOL | Boolean value to convert |
Outputs
| Name | Type | Description |
|---|---|---|
| OUT | INT | 0 for FALSE, 1 for TRUE |
Structured Text Example
// Count active sensors
Active_Count := BOOL_TO_INT(Sensor_1) + BOOL_TO_INT(Sensor_2)
+ BOOL_TO_INT(Sensor_3) + BOOL_TO_INT(Sensor_4);
// Use boolean as multiplier
Output := Base_Value * BOOL_TO_INT(Enable);20 Production-Ready Ladder Logic Templates
Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.
Platform-Specific Implementation
Siemens (TIA Portal)
Use CONVERT instruction or BOOL_TO_INT in SCL.
Allen-Bradley (Studio 5000)
Implicit in most contexts; boolean contacts evaluate to 0/1.
CODESYS
Use BOOL_TO_INT() function in ST.
Common Applications
- Counting active conditions
- Status code construction
- Conditional arithmetic
- Boolean to numeric conversion for HMI
- Weighted voting systems
Frequently Asked Questions
What is BOOL_TO_INT (Boolean to Integer Conversion) in PLC programming?
Converts FALSE to 0 and TRUE to 1 for numeric operations. The BOOL_TO_INT function converts a boolean value to an integer: FALSE becomes 0 and TRUE becomes 1. This conversion is useful for accumulating boolean conditions into numeric values, creating status codes from individual bits, and using boolean signals in arithmetic calculations.
What are common applications of BOOL_TO_INT (Boolean to Integer Conversion)?
BOOL_TO_INT (Boolean to Integer Conversion) is commonly used for: Counting active conditions, Status code construction, Conditional arithmetic, Boolean to numeric conversion for HMI, Weighted voting systems.
How do I use BOOL_TO_INT (Boolean to Integer Conversion) in different PLC platforms?
Siemens: Use CONVERT instruction or BOOL_TO_INT in SCL. Allen-Bradley: Implicit in most contexts; boolean contacts evaluate to 0/1. CODESYS: Use BOOL_TO_INT() function in ST.
Related Function Blocks
INT_TO_REAL (Integer to Real Conversion)
Converts 16-bit integer to 32-bit floating-point real value.
View Reference →REAL_TO_INT (Real to Integer Conversion)
Converts 32-bit floating-point value to 16-bit integer with rounding.
View Reference →INT_TO_STRING (Integer to String Conversion)
Converts integer value to its decimal string representation for display or logging.
View Reference →ANY_TO_ANY (Universal Type Conversion)
General type conversion framework covering all IEC 61131-3 type conversion functions.
View Reference →Stop Writing Ladder Logic From Scratch
Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.
Instant download - 30-day money-back guarantee - Use on unlimited projects