Author Topic: serial connection  (Read 8471 times)

dwkw

  • Newbie
  • *
  • Posts: 3
  • I'm a llama!
    • View Profile
serial connection
« on: October 06, 2008, 07:59:02 PM »
Hi,i am doing a project on a chinup trainer.i am using a photo sensor to capture the number of chinups into a channel.I am also using vb.net to communicate with plc and store the record in access.i would like to know in what format the data is recorded?And also is this code sufficient to store number of chinups in variable 'int'?

Public Class Form1
      Private WithEvents serialPort As New IO.Ports.SerialPort("COM1")

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            serialPort.Open()
       
            Dim int As String = ""

       

            'Read the corresponding value and store
            int = Me.serialPort.ReadLine()
            serialPort.Close()

       

        End Try

    End Sub

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:serial connection
« Reply #1 on: October 07, 2008, 09:34:52 AM »
What model of PLCs are you using? Which variable in the PLC do you want to access? To access the T100MD+ PLC, the command and response format are stated in Chapter 3 and 4 of the User's Manual.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

dwkw

  • Newbie
  • *
  • Posts: 3
  • I'm a llama!
    • View Profile
Re:serial connection
« Reply #2 on: October 16, 2008, 07:34:37 PM »
So if i want to read from EEPROM,in my vb program i just have to connect to serial and send a host link command right?What is the response for?
I am using T100MD-1616+

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:serial connection
« Reply #3 on: October 16, 2008, 11:11:08 PM »
Yes, you send a command such as "@01RXI00010400" which is to read EEPROM  address 1 to 4. The response string contains the data you requested and you have to extract them from the response string using the VisualBasic MID command.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

dwkw

  • Newbie
  • *
  • Posts: 3
  • I'm a llama!
    • View Profile
Re:serial connection
« Reply #4 on: October 22, 2008, 10:34:42 PM »
Is it something like this?

Public Class Form1
    Dim int As String
    Dim temp As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.Open()

        SerialPort1.Write("@nnRUnn00*")
        int = SerialPort1.ReadLine()
        temp = Mid$(int, 1, 4)

    End Sub
End Class

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:serial connection
« Reply #5 on: October 23, 2008, 04:38:17 AM »
Please follow examples provided in the following links:

http://www.tri-plc.com/applications/VBsample.htm
Email: support@triplc.com
Tel: 1-877-TRI-PLCS