Siemens#Scatter Instructions

This time I would like to explain how to “Group” and “Ungroup” the Byte,Word and DWord variables to Bool Array ,Struct or User data type.Sure that you can use Variable.%X0 to finish your task, but that is not bad to learn a new things, Right?:)

Scatter

While we open the Online help in the TIA,

The “Parse the bit sequence into individual bits” instruction parses a tag of the BYTE, WORD, DWORD or LWORD data type into individual bits and saves them in an ARRAY of BOOL, an anonymous STRUCT or a PLC data type exclusively with Boolean elements.

It means that you can parse the Byte ,word DWord, LWord Variables to Bool Array, Structure, PLC Data type.

Blocks

SCATTER(IN := #SourceWord,

OUT => #DestinationArray);

Interface

S7-1200S7-1500
INByte,Word,DWordByte,Word,DWord,LWordSource data that you want to parse
OUTArray[*] of Bool,
PLC data type,The length of * should be 8,16,32 or 64.
Array[*] of Bool,
PLC data type, The length of * should be 8,16,32 or 64.
Variables that you would like to parse to 

Example1-Word to Bool Array

Result

Example2-DWord to Bool Array

Result

Example3-Byte to Bool Array

Result

Example4-Word to Structure

Result

Example5-PLC data type to structure

Firstly, we define a PLC data type that is named udt1.

the variables , there are 16 bool.

And here is the Program.

Result

Please download the source code in here:

https://github.com/chwAmu/Siemens_TIA/blob/master/General/ScatterExample.zap15_1

Footer_Basic

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする