Láser pin pwm. Help-__-
I do not understand how to implement or manage the pwm pulses of 0-255.
I have arduino mega + ramps v 1. 4.
I understand that pin 44 is pwm.
I also have this
To be.
https://m.banggood.com/450nm-3500mW-3_5W-Blue-Laser-Module-With-TTL-Modulation-for-DIY-Laser-Cutter-Engraver-p-1103261.html?rmmds=orderdetail
I work with the laser with this code.
/////
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness = 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
/////
I send this from the console.
M452 // mode laser
M3 s33 //
but nothing happens.
#define SUPPORT_LASER 1
#define LASER_PIN 44
#define LASER_ON_HIGH 1
#define LASER_WARMUP_TIME 0
#define LASER_PWM_MAX 255
#define LASER_WATT 2
//////****
how to modify this file so that it works?
Drivers.h
#if defined(SUPPORT_LASER) && SUPPORT_LASER
secondspeed_t LaserDriver::intensity = LASER_PWM_MAX; // Intensity to use for next move queued if we want lasers. This is NOT the current value!
secondspeed_t LaserDriver::intens = 0;
bool LaserDriver::laserOn = false;
bool LaserDriver::firstMove = true;
void LaserDriver::initialize()
{
if(EVENT_INITIALIZE_LASER)
{
#if LASER_PIN > -1
SET_OUTPUT(LASER_PIN);
#endif
}
changeIntensity(0);
}
void LaserDriver::changeIntensity(secondspeed_t newIntensity)
{
#if defined(DOOR_PIN) && DOOR_PIN > -1
if(Printer::isDoorOpen()) {
newIntensity = 0; // force laser off if door is open
}
#endif
if(EVENT_SET_LASER(newIntensity))
{
// Default implementation
#if LASER_PIN > -1
WRITE(LASER_PIN,(LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));
#endif
}
intens=newIntensity;//for "Transfer" Status Page
}
#endif // SUPPORT_LASER
*********
I modific
#if LASER_PIN > -1
WRITE(LASER_PIN,(LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));
#endif
To
#if LASER_PIN > -1
analogWrite( LASER_PIN, newIntensity);
#endif
... no found
I have arduino mega + ramps v 1. 4.
I understand that pin 44 is pwm.
I also have this
To be.
https://m.banggood.com/450nm-3500mW-3_5W-Blue-Laser-Module-With-TTL-Modulation-for-DIY-Laser-Cutter-Engraver-p-1103261.html?rmmds=orderdetail
I work with the laser with this code.
/////
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness = 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
/////
I send this from the console.
M452 // mode laser
M3 s33 //
but nothing happens.
#define SUPPORT_LASER 1
#define LASER_PIN 44
#define LASER_ON_HIGH 1
#define LASER_WARMUP_TIME 0
#define LASER_PWM_MAX 255
#define LASER_WATT 2
//////****
how to modify this file so that it works?
Drivers.h
#if defined(SUPPORT_LASER) && SUPPORT_LASER
secondspeed_t LaserDriver::intensity = LASER_PWM_MAX; // Intensity to use for next move queued if we want lasers. This is NOT the current value!
secondspeed_t LaserDriver::intens = 0;
bool LaserDriver::laserOn = false;
bool LaserDriver::firstMove = true;
void LaserDriver::initialize()
{
if(EVENT_INITIALIZE_LASER)
{
#if LASER_PIN > -1
SET_OUTPUT(LASER_PIN);
#endif
}
changeIntensity(0);
}
void LaserDriver::changeIntensity(secondspeed_t newIntensity)
{
#if defined(DOOR_PIN) && DOOR_PIN > -1
if(Printer::isDoorOpen()) {
newIntensity = 0; // force laser off if door is open
}
#endif
if(EVENT_SET_LASER(newIntensity))
{
// Default implementation
#if LASER_PIN > -1
WRITE(LASER_PIN,(LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));
#endif
}
intens=newIntensity;//for "Transfer" Status Page
}
#endif // SUPPORT_LASER
*********
I modific
#if LASER_PIN > -1
WRITE(LASER_PIN,(LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));
#endif
To
#if LASER_PIN > -1
analogWrite( LASER_PIN, newIntensity);
#endif
... no found
Comments
But also notice that it only enables laser on G1 moves if you have enabled the laser with M3 before the move. If it stands still laser will be off.