In our earlier article we saw the >Basic of Mint MT language and the basic syntax for declaration and use of Variables , constants in Mint MT programming language. In this post we will see about the arrays and scope of variables and also some basic functions for simplifying the motion tasks.
Mint MT ( Multi - Tasking ) Programming Language Tutorial :-
Let us first understand what are arrays ? An array refers to a series of variables referenced by a single name, using an INDEX to tell them apart.Arrays are initialized at compile time so can be placed anywhere within the program. Also On program download array contents are initialized to zero . Array contents are retained in fixed programs on controllers with battery-backup (NMBX), even after powering the controller. Values are not retained after power off on Nextmove PCI or Mintdrive II (unless specifically saved to NVRAM).No NVRAM on Flex+Drive II so arrays are always non-retentive.
Defining and Dealing with Arrays in MINT
||Declaration Of Array in Mint Language||
As we know that before using any variable in the program we have to first declare it and same is the case with Array. Arrays are also defined with the DIM keyword
DIM myArray(5) = 10, 20, 30, 40, 50
To refer any array in program , we can just refer any array by its name -
myArray = 10, 20, 30, 40, 50
To read any element of array we have to write following syntax
PRINT myArray(2)
20
Also the individual element of the array can be changed ,
myArray(5) = 100
With the above line , the fifth element of myarray will be assigned value 100. Similarly it can be done for any element of any array.
Subscribe to Automation-Talk by Email
As Mint Language is specially for Motion Control , so for high end applications where we need Machine Recipe we have the option to define Multi-Dimensional array.
Dim nXArray(10) as Integer
Dim nXYArray(10,100) as Integer
With the help of these Multi Dimensional Array we can define machine recipe as follows
Product No-----------Width-----Length---Speed----Accel
1-----------------------100---------200-------50---------5
2 ---------------------- 200--------300 -------100 ------10
3 ---------------------- 150 --------100 -------200-------50
It is also possible to declare User Define Array Index ranges as follows :-
Dim UkTemperature ( -15 To 33)
Dim nMyLoggedData (0 To 1000)
Also one point to be noted is that array are column centric , for example
Dim index(2, 3) As Integer = 1, 2, 3, 4, 5, 6
will result in array as
1- 3- 5
2- 4- 6
We will continue this Mint Programming tutorial series , so dont forget to subscribe to get all Mint Programming Tutorials in yours Inbox.Subscribe to Automation-Talk by Email.
Advertisements :-
0 comments:
Post a Comment