Author Topic: Read from a Omron PLC without using any controls  (Read 1079 times)

Nagato

  • Newbie
  • *
  • Posts: 2
    • View Profile
Read from a Omron PLC without using any controls
« on: January 26, 2016, 11:27:33 AM »
Hi,
I need to read from a Omron CJ1M PLC some variables and save them on a database. I want to do this work only using a code, for example, creating a driver object and then read all variables from that driver.
For example:
 -   declaration of the driver
 -   setting the comunications parameters in the form load
 -   read the variables in a timer sub

I hope I explain well what I want to do.
Thank you for your help.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Read from a Omron PLC without using any controls
« Reply #1 on: January 26, 2016, 12:30:47 PM »
        Dim MyDriver As New AdvancedHMIDrivers.Omron.OmronEthernetFINSCom
        MyDriver.IPAddress = "192.168.0.1"
        Dim MyValue As String = MyDriver.Read("D0")

Nagato

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Read from a Omron PLC without using any controls
« Reply #2 on: January 27, 2016, 09:57:34 AM »
I cannot use the object OmronEthernetFINSCom, I have to use OmronSerialHostLinkCom object.
I try to read in this way:

Dim OmronConnection As New AdvancedHMIDrivers.Omron.OmronSerialHostLinkCom

set the comunication parameters at start

Dim appstring = OmronConnection.Read("D500", 1)

But it go in exception in the HostLinkBaseCom.vb at line 1116 (Function WaitForResponse) with this exception: "Object reference not set to an instance of an object."
I cannot understand why it happens.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Read from a Omron PLC without using any controls
« Reply #3 on: January 27, 2016, 04:19:05 PM »
Try adding an instance of the driver to your form, then use this code to see if it works:

Dim appstring as string = OmronConnection.Read("D500")