I installed a laser modul on my cnc beside the spindle. It is mounted on a Linear Guideways.
I want to be able to use both in the same Gcode file, the laser will be use with selecting the tool #20
1/ In my M6 macro, if new tool is 20, I would like drive the stepper to move down the laser
The diver run with Pulse/Dir signals, nema 11 stepper 200 pulses/r , up and down limit swith.
I tried a simple macro like this but its no satisfactory.
How can I program this ?
Have you any suggest ?
- Code: Select all
int port_step;
int pin_step;
int port_dir;
int pin_dir;
int port_FDC_haut;
int pin_FDC_haut;
int port_FDC_bas;
int pin_FDC_bas;
// direction 1 pour descendre
exec.Setoutpin(port_dir, pin_dir);
while (Getinpin(port_FDC_bas,pin_FDC_bas) = = false)
{
exec.Setoutpin(port_step, pin_step);
// Thread.Sleep(1);
exec.Clroutpin(port_step, pin_step);
//Thread.Sleep(1);
}
//*********************************************************
// FONCTIONS
#Events
bool Getinpin(int port,int pin) {
bool pinread = AS3.GetLED(LEDnum(port,pin));
return pinread;
}
int LEDnum(int port,int pin) {
//Port #1 Pin 1 - 17 = LED 1 - 17
//Port #2 Pin 1 - 17 = LED 69 - 85
//Port #3 Pin 1 - 17 = LED 86 - 102
//Port #4 Pin 1 - 17 = LED 103 - 119
//Port #5 Pin 1 - 17 = LED 120 - 136
int LED = 0;
if ((port < 1) || (port > 5) || (pin < 1) || (pin > 17)) {
LED = -1;
}
else {
if (port == 2) { LED = 68; }
if (port == 3) { LED = 85; }
if (port == 4) { LED = 102; }
if (port == 5) { LED = 119; }
LED += pin;
}
return LED;
}
2/ the laser modul has 3 pins : +12vcc ; 0v ; pwm
I connected +12v/0v on permanent voltage and the pwm on the laser pin / port in I/O setup 1 with shielded cable but when spindle is running, some noise are doing pwm signal and the laser will light up a little even if a do M10 Q0 or M11 command.
I need add a relay to turn off the +12V, but how pilot it ? I also use the laser engrave plugin.
Can i write a macro loop that detect the M10/M11 command and turn on/off the relay or need do this in the M6 macro when tool #20 is loaded
thank you in advance