Skip to main content

Example - Ladder Diagram

BSER


The BSER instruction searches for both the least and most significant bit set (ON or 1) in the WORD value, S.
If the least significant bit is set (ON or 1), the bit location, with a +1 offset (1-based), is saved in an assigned WORD data register, D.
If the most significant bit is set (ON or 1), the bit location, with a +1 offset (1-based), is saved in an assigned WORD data register, D+1.

Ladder Diagram Example


The result of the search will be saved in the data registers, D17 and D18.




When the contact, M1.5, is powered ON (1), the instruction searches for the location of the least and most significant bits of the data register, D15.

Memory Monitor


The least significant bit with a value of 1 in the data register, D15 is bit 2 (D15.2), The bit location, 2, with an offset of +1 (3), is saved in the data register, D17.

The most significant bit with the value of 1 in the data register, D15 is bit C (D15.C), or position 12. The bit location, 12, with an offset of +1 (13), is saved in the data register, D18.

BSERP


The BSERP instruction searches for both the least and most significant bit set (ON or 1) in the WORD value, S.
If the least significant bit is set (ON or 1), the bit location, with a +1 offset (1-based), is saved in an assigned WORD data register, D.
If the most significant bit is set (ON or 1), the bit location, with a +1 offset (1-based), is saved in an assigned WORD data register, D+1.
Every time this instruction executes, it energizes the output only once.

Ladder Diagram Example


The result of the search will be saved in the data registers, D27 and D28.




When the contact, M2.5, is powered ON (1), the instruction searches for the location of the least and most significant bits of the data register, D25.

Memory Monitor


The least significant bit with a value of 1 in the data register, D25 is bit 1 (D25.1), The bit location, 1, with an offset of +1 (2), is saved in the data register, D27.

The most significant bit with the value of 1 in the data register, D25 is bit F (D15.F), or position 15. The bit location, 15, with an offset of +1 (16), is saved in the data register, D28.