exec.codesync issue

If you have a question about the software please ask it here.

exec.codesync issue

Postby girogiri » Fri Jul 01, 2022 12:18 pm

Hello,

can somebody explain why this code, executed in a macro, gives unexpected movements if stop button is pressed during execution?
Doesn't matter if after every line we put "while(exec.IsMoving()){}"

Code: Select all
exec.Codesync("G53 y400");
exec.Codesync("G53 x400");


No problems if we use exec.Codelist or simply exec.code
Is there a documentation that explain the differences between exec.Code, exec.Codesync and exec.Codelist?

thanks Giorgio
girogiri
 
Posts: 35
Joined: Fri Jun 19, 2020 2:50 pm

Re: exec.codesync issue

Postby ger21 » Fri Jul 01, 2022 3:56 pm

You're macro should monitor the status of the stop button, and exit the macro if it is pressed.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: exec.codesync issue

Postby girogiri » Mon Jul 04, 2022 7:28 am

Hi Ger,

thanks for your reply,
you say I should check "macrostopped" on every single line of code?
Anyway there is a macrostopped after those two lines of code.
The problem is that as soon as i press stop while executing the first G53 the machine goes crazy and moves at G0 ( even if it was in G1) in unpredictable positions before stopping, you can only Reset, stop is not working anymore.
Same thing doesn't happen if we use exec.codelist or exec.code. We were suggested by Deszoe to use codesync or codelist.
It's not nice when a 1000kg machine moves at G0 in a way you cannot predict.
Anybody knows the difference in terms of behavior between the three instructions: code/codesync/codelist?

thanks
in advance.
girogiri
 
Posts: 35
Joined: Fri Jun 19, 2020 2:50 pm

Re: exec.codesync issue

Postby dezsoe » Mon Jul 04, 2022 10:00 am

As Ger wrote, you should check for stop after each Codesync. To be clear:

- Codelist runs the whole list as a g-code file: if you press stop then the execution is stopped.
- Code runs only one sentece of code.
- Both Codelist and Code check for stop first and if it was pressed then return without running the code. This means that after a stop no more Codelist or Code will be executed.
- Codesync clears the stop flag when you call it and only after this executes the code.

This is what happens: you stop the first Codesync, but don't check for stop state, so the next Codesync will start from a not finished movement.

The advantage of how Codesync works is if you want to clear the stop state then you simply call exec.Codesync("").

Code and Codesync can be handy for lazy probrammers, however, if you control something complex with direct outputs then it creates a lot of trouble. Imagine a tool changer macro which is stopped: the spindle does not move to the required position, but opens the chuck...

Always check for stop condition.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: exec.codesync issue

Postby girogiri » Wed Jul 06, 2022 8:16 am

Dezsoe,
thanks for your kind reply, now it's clear.
Is there an updated manual with these informations? ( the latest we found is ver. 1.2110)
These problems arise from the lack of detailed documentation and proper customer support ( I wrote you 3 emails asking for paid support and didn't get any reply)
For a professional user is a real pain to have to dig the forum to have answers.

thanks again
Giorgio
girogiri
 
Posts: 35
Joined: Fri Jun 19, 2020 2:50 pm

Re: exec.codesync issue

Postby girogiri » Tue Jul 12, 2022 5:28 pm

Dezsoe ..... forget my previous message: it's not clear ;-)

we changed most of the exec.codesync into exec.codelist and we check for stop everywhere, well some g-codes in the codelist are skipped and I don't understand why. ( the macro was not stopped during execution)
here is a function inside a macro, in this case G31 is non executed at all and after the very first g53 in the codelist, the machines moves in x/y with "FeedrateFast":

Code: Select all
public double Probing(int mode, double x_offset = 0, double y_offset = 0){
   if (mode == (int)Probe_type.FIXED){
      if(!exec.Ismacrostopped()){
         exec.Codesync("G53 G0 Z"+ safeZ);
         while(exec.IsMoving()){}
      }
      
      if(!MoveRak((ushort)Command_rak.OPEN)){
         return probe_alarm_num;
      }
      
      code.Clear();
      code.Add("G53 G0 X" + Convert.ToString(cones[0,0] + x_offset)  + "Y" + Convert.ToString(cones[0,1]+ y_offset));
      code.Add("G31 Z" + Zmin + "F" + FeedrateFast); // Do the Z probing with Fast feedrate first
      code.Add("G91 G0 Z" + Retract_for_second_measurement);
      code.Add("G90");
      // Second touch
      code.Add("G31 Z" + Zmin + "F" + FeedrateSlow); // Do the Z probing again with Slow Feedrate to get a more accurate reading
      exec.Codelist(code);
      while(exec.IsMoving()){}
      
      
      double Z = exec.GetZmachpos();
      if(!exec.Ismacrostopped()){
         exec.Codesync("G53 G0 Z"+ safeZ);
         while(exec.IsMoving()){}
      }
      
      if(exec.Ismacrostopped()){
         return probe_alarm_num;
      }
      
      return Z;
   }
   return probe_alarm_num;
}

.....
....
#Events
...
List <String> code = new List <String>();
...






Then we went for a SUPERconservative way, in this case it almost works, the problem is that the second G31 sometimes is not executed at "FeedrateSlow" but at "FeedrateFast"

Code: Select all
public double Probing(int mode, double x_offset = 0, double y_offset = 0){
   if (mode == (int)Probe_type.FIXED){
      if(!exec.Ismacrostopped()){
         exec.Codesync("G53 G0 Z"+ safeZ);
         while(exec.IsMoving()){}
      }
      
      if(!MoveRak((ushort)Command_rak.OPEN)){
         return probe_alarm_num;
      }
      
      if(!exec.Ismacrostopped()){
         exec.Codesync("G53 G0 X" + Convert.ToString(cones[0,0] + x_offset)  + "Y" + Convert.ToString(cones[0,1]+ y_offset));
         while(exec.IsMoving()){}
      }
      
      if(!exec.Ismacrostopped()){      
         exec.Codesync("G31 Z" + Zmin + "F" + FeedrateFast); // Do the Z probing with Fast feedrate first
         while(exec.IsMoving()){}
      }
      
      if(!exec.Ismacrostopped()){
         exec.Codesync("G91 G0 Z" + Retract_for_second_measurement);
         while(exec.IsMoving()){}
      }
      if(!exec.Ismacrostopped()){
         exec.Codesync("G90");
      }

      // Second touch
      if(!exec.Ismacrostopped()){
         exec.Codesync("G31 Z" + Zmin + "F" + FeedrateSlow); // Do the Z probing again with Slow Feedrate to get a more accurate reading
         while(exec.IsMoving()){}
      }
            
      double Z = exec.GetZmachpos();
      if(!exec.Ismacrostopped()){
         exec.Codesync("G53 G0 Z"+ safeZ);
         while(exec.IsMoving()){}
      }
      
      if(exec.Ismacrostopped()){
         return probe_alarm_num;
      }
      
      return Z;
   }
   return probe_alarm_num;
}


Can you please tell what's wrong?
Last but not least, would you please explain in terms of thread execution the differences between code/codesync/codelist?
thanks Giorgio
girogiri
 
Posts: 35
Joined: Fri Jun 19, 2020 2:50 pm


Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 30 guests