Description
Hello! How are you? I'm finishing my CNC and I want to put the laser on it but I'm having problems, I'm using ramps 1.4
and a laser lt-40W-aa from laser tree, in the connections description, it says PWM )0/3-12v, 0-5khz.
What I see is that it handles a pwm between 6 and 12v, so I connected D9 to the pwm, D9+ to 12v and negative to gnd
(to the input D driver adapter P-da-01) I also tried all the possible configurations, commenting or uncommenting invert, separate, output, I tried in D8, I supported pwm in lasergrbl, $RST=* , $30=255 $31=1 $30=1000
The problem is that the laser is always on, m5 turns it on, m3 or m4 turns it off (sxxx does not work) I'm already thinking that it could be a fault in the mosfet or that the khz or rpm are incorrectly adjusted, something like that.
// Spindle, laser and other PWM output
//----------------------------------------------------------------------
// Chose the spindle pin output :
// SPINDLE_PWM_ON_D8 => 0-12v 16 bits PWM on RAMPS D8 (default)
// SPINDLE_PWM_ON_D9 => 0-12v 8 bits PWM on RAMPS D9
// SPINDLE_PWM_ON_D6 => 0-5v 8bits PWM on RAMPS Servo 2 signal (Mega 2560 D6)
// Uncomment the line which correspond to your hardware
//#define SPINDLE_PWM_ON_D8
#define SPINDLE_PWM_ON_D6
//#define SPINDLE_PWM_ON_D9
// Spindle PWM signal inversion:
// In case of particular electronics, it may be necessary to invert the values
// of the PWM signal of the spindle. For example, if the minimum spindle
// rpm is 1 and maximum is 1000, M3S250 will output 75% instead of 25% and
// M3S750 will output 25% instead of 75%. Disabled by default
//#define INVERT_SPINDLE_PWM_VALUES
// Use different spindle output pin in laser mode:
// Spindle or laser tools do not have the same hardware specifications.
// When using both spindle and laser on the same machine it will be useful
// to have spindle and laser on diffrents pins which can deliver the
// differents outputs nedded.
//----------------------------------------------------------------------
// ! IMPORTANT: When changing the SEPARATE_SPINDLE_LASER_PIN compil option,
// don't forget to issue the reset factory defaults Grbl command: $RST=*
// if you forget the $RST=* command after change, Grbl may have
// unpredictable behavior!
//----------------------------------------------------------------------
// Uncomment the next line to enable this functionality (default disabled):
#define SEPARATE_SPINDLE_LASER_PIN
#ifdef SEPARATE_SPINDLE_LASER_PIN
// Laser PWM can be on D6 (default) or on D8 or D9.
//#define LASER_PWM_ON_D6
//#define LASER_PWM_ON_D8
#define LASER_PWM_ON_D9
#endif
// Use output PWM drived by GCode command M67(Analog Output,Synchronized)
// or GCode command M68(Analog Output, Immediate).
//----------------------------------------------------------------------
// ! IMPORTANT: When changing the USE_OUTPUT_PWM compil option,
// don't forget to issue the reset factory defaults Grbl command: $RST=*
// if you forget the $RST=* command after change, Grbl may have
// unpredictable behavior!
//----------------------------------------------------------------------
// Uncomment the next line to enable the use of M67/M68 PWM output (Disabled by default).
//#define USE_OUTPUT_PWM
#ifdef USE_OUTPUT_PWM
// Optional PWM can be on D9 (default) or on D8 or D6.
// Warning ! Optional can't use the same timer than the spindle or the laser pin
// For more information about this, see the comment of the relevant section in cpu_map.h
//#define OUTPUT_PWM_ON_D9
//#define OUTPUT_PWM_ON_D8
//#define OUTPUT_PWM_ON_D6
cpu_map it`s default
#elif defined (LASER_PWM_ON_D9)
// Set Timer up to use TIMER2B which is attached to Digital Pin 9 - Ramps D9
#define LASER_PWM_MAX_VALUE 255.0 // Translates to about 1.9 kHz PWM frequency at 1/8 prescaler
#ifndef LASER_PWM_MIN_VALUE
#define LASER_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif
#define LASER_PWM_OFF_VALUE 0
#define LASER_PWM_RANGE (LASER_PWM_MAX_VALUE-LASER_PWM_MIN_VALUE)
//Control Digital Pin 9
#define LASER_TCCRA_REGISTER TCCR2A
#define LASER_TCCRB_REGISTER TCCR2B
#define LASER_OCR_REGISTER OCR2B
#define LASER_COMB_BIT COM2B1
// 1/8 Prescaler, 8-bit Fast PWM mode
#define LASER_TCCRA_INIT_MASK ((1<<WGM20) | (1<<WGM21))
#define LASER_TCCRB_INIT_MASK ((1<<WGM22) | (1<<CS22))
#define LASER_OCRA_REGISTER OCR2A // 8-bit Fast PWM mode requires top reset value stored here.
#define LASER_OCRA_TOP_VALUE 0xFF // PWM counter reset value. Should be the same as PWM_MAX_VALUE in hex.
// Define spindle LASER pins.
#define LASER_PWM_DDR DDRH
#define LASER_PWM_PORT PORTH
#define LASER_PWM_BIT 6 // MEGA2560 Digital Pin 9