none
Visual Basic to read data from PLC 1200 Tia Portal RRS feed

  • Question

  • We are trying to communicate Visual Basic to Tia portal in order to read data from PLC 1200, we are trying to create a HMI that shows the readings from 3 sensors (RPM, Voltage, Current). 

    ---------------------------------------------------------------------------------------------------------------------------------

    This the code we have so far to connect via IP:

    Public Class FormPrincipal
        Dim LND_WinAC As Libnodave_WinAC
        Dim DirIP As String

        Private Sub Conectar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Conectar.Click

            If LND_WinAC Is Nothing Then
                LND_WinAC = New Libnodave_WinAC
            End If

            If LND_WinAC.Conectado Then
                Mensajes.Items.Add("Desconectando...")
                Me.Update()
                If LND_WinAC.Desconectar() Then
                    IP1.Enabled = True
                    IP2.Enabled = True
                    IP3.Enabled = True
                    IP4.Enabled = True
                    Puerto.Enabled = True
                    NumRack.Enabled = True
                    NumSlot.Enabled = True
                    GBLE.Enabled = False
                    Conectar.Text = "Conectar"
                    Mensajes.Items.Add("Conexión cerrada correctamente.")
                Else
                    Mensajes.Items.Add(LND_WinAC.Mensaje)
                End If

            Else
                DirIP = IP1.Value & "." & IP2.Value & "." & IP3.Value & "." & IP4.Value
                Mensajes.Items.Add("Conectando...")
                Mensajes.Items.Add("IP " & DirIP & ", Puerto " & Puerto.Value & _
                                   ", Rack " & NumRack.Value & ", Slot " & NumSlot.Value)
                Me.Update()
                If LND_WinAC.Conectar(Puerto.Value, DirIP, NumRack.Value, NumSlot.Value) Then
                    IP1.Enabled = False
                    IP2.Enabled = False
                    IP3.Enabled = False
                    IP4.Enabled = False
                    Puerto.Enabled = False
                    NumRack.Enabled = False
                    NumSlot.Enabled = False
                    GBLE.Enabled = True
                    Conectar.Text = "Desconectar"
                    Mensajes.Items.Add("Conexión creada correctamente.")
                Else
                    Mensajes.Items.Add(LND_WinAC.Mensaje)
                End If
            End If
        End Sub

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Mensajes.Items.Clear()
        End Sub

        Private Sub Leer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Leer.Click
            LND_WinAC.LeerBytesDB(10, 0, 1)
            LeerByte.Text = LND_WinAC.BufferLectura(0)
        End Sub

        Private Sub Escribir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Escribir.Click
            LND_WinAC.BufferEscritura(0) = EscribirByte.Value
            LND_WinAC.EscribirBytesDB(10, 0, 1)
        End Sub

        Private Sub GBLE_Enter(sender As Object, e As EventArgs) Handles GBLE.Enter

        End Sub
    End Class

    ---------------------------------------------------------------------------------------------------------------------------------

    I would appreciate so much if you could walk us thru with a sample code or help us complete the one we currently have.

    Thank you!

    Wednesday, July 10, 2019 2:34 AM

All replies

  • Hi,

    see the following link,I hope it can help you:

    https://alexsentcha.wordpress.com/libnodave-exchange-data-with-siemens-plc-2/vb-net-exchange-data-with-siemens-plc/

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 10, 2019 5:58 AM
    Moderator