Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: snark on December 30, 2011, 02:33:23 AM

Title: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: snark 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.
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: snark on December 30, 2011, 02:37:36 AM
That is serialize!!!!
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: stirling on December 30, 2011, 05:30:44 AM
maybe post the code?
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: ger21 on December 30, 2011, 12:59:50 PM
If you're using 3.43.022, then try the development version.
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: snark 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
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: stirling 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.

Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: snark 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"     
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: ger21 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
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: snark 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
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: poppabear on January 01, 2012, 08:55:24 AM
do this:

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

scott
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: snark on January 01, 2012, 10:06:38 PM
I have a question, is the use of the parenthesis  invalid or redundant? (IsMoving()) <-> IsMoving()
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: stirling on January 02, 2012, 05:19:06 AM
I have a question, is the use of the parenthesis  invalid or redundant? (IsMoving()) <-> IsMoving()
It's a moot point - I'm not aware of the formal syntax diagrams being published for CB so I can only assume that CB's syntax is similar to other dialects of BASIC. With that assumption, it shouldn't actually matter because if the parentheses arn't formally part of the while syntax (as they are in C for example) then they would be parsed as a part of the expression syntax (in most BASIC dialects an expression can have an arbitrary number of balanced parentheses around it)

This is not to be confused with the fact that some dialects of BASIC have a peculiar syntax with regards to actual parameter lists. Function calls use parenthesis whereas procedure calls don't UNLESS preceded by the CALL keyword. CB doesn't appear to care!

Meanwhile...

I don't see the syntax error nor does the editor. I see the funny looking ' but can't explane it.
The funny looking ` as you put it IS the syntax error. The comment char in CB is '. You can ignore it if you like but I find it interesting that this is the second time in a week where W7 has been reported to have failed to catch a syntax error that XP succeeds in catching. If an interpreter fails to catch a syntax error then personally I would not trust it after that. Your problem may have more to do with this anomaly than you might think.
Title: Re: MACH3 Locks up in WHILE (IsMoving()) loop
Post by: snark on January 02, 2012, 05:36:37 PM
The Macro in the Macro Library has ' for comment. I am unable to find the displayed charactor on my keyboard and I am sure that I struck the ' key when I entered the code. Is there a way to display the Hex  value of the charactor in the listing. I would expect a different responce when attempting to run, if the comment hadn't been recognized and the editor were to try to execute the comment as code.

Point being: I think the problem is with the web browser and not the editor. Otherwise I can't explane it. 'C  'D  'c  ' d