Author Topic: Omron Serial Host Link connection problem  (Read 5414 times)

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Omron Serial Host Link connection problem
« on: January 05, 2017, 07:25:49 AM »
Hi All,
Happy New Year every one.

Recently i'm trying to get connected to Omron CP1-E PLC using Serial Host-Link with AdvanceHMI V3.99S. Problem is whenever i try to get connected it throws Error "No response from PLC. Ensure baudrate is correct".

The parameters on OmronSerailHostLinkCom1 is 9600,7,E,2 with node address 0, unit address 0 the same is in PLC

I've tried using serial cable with connection as 2-3-9 on PLC side with looping 4-5 and on PC side 3-2-9  as it works with HMI but with same result as displayed above

Then i got another cable connection details saying 2-3-9 with looping 4-5 and on PLC side and on PC side 2-3-5 with looping 4-6 and 7-8 tried that too but with same result

I'm confused as to weather its as problem of serial communication cable or the PLC protocol settings are wrong.

Please guide me.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Omron Serial Host Link connection problem
« Reply #1 on: January 05, 2017, 07:42:58 AM »
Is your programming software on the same PC? If so, is it completely shut down to allow AdvancedHMI to get access to the COM port?

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #2 on: January 05, 2017, 08:11:19 AM »
Hi Archie,

No my Programming software is on a different Computer.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Omron Serial Host Link connection problem
« Reply #3 on: January 05, 2017, 08:49:58 AM »
This is the RS232 cable I use for testing on the CP1H:

PC ------PLC
2---------2
3---------3
5---------9

9 pin female on PC side and 9 pin male on PLC side
No jumpers

To verify my COM settings, I use the Auto-Online of CX-Programmer to let it find the correct settings to put in AdvancedHMI
« Last Edit: January 05, 2017, 08:51:48 AM by Archie »

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #4 on: January 05, 2017, 09:43:09 AM »
Hey Archie,

Thanks for the speedy response. I'll try using Auto-Online of CX-Programmer to let it find the correct settings to put in AdvancedHMI and let you know the output.

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #5 on: January 05, 2017, 09:57:04 PM »
Hey Archie,

I've got the serial port parameters. They are Data Bit = 7,Parity = Even,Stop Bit = 2.

These parameters are same as I've set them previously.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Omron Serial Host Link connection problem
« Reply #6 on: January 05, 2017, 10:21:19 PM »
When you did the Auto-Online with CX-Programmer, was it the same PC as you are trying to run AdvancedHMI on?

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #7 on: January 06, 2017, 12:25:25 AM »
yes...

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #8 on: January 06, 2017, 12:30:54 AM »
Hey Archie,

Sorry my serial cable was cross and your diagram shows a straight one. Let me please try it out.

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #9 on: January 11, 2017, 01:02:42 PM »
Hi Archie,

I got to test the CP1-E with Serial Host Link protocol today. I've checked and double checked the cable with the diagram you specified. But I'm getting same "Check Baud Rate" error. Kindly advise.

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #10 on: January 13, 2017, 01:17:07 AM »
Hey Archie,

Thanks for the support. I finally got connected. I changed the serial wire connection

Loop in 4 & 5 on PLC side and looping 4 & 6 and 7 & 8 from pc side.

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #11 on: January 13, 2017, 01:18:31 AM »
Hey guys,

Just wanted to know how to read W0.0 and C000 i,e. Register to read and write and counter

It pops an error of header.
« Last Edit: January 13, 2017, 01:30:39 AM by aquilmustafa »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Omron Serial Host Link connection problem
« Reply #12 on: January 13, 2017, 08:01:34 AM »
What code do you have on line 191? I checked the latest version and line 191 wouldn't be able to throw that exception.

Do you have TreatAsHex property set to True?

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: Omron Serial Host Link connection problem
« Reply #13 on: January 13, 2017, 08:21:22 PM »
Hey Archie,

Yes i have enabled "TreatDataAsHex = TRUE".

The HostLinkBaseCom.vb of AdvanceHMI3.99s has a function:

Public Overrides Function BeginWrite(ByVal address As MfgControl.AdvancedHMI.Drivers.Omron.OmronPlcAddress, ByVal dataToWrite() As String) As Integer

where you will fnd the below code:

            If address.BitsPerElement = 16 Then
                Dim x(1) As Byte
                For i As Integer = 0 To dataToWrite.Length - 1
                    If m_TreatDataAsHex Then
                        Dim data As Integer
                        Try
                            data = Convert.ToUInt16(dataToWrite(i), 16)
                        Catch ex As Exception
                            Throw New MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException("Invalid hexadecimal value " & dataToWrite(i))
                        End Try
                        x(0) = CByte(data And 255)
                        x(1) = CByte(data >> 8)
                    Else
                        x = BitConverter.GetBytes(CUShort(dataToWrite(i)))
                        If address.IsBCD Then
                            '* Convert to BCD
                            x(1) = CByte(CUShort(Math.Floor(CDbl(dataToWrite(i)) / 100)))
                            x(0) = MfgControl.AdvancedHMI.Drivers.Common.CalculationsAndConversions.HexToByte(Convert.ToString(CUShort(dataToWrite(i)) - (x(1) * 100)))
                            x(1) = MfgControl.AdvancedHMI.Drivers.Common.CalculationsAndConversions.HexToByte(Convert.ToString(x(1)))
                        End If
                    End If
                    '* Bitconverter uses LittleEndian
                    '* Omron uses BigEndian, so reverse
                    dataPacket.Add(x(1))
                    dataPacket.Add(x(0))
                Next
            Else

The line in red colour is the error thrown whenever i try to write the String Values to CP1-E PLC

Apart from that i'm even unable to convert the String values read from PLC from hex to string readable format. I've written the code as below:

    Public Sub convertToString()
        Label4.Text = ""    'Label4.Text shows converted value read from PLC
        Try
            Dim st As String = Label1.Text 'Label1.Text has the hexa value read from PLC
            Dim com As String = ""
            For x = 0 To st.Length - 1 Step 2
                Dim k As String = st.Substring(x, 2)
                com &= System.Convert.ToChar(System.Convert.ToInt32(k, 16)).ToString
            Next
            'Label4.Text = Trim(com)
            Dim s(12) As Char
            s = com.ToCharArray()
            For i = 0 To s.Length - 1
            TextBox2.Text += com
            Next
        Catch ex As Exception
            'MsgBox(ex.Message)
            'Label4.Text = ex.Message
        End Try
    End Sub

The values comes to s but then i'm unable to show them in Textbox or label.


Apart from that I've buttons whose register values are W25.01, W25.02 and etc. I've tried them with buttons control of AHMI, I've tried writing them in code on button click event. But it always pops a error msg of some Header mismatch should be 2 char or something like that. I've tried using WP also instead of W but with no result.

Please Help me resolve these Problems..
« Last Edit: January 13, 2017, 08:27:44 PM by aquilmustafa »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Omron Serial Host Link connection problem
« Reply #14 on: January 13, 2017, 08:52:20 PM »
What is the complete error, you are getting? I can't find where you posted it previously. It should be something like this:

Invalid hexadecimal value xyz