mycnc:gantry_alignment_macro_wizard
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
mycnc:gantry_alignment_macro_wizard [2018/08/25 11:38] – skirillov | mycnc:gantry_alignment_macro_wizard [2020/01/27 15:23] – 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. | + | Gantry Alignment macro wizard helps the user to generate |
==== Method 1 ==== | ==== Method 1 ==== | ||
- | 2 sensors on each side of gantry used to find side position. The alignment procedure is described below- | + | Two sensors on each side of the gantry |
- | - CNC activates motors on both sides and moves toward | + | - CNC activates motors on both sides and moves towards |
- | - When one of the sensors is triggered, CNC control disconnects motor on this side, the 2nd motor continues to move. \\ {{mycnc: | + | - When one of the sensors is triggered, CNC control disconnects |
- | - When both sensors are triggered, motion | + | - When both sensors are triggered, |
- | - In case of sensors, | + | - 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 |
+ | {{: | ||
- Both motors are activated and move together. \\ {{mycnc: | - Both motors are activated and move together. \\ {{mycnc: | ||
- | - The machine moves out from the sensors | + | - The machine moves out from the sensors |
+ | {{mycnc: | ||
- | To generate this kind of alignment macro can be used the wizard. See below a screenshot of the Gantry Alignment | + | To generate this kind of alignment, the alignment macro will be generated by the Macro Wizard. A screenshot of the Macro Wizard |
- | {{mycnc:mycnc-wizard-gantry-align-001.png}} | + | {{:mycnc:gantry-alignment-v2-008-macro-forward.png}} |
- | On the screen we have | + | On this screen, we have: |
- | - **Axis, Direction** - Macro is generated for Y axis | + | - **Axis, Direction** - In this example, the macro will be generated for the 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 " | - **Sensor numbers** - sensor #0, #1 are used as sensors on each side of gantry, both senors are " | ||
- **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-box) while alignment to prevent | + | - **Ignore Limits while align** - If sensors #0 or #1 is used as limit sensor, then Limits should be ignored (set the check mark to ON) during the alignment |
- | - **Align while move** - Forward | + | - **Align while move** - set to Forward |
+ | - The Forward configuration works as follows: One side reaches the sensor, and the motor for that side stops, while the other side's motor continues forward until the opposite sensor is reached, then stops as well. This method is not ideal as the first initial stop is done at a high speed as the machine suddenly comes into contact with the sensor. The other method is to go Backwards, by triggering one sensor, passing that sensor on one side, then reaching the sensor on the other, and afterwards aligning the system by using the first initial sensor. This method is preferable as the alignment process is done at a lower speed, however it is not feasible if the sensors are set up right near the edge of the table, preventing the machine from moving past them (in that case, the Forward setting should be used). | ||
- **Final tuning (Motor #1 offset)** - set distance to adjust sensors | - **Final tuning (Motor #1 offset)** - set distance to adjust sensors | ||
- | - **Double check** | + | - **Double check** |
- **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 a 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: | + | - **Slow Speed** - not used for "Align while move: |
- | - **Reset work position after align** | + | - **Reset work position after align** |
- | - **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" | + | - **Generate** - to generate macro source and show it in "Macro preview" |
- | - **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, |
==== 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 |
- | The alignment procedure is described below- | + | The alignment procedure is described below in further detail: |
- CNC activates motors on both sides and moves toward the sensors. \\ {{mycnc: | - CNC activates motors on both sides and moves toward the sensors. \\ {{mycnc: | ||
- | - PLC controoler | + | - PLC controller |
- | - Motion stopped at the moment both sensors are triggered. \\ {{mycnc: | + | - Motion |
- | - PLC procedure calculates the difference between | + | - PLC procedure calculates the difference between |
- | - The second motor control temporarily disabled, the first motor only is rotated accordingly calculated adjustment | + | - The second motor control |
- | - Then the second | + | - Then, after the alignment has completed |
- | That's the plan. How to implement it? | ||
- | | + | ==== Gantry alignment code walkthrough ==== |
+ | |||
+ | For simply gantry alignments, it is largely unnecessary to edit the macro yourself, or to into much further detail beyound what's already shown in the manual above. However, if a complex gantry alignment procedure is necessary, or if you just want to understand what exactly is happening when gantry alignment is performed, here is a step-by-step description of the process: | ||
+ | |||
+ | | ||
<code C M219.plc> | <code C M219.plc> | ||
Line 82: | Line 88: | ||
</ | </ | ||
- | * PLC controller procedure | + | * PLC controller procedure |
<code C M144.plc> | <code C M144.plc> | ||
#include pins.h | #include pins.h | ||
- | // Look after INPUT_GANTRY_S1 & INPUT_GANTRY_S2 | + | // Look after INPUT_GANTRY_S1 & INPUT_GANTRY_S2 |
// Position X is stored in register #801 when sensor s1 triggered | // Position X is stored in register #801 when sensor s1 triggered | ||
// 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 |
- | // - Position difference is calculated and stored | + | // - Position difference is calculated and stored |
main() | main() | ||
Line 119: | Line 125: | ||
if (mode1==0)// | if (mode1==0)// | ||
{ | { | ||
- | if (s1!=s1_old) //if triggered now | + | if (s1!=s1_old) //if the sensor is triggered now |
{ | { | ||
| | ||
Line 130: | Line 136: | ||
if (mode2==0)// | if (mode2==0)// | ||
{ | { | ||
- | if (s2!=s2_old) //if triggered now | + | if (s2!=s2_old) //if the sensor is triggered now |
{ | { | ||
| | ||
Line 155: | Line 161: | ||
</ | </ | ||
- | The M144.plc procedure uses predefined values as the alignment sensor | + | The M144.plc procedure uses predefined values as the input pin numbers |
<code C > | <code C > | ||
#include pins.h | #include pins.h | ||
Line 177: | Line 183: | ||
</ | </ | ||
- | Actual input numbers should be defined in define file " | + | Actual input numbers should be defined in the " |
<code C pins.h> | <code C pins.h> | ||
Line 189: | Line 195: | ||
</ | </ | ||
- | You can put numbers directly | + | You can also put numbers directly |
<code C > | <code C > | ||
... | ... | ||
Line 204: | Line 210: | ||
</ | </ | ||
+ | * 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 | + | |
< | < | ||
| | ||
</ | </ | ||
- | * PLC procedure calculates the difference between | + | * PLC procedure calculates the difference between |
< | < | ||
Line 226: | Line 230: | ||
</ | </ | ||
- | * The second motor control temporarily disabled, the first motor only is rotated accordingly calculated adjustment. | + | * The second motor control |
- | + | Connect/ | |
- | - Then the second | + | Depends on external parameter (which |
- | + | ||
- | + | ||
- | + | ||
- | PLC procedure | + | |
- | + | ||
- | + | ||
- | M210 PLC procedure to connect/disconnect motor output #2 from X axis | + | |
- | If P-parameter ==0, motor disconnected, | + | |
<code C M210.plc> | <code C M210.plc> | ||
Line 254: | Line 250: | ||
parameter=0+16; | parameter=0+16; | ||
}; | }; | ||
- | | + | |
| | ||
| | ||
}; | }; | ||
- | |||
</ | </ | ||
+ | As a result, | ||
+ | * Code to disconnect the motor output #1 is **M210 P0** | ||
+ | * Code to connect the motor output #1 to axis X is **M210 P1** | ||
- | A complete macro to gantry alignment (Method #2) is shown below | + | |
+ | * 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. \\ < | ||
+ | |||
+ | A complete macro for Method #2 of the gantry alignment | ||
<code awk M139> | <code awk M139> | ||
M144 (# Set watching for GANTRY Sensors) | M144 (# Set watching for GANTRY Sensors) | ||
G91 G0 X-1000 F500 (# Move toward Gantry Sensors) | G91 G0 X-1000 F500 (# Move toward Gantry Sensors) | ||
+ | |||
+ | ( It takes time for the PLC controller to register the information in the ) | ||
+ | ( updated register # | ||
+ | ( Add 0.5 seconds pause to get all the registers updated ) | ||
+ | |||
+ | G4 P0.5 (# Pause) | ||
G10 L81 P810 Q800 (# Get offset in pulses) | G10 L81 P810 Q800 (# Get offset in pulses) | ||
Line 282: | Line 289: | ||
</ | </ | ||
+ | ==== Method 2+ ==== | ||
+ | |||
+ | What should be changed if the Gantry alignment procedure is required for another axis (for example, axis Y instead of X)? | ||
+ | |||
+ | 1) Let's say Motor outputs #0 and #1 are configured as Y. | ||
+ | |||
+ | {{mycnc: | ||
+ | |||
+ | 2) Procedure to connect both outputs to Y axis will look the following: | ||
+ | |||
+ | <code C M219.plc> | ||
+ | #include vars.h | ||
+ | main() | ||
+ | { | ||
+ | |||
+ | // | ||
+ | | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | |||
+ | 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 | ||
+ | |||
+ | |||
+ | <code C M145.plc> | ||
+ | #include pins.h | ||
+ | |||
+ | // Look after INPUT_GANTRY_S1 & INPUT_GANTRY_S2 input pins | ||
+ | // Position Y is stored in register #801 when sensor s1 is triggered | ||
+ | // Position Y is stored in register #802 when sensor s2 is triggered | ||
+ | // If both sensors triggered, then | ||
+ | // - Motion stopped | ||
+ | // - Position difference is calculated and stored into register #800 | ||
+ | |||
+ | main() | ||
+ | { | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | do | ||
+ | { | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | if (mode1==0)// | ||
+ | { | ||
+ | if (s1!=s1_old) //if triggered now | ||
+ | { | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | }; | ||
+ | |||
+ | | ||
+ | |||
+ | if (mode2==0)// | ||
+ | { | ||
+ | if (s2!=s2_old) //if triggered now | ||
+ | { | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | }; | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | |||
+ | 4) We need to fix the PLC procedure that disables the motor. Change procedure name to M211 (instead of M210) | ||
+ | |||
+ | <code C M211.plc> | ||
+ | #include vars.h | ||
+ | |||
+ | main() | ||
+ | { | ||
+ | | ||
+ | |||
+ | | ||
+ | if (connect==0) | ||
+ | { | ||
+ | parameter=15; | ||
+ | }else | ||
+ | { | ||
+ | parameter=1+16; | ||
+ | }; | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | 5) change the alignment macro to use Y axis instead of X axis | ||
+ | |||
+ | <code awk M139> | ||
+ | M145 (# Set watching for GANTRY Sensors) | ||
+ | G91 G0 Y-1000 F500 (# Move toward Gantry Sensors) | ||
+ | |||
+ | ( There is message delivery time from PLC to CNC control software) | ||
+ | ( Need to wait some time till registers #800-802 will be updated ) | ||
+ | ( Add 0.5 seconds pause to get all the registers refreshed ) | ||
+ | |||
+ | G4 P0.5 (# Pause) | ||
+ | |||
+ | G10 L81 P809 Q800 (Get offset in pulses) | ||
+ | G10 L193 P809 Q5531 | ||
+ | |||
+ | G10 L81 P810 Q809 (Copy Offset in units/mm to #810) | ||
+ | G10 L190 P810 Q805 (Add tuning offset) | ||
+ | |||
+ | M211 P0 (# OFF the second motor, the Only first motor is ON ) | ||
+ | |||
+ | G10 L190 P810 Q5022 (# Add current machine position) | ||
+ | G28.9 Y810 (# Move 1 motor to adjust) | ||
+ | |||
+ | M211 P1 (# ON the second motor, both motors are moved together) | ||
+ | |||
+ | </ | ||
mycnc/gantry_alignment_macro_wizard.txt · Last modified: 2020/01/31 14:24 by ivan