laser section

Hello everyone, I activated the laser section with the 11-pin PWM servo (TTL mode)
You can be added to display the handling of a laser with maybe on / off and one with wheel to manage 0-255 to calibrate the laser to the material change?
Thank you


  • The default laser driver has no PWM but can be exchanged by one that does it if by accident your board has a PWM with unused time for it. In that context the gcode should set the intensity I think as this also depends on speed of following moves.

    A mode switch between FDM/Laser/CNC might in deed be a good idea for menu. Will see if I get the time.
  • My laser is ttl version and i use a pwm pin 11 (servo) with m42 gcode command.

    is possible use the laser to active the servo mode and not a laser section ?

    I am confusion for different a laser slection or servo mode in firm


  • edited January 2017


    Menu for laser section for me idea

    my laser into the gcode change the power whit a pwm not for speed

  • M42 is not really the way to change intensity. There is no timing adjustment with moves so you need to put M400 before it to stop all moves. M3 Sxx would be the better way but then you need to change driver to set intensity in laser.

    Image is not readable!
  • Sorry the ttl is a 5v and i use a pin 11 pwm servo. In this solution you control the poeer of laser in black 255 white 0 and a gray scale
  • edited January 2017
    Hello is possible to limit a voltage in firm section at the fan connector or in hot bed 2 (5v)?

  • 0 is black, 255 is white.

    You can not change voltage - AVR always outputs 5V but with high frequency and some electronics you might convert pwm to voltage. But firmware has no limits for fan - can always go to 255. But you can modify the set fan speed function to reduce it if necessary. But be aware that firmware uses software PWM with low frequency!Normally not suitable for voltage or laser PWM.
  • ok thanks a lot for information, but now i have a ttl 5v laser control, where i connect the ttl input and that gcode use for use the laser?
    Is possible to modify repeiter in this mode?
  • Sure, with some modification M3 Sx would set new intensity. See driver.cpp

    void LaserDriver::changeIntensity(uint8_t newIntensity)
            // Default implementation
    #if LASER_PIN > -1
            WRITE(LASER_PIN,(LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));

    so implement new custom event EVENT_SET_LASER that returns false and sets the intensity with ttl/PWM whatever you want. Just as I said, do not use timers used by firmware for this.
  • Sorry but is not possible to insert into the fim the m42 value pwm (s0 5v s255 5v) in pin 4 servo for command a driver ttl ? is this difficult feature, because is not use a ttl laser driver with repetier firm but i can t use marlin firm.
    Help me please
  • M42 does not use correct timing to enable/disable. Equivalent would be in Driver.cpp replace the line already shown above

    WRITE(LASER_PIN,(LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));



    which is what M42 does, only now you have it with correct timing. Even better is to put it into the event system so you do not have to change line for every update.
  • Sorry, buti in this case i have <199 0v and >200 5v ?
    I need a pwm effect, to scale 0-5v in 0-255 for command ttl laser power
    I understand that this modify is ok
  • The fixed version sets values from 0 to 255. The 199 is for digital only on/off.
  • Is not possible have to a scale 0 5v to 0-255?
  • I just said it is what you have, except it is pwm. You can not set analog values on AVR, just toggle 0/5V at different speeds.
  • Are there any plans to support PWM in the near future? Since the Gcode allready seems to support intensity.

  • Not really. Problem is that no one would read the contraints and just start questioning why it does not work. I'm also not sure what pwm frequency would be necessary for correct result. Do you know that? 16Hz could be done in software for all. For hardware solution only very few pins can be used and these depend on processor and board. For these cases the 1 line change mentioned above would work.
  • I think that M42 is not really the way to change intensity.
    bullet force
  • No, M42 does change when it's called independent of head position. But if that works, you can modify the laser driver to just use analogWrite to set intensity instead of the digital write.
  • Your article has brought a lot of valuable information. vex 1
  • I think it is a good idea, I have thought of it but not as detailed as you.
  • I really wanted to send a small word to say thanks to you for the fantastic points you are writing on this site.

    hotmail login

    gmail sign up

Sign In or Register to comment.