in

Allen Bradley PLC: Turning on Bits with Binary

Understanding Binary in Allen Bradley PLCs

In the world of Allen Bradley Programmable Logic Controllers (PLCs), binary code is the language that speaks to the heart of the machine. It’s the foundation of how PLCs understand and execute instructions. While you might not write PLC programs directly in binary, understanding its principles is crucial for efficient troubleshooting and program optimization.

What is Binary?

Binary is a number system that uses only two digits: 0 and 1. Think of it like a light switch – it’s either on (1) or off (0). Each position in a binary number represents a power of 2, starting from the rightmost position as 20, then 21, 22, and so on.

For example, the binary number 1011 translates to decimal as follows:

Binary Decimal Value Power of 2
1 8 23
0 0 22
1 2 21
1 1 20

Adding up the decimal values, we get 8 + 0 + 2 + 1 = 11. So, the binary number 1011 is equivalent to the decimal number 11.

Turning on Bits in PLCs

In Allen Bradley PLCs, bits are individual memory locations that can hold either a 0 or a 1. Turning on a bit means setting its value to 1. This can be done using various instructions, but let’s focus on the most common one: the ‘SET’ instruction.

The ‘SET’ Instruction

The ‘SET’ instruction is used to force a bit to a value of 1. It takes two parameters: the address of the bit you want to set and the value to set it to (which is always 1).

For example, if you want to turn on bit 0 of the output register ‘O:0/0’, you would use the following instruction:

SET O:0/0.0

This instruction would set the first bit (bit 0) of the output register ‘O:0/0’ to a value of 1.

Practical Example: Controlling a Light

Imagine you have a light connected to output bit 0 of the output register ‘O:0/0’. To turn the light on, you would use the ‘SET’ instruction as shown above.

Here’s a basic program structure:

// Turn on the light
SET O:0/0.0

When this program executes, the PLC will set bit 0 of the output register ‘O:0/0’ to 1, which will turn on the connected light.

Important Considerations

  • Bit Addressing: In Allen Bradley PLCs, bits are addressed within a register. For example, ‘O:0/0.0’ refers to the first bit (bit 0) of the output register ‘O:0/0’.
  • Data Types: Different data types in PLCs have different bit sizes. For example, a Boolean variable is a single bit, while an Integer variable is 16 bits.
  • Program Logic: Turning on bits is often part of a larger program logic that controls the overall operation of the system.

Conclusion

Understanding binary and how to manipulate bits is a fundamental skill for Allen Bradley PLC programmers. The ‘SET’ instruction is a powerful tool for controlling outputs and driving system behavior. By mastering these concepts, you can write efficient and effective PLC programs that meet your automation needs.