Learn PLCs free
Type ConversionBeginnerIEC 61131-3

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

NameTypeDescription
INBOOLBoolean value to convert

Outputs

NameTypeDescription
OUTINT0 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

S

Siemens (TIA Portal)

Use CONVERT instruction or BOOL_TO_INT in SCL.

AB

Allen-Bradley (Studio 5000)

Implicit in most contexts; boolean contacts evaluate to 0/1.

C

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.

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.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →