Tri Plc Visual Basic dll Usage

 Any suggestions and / or comments are welcome.

 Please reply to: E-Mail  bds1@triwest.net

 Tri Plc dll is free software.

 Tri Plc dll is distributed in the hope that it will be useful,

 but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

 ENJOY !!

Installation

  1. Run the Dll TriPlc install 1st.
  2. Run the TriPlc install 2nd.

This will install the controls and the TriPlc.dll needed for communication with the Triangle Research Plc. This control has been tested with a T100MD + 888 Plc.

This control was created in Visual Basic 6.0.

The control uses VB’s Winsock control for transport.

Included

      TriangleResearch.vbp  (Visual Basic 6.0 Project) to interface with the dll.

      Tri Plc Test.xls  Excel Example

      Tri-Plc.dll

Visual Basic and VBA (Excel) Usage

     1. Call a reference to the Tri-Plc.dll in the windows system32 directory.

         Then place code like this in the VB editor.

         The Timeout for the dll communications is set by default to 3000 but can be adjusted as you like.

Example:

        

Dim Try As New TriPlc1

Private Sub cmdConnect_Click() 'Connect to X Server

   Try.Connect_Xserver “192.168.1.101”, 9080, “UserName”, “Password”

   Text1.Text = Tri.SocketStatus   ‘ Important to call this function after connection or you will receive a    warning.

End Sub

Username and Password are Optional. If you use the X-Server without Username and Password, then just omit them when you call the connection.

NOTE: Text1.Text = Tri.SocketStatus   ‘ Important to call this function after connection or you will receive a   warning.

Private Sub CmdDisconnect_Click() 'Disconnect X-Server

   Try.DisConnectXServer

Text1.Text = Tri.SocketStatus  

End Sub

Private Sub CmdPlcID_Click() 'Read Device ID

   TxtPlcID = Try.ReadDevId

End Sub

Private Sub Cmdstart_Click() 'Set Input 0 (Input,Output,Relay)

Dim res 

    res = Try.SetBit(1, SR_Input, 0)

End Sub

Private Sub CmdStop_Click() 'Reset Input 0 (Input,Output,Relay)

Dim res

                                                             # of item

    res = Try.ResetBit(1, SR_Input, 0)


End Sub                          Plc ID      Input,Output,relay

 Private Sub Command3_Click() ' Read Plc Real Time Clock *********

Dim res1 As String, res2 As String, res3 As String

    res1 = Try.ReadSystemVariables(1, Type_Clock, 1)

    res2 = Try.ReadSystemVariables(1, Type_Clock, 2)

    res3 = Try.ReadSystemVariables(1, Type_Clock, 3)

  If res1 <> "" And res2 <> "" And res2 <> "" Then

    Text8 = Format(res1, "00") & ":" & Format(res2, "00") & ":" & Format(res3, "00")

  End If

End Sub

Private Sub Command4_Click()

           ' Read Output group and return as Binary String (8 at a time)

           ' If Integer return is prefered, Then use "False"

   Text2 = Try.ReadOutput(1, Text5, True)

End Sub

Private Sub Command5_Click()

           ' Read Input group and return as Binary String (8 at a time)

           ' If Integer return is prefered, Then use "False"

   Text11 = Try.ReadInput(1, Text12, True)

End Sub

Private Sub Command6_Click()

           ' Read Relay group and return as Binary String (8 at a time)

           ' If Integer return is prefered, Then use "False"

   Text13 = Try.ReadRelay(1, Text14, True)

End Sub

Private Sub Command7_Click() ' Read Varriable Strings **********

  Text15 = Try.ReadVariableStrings(1, Combo1.Text)

End Sub

Private Sub Command8_Click() ' Write Varriable Strings **********

  Dim res As String

  res = Try.WriteVariableStrings(1, Combo1.Text, Text16)

End Sub

Private Sub ReadLCD() ' Read Plc LCD Strings (Only 4 Strings)*********

Dim res1, res2, res3, res4

  res1 = Try.ReadVariableStrings(1, 1)

  res2 = Try.ReadVariableStrings(1, 2)

  res3 = Try.ReadVariableStrings(1, 3)

  res4 = Try.ReadVariableStrings(1, 4)

 

  If res1 <> "" Then Label3(0).Caption = res1

  If res2 <> "" Then Label3(1).Caption = res2

  If res3 <> "" Then Label3(2).Caption = res3

  If res4 <> "" Then Label3(3).Caption = res4

End Sub