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_0001Free · no signup to try
Run this block in your browser
Try the instruction on a live rung before you copy it into a project — nothing to install.
Try it in your browser — no signupOpens plcsimulationsoftware.com — same team
Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad
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 →Free · no signup to try
Wire this block up and run it
Drop the instruction into a rung, press Run and watch it execute in your browser — then adapt it to your vendor tool.
Try it in your browser — no signupOpens plcsimulationsoftware.com — same team
Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad