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 12:09] skirillovmycnc:gantry_alignment_macro_wizard [2018/08/26 10:45] skirillov
Line 288: Line 288:
 </code> </code>
  
 +==== Method 2+ ====
 +
 +What should be changed if Gantry alignment procedure needed for other axis (for example Y axis instead of X)
 +
 +1) Let's say Motor outputs #0 and #1 configured as Y.
 +
 +{{mycnc:configuration:mycnc-gantry-005.png}}
 +
 +2) Procedure to connect both outputs to Y axis will look as
 +
 +<code C M219.plc>
 +#include vars.h
 +main()
 +{
 +
 + //parameter=0+16; //"0" is axis X; "16" is axis inversion.
 + parameter=1+16; //"1" is axis Y; "16" is axis inversion.
 + //parameter=2+16; //"2" is axis Z; "16" is axis inversion.
 + //parameter=3+16; //"3" is axis A; "16" is axis inversion.
 + //parameter=4+16; //"4" is axis B; "16" is axis inversion.
 + //parameter=5+16; //"5" is axis C; "16" is axis inversion.
 +
 + command=112+0; //Motor output #0 
 + message=PLCCMD_SET_CNC_VAR;
 + timer=2;do{timer--;}while(timer>0); 
 +
 + command=112+1; //Motor output #1
 + parameter=1+16; //"1" is axis Y; "16" is axis inversion.
 + message=PLCCMD_SET_CNC_VAR;
 + timer=2;do{timer--;}while(timer>0);
 +
 + exit(99);
 +};
 +</code> 
 +
 +
 +3) Need to change PLC procedure that looks after 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 triggered 
 +// Position Y is stored in register #802 when sensor s2 triggered
 +// If both sensors triggered, then 
 +//  - Motion stopped
 +//  - Position difference is calculated and stored into register #800
 +
 +main()
 +{
 + timer=0;
 +
 + message=PLCCMD_MOTION_CONTINUE;
 + texit=timer+30;do{timer++;}while(timer<texit);
 +
 + mode_12=0;
 +
 + ready=0;
 +
 + s1_old=portget(INPUT_GANTRY_S1);
 + s2_old=portget(INPUT_GANTRY_S2);
 +
 + do
 + {
 + timer++;
 +
 + s1=portget(INPUT_GANTRY_S1);
 + s2=portget(INPUT_GANTRY_S2);
 +
 + mode1=mode_12&1;
 +
 + if (mode1==0)//if sensor 1 wasn't triggered
 + {
 +  if (s1!=s1_old) //if triggered now
 +   {
 +     mode_12=mode_12|1; //set flag for sensor1
 +     position1=gvarget(5021+1); //Save the Machine Y position
 +   };
 + };
 +
 + mode2=mode_12&2;
 +
 + if (mode2==0)//if sensor 2 wasn't triggered
 + {
 +  if (s2!=s2_old) //if triggered now
 +   {
 +     mode_12=mode_12|2; //set flag for sensor2
 +     position2=gvarget(5021+1); //Save the Machine Y position
 +   };
 + };
 +
 + }while(mode_12!=3);
 +
 + message=PLCCMD_MOTION_SKIP;
 + timer=2;do{timer--;}while(timer>0);
 +
 + gvarset(801,position1); //send the position to myCNC software Register #801
 + timer=50;do{timer--;}while(timer>0);
 + gvarset(802,position2); //send the position to myCNC software Register #802
 + timer=50;do{timer--;}while(timer>0);
 +
 + offset=position1-position2;
 + gvarset(800,offset);
 + timer=50;do{timer--;}while(timer>0);
 +
 + exit(99);
 +};
 +</code>
 +
 +
 +4) Fix disable motor PLC procedure. Change procedure name to M211 (instead of M210)
 +
 +<code C M211.plc>
 +#include vars.h
 +
 +main()
 +{
 + connect=eparam;
 +
 + message=PLCCMD_SET_CNC_VAR;
 + if (connect==0)
 + {
 +  parameter=15;   //OFF
 + }else
 + {
 +  parameter=1+16; //"1" is axis Y; "16" is axis inversion.
 + };
 + command=112+1; //Motor output #1
 + timer=2;do{timer--;}while(timer>0);
 +
 + exit(99);
 +};
 +</code>
 +
 +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 P810 Q800     (# Get offset in pulses)
 +G10 L192 P810 Q5531   (# Calculate offset in units/mm)
 +
 +G10 L190 P810 Q805    (# Add adjustment offset)
 +
 +M211 P0               (# OFF the second motor, the Only first motor is ON )
 +
 +G10 L190 P810 Q5021   (# Add current machine position)
 +G28.9 Y810            (# Move 1 motor to adjust)
 +
 +M210 P1               (# ON the second motor, both motors are moved together)
 +
 +</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