Change in macro behavior in 1.2031?

Post anything you want to discuss with others about the software.

Re: Change in macro behavior in 1.2031?

Postby cncdrive » Thu Jan 12, 2017 3:29 pm

Yes, and G33.1/2 and G76 and G31.

These and the other motion condes the G0, G1, G2, G3. required the while ismoving already, because if the motion did not stop before executing a new movement code already could cause issues in previous versions of the software also. The issue was that then the new macro exec.Code movement took the current point coordinates while still in movement, so then that new movement command moved the currently not moving axis to the wrong coordinates. Uhh, hard to explain. :)
This is one reason why multiply exec.Code calls can't be used for CV calculated movements and this is why the exec.Codelist function was introduced which function can do that.

Why the F code did not cause a problem in earlier versions and now in the new version it became a problem is because the macro starts up and executes faster is the F feedrate setting code.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Change in macro behavior in 1.2031?

Postby ger21 » Thu Jan 12, 2017 3:42 pm

Do you have an example on how to use exec.Codelist?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Change in macro behavior in 1.2031?

Postby cncdrive » Thu Jan 12, 2017 3:59 pm

Yes, there is one in the macro capability detailed document in the /Documentation folder of the UCCNC.
I'm copying the example below:

Function: void Codelist(List<string> codelist)
Description: This function is similar to the Code function, but it executes not only a single, but multiply lines of g-codes from inside a macro. The g-code lines are sent as a string List in the parameter of the function and are interpreted in execution time. This function differs from calling multiply Code functions, because the Codelist function loads all the code lines the same time into the motion control API, so the lines are optimised by the Constant velocity interpolator while the multiply Code function calls are executed one-by-one separately.
Example:
List<string> codelist = new List<string>(); //Create a new List of strings.
codelist.Add("G0 Z-25"); //Add g-code lines to the List.
codelist.Add("M3");
codelist.Add("G1 X0 Y0 F500");
codelist.Add("#5 = 12.23");
codelist.Add("G1 X#5 Y2");
exec.Codelist(codelist); //Execute the List of g-codes.


How it works is simple, you create a List of strings and you add the code lines to the list and finally pass the list as parameter to the exec.Codelist function.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Change in macro behavior in 1.2031?

Postby ger21 » Thu Jan 12, 2017 4:15 pm

Thank You.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Change in macro behavior in 1.2031?

Postby A_Camera » Thu Jan 12, 2017 7:26 pm

cncdrive wrote:Yes, there is one in the macro capability detailed document in the /Documentation folder of the UCCNC.
I'm copying the example below:

Function: void Codelist(List<string> codelist)
Description: This function is similar to the Code function, but it executes not only a single, but multiply lines of g-codes from inside a macro. The g-code lines are sent as a string List in the parameter of the function and are interpreted in execution time. This function differs from calling multiply Code functions, because the Codelist function loads all the code lines the same time into the motion control API, so the lines are optimised by the Constant velocity interpolator while the multiply Code function calls are executed one-by-one separately.
Example:
List<string> codelist = new List<string>(); //Create a new List of strings.
codelist.Add("G0 Z-25"); //Add g-code lines to the List.
codelist.Add("M3");
codelist.Add("G1 X0 Y0 F500");
codelist.Add("#5 = 12.23");
codelist.Add("G1 X#5 Y2");
exec.Codelist(codelist); //Execute the List of g-codes.


How it works is simple, you create a List of strings and you add the code lines to the list and finally pass the list as parameter to the exec.Codelist function.


This is great! So we only need to define the code list once and inside the same macro just call the list any number of times like this:

List<string> codelist = new List<string>(); //Create a new List of strings.
codelist.Add("G0 Z-25"); //Add g-code lines to the List.
codelist.Add("M3");
codelist.Add("G1 X0 Y0 F500");
codelist.Add("#5 = 12.23");
codelist.Add("G1 X#5 Y2");

... some lines of macro code ...

exec.Codelist(codelist); // First execution the List of g-codes

... some more lines of macro code ...

exec.Codelist(codelist); // Second execution the List of g-codes

...and so on.

Very useful. Right now I am busy writing probe macro codes, and in some of them I need to repeatedly add the same code, but with this new feature that's simply done. Makes the code nicer looking. Just one question... do we need while(exec.IsMoving()) or is that included in the exec.Codelist(codelist)? It would be nice if it was included... ;)
A_Camera
 
Posts: 639
Joined: Tue Sep 20, 2016 11:37 am

Re: Change in macro behavior in 1.2031?

Postby cncdrive » Thu Jan 12, 2017 8:37 pm

Hi Josef,

Yes, you can execute the same list of codes any time.
Also you can add more lines of g-codes (strings) to the list any time and you can also clear the list any time.
Some informations, the functions of the List class: https://msdn.microsoft.com/en-us/librar ... 9(v=vs.110).aspx
And some examples and descriptions of the List class usage in C#: https://www.dotnetperls.com/list

The code in the list which you pass to the exec.Codelist function are all executed and passed to the motion control API in one piece,
so the movements fill the motion buffer and the CV planner optimises the path if in G64 CV mode.

If you need a while Ismoving check after it depends on what you doing after the list of codes in your macro.
What the while ismoving is doing is it waits while there is motion ongoing.
If there is more motion commands after the Codelist movements then it is recommended to wait until they finishes, so in most cases the while ismoving is needed.
Otherwise the same issue can happen in the next motion commands what I previously described, that the currently moving and in later command not moving axis will get their current coordinates while there is still motion which will cause a wrong movement on those axis in the next movement commands if there is no wait for the motion to end before executing the next exec.Code or next exec.Codelist command.
But this was worked the same in earlier versions also, there is no change about how this works.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Previous

Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: No registered users and 32 guests