Siemens 1200/1500 PLC indefinite length array selection sorting programming example

Publisher:温柔的心情Latest update time:2024-07-04 Source: elecfansKeywords:Siemens Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The selection sort algorithm first selects all elements from the first position, selects the smallest element among all elements and gives it to that position, then selects the second position, and selects the smallest element among the remaining elements and gives it to that position; and so on, repeating the selection of the "smallest element" until the selection of the element at the (n-1)th position is completed. Then there is only one largest element left at the nth position, and no further selection is required.

caf858fa-358c-11ee-9e74-dac502259ad0.png

cb12b222-358c-11ee-9e74-dac502259ad0.png

Example: Selection sort programming of variable length array

01: Create a new function block FC: SelectSort_Functions

02: Interface definition:

cb24bc2e-358c-11ee-9e74-dac502259ad0.png

03: Programming:

cb3e4cca-358c-11ee-9e74-dac502259ad0.png

04: Define global data block:

cb9bfd2a-358c-11ee-9e74-dac502259ad0.png

05: Call subroutine in OB:

cbea829c-358c-11ee-9e74-dac502259ad0.png

06: Program demonstration results:

cbffcc1a-358c-11ee-9e74-dac502259ad0.png


Keywords:Siemens Reference address:Siemens 1200/1500 PLC indefinite length array selection sorting programming example

Previous article:How to read the station name of the ET 200SP PROFINET IO device
Next article:Installation and advantages of CH44X series Hall sensors in brushless motors

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号