User Tools

Site Tools


mycnc:move-a-to-0

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mycnc:move-a-to-0 [2019/11/15 09:17] ivanmycnc:move-a-to-0 [2019/11/18 11:37] (current) ivan
Line 1: Line 1:
 ==== Rotate A axis to 0 position ==== ==== Rotate A axis to 0 position ====
  
-For certain applications, the A axis is programmed as endlessly rotating. Therefore, the **A** position (in both machine and program coordinates) may be specified as several thousand degrees after the G-code has completed running. An example of such behaviour can be seen in the screenshot below:+For certain applications, the A axis is programmed as being endlessly rotating. Therefore, the **A** position (in both machine and program coordinates) may be specified as several thousand degrees after the G-code has completed running. An example of such behaviour can be seen in the screenshot below:
  
 {{:mycnc:macros-m309-002.png}} {{:mycnc:macros-m309-002.png}}
  
-At the start of a new job which utilizes the A axis, the A position has to be equal to zero, therefore the axis will have to rotate to zero before starting a new job. Jogging (physical rotation) to "0" may take a long time (can be hundreds of complete turn to run). In some cases it's possible to simply reset the A axis position to zero at the end of the job run, indicating that whatever point the A axis has stopped at will be the next zero, thus saving time on the rewind process. This, however, runs into the problem of a lost orientation for the A axiswhich may then require homing. Therefore, the best way to still keep the A-axis orientation, but still save time is to reset all complete rotation turns of the A axis (360 degree), and then physically jog to the A-axis "0", retaining the previous orientation.+At the start of a new job which uses the A axis, the A position will have to be rewound back to zero before starting a new run. Jogging (physical rotation) to "0" from a large A position left over from the previous job may take a considerable time (can be hundreds of complete turn to run). In some cases it's possible to simply reset the A axis position to zero at the end of the job run, indicating that whatever point the A axis has stopped at will be the next zero, thus saving time on the rewind process. This, however, runs into the problem of losing the proper A-axis orientation which may then require homing. Therefore, the best way to keep the A-axis orientation, but still save time by foregoing the physical rewind back to zero, is to reset all complete rotation turns of the A axis (each 360 degrees), and then physically jog to the A-axis "0", retaining the previous A-axis orientation.
  
-This can be done through macro programming, using the M309 macro. All recent myCNC profiles should have the M309 macro in their Macro List. If your profile does not have the M309 macro, it is possible to add it using the macro code provided below. +This can be done through macro programming, using the M309 macro by default. All recent myCNC profiles should have the M309 macro in their Macro List. If your profile does not have the M309 macro, it is possible to add it using the code provided below. 
  
-A-axis program position value is mapped to the global variable #5044. In the macro we will: +In the macro we will: 
-  * Check if our A-position is positive +  * Check if our A-position is positive (A-axis program position value is mapped to global variable #5044)
-  * Add a code loop+
   * Check the current coordinate and subtract 360 degree if current coordinate is more than 360 degree (more than 1 full turn)    * Check the current coordinate and subtract 360 degree if current coordinate is more than 360 degree (more than 1 full turn) 
-  * Store the resulting value as the current A-axis position  +  * Enter a code loop which will continuously check if the current remaining coordinate is more than 360 degrees, and repeat the previous step if it is. 
-  * Move A-axis to "0".+  * After the coordinate is less than 360 degrees, this value will be stored as the current A-axis position  
 +  * Move A-axis to "0"
   * Add a similar branch for a situation in which we have a negative A-coordinate value.   * Add a similar branch for a situation in which we have a negative A-coordinate value.
  
 <code php M309> <code php M309>
-G90G0Z[#7020]+G90G0Z[#7020] (Lift to a safe height)
 #10=#5044 (Store A coordinate in register #10) #10=#5044 (Store A coordinate in register #10)
  
 N10 N10
-IF [#10 LT 180]  20+IF [#10 LT 180]  20 (Go to line 20 if the loop is complete)
 #10=#10-360 #10=#10-360
 JUMP 10 JUMP 10
  
 N20 N20
-IF [#10 GT -180]  50+IF [#10 GT -180]  50 (Go to line 50 if the loop is complete)
 #10=#10+360 #10=#10+360
 JUMP 20 JUMP 20
Line 33: Line 33:
 N50 N50
 G91 G0 A [-1*#10] G91 G0 A [-1*#10]
-G90 G10 L70 P0 A0 +G90 G10 L70 P0 A0 (resets machine coordinates) 
-G90 G10 L70 P#5220 A0</code>+G90 G10 L70 P#5220 A0 (resets program coordinates)</code>
  
 Below is a video which illustrates the way the M309 macro functions: Below is a video which illustrates the way the M309 macro functions:
Line 40: Line 40:
 {{youtube>-gK4bl4JZ3Q?large}} {{youtube>-gK4bl4JZ3Q?large}}
  
-The main screen of the myCNC software has a "Move A to 0" button by default, as shown in the screenshot at the top of this page. The way to add such a button to the screen is described here: [[mycnc-screen:1280_series_screen_configuration_examples#add_move_a_to_0_button_to_run_macro_with_confirmation|Add a "Move A to 0" button example]], and more information on adding buttons and on-screen elements can be found in the [[mycnc:mycnc_screen_configuration|MyCNC Screen Configuration]] manual.+The main screen of the myCNC software already has a "Move A to 0" button which uses the M309 macro by default, as shown in the screenshot at the top of this page. The process to add such a button to the screen is described here: [[mycnc-screen:1280_series_screen_configuration_examples#add_move_a_to_0_button_to_run_macro_with_confirmation|Add a "Move A to 0" button example]], and more information on adding buttons and on-screen elements can be found in the [[mycnc:mycnc_screen_configuration|MyCNC Screen Configuration]] manual. 
 + 
 +In cases where it is necessary to lift the tool to the top instead of safe height (global variable #7020), we can edit the first line to use Global Variable #5433, which is our maximum Z-axis limit, or use #5433 - 1, which will be 1 mm lower than the maximum allowable limit to prevent the machine from reaching the very top of the allowable Z-axis travel. The code in this case will look the following way: 
 + 
 +<code php M309> 
 +G90G0Z[#5433 - 1] 
 +#10=#5044 (Store A coordinate in register #10) 
 + 
 +N10 
 +IF [#10 LT 180]  20 
 +#10=#10-360 
 +JUMP 10 
 + 
 +N20 
 +IF [#10 GT -180]  50 
 +#10=#10+360 
 +JUMP 20 
 + 
 +N50 
 +G91 G0 A [-1*#10] 
 +G90 G10 L70 P0 A0 
 +G90 G10 L70 P#5220 A0 
 +</code>
  
mycnc/move-a-to-0.txt · Last modified: 2019/11/18 11:37 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki