User Tools

Site Tools


mycnc:macro_examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
mycnc:macro_examples [2017/06/14 17:38] skirillovmycnc:macro_examples [2017/09/04 12:13] skirillov
Line 1: Line 1:
-==== Rotate A axis to 0 position ====+==== Macro Examples ====
  
-For some applications A-axis is programmed as endless rotation. +  * [[mycnc:move-a-to-0|Move A to 0]]
-Program position of A may come to many hyndreds degree after G-code finished. See screenshot example below -+
  
-{{mycnc:mycnc-1280m4-001.png}} 
- 
-To start new job A position should be roll back to about "0" position. Jogging to "0" may take a long time. In some cases it's possible just reset A position, but A axis orientation will be lost. 
-The best way to substract from current A-coordinates a whole number of turns (360 degree), then move to "0". 
- 
-This can be done through macro-programming. 
- 
-We will add macro M335 to bring A axis to "0", then add a button to run the macro. 
- 
-A-axis program position value is mapped to global variable #5044. In the macro we -  
-  * Check if A-position is positive 
-  * Add a code loop,  
-  * Test in the loop A-coordinate and subtract 360 degree if current coordinate is more than 360 degree (more than 1 turn).  
-  * Store result value as current A-axis position and then  
-  * Move A-axis to "0". 
-  * Add similar branch for negative A-coordinate value. 
- 
-<code php M335>(Move to position A=0) 
-#10=#5044 (Get position A) 
- 
-if [ #10 LT 0 ] 300 (Test If A-position is negative) 
-(if positive) 
-N100 
-if [ #10 LT 180 ] 200 (Test if A-position higher than 180 degrees) 
- 
-#10 = #10 - 360 (Subtract a whole turn - 360 degree) 
-JUMP 100 (Jump to begin of the Loop) 
- 
-N200 
-JUMP 400 
- 
-N300 
-if [ #10 GT -180 ] 400 (Test if A-position lower than -180 degrees) 
-#10 = #10 + 360 (Add a whole turn - 360 degree) 
-JUMP 300 (Jump to begin of the Loop) 
- 
-N400 
-G90 G10 L70 P#5220 A#10 (store #10 value as A-axis program position) 
-G90 G0 A0 (rotate A axis to 0) 
-</code> 
- 
-[[mycnc:mycnc_setup#add_move_a_to_0_button_to_run_macro_with_confirmation|Add "move A to 0" button]] 
  
mycnc/macro_examples.txt · Last modified: 2022/03/29 15:54 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki