Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - DougLyons

Pages: [1]
1
Support Questions / ModbusTCPCom Write Bit Failure
« on: August 25, 2016, 07:45:41 PM »
I am using AHMI Version 3.99n which I believe is the latest. I started with adding a ModbusTCPCom driver to the form.
Then I added a DigitalPanelMeter and set its PLCAddress value to 40001. Then I added a MomentaryButton and set its PLCAddressClick to 40001.0.
When I run this program, clicking on the button makes no change to the value in 40001 when it is zero.
If I set it to 1, then clicking the button has no effect until it is released and then the value goes to zero. Using ModRSsim2 I can see the following debug information.

Original Value of zero at beginning:
Button Press: In=0000 And=FFFF Or=0001 Out=0000
Button Release: In=0000 And=FFFE Or=0000 Out=0000

Original Value of one at beginning:
Button Press: In=0001 And=FFFF Or=0001 Out=0001
Button Release: In=0001 And=FFFE Or=0000 Out=0000

It seems that in the case of the Button Press, the And value should be FFFE like it is in the Button Release.

Also, I noticed that if I delete the DigitalPanelMeter and run the program there is no polling or communications at all.
Nothing is sent to the server (ModRSsim2) at all when the button is pressed or released.

Thanks for any help that you can provide.

2
Support Questions / Modbus TCP Driver Failure in 3.84 & 3.85
« on: December 01, 2014, 08:25:16 AM »
Archie,

I have not been able to make the ModbusTcpCom driver work with only a Digital Panel Meter for the 40001 register in version 3.84 or 3.85. I also tested registers 40002-40005 and these failed the same way.

The message at the top of the display shows the following:

INVALID VALUE RETURNED!Illegal Modbus Address

This happens regardless of what value I put into the registers.

Thanks for any help that you can provide.

3
Feature Request / Using Modbus Register Bits in Controls
« on: November 15, 2014, 10:36:02 AM »
Hi Archie,

It would be really great if you could accommodate some of the Modbus community on this.
The ability to address a Modbus Register Bit where you need a Boolean in the controls would be nice.
It was actually fairly easy to do in version 3.70, but now in 3.80 the PLCAddress has moved inside the driver.
This means that it is not as easy to handle the PLCAddress to set up polling and then decode the bits of the data.

For Example on the BasicIndicator if the PLCAddressSelectColor2 could contain "40001.1" to use Bit 1.
This could be extended to all of the 16 bits with the highest being accessed using "40001.16".
I have been able to make this work by modifying the PolledDataReturned and adding a BitTest.
Unfortunately it fails when the bit number goes beyond one digit, so 10, 11, ..16 do not work.

Here is my code to show you want I was trying to do:

Code: [Select]
    Private Sub PolledDataReturned(ByVal sender As Object, ByVal e As SubscriptionHandlerEventArgs)
        If e.PLCComEventArgs.ErrorId = 0 Then
            Try
                Dim TempValue As Boolean
                '* Write the value to the property that came from the end of the PLCAddress... property name
                If e.SubscriptionDetail.PLCAddress.IndexOf(".") = 5 And _
                    Val(Mid(e.SubscriptionDetail.PLCAddress, 6)) > 0 And _
                    sender.ToString.ToUpper.IndexOf("MODBUS") >= 0 Then
                    TempValue = BitTest(e.PLCComEventArgs.Values(0), _
                    Val("&H" & Mid(e.PLCComEventArgs.PlcAddress, 7)))
                    Me.GetType().GetProperty(e.SubscriptionDetail.PropertyNameToSet). _
                        SetValue(Me, Convert.ChangeType(TempValue, _
                        Me.GetType().GetProperty(e.SubscriptionDetail.PropertyNameToSet).PropertyType), Nothing)
                Else
                    Me.GetType().GetProperty(e.SubscriptionDetail.PropertyNameToSet). _
                                SetValue(Me, Convert.ChangeType(e.PLCComEventArgs.Values(0), _
                                Me.GetType().GetProperty(e.SubscriptionDetail.PropertyNameToSet).PropertyType), _
                                Nothing)
                End If
            Catch ex As Exception
            DisplayError("INVALID VALUE RETURNED!" & e.PLCComEventArgs.Values(0))
        End Try
        Else
        DisplayError("Com Error. " & e.PLCComEventArgs.ErrorMessage)
        End If
    End Sub
    Private Function BitTest(Number As Long, bit As Integer) As Boolean
        If bit = 16 Then
            BitTest = ((Number < 0) * -1.0)             ' Bit 16 (High Bit)
        Else
            BitTest = ((Number And 2 ^ (bit - 1)) <> 0) * -1
        End If
    End Function

I know that my code is not the best, but you should be able to make any necessary changes easily.

It appears that if you changed the internals of the driver to accept Modbus addresses from 5-8 characters this would work.
I have attached a copy of the output showing the error when using the high bit.

Is it possible that you could change the driver to allow this syntax?
If that were the case, then it would be easy to start adding the additional code to handle this one control at a time.
The code above actually works fine for bits 1 through 9 on the BasicIndicator and seems to prove the concept.

Also, I attempted to use Hex values such as "40001.A", but this caused errors as well.
I have attached a screen capture showing this.

Thanks for all of your work on this project. It is always impressive to me to see it grow.

Pages: [1]