Hello Guest it is April 12, 2021, 07:23:08 PM

Author Topic: Getting familiar with macros and cant get isMoving() to return right value  (Read 360 times)

0 Members and 1 Guest are viewing this topic.

Im diving into macros in Mach3 and trying to figure out why, when I run a program just to read the state of isMoving(), it returns the wrong value. Am I missing something here? I've got the documentation open but can't find anything in there that would indicate why its reporting the wrong value.

Code: [Select]
state = isMoving()
Message "Machine Moving = " & state

This values returns a 1, even though the machine is not moving (expecting a 0).

Offline TPS

*
  •  2,102 2,102
    • View Profile
just tested here in the VB Scripter window. working here.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Thank you for your response. When I put the code in the VB Scripter window I also get the expected 0. However when I load the code in a separate file (M801.M1S) and run M801 through the MDI input, it returns a 1. It is interpreting those two methods differently, not sure why.. or maybe im not loading it properly through MDI?

Offline Graham Waterworth

*
  • *
  •  2,305 2,305
  • Yorkshire Dales, England
    • View Profile
You would normally have it in a while loop, mach3 only updates ever 50ms to 100ms or in some cases a short sleep(50) after the call helps.

While isMoving()
Sleep(10)
Wend

or

state = isMoving()
Sleep(50)
« Last Edit: May 08, 2020, 12:30:10 PM by Graham Waterworth »
Without engineers the world stops