Author Topic: ModbusTCP Word swap not swapping on data write  (Read 3931 times)

brett.mckenzienz

  • Newbie
  • *
  • Posts: 3
    • View Profile
ModbusTCP Word swap not swapping on data write
« on: January 25, 2017, 05:00:34 PM »
Hi all,

I am using ver 3.99s, i see 3.99t has been released, but Archie's changelog doesn't list my issue so I haven't tried it

I have used Advanced HMI and automation direct PLCs several times, and often used floating point with them with no issue. Today I am trying to pair a Siemens S7-1200 with advanced HMI. The issue I am currently having a problem with is word swapping and floating point values.

With word swap = false in my driver settings the words are in the incorrect order when writing to the PLC (Keyboard Input tool) and also in the incorrect order when reading the value (BasicLabel)

With word swap = true in my driver settings the words are in the CORRECT order when reading from the PLC (BasicLabel) and in the INCORRECT order when writing the value to the PLC (Keyboard input tool)

If I enter a value into one of my holding registers in the PLC with the Siemens TIA software, it shows the value correctly on the HMI basiclabel. When i then attempt to write the value to the holding register with the HMI, it writes the words in reversed order, and shows the same garbage value in TIA and on the HMI basiclabel.

Thanks in advance for any help with this
Brett

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ModbusTCP Word swap not swapping on data write
« Reply #1 on: January 25, 2017, 06:28:46 PM »
I have to say that I am quite surprised this slipped through and hasn't been reported until now. The driver was ignoring the swaps when writing. I posted a patch 4 for 3.99t to see if it corrects the problem:

https://sourceforge.net/projects/advancedhmi/files/advancedhmi/3.5/Patches/

- Download and extract the driver patch 4
- Open your version 3.99t project in Visual Studio
- In Solution Explorer, expand down the AdvancedHMIDrivers project
- Right click the \support folder and select Add Existing Item
- Browse to and select the extracted patch file
- Rebuild the solution

brett.mckenzienz

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: ModbusTCP Word swap not swapping on data write
« Reply #2 on: January 25, 2017, 08:25:40 PM »
Thanks Archie for your help.

It took me a couple of attempts to get your patch running, the only success I have had is to import it into my project as 3.99s. I did migrate a version into 3.99t but that caused me some grief and once loading the patch I couldn't get anything to work.

Anyway - provided that patched .dll is the same running on v 3.99s these are the results:

Before the patch my swap bytes was true, and my swap words was true. - this is the setting where reading the value is correct, but writing is word swapped.

After patching, to READ the correct value I use Byte Swap = True, Word Swap = True.
to WRITE the correct value I use Byte Swap = False, Word Swap = True.

 I'm certain that before the patch the bytes were following the same order reading and writing as I did a word swap only in my PLC as a temporary workaround which worked well. (with byte swap = true word swap = false)

Thanks very much for your quick support

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ModbusTCP Word swap not swapping on data write
« Reply #3 on: January 25, 2017, 09:09:20 PM »
Based on that I made a Patch 5 that can be downloaded from the same place.

brett.mckenzienz

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: ModbusTCP Word swap not swapping on data write
« Reply #4 on: January 26, 2017, 12:56:33 AM »
Thanks Archie!

Works fine now. both swap settings at true reads and writes data correctly.

Another issue that came up and I cant figure out how to fix is I get this message when trying to set a PLCAddressWriteValue property in the keyboard input tool. I have used a basic label instead and I am able to set the PLC properties on that. This was the same problem I came across when trying to upgrade my 3.99s to 3.99t earlier today.

Message - "Object of type 'MfgControl.AdvancedHMI.Drivers.PLCAddressItem' cannot be converted to type 'MfgControl.AdvancedHMI.Drivers.PLCAddressItem'."

Thanks again for you exceptional service!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ModbusTCP Word swap not swapping on data write
« Reply #5 on: January 26, 2017, 09:32:08 AM »
Another issue that came up and I cant figure out how to fix is I get this message when trying to set a PLCAddressWriteValue property in the keyboard input tool. I have used a basic label instead and I am able to set the PLC properties on that. This was the same problem I came across when trying to upgrade my 3.99s to 3.99t earlier today.

Message - "Object of type 'MfgControl.AdvancedHMI.Drivers.PLCAddressItem' cannot be converted to type 'MfgControl.AdvancedHMI.Drivers.PLCAddressItem'."
This is a Visual Studio quirk when working with open source files and updating certain things. It's an easy fix:

- Window->Close All Documents
- Build->Clean Solution
- Exit Visual Studio
- Re-open the project
- Build->Rebuild Solution

abdala

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: ModbusTCP Word swap not swapping on data write
« Reply #6 on: February 10, 2017, 11:55:35 AM »
 error  ModbusRTU or BeginWrite in m_SwapBytes is True
 or
 error  ModbusRTU or BeginRead in m_SwapBytes is False

this AdvancedHMIv399t