Hello Guest it is March 28, 2024, 06:39:01 AM

Author Topic: Problem with Do Until Loop  (Read 4122 times)

0 Members and 1 Guest are viewing this topic.

Problem with Do Until Loop
« on: October 21, 2008, 06:22:47 PM »
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
Re: Problem with Do Until Loop
« Reply #1 on: October 31, 2008, 08:02:45 PM »
hi, i flame cut as well as plasma cut.while i do not have such a complex macro as yours , this works for me.

i call it m777

SystemWaitFor(1005)   '  lets the z axis be jogged down manually for  preheat and start height



code"g92z0"                 'zeros the z so that the top of plate is known
While ismoving()
Wend



code"g0z.2"                      'jog up .2 inch quickly for the pierce
ActivateSignal(OUTPUT1)   'oxy pierce valve  turned on.
While ismoving()
Wend
code"g0z0"                     ' jog back down for return to part file
While ismoving()
Wend

i have a manual button that triggers oem code for resume.





Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Problem with Do Until Loop
« Reply #2 on: November 23, 2008, 11:10:00 AM »
there is no

getUserLED(821) represents Input #1.
getUserLED(822) represents Input #2.
 
in mach ULed range is from 1000-2255, same for Udros.

you 821,822 will not error out in a script, but they just dont exist, you cant set them.

scott
fun times