mycnc:gantry_alignment_macro_wizard
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
mycnc:gantry_alignment_macro_wizard [2018/08/25 13:26] – skirillov | mycnc:gantry_alignment_macro_wizard [2020/01/31 14:05] – 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 |
+ | |||
+ | The following video goes over this manual: | ||
+ | |||
+ | {{youtube> | ||
==== 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 |
+ | |||
+ | |||
+ | ==== Gantry alignment code walkthrough ==== | ||
- | That's the plan. How to implement it? Here is step-by-step | + | For simply gantry alignments, it is largely unnecessary to edit the macro yourself, or to into much further detail beyound what' |
- | * CNC activates motors on both sides and moves toward the sensors. \\ Actually | + | * CNC activates |
<code C M219.plc> | <code C M219.plc> | ||
Line 82: | Line 92: | ||
</ | </ | ||
- | * PLC controller procedure | + | * PLC controller procedure |
<code C M144.plc> | <code C M144.plc> | ||
Line 91: | Line 101: | ||
// 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 129: | ||
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 140: | ||
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 165: | ||
</ | </ | ||
- | 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 |
<code C > | <code C > | ||
#include pins.h | #include pins.h | ||
Line 177: | Line 187: | ||
</ | </ | ||
- | 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 199: | ||
</ | </ | ||
- | You can put numbers directly | + | You can also put numbers directly |
<code C > | <code C > | ||
... | ... | ||
Line 204: | Line 214: | ||
</ | </ | ||
+ | * 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 234: | ||
</ | </ | ||
- | * The second motor control temporarily disabled, the first motor only is rotated accordingly calculated adjustment. | + | * The second motor control |
Connect/ | Connect/ | ||
Line 254: | Line 262: | ||
As a result, | As a result, | ||
- | * Code to disconnect motor output#1 is **M210 P0** | + | * Code to disconnect |
- | * Code to connect motor output#1 to axis X is **M210 P1** | + | * Code to connect |
- | * Then the second motor control is activated again and both motors moved together. \\ G-code G28.9 can be used to move axis accordingly | + | * 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 | |
- | + | ||
- | + | ||
- | A complete macro to gantry alignment (Method #2) is shown below | + | |
<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 a time PLC controller | + | ( It takes time for the PLC controller |
( updated register # | ( updated register # | ||
( Add 0.5 seconds pause to get all the registers updated ) | ( Add 0.5 seconds pause to get all the registers updated ) | ||
Line 274: | Line 279: | ||
G4 P0.5 (# Pause) | G4 P0.5 (# Pause) | ||
- | G10 L81 P810 Q800 (# Get offset in pulses) | + | G10 L81 P809 Q800 (Get offset in pulses) |
- | G10 L192 P810 Q5531 (# Calculate offset in units/mm) | + | G10 L193 P809 Q5531 |
- | G10 L190 P810 Q805 (# Add adjustment | + | G10 L81 P810 Q809 (Copy Offset in units/mm to #810) |
+ | G10 L190 P810 Q805 (Add tuning | ||
M210 P0 (# OFF the second motor, the Only first motor is ON ) | M210 P0 (# OFF the second motor, the Only first motor is ON ) | ||
Line 290: | Line 296: | ||
==== Method 2+ ==== | ==== Method 2+ ==== | ||
- | What should be changed if Gantry alignment procedure | + | What should be changed if the Gantry alignment procedure |
- | 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: | {{mycnc: | ||
- | 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 330: | ||
- | 3) Need to change PLC procedure that looks after sensors to store Y position instead of X. | + | 3) We need to change |
Change procedure name to M145.plc | Change procedure name to M145.plc | ||
Line 332: | Line 338: | ||
// 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 406: | ||
- | 4) Fix disable motor PLC procedure. Change procedure name to M211 (instead of M210) | + | 4) We need to fix the PLC procedure |
<code C M211.plc> | <code C M211.plc> | ||
Line 430: | Line 436: | ||
G91 G0 Y-1000 F500 (# Move toward Gantry Sensors) | G91 G0 Y-1000 F500 (# Move toward Gantry Sensors) | ||
- | ( It takes a time PLC controller | + | ( There is message delivery |
- | ( updated register | + | ( Need to wait some time till registers |
- | ( Add 0.5 seconds pause to get all the registers | + | ( Add 0.5 seconds pause to get all the registers |
G4 P0.5 (# Pause) | G4 P0.5 (# Pause) | ||
- | G10 L81 P810 Q800 (# Get offset in pulses) | + | G10 L81 P809 Q800 (Get offset in pulses) |
- | G10 L192 P810 Q5531 (# Calculate offset in units/mm) | + | G10 L193 P809 Q5531 |
- | G10 L190 P810 Q805 (# Add adjustment | + | G10 L81 P810 Q809 (Copy Offset in units/mm to #810) |
+ | G10 L190 P810 Q805 (Add tuning | ||
M211 P0 (# OFF the second motor, the Only first motor is ON ) | M211 P0 (# OFF the second motor, the Only first motor is ON ) | ||
- | G10 L190 P810 Q5021 (# Add current machine position) | + | G10 L190 P810 Q5022 (# Add current machine position) |
G28.9 Y810 (# Move 1 motor to adjust) | G28.9 Y810 (# Move 1 motor to adjust) | ||
- | M210 P1 (# ON the second motor, both motors are moved together) | + | 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