Jump to content

Corey

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by Corey

  1. Three questions related to tables in DataXport.  If I have the V570 in a testing device which has programs for each product I'm testing, and each of those programs saves a separate results table (Samples_P01, Samples_P02, Samples_P03, etc.):

    • 1)  If I download a table from the PLC using DataXport, is there a way to flag it as having been received?  I don't want to download the same data again until all the results in the table have been updated with new results.
    • 2)  How can I switch to another table (which is another product's results) without stopping, editing the site, selecting the table, unselecting the previous table, and running again?  The other option I found is to create multiple sites for the same PLC, each with a different table selected.  This still requires you to stop the call log, edit the current site to uncheck enable, edit the other site to check enable, then running again.  Just as much work.
    • 3)  Is there a way to pull the table without using schedules?  I don't want the data to continuously pull every minute or hour, but rather only when the operator performed new tests.  Otherwise, I am getting the same data over and over in new CSV files.  I'd rather force a call when they need it and bypass schedules.
  2. In UniDDE, if you right click on your open project or use the menu buttons, you can copy the Read Command, Stop PLC Macro, Run PLC Macro, and Run/Stop Toggle macro.  If I have the read command in an Excel worksheet, it tries to start UniDDE.exe but fails.  Instead, I had to clear the field until the workbook is open then add the read command =UniDDE|Items!'lblDDE(1)' to the cell afterwards. 

    My second issue (the first being that I can't seem to get the UniDDE read command to automatically load the software) is that the PLC is not in Run mode.  Therefore, I try to use the code that UniDDE provides with those copy buttons.  If I use the "Run/Stop" toggle it will properly stop the PLC connection if it's already running.  If I execute that code to make it run, it will run but Excel freezes until I click escape.  I also tried the "Run PLC" macro, but it does absolutely nothing.

     

    My VBA to start the UniDDE software is below. 

    Cell F1 = "C:\Program Files (x86)\Unitronics\Unitronics DDE Server\UniDDE.exe"

    Cell F2 = "UniDDE.exe"

    Cell F3 = "U:\Display Result and Write CSV.ude"

    Sub Load_UniDDE()
        Application.StatusBar = "loading PLC application"
        
        Dim strApp, strAppShort, strFile As String
        Dim WB As Workbook
        Set WB = ThisWorkbook
        strApp = WB.Worksheets(1).Range("F1").Value
        strAppShort = WB.Worksheets(1).Range("F2").Value
        strFile = WB.Worksheets(1).Range("F3").Value
            
    
        If strApp = "" Or strAppShort = "" Then
            Application.WindowState = xlMaximized
            WB.Worksheets(1).Range("F1").Select
            
            MsgBox "Please correct the software path and process in the Excel worksheet."
        Else
            If Dir(strFile) <> "" Then
                Dim objList As Object
                
                Set objList = GetObject("winmgmts:").ExecQuery("select * from win32_process where name='" & strAppShort & "'") ' determine if the DDE app is already running
                If objList.Count = 0 Then
                    Shell strApp & " " & strFile, vbMinimizedFocus ' open the DDE app and project file
                End If
    
            Else
                Application.WindowState = xlMaximized
                WB.Worksheets(1).Range("F3").Select
                MsgBox "Please correct the project path in the Excel worksheet."
            End If
        End If
            
        Application.StatusBar = False
    End Sub

    UniDDE provides the following macros which are not working properly

    RUN PLC:
    
    Dim lchannelNumber   As Long
    
       '/ Run PLC 
       lchannelNumber = Application.DDEInitiate("UniDDE", "Items")
       Application.DDEExecute lchannelNumber, "Last Test Result_RUN"
       Application.DDETerminate lchannelNumber
    
    RUN/STOP Toggle:
    
    Dim lchannelNumber   As Long
    
       '/ Run/stop UniDDE 
       lchannelNumber = Application.DDEInitiate("UniDDE", "Items")
       Application.DDEExecute lchannelNumber, "UniDDE_RUN/STOP"
       Application.DDETerminate lchannelNumber
    

     

×
×
  • Create New...