Example Function Block To Shift Buffer And Insert Data

Introduction
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.

Example

Data in 'buffer' before shift.

1122 3344 5566 7788       

Data in 'buffer' after shift (assuming that new byte to insert at head is 0x99)

9911 2233 4455 6677 88  
 

 

Note: The Function Block is written for CJ1/CS1 V4.x CPU's or CJ2 V1.x

 


Link:
http://www.myomron.com/index.php?action=kb&print=1313



Comments  

Translate: