Apr 27, 2011

Baldor Mint Motion Language Tutorial - Part 4

Till now in our earlier 3 tutorials we have understood the basics of Mint MT Language , Declaration of arrays their syntax ,Variable scope in Mint. In this Mint Programming tutorial we will discuss about the Subroutines , Functions and Digital I/O.
Using Subroutines in Mint Program :-
As we all knows that Subroutines makes the program shorter and also reduce the programming space required for a particular application. Mint also have the feature of Subroutines. Some of the features of Subroutine in Mint MT are :-
1.Accept Passed Parameters
2.Local Variables
3.Appears in the Program Navigator
4.True reusable code

See below sample subroutine for better understanding :-
Sub DisplayMenu(ByVal Menu As Integer ) ‘ ByRef supported as standard

Select Case Menu
Case 1 ‘ Show Main menu
Line 1, “Main Menu”
Case 2 ‘ Show Set-up Menu
End Select
End Sub

Also see another example of subroutine in Mint , in this subroutine the value of a will change but b will be preserved….
Dim a As Integer
Dim b As Integer
Input "enter a ",a Using 2,0
Input "enter b ",b Using 2,0
subcalc a,b
?"a= ",a
?"b= ",b

Sub subcalc(ByRef c As Integer,ByVal d As Integer )
End Sub

Using Functions in Mint :-
Functions return a value of defined type.
MOVER.0 = CalcTargetPos( LastPosition )
Function CalcTargetPos(CurrentPos As Integer ) As Float

CalcTargetPos = CurrentPos + 50.234

End Function

Digital & Analog I/O Usage in Mint
The IN.bank keyword can be used to read the state of all inputs on a particular BANK. Inx.channel can be used to read a single input.The OUT.bank keyword can be used to set all outputs on a particular BANK. OUTx.channel can be used to set/reset a specific output
ADC.x is used to read analogue inputs. DAC.x (Nextmove) or AUXDAC.x (Mintdrive II) are used to write to analogue outputs.

In our next tutorial we will be discussing about the Basic Program Structure and Program , Logic Making in Mint language. Till then you can subscribe to get all latest updates to receive in your Mailbox.
Subscribe to Automation-Talk by Email.

Advertisements :-


Post a Comment

Receive all updates via Facebook. Just Click the Like Button Below