Example Function Block To Shift Buffer And Insert Data
Sometimes it is necessary to byte shift data right by one byte to insert a new byte at the head of a buffer. This could be for strings or data. However the current PLC shift instructions don't enable this function easily as data is often byte swapped in a word.
The attached sample CX-Programmer file includes a Function Block (FB) which allows users to shift a 'buffer' of data by one byte. The FB also inserts a new byte at the head of the buffer.
Data in 'buffer' before shift.
Data in 'buffer' after shift (assuming that new byte to insert at head is 0x99)