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.


Messages - DougLyons

Pages: 1 ... 3 4 [5]
61
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.

62
Support Questions / Data Subscriber Question
« on: November 01, 2014, 12:22:25 PM »
Based on my testing of version 3.80 the extra Data Changed event that caused the double entries is now fixed.
Congratulations on a Job Well Done.

Thanks for giving us Advanced HMI.

63
Support Questions / Changing colors by bit
« on: October 28, 2014, 01:36:35 AM »
MrPike, The "Picturebox.Show" is not a recommended method to use. See this link from Microsoft:
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.controls.picturebox.show.aspx

I believe that you should be using the "PictureBox.Visible = True" and "PictureBox.Visible = False" methods to do this.
The problem with using the Show method is that you must balance it with the Hide method when the bit turns off.
This is accounted for in the code that I suggested because the typical "(Value1 and Number)" evaluates to True or False.
This True or False is then applied to the Visible property, so you have the balance here.

If I take your example it might be modified as follows:

 If LabelX.text = 1 then
   PictureBoxX.Show
 Else
   PictureBoxX.Hide
 End if

Also, if you are setting multiple bits at one time you have to be very careful about the Z-ordering of the overlapping boxes.
Previously in this discussion I saw that you had multiple bits set. Is this still the case?
If you are using a particular subset of bits then tell me how the subsets are divided and we can create masks to group them.
Can you make the code work if you use the Label bits as my example showed and then link to these?

Otherwise, if you can paste an example of your code here I can probably do more to help. Thanks.

64
Support Questions / Re: Changing colors by bit
« on: October 22, 2014, 12:10:57 AM »
Continuing from the above:

You can add statements such as the following to change the visibility of the PictureBoxes:

PictureBox1.Visible = (Value1 And 1)  ' Low Bit
PictureBox2.Visible = (Value1 And 2)
PictureBox3.Visible = (Value1 < 0)      'High Bit

65
Support Questions / Changing colors by bit
« on: October 21, 2014, 11:58:49 PM »
You can just insert 16 of the Common Controls "Label" components.
Name them Label1 to Label16 and change their TEXT to "0" for brevity.
Note that this is not the same as the "BasicLabel" AdvancedHMI Component.

Now the code below should set the corresponding bits in your value for you and display the bits on the labels.
This makes use of the fact that a comparison (? <> 0) returns a -1 if TRUE and a 0 if False.
Also, because values in BASIC are generally signed a value of greater than 32767 is returned as a negative number.

Code: [Select]
   
Dim Value1 As Long
Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        Try
            Value1 = e.Values(0)
            Debug.Print((Value1 < 0) * -1.0)
        Catch ex As Exception
            Debug.Print("Error in Reading")
        End Try
        Label1.Text = ((Value1 < 0) * -1.0)             ' Bit 1 (High Bit)
        Label2.Text = ((Value1 And 16384) <> 0) * -1
        Label3.Text = ((Value1 And 8192) <> 0) * -1
        Label4.Text = ((Value1 And 4096) <> 0) * -1
        Label5.Text = ((Value1 And 2048) <> 0) * -1
        Label6.Text = ((Value1 And 1024) <> 0) * -1
        Label7.Text = ((Value1 And 512) <> 0) * -1
        Label8.Text = ((Value1 And 256) <> 0) * -1
        Label9.Text = ((Value1 And 128) <> 0) * -1
        Label10.Text = ((Value1 And 64) <> 0) * -1
        Label11.Text = ((Value1 And 32) <> 0) * -1
        Label12.Text = ((Value1 And 16) <> 0) * -1
        Label13.Text = ((Value1 And 8) <> 0) * -1
        Label14.Text = ((Value1 And 4) <> 0) * -1
        Label15.Text = ((Value1 And 2) <> 0) * -1
        Label16.Text = ((Value1 And 1) <> 0) * -1       ' Bit 16 (Low Bit)
    End Sub

I have run this and it worked for me.
Let me know if you need more help.

66
Tips & Tricks / AdvancedHMI on a Tablet
« on: September 28, 2014, 07:32:42 PM »
Everyone,

I have also tested it on my Dell Latitude ST (Slate Tablet) running Windows 7 32-bit and it performs well. This device is no longer sold by Dell and I would not recommend it because it is normally slow to execute most applications, but the Advanced HMI runs fine on it.

It is really quite fun to be able to walk around and control the PLC from almost anywhere using the Wireless Network.
Others in my office are now jealous and may be purchasing their own tablets soon.

Thanks for a great product that is so much fun, Archie.

67
Support Questions / Re: Data Subscriber Question
« on: September 13, 2014, 02:33:42 PM »
Hello,

Regarding the duplication of data on a DataSubscriber_DataChanged event, I have done more testing.
Note that I am using Visual Studio Express 2013 with Update 3 and Patch KB2932965 (Sept. 8, 2014).
I downloaded a new version 3.70 and unzipped it to a new solution directory.
Then I added a new DF1Comm driver and added the components as you noted above.
When I changed the value using the BasicLabel, I got two Message Boxes instead of only one.
Could this be a result of the poll rate being 500 mSec?

I saw that you noted that the value change testing is done in the PolledDataReturnedValue event handler.
I went to this routine and did some testing and found that changing one statement fixes this for me.
The statement "LastValue = m_Value" can be changed to "LastValue = e.Values(0)" and now I get no duplications.
This might affect other things adversely so I was hoping that you might provide your knowledge on this here.

I am very impressed with the speed that you responded previously.
It took me a while to get set up with the SLC-5/05 to test your suggestions or I would have responded sooner.
I had been using a ControlLogix L63 and the EthernetIPforCLXCom driver previously.

Thanks again Archie for such a wonderful program.

68
Support Questions / Re: Data Subscriber Question
« on: September 10, 2014, 05:45:14 AM »
Hello,
I am new here and I have seen the same duplication with the EthernetIPforCLXCom driver.

The solution that seems to work for me is to change the code in the Component named DataSubscriber.vb
Here is where to look for this item:


Just add the four lines noted below or just replace the complete code with this.

Code: [Select]
‘DataSubscriber.vb Component
Protected Overridable Sub OnDataChanged(ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
    Static Dim Old As String                    ' Added
    If m_SynchronizingObject Is Nothing Then
        RaiseEvent DataChanged(Me, e)
    Else
        If DirectCast(m_SynchronizingObject, Control).IsHandleCreated Then
            Dim Parameters() As Object = {Me, e}
            If Old <> Me.Value Then             ' Added
                SynchronizingObject.BeginInvoke(dcsd, Parameters)
                Old = Me.Value                  ' Added
            End If                              ' Added
        End If
    End If
End Sub

This may not be the best way to handle this, but it did work for me.
Note: I am not sure how to embed images here and I have tried to attach the image as well.
Also, I know that I have not followed the normal naming conventions, so feel free to change the new variable name.

Thanks Archie for your great work.

Pages: 1 ... 3 4 [5]