Hello Guest it is April 25, 2024, 06:44:50 AM

Author Topic: MACH3 Locks up in WHILE (IsMoving()) loop  (Read 18998 times)

0 Members and 1 Guest are viewing this topic.

Offline snark

*
  •  15 15
    • View Profile
MACH3 Locks up in WHILE (IsMoving()) loop
« on: December 30, 2011, 02:33:23 AM »
MACH3 Locks up in WHILE (Is Moving()) loop.
I have a new MACRO FUNCTION which switches to incremental MODE, moves a requested short distance. Switches back to the MODE in which it was called (Incremental or absolute) and returns to the caller. When called it locks up in the WHILE loop used to sterilize the I/O and requires, and reboot is required to restore MACH3 to running state. I have other FUNCTIONs which use the WHILE (is moving()) loop, to sterilize, that don't have problems.
None of the working FUNCTION are incremental mode. I have no explanation for what is going on. Can anyone shed light on this one?
I use WINDOWS 7 32 BIT system with 3G processor that is Miltie path.

Offline snark

*
  •  15 15
    • View Profile
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #1 on: December 30, 2011, 02:37:36 AM »
That is serialize!!!!

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #2 on: December 30, 2011, 05:30:44 AM »
maybe post the code?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #3 on: December 30, 2011, 12:59:50 PM »
If you're using 3.43.022, then try the development version.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline snark

*
  •  15 15
    • View Profile
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #4 on: December 31, 2011, 01:43:01 AM »
I am using R3.043.056
 Will run if I Comment out all WHILE LOOPS


Function Xincrement(Distance, FeedRate As Double) As Double
REM STEP X in Incremental mode
           ‘Current add mode will be retained and restored on exit
           ‘Distance sign determines direction +X -X
           ‘Distance greater than 1 will be rejected
           ' return: zero OK, -1 rejected
  Dim  contact      As Double
  Dim  ABSadd          As Integer
  Dim  CMD1, CMD2, CMD3, CMD4 as string   'COMMAND STRING BUILDIND VARS
 
  'Set up fail value
  contact =-1
IF Distance <= 1 AND Distance >= -1 then
   ABSadd = GetOEMLED(48)
  'Build Command
   CMD1 = "G31 f" &FeedRate
   CMD2 = " X" &Distance
   CMD3 = CMD1 & CMD2
   CODE  ( "G91 ")
   While (IsMoving())
      sleep (100)         
   Wend    
 
   CODE (CMD3)                   'move  inch's
   While (IsMoving())
     sleep (100)         
   Wend    
   contact = 0
   IF ABSadd = true then
     CODE ( "G90 ")
    While (IsMoving())
      sleep (100)         
     Wend    
    end if
end if
Xincrement = contact      ' Set return value
End Function

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #5 on: December 31, 2011, 05:56:25 AM »
where are you putting this code? button? macro file? other? and what actually calls it?
In general what is it you're trying to do?

Also your code has syntax errors as you've presented it, so it doesn't even run. hint: comment syntax.

Offline snark

*
  •  15 15
    • View Profile
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #6 on: January 01, 2012, 04:37:56 AM »
Currently I am testing it using #expand in a test Macro called from the VB editor. I plan to use it in a couple of Macros for some special functions.
I would use the #expand to provide access to it as I have in the test bed. I don't see the syntax error nor does the editor. I see the funny looking ' but can't explane it.

 Sub TESTER ()
  Dim Address , one, two, tmp1, tmp2  As Double
  Dim CPAccess , Cmd1 , Cmd2, Cmd3, INST As String
  Dim I1, I2 As integer
  'tmp1 = InputBox ("how far")
  'tmp2 = inputbox ("how fast")

  I1 = GetOEMled(48)
  I2 = GetOEMled (49)
    one = Xincrement(tmp1,tmp2)
    two=two
  End Sub
   
 #expand "D:\MACH3\macros\MILL_PROFILE_2\Function\Xincrement"   ' Item being tested *************
 #expand "D:\MACH3\macros\MILL_PROFILE_2\Function\SETUL"
 #expand "D:\MACH3\macros\MILL_PROFILE_2\Function\CmdCall"
 #expand "D:\MACH3\macros\MILL_PROFILE_2\Function\RESET_LABELS"     

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #7 on: January 01, 2012, 07:56:26 AM »
You shouldn't need the Sleep(100) and the extra set of ()
so instead of    

While (IsMoving())
sleep (100)        
Wend    

try

While IsMoving()
Wend

Also,

CODE ( "G90 ")

can be written as
Code "G90"

Everything after the ' is a comment
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline snark

*
  •  15 15
    • View Profile
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #8 on: January 01, 2012, 08:30:25 AM »
My script runs fine if I  run it from a button script. It seems that I/O doesn't work well when executed from the VB  editor, I am sure everybody but  me knew that, but I really know it now and I will never forget it.

What I was doing may be confusing, After involving everybody I will share a little bit. When I feel I have need for a new function. I break it up into primitive functions. Debug the primitive functions, and then fit them together to form the complex. If all the small pieces work it is not hard to get rest to work together so, some complated function can be implemented quickly usually. The primitives are encapsulated and keep in libraries to be used in other projects, The simpler they are the more offten you can use them.
TX fer all the help.
Bill

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: MACH3 Locks up in WHILE (IsMoving()) loop
« Reply #9 on: January 01, 2012, 08:55:24 AM »
do this:

change: While(IsMoving())  to: While IsMoving()    'don't forget to put the WEnd

scott
fun times