no I didn't realize!
Thanks for the ressource, it is what got me started!
I finally managed to finish a first version of the script. It seems to work fine, but I wonder if it could affect Mach3's normal behaviour.
What is this macro pump checkbox thing?
Right now I run the script from the script editor start button. I suits my needs, but is there a cleaner way?
Here it is
Code:
Type HighResTimer
low As Long
high As Long
End Type
Declare Function QueryPerformanceCounter Lib "Kernel32" (ByRef current As HighResTimer) As Boolean
Declare Function QueryPerformanceFrequency Lib "Kernel32" (ByRef current As HighResTimer) As Boolean
Const TimeSteps = 1000
Const Dimensions = 4
Dim positions(Dimensions,TimeSteps) As Double
Dim timestamps(TimeSteps) As Long
Dim timestamp As HighResTimer
Dim frequency As HighResTimer
Dim fileNumber As Integer
DoOEMButton(1000) 'Cycle Start
For timeStep = 0 To TimeSteps
For dimension = 0 To Dimensions
positions(dimension, timeStep) = GetDRO(dimension)
Next
If(QueryPerformanceCounter(timestamp)) Then
timestamps(timeStep) = Abs(timestamp.low)
Else
MsgBox("QueryPerformanceCounter returned false!")
End If
Sleep (10)
Next
DoOEMButton(1001) 'Cycle Pause
fileNumber = FreeFile
If Not Kill("C:\Mach3\log.txt") Then
End If
Open "C:\Mach3\log.txt" For Output As fileNumber
If QueryPerformanceFrequency(frequency) Then
Print #fileNumber, "Timer frequency: " & Abs(frequency.low) & "Hz"
End If
For timeStep = 0 To TimeSteps
For dimension = 0 To Dimensions
Print #fileNumber, positions(dimension, timeStep) & " " & timestamps(timeStep)
Next
Print #fileNumber, " "
Next
Close
MsgBox ("Succes!")