Hello Guest it is April 23, 2024, 05:31:20 PM

Author Topic: How to check for a break of movement (ESC)  (Read 5223 times)

0 Members and 1 Guest are viewing this topic.

How to check for a break of movement (ESC)
« on: May 26, 2008, 08:23:26 AM »
Hi,

I'm working at a plugin for Mach3 which will implement some movement.
At the moment it is normal VBA as screen buttons but due to the size of the screenset and software maintenance it is of interest to transfer the code to a DLL/Plugin.

Everything is working fine and on the basics of the plugin-tutorial it was just a simple way to the first code (thanks to James for this nice work).

Now as an example my problem:

Code: [Select]
Code("g01x1000");
while(IsMoving())
{
  Sleep(10);
}
Code("g01x2000");
while(IsMoving())
{
  Sleep(10);
}

Now if there is ESCAPE pressed while doing the first move, this move is stopped, then the second move is done.
With VBA the whole script is stopped.

My intention is to stop the whole script as in VBA and so I need the information, if movement has been stopped by the user (or some other condition).

So my code would be
Code: [Select]
try
{
  Code("g01x1000");
  while(IsMoving())
  {
    Sleep(10);
  }
  if (MovementHasBeenEscaped())
  {
    throw (ESCAPEDMOVEMENT);
  }
  Code("g01x2000");
  while(IsMoving())
  {
    Sleep(10);
  }
}
catch(int breakcode)
{
}

So, what chance do I have to implement MovementHasBeenEscaped()?

I sought at TractoryControl, Engine an Mach4View, but until now I did'nt find a way to check for the break.

By, Steffen

Offline Leed3

*
  •  162 162
    • View Profile
Re: How to check for a break of movement (ESC)
« Reply #1 on: July 04, 2008, 01:59:28 AM »
Hi Steffen,

I don't know how to check for escape but you can test for movement by doing this:

if (! Engine->Axis[CurrentAxis].Jogging)
{
   //We are not moving so run ESCAPEMOVEMENT
}

See ShuttleWin.CPP in the SDK for more info.

Lee
 
Re: How to check for a break of movement (ESC)
« Reply #2 on: July 04, 2008, 06:13:16 AM »
Hi Lee,

But it's normal, that movement will stop (in this example at position x=1000 ;))
I',m looking for a detection of the user aborting the function.

At the moment there is a solution by the callback function Notify but the problem is, that the plugin has to be activated to get Notify.

So now I'll insert a check for he plugin to be activated with a message to the user to ativy it, it necessary.

Bye, Steffen



Re: How to check for a break of movement (ESC)
« Reply #3 on: July 07, 2008, 03:04:00 PM »
Hi,

Why not just check the current XY position and assume the move was aborted if it is not the commanded position?

-James
Re: How to check for a break of movement (ESC)
« Reply #4 on: July 07, 2008, 05:56:26 PM »
Hi,

this would be ok for my example, but not for general.

I use abstration of situations (oop), so the check for the break does not know at all, what movement has to be done.

At the moment there are two useable solutions:
-clear the error message and check if there ha arised a new message
-use the plugins notify and ensure, the plugin is active

If there would be  a way to activate a plugin by the plugin itself, it would be great.

Bye, Steffen

Hum, I believe, this is no good english, hope you understand...
« Last Edit: July 07, 2008, 05:58:36 PM by Steffen_Engel »

Offline spunk

*
  •  56 56
    • View Profile
Re: How to check for a break of movement (ESC)
« Reply #5 on: February 02, 2010, 08:28:58 AM »
I have an other issue... yet again... :-P

Want to add a counter to the escape button which goes up everytime the button is pressed...

sounds easy using brains and stuff but how do i get the "esc" button press in brain control?

Cheers