ROL (Rotate Left)
Rotates bits left; bits shifted out the left wrap around to the right.
The ROL (Rotate Left) function rotates the bits of the input value to the left by a specified number of positions. Unlike SHL, bits shifted out of the left end wrap around to the right end, so no data is lost. ROL is used for creating rotating bit patterns (sequencer outputs, LED chase patterns), implementing circular shift registers, and cyclic data manipulation.
Parameters
Inputs
| Name | Type | Description |
|---|---|---|
| IN | ANY_BIT | Value to rotate |
| N | INT | Number of bit positions to rotate left |
Outputs
| Name | Type | Description |
|---|---|---|
| OUT | ANY_BIT | Rotated result |
Ladder Logic Example
// Ladder Logic - ROL (Sequencer Pattern) // // |----[ Step_Pulse ]----[ROL]----| // | IN: Pattern | // | N: 1 | // | OUT: Pattern |
Structured Text Example
// Rotating LED chase pattern
IF Step_Pulse THEN
LED_Pattern := ROL(LED_Pattern, 1);
END_IF;
// 0000_0001 -> 0000_0010 -> 0000_0100 -> ... -> 1000_0000 -> 0000_000120 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 ROL instruction in TIA Portal.
Allen-Bradley (Studio 5000)
No native ROL; implement using BSL with feedback from last bit.
CODESYS
Use ROL() function in ST.
Common Applications
- LED chase/sequencer patterns
- Circular shift registers
- Rotating bit patterns for outputs
- Cyclic data manipulation
- Round-robin scheduling
Frequently Asked Questions
What is ROL (Rotate Left) in PLC programming?
Rotates bits left; bits shifted out the left wrap around to the right. The ROL (Rotate Left) function rotates the bits of the input value to the left by a specified number of positions. Unlike SHL, bits shifted out of the left end wrap around to the right end, so no data is lost.
What are common applications of ROL (Rotate Left)?
ROL (Rotate Left) is commonly used for: LED chase/sequencer patterns, Circular shift registers, Rotating bit patterns for outputs, Cyclic data manipulation, Round-robin scheduling.
How do I use ROL (Rotate Left) in different PLC platforms?
Siemens: Use ROL instruction in TIA Portal. Allen-Bradley: No native ROL; implement using BSL with feedback from last bit. CODESYS: Use ROL() function in ST.
Related Function Blocks
SHL (Shift Left)
Shifts bits left by N positions, filling right with zeros. Equivalent to multiply by 2^N.
View Reference →SHR (Shift Right)
Shifts bits right by N positions. Equivalent to integer division by 2^N.
View Reference →MOVE (Data Move)
Copies a value from source to destination for any data type.
View Reference →SWAP (Byte Swap)
Reverses byte order of a word value for endianness conversion.
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