Hi guys,
I have written a untrue Timer System for my Oxy Dwell. Oxy is critical during dwelling and I need to Extend the delay times if its not enough. So I have written a macro here, which is used in M03:
Sub Main()
Dim Delay, RT, ET, TStop, TSet, TExtend
TStop = 0.2
TSet = getUserLED(821)
TExtend = getUserLED(822)
Delay = getUserDRO(1051)
RT = Delay
ET = 0
ActivateSignal(Output1)
Do Until (RT <= (TStop)) Or (TSet = 1)
RT = RT - 0.2
ET = ET + 0.2
Call SetUserDRO( 1055, RT )
Call SetUserDRO( 1056, ET )
code "G4 P0.1"
While IsMoving()
Wend
Loop
If (TExtend = 1 And TStop = 0.2)Then
ET = ET + 0.2
Call SetUserDRO( 1055, 0 )
Call SetUserDRO( 1056, ET )
code "G4 P0.1"
While IsMoving()
Wend
End If
If (TSet = 1)Then
ET = ET + 0.2
Call SetUserDRO( 1056, ET )
End If
End Sub
1051 Recieves a Delay Value from a Custom DRO.
RT stands for Remaining Time, which is used on Custom DRO 1055.
ET stands for Elapsed Time, which is used on Custom DRO 1056.
getUserLED(821) represents Input #1.
getUserLED(822) represents Input #2.
What it does:
TStop is a value that I should Stop Counting from.
TSet is hooked up to Input 1.
TExtend is hooked up to Input 2.
Ive configured a time delay, for instance - 10 seconds, on DRO 1051.
When the M03 runs, Remaining Time will start displaying 10 seconds, Elapsed will display 0 seconds.
As it goes, RT will be minus by 0.2, and ET will be added by 0.2.
SetUserDRO 1055 and 1056 will put a new figure unto Elapsed and Remaining Time.
To make it more realistic, a 100ms delay is added unto the script.
The whole script repeats until TStop reaches 0.2, or Tset = 1(Input1 is triggered).
Set and Extend features is:
While the Timer is counting, If I press Set, the value on the Elapsed Time counted halfway will replace the old Delay Time.
If the Timer has finished counting, If I press Extend, Elapsed Time will continue to count Until I press set and the New Elapsed Time will replace the Old Delay Time.
If the Timer has finished counting, and a second delay has passed, the VB will ignore the signals from Elapsed Time and continue the next VB instruction.
I have been experimenting for weeks, argh, I still fail. Anyone can help me out?
I say thank you a zillion times in advance.
Charles