AdvancedHMI Software
General Category => Support Questions => Topic started by: BLFTech on June 09, 2015, 11:48:18 AM
-
I am testing the ModbusTCP driver with the Automation Direct PAC 3000 controller. I can write a float value with the basic label but the value it reads back is a random number. I added the F prefix on both Modbus addresses as needed for float values.
-
Try various combinations of byte swap and word swap settings on the driver.
-
That did not fix the issue. When I first run the App it briefly shows the correct value and then shows a very large number. Reading bits and longs work OK.
-
Does it occur if you have just 1 BasicLabel on the form?
-
Yes, it does.
-
I meant to say yes, it works correctly with only one label.
-
I only have a Modbus simulator to test with and I am not able to reproduce this. I'm fairly sure I know what is causing the problem. After the initial reads, the driver will group together reads to make things more efficient. The first read shows the correct number, but after they are grouped, something is not parsed correctly.
To test this, open ModbusBase.vb and go to line 470
((SubscriptionList(index + ItemCountToGroup + 1).Address.Element + SubscriptionList(index + ItemCountToGroup + 1).Address.NumberOfElements) - SubscriptionList(index).Address.Element) < 20
At the end of the line, change that 20 to a 1
-
After changing it to 1 it works correctly.
-
This gives me an idea of about where the problem is. I'll dig more into this.
-
Here is something else to try...
- Make sure that value of 20 is set back to 20
- In ModbusBase.vb, go to line 581
ValueIndex = Convert.ToInt32((SubscriptionList(i).Address.Element - Requests(TNSByte).Element) / 2 + index)
- Comment out that line
-
After doing these changes the label displays 0 and does not change. It still allows me to write to the tag.
-
What addresses are you using that cause the problem? I'll see if I can replicate using the same addresses.
-
I am reading a long from 400001-400002 and reading a float from 400003-400004
-
That's got me going in the right direction. My long is ok, but my float is not good.
-
ModbusBase.vb Line 467, change to this:
While (index + ItemCountToGroup + 1) < SubscriptionList.Count AndAlso _
SubscriptionList(index + ItemCountToGroup).Address.ReadFunctionCode = SubscriptionList(index + ItemCountToGroup + 1).Address.ReadFunctionCode AndAlso _
SubscriptionList(index + ItemCountToGroup).Address.BitsPerElement = SubscriptionList(index + ItemCountToGroup + 1).Address.BitsPerElement AndAlso _
((SubscriptionList(index + ItemCountToGroup + 1).Address.Element + SubscriptionList(index + ItemCountToGroup + 1).Address.NumberOfElements) - SubscriptionList(index).Address.Element) < 20 AndAlso
SubscriptionList(index + ItemCountToGroup).Address.Address.Substring(0, 1).ToUpper = SubscriptionList(index + ItemCountToGroup + 1).Address.Address.Substring(0, 1).ToUpper
-
It was line 467 in my code (version 3.98n) and when I replaced the current code it fixed the issue. I will continue testing. Thanks
-
Line 467 was right. It was my typo.