Hello Guest it is October 31, 2024, 07:53:58 PM

Author Topic: Simple pause for testing macros  (Read 4160 times)

0 Members and 1 Guest are viewing this topic.

Offline Jeff_Birt

*
  •  1,107 1,107
    • Soigeneris
Simple pause for testing macros
« on: September 10, 2008, 02:26:30 PM »
I needed to create a pause in a macro to test that a plug was receiving a flag that indicated spindle mode. Basically at the start of the tool change macro M6Start, a flag is lowered to signal that the spindle drive should switch to tool change mode. After all the tool change stuff takes place the flag is raised to signal run mode. I just needed a way to add a delay between the flag states to test that the plug-in was handling the flags properly. I searched for a pause command but did not find anything so I whipped up the following and thought it might be helpful to others. Please note having a pause in a macro like this, while useful for testing, is a bad idea in production code.

  DeActivateSignal(17)
 
  tool = GetSelectedTool()
  SetCurrentTool( tool )

  Dim TS As Single ' Start time
  Dim ET As Single ' Elapsed time
  Dim waiting As Boolean ' loop flag
 
  TS = Timer ' current time in seconds
  waiting = true ' we start out waiting
 
  While waiting
    ET = Timer
    If ET > TS + 30 Then ' the "30" is the # seconds delay
       waiting  = false
    End If
  Wend
 
  ActivateSignal(17)
Happy machining , Jeff Birt
 

Offline Bodini

*
  •  216 216
Re: Simple pause for testing macros
« Reply #1 on: September 10, 2008, 04:36:59 PM »
Jeez, I feel like I'm reading this wrong but... "G4 p30"?