Welcome, Guest. Please login or register.
Did you miss your activation email?
August 22, 2014, 10:41:40 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  MACH3 Locks up in WHILE (IsMoving()) loop
Pages: 1 2 »   Go Down
Print
Author Topic: MACH3 Locks up in WHILE (IsMoving()) loop  (Read 3263 times)
0 Members and 1 Guest are viewing this topic.
snark
Active Member

Offline Offline

Posts: 15


View Profile
« 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.
Logged
snark
Active Member

Offline Offline

Posts: 15


View Profile
« Reply #1 on: December 30, 2011, 02:37:36 AM »

That is serialize!!!!
Logged
stirling
Global Moderator
*
Online Online

Posts: 1,757

UK


View Profile WWW
« Reply #2 on: December 30, 2011, 05:30:44 AM »

maybe post the code?
Logged
ger21
Global Moderator
*
Online Online

Posts: 3,867



View Profile WWW
« Reply #3 on: December 30, 2011, 12:59:50 PM »

If you're using 3.43.022, then try the development version.
Logged

snark
Active Member

Offline Offline

Posts: 15


View Profile
« 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
Logged
stirling
Global Moderator
*
Online Online

Posts: 1,757

UK


View Profile WWW
« 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.

Logged
snark
Active Member

Offline Offline

Posts: 15


View Profile
« 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"     
Logged
ger21
Global Moderator
*
Online Online

Posts: 3,867



View Profile WWW
« 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
Logged

snark
Active Member

Offline Offline

Posts: 15


View Profile
« 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
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
*
Offline Offline

Posts: 2,064


Briceville, TN, USA


View Profile WWW
« 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
Logged

Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
https://sites.google.com/site/sssystemsautomation/
Pages: 1 2 »   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!