Inst ToolsInst ToolsInst Tools
  • Courses
  • Videos
  • Q & A
    • Interview
      • Instrumentation
      • Electronics
      • Electrical
      • Practical Questions
    • MCQ
      • Instrumentation MCQ
      • Electrical MCQ
      • Electronics MCQ
      • Control Systems MCQ
      • Analog Electronics MCQ
      • Digital Electronics MCQ
      • Power Electronics MCQ
      • Microprocessor MCQ
      • Multiple Choice Questions
  • EE
    • Electronics
      • Electronics Q & A
      • Electronic Basics
      • Electronic Devices & Circuits
      • Electronics Animation
      • Digital Electronics
    • Electrical
      • Electrical Basics
      • Electrical Q & A
      • Power Electronics
      • Electrical Machines
      • Electrical Animation
      • Power Systems
      • Switchgear & Protection
      • Transmission & Distribution
  • Measure
    • Control Valves
    • Calibration
    • Temperature
    • Pressure
    • Flow
    • Level
    • Analyzers
    • Switches
    • Vibration
    • Solenoid Valve
  • Control
    • PLC Tutorials
    • Control Systems
    • Safety Instrumented System (SIS)
    • Communication
    • Fire & Gas System
  • More
    • Design
    • Tools
    • Animation
    • Basics
    • Formulas
    • Standards
    • TextBooks
    • Common
    • Software
    • Excel Tools
    • Erection & Commissioning
    • Process Fundamentals
    • Videos
    • Books
Search
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Reading: Shift Bit Register in PLC
Share
Notification Show More
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • PLC Tutorials
  • Control Systems
Search
  • Courses
  • Videos
  • Q & A
    • Interview
    • MCQ
  • EE
    • Electronics
    • Electrical
  • Measure
    • Control Valves
    • Calibration
    • Temperature
    • Pressure
    • Flow
    • Level
    • Analyzers
    • Switches
    • Vibration
    • Solenoid Valve
  • Control
    • PLC Tutorials
    • Control Systems
    • Safety Instrumented System (SIS)
    • Communication
    • Fire & Gas System
  • More
    • Design
    • Tools
    • Animation
    • Basics
    • Formulas
    • Standards
    • TextBooks
    • Common
    • Software
    • Excel Tools
    • Erection & Commissioning
    • Process Fundamentals
    • Videos
    • Books
Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Inst Tools > Blog > PLC Tutorials > Shift Bit Register in PLC

Shift Bit Register in PLC

In this article, we will learn the concept of shift bit register in PLC programming including shift and rotate Instructions.

Last updated: May 17, 2023 12:00 pm
Viral Nagda
PLC Tutorials
No Comments
Share
6 Min Read
SHARE

There are many instructions in PLC that help in executing the logic in a simplified way. Instructions come in various categories like arithmetic, comparison, logical, controller, etc. For example, a simple addition instruction for adding two variables comes in the arithmetic category. So, similarly, many types of instructions are available in a PLC logic.

Contents
Shift Bit Register in PLCShift InstructionRotate Instruction

One such instruction which is widely used in PLC programming is shift instruction. It comes in the category of numerical processing.

In this article, we will learn the concept of shift bit register instruction in PLC programming.

Shift Bit Register in PLC

As the name implies, a shift instruction is a command for shifting bits of a word by some predefined position.

For example, you have a word of 16 bits. You want to move bit number 3 from its current fourth position to the seventh position. So, whenever a shift command pulse is given, the bit will shift in each trigger from the fourth position to the seventh position.

In that continuity, the bit in the fifth position will move to the eighth position; and the bit in the third position will move to the sixth position. So, here, you are shifting the bits in a group by the number of positions you define.

Shift Instruction

Shift instructions come in two types – shift and rotate. Let us have a look at the rotate instruction. Consider a syntax – %MW10:= SHL (%MW12, 4). %MW10 is the destination memory word and %MW12 is the source memory word.

Refer to the below image. In %MW10, when a first trigger for shift left is given, bit0 shifts to bit1, and so on. This result is stored in %MW12. When such triggers are given four times, ultimately, bit 0 will shift finally to bit 4, and so on.

The end result is stored in %MW12 anyways and you get a final answer of the bits shifted by four positions from the source word. But, one thing to remember is, with each shift, the preceding bit is filled with value 0. This you can see clearly in the image.

After the first shift, the first bit in %MW12 is 0. So, after four shifts, the end result will be – 0000 1101 1100 0000. This shift can thus be either right or left.

Shift Bit Register in PLC

One more type of shift comes in PLC; the earlier one added zeroes from the preceding position, but this second type keeps the value of the first bit (MSB for right and LSB for left) as it is. This is called arithmetic shifting.

So, if the value of the first bit (MSB for right and LSB for left) initially before the shift was 1, then the last bit will remain as 1 only and the zeroes will be added from the second preceding bit up to how many times the shift command is given. It is to be noted that the last bit which is shifted is always stored in a carry bit.

Rotate Instruction

The second type is rotate instruction. Consider the syntax – %MW10:= ROL (%MW12, 4). %MW10 is the destination memory word and %MW12 is the source memory word. We will use the same above image for reference. Rotate instruction, as the name defines, just rotates the bits by how many positions you define.

Compared to shift instruction where zero was added after every preceding bit; here, the bits are just shifted in the same sequence as it is in the left direction. So, suppose you have a source word of – 1100 1010 1100 0101; then, after a trigger of 4 positions, the end result will be – 1010 1100 0101 1100. The same logic works in the right direction. The last bit shifted is also stored in a carry bit.

One more type comes in the rotate category. Here, instead of shifting only 16 bits, the carry bit to is rolled over. This means, the last bit is shifted to the carry bit, and the carry bit will then be shifted to the first bit, and so on. In the earlier type, the last bit was only stored in the carry bit.

If you liked this article, then please subscribe to our YouTube Channel for Instrumentation, Electrical, PLC, and SCADA video tutorials.

You can also follow us on Facebook and Twitter to receive daily updates.

Read Next:

  • Find the Best PLC for Your Project
  • HMI Screens on a Mobile or Tablet
  • Top Automation Vendors in World
  • Tia Portal Interrupt Organization Block
  • Types of Sensors Used in Automobiles
Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
You've successfully subscribed !

Recommended Articles

Liquid Tank Filling and Emptying PLC System
Auto and Manual Liquid Tank System: PLC Program Example
PLC Programmer Tools
Tools Required for PLC Programmer to Carry at Site
PLC Timer Program
PLC Timer Instructions
Allen Bradley PLC Example with Sub routines
How to use Sub Routines with Allen Bradley PLC
Simple PLC example Hardware configurations
Muting Functions of Safety Control Circuits – PLC Example
Top 100 PLC Objective Questions and Answers
Top 100 PLC Objective Questions and Answers
Share This Article
Facebook Whatsapp Whatsapp LinkedIn Copy Link
Share
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

128.3kFollowersLike
69.1kFollowersFollow
208kSubscribersSubscribe
38kFollowersFollow

Categories

Recent Comments

  • William Snyder on Top Non-PLC Certification Courses for Automation Professionals
  • Kamli on Top Free PLC Software
  • Guifty Shimica on Top Non-PLC Certification Courses for Automation Professionals
  • Guifty Shimica on Top Non-PLC Certification Courses for Automation Professionals

Related Articles

Difference between Analog Signal and Digital Signal

What are Analog and Digital Signals? Differences, Examples

JMP instruction in PLC Programming

How to use JUMP Instruction in PLC Ladder Logic?

How Engineers Effectively do Problem-solve and Troubleshoot

How Engineers Effectively do Problem-solve and Troubleshoot?

Transmitters 4-20mA Current Failure Alarm Limits

Transmitters 4-20mA Current Failure Alarm Limits

Parking Garage Indicator PLC Automation

Parking Garage Indicator: PLC Automation System

Perfume filling system PLC program

CX Programmer Example: Perfume Mixing and Filling System

PLC Program for fan control unit system

PLC Programming for Fan Control Unit System for Industry

ESG in Industrial PLC Automation Systems

ESG in Industrial PLC Automation Systems

More Articles

Selection of Industrial Temperature Calibrator

Selection of Industrial Temperature Calibrator

Annunciator Panel

What is a Annunciator Panel?

D’Arsonval Movement

D’Arsonval Meter Movement

Online and Diagnostics of Siemens PLC

How to Use Diagnostic Buffer for SIEMENS PLC?

Electrical Machines Questions and Answers

Synchronous Machines EMF Polygon Questions

Servo Operated Manometer Objective Questions

Servo Operated Manometer Objective Questions

V Cone Flow Meter Working Principle

V Cone Flow Meter – Principle, Advantages, Disadvantages

Reading Clock data in PLC

Real-Time Clock in Omron PLC? – CX Programmer

Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?