I edited the CS-Lab macro and would like to make sure I can use the function : GetTickCount() (microsoft function ?)

The mill is an EMCO VMC-100.



'lubrication MACRO using CNC4PC C-32 -imcomplete

Const LastMsDRO = 1300 'DRO for data
Const StateDRO = 1301 'DRO for data
Dim CurrentMs As Long
Dim LastMs As Long
Dim State As Integer

'------------------------------------------------------------------------------------------------------------

Const LubeTime = 100 'Lubrication time
Const LubeWait = 200000 'Greasing interval
Const OutLubePump = OUTPUT1 'Digital output C32 oil pump

'------------------------------------------------------------------------------------------------------------

Sub Main

'Read data
'-------------------------------------------------------

'milliseconds that have elapsed since the system was started

CurrentMs = GetTickCount()
LastMs = GetUserDRO(LastMsDRO)
State = GetUserDRO(StateDRO)

If(CurrentMs < LastMs) Then
State = 0
End If

Select Case State
'Lubrication start
'-------------------------------------------------------
Case 0
ActivateSignal(OUTPUT1)
LastMs = CurrentMs
State = 1
Message"Lubrication START !!!"
Sleep(1000)
DeActivateSignal(OUTPUT2)

'Lubrication and stop
'-------------------------------------------------------
Case 1
If(CurrentMs > (LastMs + LubeTime)) Then
DeActivateSignal(OUTPUT2)
LastMs = CurrentMs
State = 2
Message"Lubrication STOP !!!"
End If

'Wait for lubrication
'-------------------------------------------------------
Case 2
If(CurrentMs > (LastMs + LubeWait)) Then
State = 0
End If

'-------------------------------------------------------
Case Else
State = 0
End Select

'Data record
'-------------------------------------------------------
SetUserDRO(StateDRO, State)
SetUserDRO(LastMsDRO, LastMs)

End



Thanks!