Siemens botu programming-generic and variable-length array programming, Siemens Array

Source: Internet
Author: User

Siemens botu programming-generic and variable-length array programming, Siemens Array

We know that generic is widely used in advanced languages. Can generic be used in PLC? Yes, but he can ..

Control Requirements

Calculate the maximum value in the array. The numeric types include Real and Int. Here we select two types to control the amount of code.

Control Procedure 1

Array is the input array, which can be Int or Real type. But the current size must be smaller than maxSize, which is the limit of this method. We will write a file with no size limit later.

The procedure is relatively simple. Let's briefly discuss the following points:

The second row must use UDINT_TO_DINT, because the subsequent index number must use DINT. The final output is a generic value. All maxelements must be set to Variant. Therefore, the VairantPut command must be used to transmit the corresponding type.

In addition, the corresponding code needs to be written for each type. The extensive type of PLC is very wordy and the code volume is very large. In fact, there is essentially a difference with the general type of PC.

Control Procedure 2

This time, we use the MOVE_BLK_VARIANT function to return the values in the Variant array, so we can implement a real variable-length array. Finally, output the maximum value through the VariantPut command. For instructions, see the manual provided by the system.

Control Procedure 3

This program only implements variable-length arrays.

The second line of the statement. The type is Array [*] of Int. In addition, note that the Lower_Bound and Upper_Bound functions are used in lines 1st and 2 of the program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.