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
Last revisionBoth sides next revision
mycnc:gantry_alignment_macro_wizard [2018/08/26 10:45] skirillovmycnc: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. We can offer 2 methods for gantry alignment.+Gantry Alignment macro wizard helps the user to generate a program 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, and the Macro Wizard is used to facilitate this process by quickly generating the gantry macro after the user inputs their preferred settings into the wizardIn this manual, we will show two common methods which are often used for gantry alignment. 
 + 
 +The following video goes over this manual: 
 + 
 +{{youtube>TdELVMxbB8Q?large}}
  
 ==== Method 1 ==== ==== Method 1 ====
  
-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 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 second 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 accounted for in the Tuning field:  
 +{{:mycnc:gantry-alignment-v2-006.png}}
   - 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 by a predefined distance
 +{{mycnc:configuration:gantry-alignment-014.png?300}}
  
-To generate this kind of alignment macro can be used the wizardSee below a screenshot of the Gantry Alignment Wizard +To generate this kind of alignment, the alignment macro will be generated by the Macro Wizardscreenshot of the Macro Wizard screen is shown below: 
-{{mycnc:mycnc-wizard-gantry-align-001.png}}+{{:mycnc:gantry-alignment-v2-008-macro-forward.png}}
  
-On the screen we have  +On this screenwe have: 
-  - **Axis, Direction** - Macro is generated for 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 "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** - set to Forward in this example.  
 +    - 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** (to be described later)+  - **Double check** - allows for greater precision when using the Forward movement method. This is done by moving back after hitting both sensors and then forward again at a slower speed. 
   - **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 in further detail:
  
   - 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 will be moving together to move out by the set distance \\ {{mycnc:configuration:gantry-alignment-014.png?300}} \\ 
 + 
 + 
 +==== Gantry alignment code walkthrough ====
  
-That's the planHow to implement it? Here is step-by-step implementation description.+For simply gantry alignments, it is largely unnecessary to edit the macro yourself, or to into much further detail beyound what'already shown in the manual aboveHowever, 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:
  
-  * 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 the 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 92:
 </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 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 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 129:
  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 140:
  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 165:
 </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 187:
 </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 199:
 </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 the PLC source to request the information directly from the specific ports themselves. However, we don't recommend this as it makes it harder to easily switch the inputs later - by using the pins.h file, the input list is centralized and easy to checkThis method will look the following way: 
 <code C > <code C >
 ... ...
Line 204: Line 214:
 </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 234:
 </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 262:
  
 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)
 G91 G0 X-1000 F500    (# Move toward Gantry Sensors) G91 G0 X-1000 F500    (# Move toward Gantry Sensors)
  
-( It takes time PLC controller from M144 procedure sends )+( It takes time for the PLC controller to register the information in the )
 ( updated register #800,#801,#802 values to myCNC control software ) ( updated register #800,#801,#802 values to myCNC control software )
 ( 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   (Calculate offset in units/mm)
  
-G10 L190 P810 Q805    (Add adjustment offset)+G10 L81 P810 Q809     (Copy Offset in units/mm to #810) 
 +G10 L190 P810 Q805    (Add tuning offset)
  
 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 needed for other axis (for example axis instead of X)+What should be changed if the Gantry alignment procedure is required for another 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 330:
  
  
-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 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 that disables the motor. Change procedure name to M211 (instead of M210)
  
 <code C M211.plc> <code C M211.plc>
Line 436: Line 442:
 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   (Calculate offset in units/mm)
  
-G10 L190 P810 Q805    (Add adjustment offset)+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 ) 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)
  
 </code> </code>
  
  
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