1

sometimes it may happen that MC_MoveAbsolute is called with the same current position of the axis, in this case the "done" or "busy" states cannot be used to manage the end of the function because the function must not perform any movement. I'm a newbie to these types of controls, the examples I've studied always use a state machine like this:

1: MC_MoveAbsolute .exec: = true;
  if MC_MoveAbsolute .busy then // never goes high if AxisActPos = MC_MoveAbsolute.position;
   MC_MoveAbsolute .exec: = false;
   nextStep: = 2;
end_if
2:
    if MC_MoveAbsolute.done then
          // do something

what is the best way to handle these situations?

Hyugs
  • 25
  • 4

1 Answers1

0

I normally don't use the busy bit.

1: MC_MoveAbsolute .exec: = true;
   nextStep: = 2;

2: if MC_MoveAbsolute.done then
       MC_MoveAbsolute .exec: = false;
       // do something
   end_if

The nature of the case structure is that when the step is incremented, the new code won't be executed until the next program scan. So, presuming that you are executing your MC_MoveAbsolute function block on every scan outside of the case, the done bit will be set appropriately (depending on whether motion was needed or not) before it is checked in step 2 of the case.

kolyur
  • 457
  • 2
  • 13
  • What is `MC_MoveAbsolute .exec: =`? Looks like incorrect syntax to me. May be `MC_MoveAbsolute.exec :=`? – Sergey Romanov May 04 '21 at 03:02
  • Since the platform wasn't called out in the question, I intentionally left it as-is since I was trying to emphasize the structure changes, not the syntax. With Beckhoff it should be `MC_MoveAbsolute.Execute`. – kolyur May 04 '21 at 12:04
  • Yes the code is just for example. Kolyur, your suggestion works, I saw that the done bit stays true as long as execute = true. Thank you – Hyugs May 09 '21 at 06:27