Author Topic: Possible problem with EthernetSLC Driver  (Read 1840 times)

Jesse

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Possible problem with EthernetSLC Driver
« on: January 03, 2014, 09:08:15 AM »
Ok, HMI communicates with 5 PLCS 4 of which are CLX and 1 5/05 slc.
When the user selects a machine with a CLX it changes IP and enables subsciptions for that driver and disables for the SLC driver, Vise Versa with selecting the machine with the SLC then CLX driver subscriptions are disabled.

On a side note both drivers are set to subscriptions disabled when the program loads
here is the code for sending my info from my Labels.
Code: [Select]
Private Sub SendProgramToFunaceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendProgramToFunaceToolStripMenuItem.Click

        Dim CodeLabels = {CodeLabel1, CodeLabel2, CodeLabel3, CodeLabel4, CodeLabel5, CodeLabel6, CodeLabel7, CodeLabel8, CodeLabel9, CodeLabel10, CodeLabel11, CodeLabel12, CodeLabel13, CodeLabel14, CodeLabel15, CodeLabel16, CodeLabel17, CodeLabel18, CodeLabel19, CodeLabel20, CodeLabel21, CodeLabel22, CodeLabel23, CodeLabel24, CodeLabel25, CodeLabel26, CodeLabel27, CodeLabel28, CodeLabel29, CodeLabel30, CodeLabel31, CodeLabel32, CodeLabel33, CodeLabel34, CodeLabel35, CodeLabel36, CodeLabel37, CodeLabel38, CodeLabel39, CodeLabel40, CodeLabel40}
        Dim CodeValueLabels = {CodeValueLabel1, CodeValueLabel2, CodeValueLabel3, CodeValueLabel4, CodeValueLabel5, CodeValueLabel6, CodeValueLabel7, CodeValueLabel8, CodeValueLabel9, CodeValueLabel10, CodeValueLabel11, CodeValueLabel12, CodeValueLabel13, CodeValueLabel14, CodeValueLabel15, CodeValueLabel16, CodeValueLabel17, CodeValueLabel18, CodeValueLabel19, CodeValueLabel20, CodeValueLabel21, CodeValueLabel22, CodeValueLabel23, CodeValueLabel24, CodeValueLabel25, CodeValueLabel26, CodeValueLabel27, CodeValueLabel28, CodeValueLabel29, CodeValueLabel30, CodeValueLabel31, CodeValueLabel32, CodeValueLabel33, CodeValueLabel34, CodeValueLabel35, CodeValueLabel36, CodeValueLabel37, CodeValueLabel38, CodeValueLabel39, CodeValueLabel40, CodeValueLabel40}
        Dim StepLabels = {Label1, Label2, Label3, Label4, Label5, Label6, Label7, Label8, Label9, Label10, Label11, Label12, Label13, Label14, Label15, Label16, Label17, Label18, Label19, Label20, Label21, Label22, Label23, Label24, Label25, Label26, Label27, Label28, Label29, Label30, Label31, Label32, Label33, Label34, Label35, Label36, Label37, Label38, Label39, Label40, Label40}
        Dim BatchNumber As String

        OkToSend = True

        CodeValueLabelValidation()

        If OkToSend = True Then

            If ConnToSLC = False And ConnToCLX = True Then

                BatchNumber = InputBox("Enter Batch Number: ", "Batch Number")

                Dim C As Integer
                C = 0

                Try

                    If BatchNumber <> "" Then
                        EthernetIPforCLXCom1.Write("HMI_BATCH_NUMBER_IN_BUFFER", BatchNumber)
                        EthernetIPforCLXCom1.Write("HMI_CODE[0]", inc + 1)
                    Else
                        MsgBox("You Did Not Enter A Batch Number!")
                        Exit Try
                    End If

                    ProgBarForm.Show()

                    For C = 0 To 39
                        ProgBarForm.ProgressLabel.Text = C + 1
                        ProgBarForm.ProgressBar1.PerformStep()
                        EthernetIPforCLXCom1.Write("HMI_CODE[" & C + 41 & "]", CInt(d(CodeLabels(C).Text)))
                        EthernetIPforCLXCom1.Write("HMI_CODE_VALUE[" & C + 41 & "]", CodeValueLabels(C).Text)
                        System.Threading.Thread.Sleep(25)
                    Next

                    ProgBarForm.Close()

                Catch ex As Exception
                    MsgBox(ex)
                    ProgBarForm.Close()
                End Try

            ElseIf ConnToSLC = True And ConnToCLX = False Then

                BatchNumber = InputBox("Enter Batch Number: ", "Batch Number")

                Dim C As Integer
                C = 0

                Try

                    If BatchNumber <> "" Then
                        EthernetIPforPLCSLCMicroCom1.Write("ST10:0", BatchNumber)
                        EthernetIPforPLCSLCMicroCom1.Write("N7:40", inc + 1)
                    Else
                        MsgBox("You Did Not Enter A Batch Number!")
                        Exit Try
                    End If

                    ProgBarForm.Show()

                    For C = 0 To 39
                        ProgBarForm.ProgressLabel.Text = C + 1
                        ProgBarForm.ProgressBar1.PerformStep()
                        EthernetIPforPLCSLCMicroCom1.Write("N7:" & C + 41 & "", CInt(d(CodeLabels(C).Text)))
                        EthernetIPforPLCSLCMicroCom1.Write("F8:" & C + 41 & "", CSng(CodeValueLabels(C).Text))
                        System.Threading.Thread.Sleep(25)
                    Next

                    ProgBarForm.Close()

                Catch ex As Exception
                    MsgBox(ex)
                    ProgBarForm.Close()
                End Try

            End If

        Else
            MsgBox("Did not send program due to bad Opcode or Values! Please Try Again.")
        End If

    End Sub

Here is the code for enabling and disabling subscriptions, the Boolean variables are changed when a machine is selected and then runs this sub right after:
Code: [Select]
Sub ConnState()
        If ConnToCLX = False Then
            EthernetIPforCLXCom1.DisableSubscriptions = True
        ElseIf ConnToCLX = True Then
            EthernetIPforCLXCom1.DisableSubscriptions = False
        End If

        If ConnToSLC = False Then
            EthernetIPforPLCSLCMicroCom1.DisableSubscriptions = True
        ElseIf ConnToSLC = True Then
            EthernetIPforPLCSLCMicroCom1.DisableSubscriptions = True
        End If
    End Sub


Sending info to any 4 of the CLX works fine but once i send to the SCL the loop usually gets hung up around step 28 and at catch ex As Exception it says "Argument 'Prompt' cannot be converted to type string". Also at startup it continually throws "A first chance exception of type 'MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException' occurred in AdvancedHMIDrivers.dll

Is there something wrong somewhere in my code or did I just find a fluke? Also sometime the code works for sending the info to the SLC but after the send my BasicLabels no longer updat themselves.
« Last Edit: January 03, 2014, 09:31:22 AM by Jesse »

Jesse

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Possible problem with EthernetSLC Driver
« Reply #1 on: January 03, 2014, 10:13:59 AM »
Whoops, Figured it out. Hopefully noone sees the error in the Sub ConnState()

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Possible problem with EthernetSLC Driver
« Reply #2 on: January 12, 2014, 08:20:00 AM »
Great example, I was looking how to do something similar!

Did changing the last '= true' to false solved it?

Jesse

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Possible problem with EthernetSLC Driver
« Reply #3 on: January 13, 2014, 06:01:19 PM »
Yup, That solved the problem