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

Pages: [1] 2
1
Support Questions / Re: How to handle disconnected PLC?
« on: June 28, 2017, 06:07:16 AM »
Shortly after posting this topic, I found this thread:
http://advancedhmi.com/forum/index.php?topic=1697.msg9252#msg9252

Anyway, additional advice would be appreciated.

2
Support Questions / How to handle disconnected PLC?
« on: June 28, 2017, 05:23:54 AM »
Hello
I'm doing a bit of a code that writes a string to PLC depending on the statuses read from the same PLC, Micrologix 1400.
I got the functionality that I wanted, but I have a problem, which occurs when AdvancedHMI looses connection to PLC, which I simulate by disconnecting the ethernet cable. The error message occurs, as seen in the attachment.

How can I handle this error, so that my application doesn't crash and resumes normal operation, after the PLC is reconnected?

3
Open Discussion / Re: General VB
« on: September 21, 2015, 07:55:43 AM »
So, for the sake of community I will share the follow up, although is a shame of mine. I hope someone, sometime will make use of this.  :-[

Quick intro, I developed an application based on AdvancedHMI roughly a year ago and now it required some upgrades regarding functionality. To do so, I had to write new piece of code which handled data differently than the original application. Modifications were not major, but big enough to make some room for mistakes.

As stated in post above, the problem was with saving the excel file, for which I blamed my new code and spent several days trying to fix this bug.

My "bug" has roots some six months ago, when we purchased WD Cloud and set up live auto backup feature (Cloud saves any changes to any file made on any of computers). I write to excel file every five seconds and backup software has its own agenda, collisions were bound to happen. Of course, when the file is being backed up, EPPlus can't access it.

Case closed.

4
Open Discussion / Re: General VB
« on: September 21, 2015, 03:56:00 AM »
I'm going to continue this thread, since I have a problem considering EPPlus. This application is still using AdvancedHMI 3.60.
I have a timer for 5 s, which reads data from PLC and writes it in excel file using EPPlus. After each write, I call Save(). Writing to file is successful and the data is saved, but after some various time after I start the application, I get the error (please see screenshot). Sometimes it happens after a minute or two, sometimes after cca 10 minutes. Date in the meantime is saved. Any ides what to look for?

5
Support Questions / Re: Software update
« on: July 14, 2015, 07:49:00 AM »
Since this application is working properly for months now, considering what you wrote, I think I won't be upgrading it to newer version, I'll just add the functionalities required. However, when building a new application, I'll start from the current version of AdvHMI and use parts of my code that will be applicable. This should be the best way to save on time.

6
Support Questions / Software update
« on: July 14, 2015, 02:54:14 AM »
Hello!
It has been a while since I had time and need to develop application in Advanced HMI and I was very pleased to see how much it was developed. Great job, I really like this software and I'm looking forward to using it.

Related to that, I made an application based on Advanced HMI version 3.50 over a year ago. It involved a great amount of programming (I must thank Archie again for his advice on multiple occasions) and now I must upgrade my application with new functionality. While at it, I would like to upgrade the Advanced HMI software itself, since there have been upgrade to data subscribers etc. My question is, what is the most painless way to upgrade from version 3.50 to current 3.98t? I noticed, the placement of the HMI system files in not the same in both versions, so I'm not sure how to interchange between them.

7
Open Discussion / Re: General VB
« on: October 20, 2014, 03:32:31 AM »
Problem was solved by using FromOADate on data that was read from excel file.

8
Open Discussion / Re: General VB
« on: October 17, 2014, 07:34:21 AM »
Well, I found a problem that appeared with using EPPlus instead of Excel. When exporting events in xlsx file, current date and time are logged:

Code: [Select]
GlobalVariables.worksheet_event.Cells("B" + CStr(GlobalVariables.index_event)).Value = Now()
I display event log in a separate form, using DataGridView. DataGridView is filled with this code:

Code: [Select]
                With Me.DataGridView1.Rows(Me.DataGridView1.Rows.Count - 1)
                    .Cells("id").Value = GlobalVariables.worksheet_event.Cells("A" + CStr(i)).Value
                    .Cells("vrijeme").Value = GlobalVariables.worksheet_event.Cells("B" + CStr(i)).Value 'this is the time cell
                    .Cells("dogadaj").Value = GlobalVariables.worksheet_event.Cells("C" + CStr(i)).Value
                    .Cells("objekt").Value = GlobalVariables.worksheet_event.Cells("D" + CStr(i)).Value
                End With

In DataGridiew, column B format is DateTime. When I was using excel, the values in column B were shown as e.g. "10. siječnja 2014. 13:55:14" (10th January 2014 13:55:14). When retrieving values from excel event log using EPPlus, DataGridView shows them as a number, presumably because retrieved values are in double format. I'm stuck on this, because I can't convert this value into a date.

9
Open Discussion / Re: General VB
« on: October 16, 2014, 08:58:57 AM »
Thank you Archie. I modified my code, so it doesn't use Excel any more, but EPPlus, and charting is definitely faster. I'm still testing other functions, to see how they do after conversion.

10
Open Discussion / Re: General VB
« on: October 15, 2014, 08:29:19 AM »
Sorry, missed a line when copying:

Code: [Select]
Private Sub plot_Click(sender As Object, e As EventArgs) Handles iscrtaj.Click
        Dim excel As Object = GlobalVariables.oSheet_data
        For i As Integer = 900 To 910
            Chart1.Series("Nivo VS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("C" + CStr(i)).Value / 100)
            Chart1.Series("Nivo CS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("D" + CStr(i)).Value / 100)
            Chart1.Series("Tlak CS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("E" + CStr(i)).Value)
            Chart1.Series("Protok CS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("F" + CStr(i)).Value)
            Chart1.Series("Struja CS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("G" + CStr(i)).Value)
            Chart1.Series("Želj. protok").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("H" + CStr(i)).Value)
            Chart1.Series("Snaga UV").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("I" + CStr(i)).Value)
            Chart1.Series("N. uklj. T1").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("J" + CStr(i)).Value / 100)
            Chart1.Series("N. isklj. T1").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("K" + CStr(i)).Value / 100)
            Chart1.Series("N. uklj. T2").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("L" + CStr(i)).Value / 100)
            Chart1.Series("N. isklj. T2").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("M" + CStr(i)).Value / 100)
        Next
    End Sub

Separate class to hold the variables I use throughout application:

Code: [Select]
Public Class GlobalVariables
    '**************************************************************************************************
    'declaration of variables for Excel file
    'data log
    Public Shared CellIndexRow_data As Long = 2 'prvi red je zaglavlje
    Public Shared oExcel_data As Object
    Public Shared oBook_data As Object
    Public Shared oSheet_data As Object
    '**************************************************************************************************
'** rest of variables omitted to shorten the code
End Class

On application startup, this code is performed in MainForm_Load:
Code: [Select]
        GlobalVariables.oExcel_data = CreateObject("Excel.Application")
        GlobalVariables.oExcel_data = New Excel.Application
        GlobalVariables.oExcel_data.Workbooks.Open("C:\data_Medven.xlsx")
        GlobalVariables.oBook_data = GlobalVariables.oExcel_data.Workbooks(1)
        GlobalVariables.oSheet_data = GlobalVariables.oBook_data.Worksheets(1)
        While (GlobalVariables.oSheet_data.Range("A" + CStr(GlobalVariables.CellIndexRow_data)).Value <> 0)
            GlobalVariables.CellIndexRow_data = GlobalVariables.CellIndexRow_data + 1
        End While

11
Open Discussion / General VB
« on: October 15, 2014, 08:03:06 AM »
I'm developing my applications based on AdvancedHMI, which includes a great amount of coding. Since my first touch with Visual Basic was trough AdvancedHMI, I'm still battling difficulties of writing a good code in this language. So, I would like to open this topic, which could cover some more general issues, when upgrading your own AdvancedHMI code.

As I stated in my other posts, my application logs data to excel file on a time basis. On one of my forms I have a chart, where this data should be plotted. Data is plotted by pressing a button, next to the chart. Code for the Plot button, where I read data from excel file and fill the chart series, is:

Code: [Select]
    Private Sub plot_Click(sender As Object, e As EventArgs) Handles iscrtaj.Click
            For i As Integer = 900 To 910
            Chart1.Series("Nivo VS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("C" + CStr(i)).Value / 100)
            Chart1.Series("Nivo CS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("D" + CStr(i)).Value / 100)
            Chart1.Series("Tlak CS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("E" + CStr(i)).Value)
            Chart1.Series("Protok CS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("F" + CStr(i)).Value)
            Chart1.Series("Struja CS").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("G" + CStr(i)).Value)
            Chart1.Series("Želj. protok").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("H" + CStr(i)).Value)
            Chart1.Series("Snaga UV").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("I" + CStr(i)).Value)
            Chart1.Series("N. uklj. T1").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("J" + CStr(i)).Value / 100)
            Chart1.Series("N. isklj. T1").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("K" + CStr(i)).Value / 100)
            Chart1.Series("N. uklj. T2").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("L" + CStr(i)).Value / 100)
            Chart1.Series("N. isklj. T2").Points.AddXY(excel.Range("B" + CStr(i)).Value, excel.Range("M" + CStr(i)).Value / 100)
        Next
    End Sub

B column contains data and time, other columns are data. Counter "i" is now set to fixed values, later I plan to implement to plot data according to date picker.

My problem is, plotting this way is SLOW (can't stress this hard enough). When pressing the button, plotting is performed with a speed of 1 - 2 data point per second. I log data every minute, and should be able to chart data for several days, which comes to >10000 data points per series and I have 11 series in chart. What can I do to speed up the plotting?

12
Support Questions / Re: Data Subscriber Question
« on: September 15, 2014, 08:58:30 AM »
See if this code works for you:
Code: [Select]
        Try
            Dim Result As Integer
            If Integer.TryParse(e.Values(0), Result) Then
                GlobalVariables.cs_tel = ((Result And 1) > 0)
            Else()
                MsgBox("Error in value " & v)
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Thank you Archie.

I modified my code similar to the way you suggested and it works, application continues to work normally. Also, your code suggestion is a bit more elegant than my old code.

However, there is now a new problem, I believe unrelated to data subscriber.

The setup is: two Micrologix 1400 and a PC connected via ethernet. Every PLC has a its own driver in PC application. My test was, what happens when I physically disconnect the cable connecting one PLC. First thing was, I got the error, which we now resolved. But now, when I reconnect the cable to the PLC, it seems that ethernet driver doesn't reconnect with that PLC and communication between PC and PLC cannot be continued.

13
Support Questions / Re: Data Subscriber Question
« on: September 12, 2014, 09:02:51 AM »
Hello again.

I'm using data subscriber to read data from Micrologix 1400 using ethernet driver. However, when network cable between Micrologix and PC is physically disconnected, application generates the following error (please see screenshot). You can also see the line, when error is generated. Data subscriber reads an integer from N100 file, which is then processed bit by bit.

Does anyone have suggestion how to resolve this issue?

14
Support Questions / Re: Processing signal and data in Advanced HMI
« on: December 11, 2013, 03:53:38 AM »
Works great! I have no open files left after application crash.

15
Support Questions / Re: Variable conversions
« on: December 11, 2013, 03:40:02 AM »
Hi. I had similar question. If you have your DataSubscriber in celsius where you get your data (lets call it DS_temperature), click on it, go to properties panel, click on events and double click on DataChanged event. It should take you to a sub that handles change od subscriber data. I'm going to assume that result is going in basic label, BL_fahrenheit.

Code: [Select]
Private Sub DS_temperature_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DS_temperature.DataChanged
        BL_fahrenheit.Value = CInt(DS_temperature.Value)*1.8+32
    End Sub

Pages: [1] 2