hexagon logo

Runtime script with inexplicable results...

I have a function in my scripts to calculate the runtime in seconds for a program, using the Timer value from windows, which returns the current time as seconds from midnight.

The blue code is my script run at the beginning of a part program. The red code is what is run at the end. (I've cut and pasted these sections from the scripts...they are too long.) In the event that a program runs through midnight, I have a section in the red code to correctly calculate runtime. I've tested this code in the excel editor while resetting my computer clock to 11:59 PM and running it through midnight, and it works. Unfortunately, this code does not work when running PC-DMIS through midnight. I get program times of more than 86400.

Any ideas why this is not calculating correctly only when run through PC-DMIS?

[COLOR="Blue"]Sub Main()

Dim BeforeTime As String
BeforeTime = Timer
BeforeTime = CLng(BeforeTime)

End Sub[/COLOR]

[COLOR="Red"]
Sub Main()

Dim Aftertime As String
Aftertime = Timer
Aftertime = CLng(Aftertime)
Dim RunTime As String

If Aftertime < BeforeTime Then
RunTime = (86400 - BeforeTime) + Aftertime
Else
RunTime = Aftertime - BeforeTime
End If

End Sub[/COLOR]
  • Code:

    Sub Main()

    Dim BeforeTime As String
    BeforeTime = Timer
    BeforeTime = CLng(BeforeTime)

    End Sub


    Sub Main()

    Dim Aftertime As String
    Aftertime = Timer
    Aftertime = CLng(Aftertime)
    Dim RunTime As String

    If Aftertime < BeforeTime Then
    RunTime = (86400 - BeforeTime) + Aftertime
    Else
    RunTime = Aftertime - BeforeTime
    End If

    End Sub

    I've always had to place brackets around the complete formula err for:

    RunTime = ((86400 - BeforeTime) + Aftertime)

    However I'm using 3.5MR2
  • Tried using other data types than strings?
  • Nope. I'll try that and the parentheses, too. Thanks for the suggestions, guys.
  • Do you need to know the runtime in the PCDMIS porngram itself?
  • Yes, that is what this does. I do it through a begin and end script because I have operator inputs at the beginning and end of a program, and I want to track the time the PROGRAM runs. I have a separate bit in the same endscript that tracks how long it took for the operator to enter his queries after the program actually finishes. I think you were going to suggest another method of tracking program time, and this is why I haven’t done it like the examples elsewhere on the board.

    With the script, I export a txt file with a ton of information each program run, and I pull a lot of data into excel and use pivot tables and charts to track variables such as: Runtime, machine number, delay time, whether the probe crashed or missed during a program execution, number of dimensions out of tolerance, serial number, part number, operator number, operation number, etc….

    This allows me to very easily evaluate everything that goes through the CMM. I can see what part goes through the CMM the most, what part always shows bad because of an incorrect program tolerance, where we are losing time because an operator is always away from the machine when a program ends, how much of the day is spent on tooling vs part measurement, etc.
  • Ok... I do the same thing on some of my customer's parametric programs. It is mostly for me for debugging purposes and also to tell what programs they ran, how often, etc... A customer can also tell if they cancel a program, run a tip cal, if they let a CMM sit waiting for operator entry, didnt measure parts when they said they did, didnt measure the correct number during a shift.

    I do not bring any of it back into the measurement software though, it is all written to a CSV file and then if I need to analyze the run time or whatever, I open in excel and do the time deltas in excel.

    Each activity is a separate time stamp in the CSV file. Each program start, each stop, etc.... I have entries to show what each time stamp means. Program path and file name to make sure they ran the correct program. Each entry begins with the date and time, that is followed by the reason, then the other misc information.
  • Yeah pretty much the same thing! I don't go to quite as much depth, as far as probe calibration or if an operator cancels out.

    The stats are passed into .txt files at the beginning script and read back into the end script, and only variables needed for the report header are passed back to PC-DMIS.
  • This is what I use...

    Sub Main
    Dim AssetNumber As String
    Dim AssetLocation As String
    Dim PCDiLocation As String

    Dim StartDate As String
    Dim StartTime As String

    StartDate = Format(Date, "Short Date")
    StartTime = Format(Time, "Short Time")

    Open "c:\temp\CMMInit.txt" For Input As #1
    Input #1, PCDiLocation, AssetNumber, AssetLocation
    Close #1

    Open "c:\CMMAvail.txt" For Append As #1
    Print #1, AssetNumber & "," & AssetLocation & ",1," & StartDate & "," & StartTime
    Close #1

    End Sub


    I know what my average cycle time is for setting up and running a part program is. I just want to know if the machine is being use effectively.
  • Just as a note....when you start tracking this stuff in-depth, things really start popping out. Things you never thought were a problem. Trends over months can be observed, and you can really start to tweak things to get the CMM running optimally. It's the next leap forward if you have the desire to improve. (And don't have datapage, you cheap bastards...)
  • Do you need to know the runtime in the PCDMIS porngram itself?


    Sunglasses