User Tools

Site Tools


mycnc:gantry_alignment_macro_wizard

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
Next revisionBoth sides next revision
mycnc:gantry_alignment_macro_wizard [2018/08/25 13:26] skirillovmycnc:gantry_alignment_macro_wizard [2019/10/24 14:49] ivan
Line 1: Line 1:
 ===== Gantry Alignment ===== ===== Gantry Alignment =====
  
-Gantry Alignment macro wizard helps to generate macro for dual motor gantry alignment. There can be several methods for gantry alignment. Almost any of method can be implemented by (advanced) user through macro/PLC layer. We can offer methods for gantry alignment.+Gantry Alignment macro wizard helps to generate the macro for dual motor gantry alignment. There exist several possible methods for gantry alignment. Almost any method can be implemented by the (skilled) user through the macro/PLC layer. We can offer two such common methods for gantry alignment.
  
 ==== Method 1 ==== ==== Method 1 ====
  
-2 sensors on each side of gantry used to find side position. The alignment procedure is described below-  +2 sensors on each side of the gantry are used to find the side position. The alignment procedure is as follows:  
-  - CNC activates motors on both sides and moves toward the sensors. \\ {{mycnc:configuration:gantry-alignment-001.png?300}} \\ +  - CNC activates motors on both sides and moves towards the sensors. \\ {{mycnc:configuration:gantry-alignment-001.png?300}} \\ 
-  - When one of the sensors is triggered, CNC control disconnects motor on this side, the 2nd motor continues to move. \\ {{mycnc:configuration:gantry-alignment-002.png?300}} \\ {{mycnc:configuration:gantry-alignment-003.png?300}} \\  +  - When one of the sensors is triggered, CNC control disconnects the motor on that side, while the 2nd motor continues to move. \\ {{mycnc:configuration:gantry-alignment-002.png?300}} \\ {{mycnc:configuration:gantry-alignment-003.png?300}} \\  
-  - When both sensors are triggered, motion stopped. \\ {{mycnc:configuration:gantry-alignment-004.png?300}} \\ +  - When both sensors are triggered, the motion stops. \\ {{mycnc:configuration:gantry-alignment-004.png?300}} \\ 
-  - In case of sensors, the position should be adjusted at this point can be setup move of 1 motor to given adjustment distance.+  - It is important to note that the sensors do not have to be perfectly aligned on the same line - they can be placed wherever it is convenient, provided that the offset distance between them is recorded. This distance will be then adjusted for by myCNC.
   - Both motors are activated and move together. \\ {{mycnc:configuration:gantry-alignment-005.png?300}} \\   - Both motors are activated and move together. \\ {{mycnc:configuration:gantry-alignment-005.png?300}} \\
-  - The machine moves out from the sensors for given distance. {{mycnc:configuration:gantry-alignment-006.png?300}}+  - The machine moves out from the sensors for a predefined distance. {{mycnc:configuration:gantry-alignment-006.png?300}}
  
-To generate this kind of alignment macro can be used the wizard. See below screenshot of the Gantry Alignment Wizard+To generate this kind of alignment, the alignment macro will be generated by the Macro Wizard. See below the screenshot of the Gantry Alignment Wizard screen:
 {{mycnc:mycnc-wizard-gantry-align-001.png}} {{mycnc:mycnc-wizard-gantry-align-001.png}}
  
-On the screen we have +On this screenwe have:
   - **Axis, Direction** - Macro is generated for Y axis   - **Axis, Direction** - Macro is generated for Y axis
   - While alignment machine moves toward Y-MIN   - While alignment machine moves toward Y-MIN
   - **Sensor numbers** - sensor #0, #1 are used as sensors on each side of gantry, both senors are "Normally Closed"   - **Sensor numbers** - sensor #0, #1 are used as sensors on each side of gantry, both senors are "Normally Closed"
   - **Use Encoder Z signals for align** - not used   - **Use Encoder Z signals for align** - not used
-  - **Ignore Limits while align** - If sensors #0 or #1 is used as limit sensor, then Limits should be ignored (put check-boxwhile alignment to prevent abort procedure.+  - **Ignore Limits while align** - If sensors #0 or #1 is used as limit sensor, then Limits should be ignored (set the check mark to ONduring the alignment procedure to prevent the machine from aborting the procedure once the limit sensors are triggered.
   - **Align while move** - Forward   - **Align while move** - Forward
   - **Final tuning (Motor #1 offset)** - set distance to adjust sensors   - **Final tuning (Motor #1 offset)** - set distance to adjust sensors
   - **Double check** (to be described later)   - **Double check** (to be described later)
   - **Move distance** Distance expected from start position to alignment sensors. This distance should be set a more than real distance to alignment sensors.   - **Move distance** Distance expected from start position to alignment sensors. This distance should be set a more than real distance to alignment sensors.
-  - **Gap** - move out from the sensors for given distance. +  - **Gap** - move out from the sensors for given distance. 
-  - **Speed** - speed for motion toward the sensors +  - **Speed** - speed for the motion toward the sensors 
-  - **Slow Speed** - not used for "Align while move:Forward" method. +  - **Slow Speed** - not used for "Align while move:Forward" method (this would be the speed on the backwards movement)
-  - **Reset work position after align** +  - **Reset work position after align** allows the work position to be set to the alignment position after the procedure has been completed. 
-  - **Macro filename** - File name to ave macro source to file.+  - **Macro filename** - File name to save the macro source to file.
  
 To generate and save macro (As usual for the Macro wizard) 3 buttons should be pressed To generate and save macro (As usual for the Macro wizard) 3 buttons should be pressed
-  - **Save** (top-right corner - to save macro wizard settings and use them for future macro generate +  - **Save** (top-right corner - to save macro wizard settings and use them for future macro generation) 
-  - **Generate** - to generate macro source and show it in "Macro preview" window. If Generate button pressed, new macro is shown ONLY in the preview window and is not activated !! At this point, auser can manually edit the macro source in **Macro preview** window +  - **Generate** - to generate macro source and show it in "Macro preview" window. If the Generate button is pressed, the new macro is shown ONLY in the preview window and is not activated !! At this point, the user can manually edit the macro source in **Macro preview** window 
-  - **Save Macro** - save macro from **Macro preview** for the macro file with the name given in **Macro filename**, then reload all macros to CNC memory.+  - **Save Macro** - save macro from the **Macro preview** for the macro file with the name given in **Macro filename**, then reload all macros to CNC memory.
  
  
-Gantry Alignment procedure either can work simultaneously as a homing procedure (if the alignment sensor is used as a homing sensor as well), or Homing procedure can be run just after gantry alignment procedure.+Gantry Alignment procedure either can work simultaneously as a homing procedure (if the alignment sensor is used as a homing sensor as well), or, alternatively, the Homing procedure can be run just after gantry alignment procedure has taken place.
  
 ==== Method 2 ==== ==== Method 2 ====
  
-2 sensors on each side of gantry used to find each side positions. When both sensors actual positions found, CNC control moves the only side to get the gantry aligned.+2 sensors on each side of gantry can used to find each respective side position. When both sensorsactual positions are found, CNC control moves only one side (using only one motor) to get the gantry aligned.
  
 The alignment procedure is described below-  The alignment procedure is described below- 
  
   - CNC activates motors on both sides and moves toward the sensors. \\ {{mycnc:configuration:gantry-alignment-010.png?300}} \\    - CNC activates motors on both sides and moves toward the sensors. \\ {{mycnc:configuration:gantry-alignment-010.png?300}} \\ 
-  - PLC controoler procedure latches machine positions at the moment every sensor is triggered. \\ {{mycnc:configuration:gantry-alignment-011.png?300}} \\  +  - PLC controller procedure records machine positions at the moment that each respective sensor is triggered. \\ {{mycnc:configuration:gantry-alignment-011.png?300}} \\  
-  - Motion stopped at the moment both sensors are triggered. \\ {{mycnc:configuration:gantry-alignment-012.png?300}} \\ +  - Motion is stopped at the moment both sensors are triggered. \\ {{mycnc:configuration:gantry-alignment-012.png?300}} \\ 
-  - PLC procedure calculates the difference between latched positions and add an adjustment offset +  - PLC procedure calculates the difference between the recorded positions and adds an adjustment offset (if such an offset exists between the sensors) 
-  - The second motor control temporarily disabled, the first motor only is rotated accordingly calculated adjustment \\ {{mycnc:configuration:gantry-alignment-013.png?300}} \\ +  - The second motor control is then temporarily disabled, while the other motor moves the machine by the necessary distance to align the gantry \\ {{mycnc:configuration:gantry-alignment-013.png?300}} \\ 
-  - Then the second  motor control is activated again and both motors moved together \\ {{mycnc:configuration:gantry-alignment-014.png?300}} \\+  - Then, after the alignment has completed the second  motor control is activated again and both motors moved together to move out by the set distance \\ {{mycnc:configuration:gantry-alignment-014.png?300}} \\
  
-That's the plan. How to implement it? Here is step-by-step implementation description.+That's the plan, but how do we implement it? Here is step-by-step implementation description.
  
-  * CNC activates motors on both sides and moves toward the sensors. \\ Actually both motors for the gantry should be configured in "Axes/Motors" configuration widget by default. Howeverextra M-code can be used to be sure both motors are turned on. For example, M219.plc connects axis X to both motor output #0 and #1 +  * CNC activates motors on both sides and moves toward the sensors. \\ NOTE: While both motors for the gantry alignment procedure should be already configured in the Axes/Motors tab in the myCNC Settings by default, additional M-code can also be used to make sure that both motors are turned on and ready to go before starting the procedure. This is done in situations where one of the motors might have been turned off previously due to triggering one of the sensors/limits, which would lead to issues when the gantry procedure would attempt to perform the alignment with only one motor being operational. For example, M219.plc connects axis X to motor outputs #0 and #1 
  
 <code C M219.plc> <code C M219.plc>
Line 82: Line 82:
 </code>  </code> 
  
-  * PLC controller procedure latches machine positions at the moment every sensor is triggered. For this example, we use procedure M144.plc written specially for the example. Any other implementation can be used as well+  * PLC controller procedure records the machine positions at the moment of each respective sensor being triggered. For this example, we use the M144 PLC procedure (written specially for this example). Any other implementation can be used as well
  
 <code C M144.plc> <code C M144.plc>
Line 91: Line 91:
 // Position X is stored in register #802 when sensor s2 triggered // Position X is stored in register #802 when sensor s2 triggered
 // If both sensors triggered, then  // If both sensors triggered, then 
-//  - Motion stopped +//  - Motion will be stopped 
-//  - Position difference is calculated and stored into register #800+//  - Position difference is calculated and stored the register #800
  
 main() main()
Line 119: Line 119:
  if (mode1==0)//if sensor 1 wasn't triggered  if (mode1==0)//if sensor 1 wasn't triggered
  {  {
-  if (s1!=s1_old) //if triggered now+  if (s1!=s1_old) //if the sensor is triggered now
    {    {
      mode_12=mode_12|1; //set flag for sensor1      mode_12=mode_12|1; //set flag for sensor1
Line 130: Line 130:
  if (mode2==0)//if sensor 2 wasn't triggered  if (mode2==0)//if sensor 2 wasn't triggered
  {  {
-  if (s2!=s2_old) //if triggered now+  if (s2!=s2_old) //if the sensor is triggered now
    {    {
      mode_12=mode_12|2; //set flag for sensor2      mode_12=mode_12|2; //set flag for sensor2
Line 155: Line 155:
 </code> </code>
  
-The M144.plc procedure uses predefined values as the input pin numbers the alignment sensors connected to+The M144.plc procedure uses predefined values as the input pin numbers that the alignment sensors are connected to.
 <code C > <code C >
 #include pins.h #include pins.h
Line 177: Line 177:
 </code> </code>
  
-Actual input numbers should be defined in define file "pins.h". The content of "pins.h" file should be included at the start of each macro. If using this programming style, the "pins.h" is the single file you need to edit to customize your input/output assignments. +Actual input numbers should be defined in the "pins.h" file (Settings > Config > PLC > Hardware PLC > pins.h). The content of the "pins.h" file should be included at the start of each macro. If using this programming style, the "pins.h" is the single file you need to edit to customize your input/output assignments (as you will be referring to this file in all your other macros)
 <code C pins.h> <code C pins.h>
  
Line 189: Line 189:
 </code> </code>
  
-You can put numbers directly to portget/portset functions of PLC source (however, we don't recommend this). It will look like this +You can also put numbers directly into portget/portset functions of PLC source (however, we don't recommend this). It will look like this
 <code C > <code C >
 ... ...
Line 204: Line 204:
 </code> </code>
  
 +  * Motion is stoppped at the moment that both sensors are triggered. This is implemented in the M144.plc procedure.
  
-  +The PLC sends message to the Motion controller to end the current motion and jump to the next line of the G-code
-  * Motion stopped at the moment both sensors are triggered. This is implemented in the M144.plc +
- +
-PLC sends message to the Motion controller to end the current motion and jump to the next g-code line+
 <code> message=PLCCMD_MOTION_SKIP; <code> message=PLCCMD_MOTION_SKIP;
  timer=2;do{timer--;}while(timer>0);  timer=2;do{timer--;}while(timer>0);
 </code> </code>
  
-  * PLC procedure calculates the difference between latched positions and adds an adjustment offset. This is implemented in M144.plc as well+  * PLC procedure calculates the difference between the recorded positions and adds an adjustment offset (if one exists). This is implemented in the M144.plc procedure as well:
  
 <code> <code>
Line 226: Line 224:
 </code> </code>
  
-  * The second motor control temporarily disabled, the first motor only is rotated accordingly calculated adjustment. +  * The second motor control is temporarily disabled, while the first motor only is rotated accordingly calculated adjustment. 
  
 Connect/disconnect Axis X from motor output pin is implemented in the M210.plc procedure. Connect/disconnect Axis X from motor output pin is implemented in the M210.plc procedure.
Line 254: Line 252:
  
 As a result,  As a result, 
-  * Code to disconnect motor output#1 is **M210 P0** +  * Code to disconnect the motor output #1 is **M210 P0** 
-  * Code to connect motor output#1 to axis X is **M210 P1**+  * Code to connect the motor output #1 to axis X is **M210 P1**
  
  
-  * Then the second motor control is activated again and both motors moved together. \\ G-code G28.9 can be used to move axis accordingly register value. \\ <code>G28.9 X810 (# Move X coordinate to the position stored in register #810)</code>+  * Then the second motor control is activated again and both motors moved together. \\ G-code G28.9 can be used to move the axis according to the register value. \\ <code>G28.9 X810 (# Move X coordinate to the position stored in register #810)</code>
  
- +A complete macro for Method #2 of the gantry alignment is shown below:
- +
- +
-A complete macro to gantry alignment (Method #2is shown below+
 <code awk M139> <code awk M139>
 M144                  (# Set watching for GANTRY Sensors) M144                  (# Set watching for GANTRY Sensors)
Line 290: Line 285:
 ==== Method 2+ ==== ==== Method 2+ ====
  
-What should be changed if Gantry alignment procedure needed for other axis (for example axis instead of X)+What should be changed if the Gantry alignment procedure is required for other axis (for exampleaxis instead of X)?
  
-1) Let's say Motor outputs #0 and #1 configured as Y.+1) Let's say Motor outputs #0 and #1 are configured as Y.
  
 {{mycnc:configuration:mycnc-gantry-005.png}} {{mycnc:configuration:mycnc-gantry-005.png}}
  
-2) Procedure to connect both outputs to Y axis will look as+2) Procedure to connect both outputs to Y axis will look the following:
  
 <code C M219.plc> <code C M219.plc>
Line 324: Line 319:
  
  
-3) Need to change PLC procedure that looks after sensors to store Y position instead of X.+3) We need to change the PLC procedure that monitors the sensors to store Y position instead of X.
 Change procedure name to M145.plc Change procedure name to M145.plc
  
Line 332: Line 327:
  
 // Look after INPUT_GANTRY_S1 & INPUT_GANTRY_S2 input pins // Look after INPUT_GANTRY_S1 & INPUT_GANTRY_S2 input pins
-// Position Y is stored in register #801 when sensor s1 triggered  +// Position Y is stored in register #801 when sensor s1 is triggered  
-// Position Y is stored in register #802 when sensor s2 triggered+// Position Y is stored in register #802 when sensor s2 is triggered
 // If both sensors triggered, then  // If both sensors triggered, then 
 //  - Motion stopped //  - Motion stopped
Line 400: Line 395:
  
  
-4) Fix disable motor PLC procedure. Change procedure name to M211 (instead of M210)+4) We need to fix the PLC procedure that disables the motor. Change procedure name to M211 (instead of M210)
  
 <code C M211.plc> <code C M211.plc>
Line 430: Line 425:
 G91 G0 Y-1000 F500    (# Move toward Gantry Sensors) G91 G0 Y-1000 F500    (# Move toward Gantry Sensors)
  
-It takes a time PLC controller from M144 procedure sends +There is message delivery time from PLC to CNC control software
-updated register #800,#801,#802 values to myCNC control software +Need to wait some time till registers #800-802 will be updated 
-( Add 0.5 seconds pause to get all the registers updated )+( Add 0.5 seconds pause to get all the registers refreshed )
  
 G4 P0.5               (# Pause) G4 P0.5               (# Pause)
mycnc/gantry_alignment_macro_wizard.txt · Last modified: 2020/01/31 14:24 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki