Author Topic: How read and write to SLC controller using VB  (Read 1160 times)

Shark13

  • Newbie
  • *
  • Posts: 40
    • View Profile
How read and write to SLC controller using VB
« on: February 06, 2020, 07:52:01 AM »
Looking for some advice on how to properly code the VB side using advanced HMI to read and write values using windows forms rather than an advanced HMI control. I mostly need to be able to write an integer to the PLC and read an integer from (N7) the PLC, ect. I'm looking to populate a datagridview with that information. I mostly need help on how to properly call the PLC address values in the VB program.

I'm brand new to VB type coding, so the proper syntax is what I am unsure of. Can anyone recommend a good source for this on the web? I've looked on YouTube but only seem to find videos of people using another 3rd party driver system with control logix (tag) platform.

Shark13

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: How read and write to SLC controller using VB
« Reply #1 on: February 06, 2020, 10:28:28 AM »
So I figured out how to receive value from PLC, with using a button/label, in case someone else is ever having this issue. I'm currently using the Advanced HMI basic label to write value to PLC for conveyance. Would write to PLC be the same as below, except use the .write("") instead of .read("") ? 
 
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label2.Text = EthernetIPforSLCMicroCom1.Read("N7:0")

    End Sub

dmroeder

  • Global Moderator
  • Full Member
  • *****
  • Posts: 208
    • View Profile
Re: How read and write to SLC controller using VB
« Reply #2 on: February 06, 2020, 11:43:53 PM »
Close.  You have to provide the Write method with 2 pieces of information, the data file you are writing to and the value:

EthernetIPforSLCMicroCom1.Write("N7:0", 10)

It's up to you to decide how to provide that value.  If I'm not mistaken though (I don't have it in front of me at the moment), the BasicLabel has a keypad popup where you can type in a value you want to write to the PLC.  It's all handled by the BasicLabel so writing code is not necessary.

Shark13

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: How read and write to SLC controller using VB
« Reply #3 on: February 07, 2020, 07:24:31 AM »
Close.  You have to provide the Write method with 2 pieces of information, the data file you are writing to and the value:

EthernetIPforSLCMicroCom1.Write("N7:0", 10)

It's up to you to decide how to provide that value.  If I'm not mistaken though (I don't have it in front of me at the moment), the BasicLabel has a keypad popup where you can type in a value you want to write to the PLC.  It's all handled by the BasicLabel so writing code is not necessary.
OK Thanks! Yes the basic label can handle the write. I just wanted the coding for reference for the future.