Author Topic: Cannot Read with ReadInt or ReadAny  (Read 4203 times)

Robert1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Cannot Read with ReadInt or ReadAny
« on: June 13, 2013, 10:27:21 AM »
I'm trying to read from the ML 1400 PLC using ReadInt and ReadAny, 0 is returned.  I can write using:
   
EthernetIPforPLCSLCMicroComm1.WriteData("L12:1", 333)

These do not work:
        Dim myint() As Integer
        myint = EthernetIPforPLCSLCMicroComm1.ReadInt("L12:1", 4)

        Dim mystr As String
        mystr = EthernetIPforPLCSLCMicroComm1.ReadAny("L12:1")

Any suggestions?  Thank you in advance.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Cannot Read with ReadInt or ReadAny
« Reply #1 on: June 13, 2013, 10:33:48 AM »
If you are on the latest version, try using ReadSynchronous

Robert1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Cannot Read with ReadInt or ReadAny
« Reply #2 on: June 13, 2013, 11:13:42 AM »
Using 3.26

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Cannot Read with ReadInt or ReadAny
« Reply #3 on: June 14, 2013, 07:08:46 AM »
Version 3.26 had a problem where the read would sometimes return a transaction number. This would typically occur if the form had many visual controls and a read was done in code. With that version the best you can do is this:
Code: [Select]
Dim mystr As String
EthernetIPforPLCSLCMicroComm1.AsyncMode=False
mystr = EthernetIPforPLCSLCMicroComm1.ReadAny("L12:1")

Robert1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Cannot Read with ReadInt or ReadAny
« Reply #4 on: June 17, 2013, 12:08:05 PM »
Now using version 3.4, I have 26 text box controls corresponding to the 26 parameters I desire to read from the PLC.  Periodically, without changing the value in the PLC, 0 is returned instead of the value.  I'm using a button to initiate the read.

Each of the 26 reads are similar to this:

Dim addOffset1 As String = "L11:1"
Dim myStr1() As String
myStr1 = EthernetIPforPLCSLCMicroComm1.ReadSynchronous(addOffset1, 1)
txtOffset1.Text = myStr1(0)

I am using Windows 7-64bit and VS2010.  I get the actual value, say 4400 or 0.  Where the 4400 is what I expect and the 0 is not what I expect.
Also, I disable the button after I press it and after the 26 reads, I re-enable the button.

Thank you.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Cannot Read with ReadInt or ReadAny
« Reply #5 on: June 18, 2013, 06:39:06 PM »
I will have to try to replicate this. Do you have other controls on the screen that are updating, or are you just reading the values using your code?

You can also try to read the values asynchronously by setting the property AsyncMode to true, using ReadAny, then create a DataReceived event handler.

Code: [Select]
    Private Sub EthernetIPforPLCSLCMicroComm1_DataReceived(sender As System.Object, e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs) Handles EthernetIPforPLCSLCMicroComm1.DataReceived
        If e.PlcAddress = "L11:1" Then
            txtOffset1.Text = e.Values(0)
        End If
    End Sub

Robert1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Cannot Read with ReadInt or ReadAny
« Reply #6 on: June 20, 2013, 09:19:30 AM »
I am in the testing / learning phase, so there is a DigitalPanelMeter displaying one of the same values and 1 BasicIndicator monitoring the PLC "Heartbeat".  I'll remove these and report back.

Robert1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Cannot Read with ReadInt or ReadAny
« Reply #7 on: August 08, 2013, 10:37:22 AM »
I removed the heartbeat control and it is behaving.