Example - Ladder Diagram
BSFR
The BSFR instruction shifts n-bit data of the data register, D, 1 bit to the right starting at the bit, D.
The carry flag, F11.2, can be used.
Ladder Diagram Example
The initial value of the WORD data register, D0, is 61.
The initial value of the BOOL data register, D0.4 is 1.
When the contact, M0.8, is powered ON (1), the instructions shifts 6 bits of the WORD data register, D0, 1 bit to the right, starting at the BOOL data register, D0.4.
The value of the WORD data register, D0, changes from 61 to 29.
The value of the BOOL data register, D0.4 changes from 1 to 0.
![]()
The existing bits are shifted 1 bit to the right. The most significant bit is shifted into the carry flag bit, F11.2.
![]()
When the instruction is reenergized, the bits are shifted 1 bit to the right again.
The value of the WORD data register, D0, changes from 29 to 13.
The value of the BOOL data register, D0.4 remains 0.
![]()
The existing bits are shifted 1 bit to the right. The most significant bit is shifted into the carry flag bit, F11.2.
![]()
The previous value stored in the carry flag bit, F11.2, is discarded.
BSFRP
The BSFRP one-shot instruction shifts n-bit data of the data register, D, 1 bit to the right starting at the bit, D.
The carry flag, F11.2, can be used.
Every time this instruction executes, it energizes the output only once.
Ladder Diagram Example
The initial value of the WORD data register, D0, is -5,338.
The initial value of the BOOL data register, D0.4 is 1.
![]()
When the contact, M0.9, is powered ON (1), the instructions shifts 10 bits of the WORD data register, D0, 1 bit to the right, starting at the BOOL data register, D0.4.
The value of the WORD data register, D0, changes from -5,338 to -10,858.
The value of the BOOL data register, D0.4 changes from 1 to 0.
![]()
The existing bits are shifted 1 bit to the right. No bit is shifted into the carry flag bit, F11.2.
![]()
When the instruction is reenergized, the bits are shifted 1 bit to the right again.
The value of the WORD data register, D0, changes from -10,858 to -13,626.
The value of the BOOL data register, D0.4 changes from 0 to 1.
![]()
The existing bits are shifted 1 bit to the right. The most significant bit is shifted into the carry flag bit, F11.2.
![]()