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 - qwideman

Pages: [1] 2 3
1
Tips & Tricks / Re: More than just PLCs
« on: October 07, 2014, 05:14:09 PM »
This looks like fun! Thanks a lot for your hard work. Hopefully I can use the RTU driver after I finish this project.

This driver should be useful for school/education demos - Where the student can see possibilities immediately, without first having to know how to program the PLC.

2
I'd like to run a subroutine whenever my PLC connection causes an error. I'm using Modbus TCP/IP.

I have tried:
 
Sub Comm_error(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModbusTcpCom.ComError
Msgbox...etc
End Sub

This does not execute, even if I set ModbusTcpComm to an address other than my PLC.


How should I be doing this?

Quinton
Rolan Inc.

3
Feature Request / Re: Idea for a new somewhat complicated control
« on: January 29, 2014, 01:19:26 PM »
...I haven't been on the AdvancedHMI project in a bit (waiting for ModbusRTU driver) but it seems to me I recall doing that. If you already can code to a database, u might be able to code this in VB, all u need is to use a "chart object". It works something like "chart1.plotpoint(x,y)" but I don't recall the actual instruction for it.

Quinton

4
Open Discussion / Re: dijital panel meter show not value
« on: January 13, 2014, 01:35:46 PM »
Not sure,

Did you try address 40002 first? 44002 may be too big.

Quinton

5
Feature Request / Re: Request a MODBUS over RS232 driver
« on: December 20, 2013, 03:06:32 PM »
Can't wait to see this. Does anyone know if its out yet?

Quinton
Rolan

6
Support Questions / Re: Communication with DELTA PLC
« on: December 03, 2013, 05:01:47 PM »
Archie's indicated that he'll come out with an RS232 Modbus driver for this, so yes - soon.

see http://advancedhmi.com/forum/index.php?topic=180.0


Quinton Wideman
Rolan Inc.

8
Support Questions / Re: Line chart
« on: October 23, 2013, 02:13:42 PM »
That shouldn't be too complicated, but you will need to write some code.
It doesn't take too long to learn to use a bit of VB...

First, using AdvancedHMI controls, make sure you have the correct MODBUS addresses (this took me some time - PLCs vary widely)
Basically you need to set up several datasubscribers, when there is a change you update your graph:

Private Sub DataSubscriber2_DataChanged(ByVal sender As System.Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged,DataSubscriber2.DataChanged, DataSubscriber3.DataChanged, DataSubscriber4.DataChanged
'This fires an event every time your data changes. Use this space to update your graph.
End Sub

Hope this gets you started.

Quinton Wideman
Rolan Inc





9
BINGO!

Thanks Archie!


10
I am getting an error at:
Transactions(e.TransactionNumber And 255) "Index was outside the bounds of the array."
Code: [Select]
   If Transactions(e.TransactionNumber And 255) IsNot Nothing Then
            Transactions(e.TransactionNumber).ErrorReturned = True
        Else
            MsgBox(e.ErrorMessage)
        End If
in ModbusTcpipComm.vb

What does this mean? This is on a form with 1 ModbusTcpipComm object, 2 DataSubscribers, 12 AdvancedHMI Controls and a picturebox.

EDIT: Each pipe has a property set to "PLC" which is what I named the "ModbusTcpComm1"...  There are a lot of pipes, but less than 50. Are these interfering? I can't change the CommComponent for a pipe without it reverting automatically...

Any help would be much appreciated.

Quinton Wideman

11
Thank you! That works great and is a lot neater. I didn't realize that I could add a Comm Driver directly to my class, so I was using my class to read a value from a DataSubscriber.

Now I would just use

Code: [Select]
Me.m_ComComponent.Read(40100)

Will this command cause interference? Are there any cases, such as simultaneous "reads" that would cause an error where a DataSubscriber might automatically prevent an error?


Thanks again!
Your reply explains a few things for me, I should look at vb in more depth.

Quinton

12
I think I'm getting this.

In my class (which has no form associated with it) I added a DataSubscriber as a property. Now myclass.thedatasubscriber.plcaddressvalue can be equal to = myclass.modbusoffset + myclass.plcaddress

It looks promising at this point; if someone has advice for me on style, feel free to let me know. I'm not totally sure if I can explain what Archie meant by "a hard-coded reference to an external instance".  Are  (thisinstance.property = 7 and thatinstance.property = 4) examples of that?
I eliminated the function readPLC when I couldn't get it working.



EDIT: Its working for me now. Thanks Archie.

13
I appreciate your advice. I'll try to brush up on my technique later, but I'd like to see this working for now.


I know I can do this
Code: [Select]
Me.PLC.Read(40100)  'line A
from class "Mainform"

But I can't do this:
Code: [Select]
MainForm.PLC.Read(40100) 'line B
from my second class. If I comment "line B", I don't get the error. If I replace "line B" with "Return 100", it will happily return the value of 100.
So it seems to me that for some reason my instance of the second class isn't communicating with the ModbusTcpComm on MainForm.

PS: Yes, my driver's synchronizing property is set to mainform.  I'm still not understanding it, but I might be able to design a workaround.
      (Basically I made a class with custom functions for one register in the PLC: I can assign .name .address .emailalertsenabled .location_of_csv_file_to_save_to and etc. properties. I also wanted a function in this class that was supposed to read the value from the PLC. That way I could name each instance and read the current value from a function: temperature.currentvalue, pressure.currentvalue etc.)



Quinton Wideman
Rolan Inc



14
Ok... that makes sense. I made those changes, but still some difficulty. Now I have :

Code: [Select]
    Dim asd As New secondclass

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Me.IsHandleCreated = True Then
            Timer1.Enabled = False
            BackgroundWorker1.RunWorkerAsync()
        End If
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        'MsgBox(Me.PLC.Read(40100))
        MsgBox(asd.readPLC(40100))
    End Sub
End Class
Public Class secondclass

    Public Function readPLC(ByVal address As UInteger)
        Return MainForm.PLC.Read(address)
    End Function

End Class


It still doesn't work, same error. I realize that I wouldn't have to use the second class to do this, but this is just a small part of my code, and I want to use this class for multiple objects in my program. I know that the commented line works, but I want to make use of the second class for testing purposes. Can you please explain?

15
I'm getting the following error: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."at line 612 of ModbusTcpComm and I haven't been able to get rid of it. I am trying to monitor the PLC using a "backgroundworker" component on a  form that I want to keep minimized most of the time. However, that form should show a progressbar to indicate that the program is running. There may be a better approach for what I am trying to do, I'm open.

Regardless, I would like to know what I did wrong.
I got rid of unnecessary parts, and now I have just one form, with a ModbusTcpComm component (PLC), and a Background worker on it.



' I added the following code at the bottom of MainForm.vb. Notice that this contains an "End Class", which replaces the one that's there.   

Code: [Select]

 Dim asd As New secondclass

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
        BackgroundWorker1.RunWorkerAsync()
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        MsgBox(asd.readPLC(40100))
    End Sub
End Class

Public Class secondclass
    Public Function readPLC(ByVal address As UInteger)
        Return MainForm.PLC.Read(address)
    End Function
End Class

Any help would be much appreciated!

Thanks,
Quinton Wideman
Rolan Inc

Pages: [1] 2 3