Engrave Photos with PWM Laser

edited May 2017 in Tips & Tricks
Hi,
is there anyone experienced in engraving photos with PWM Laser?
just need some setups regarding grayscales as i´m not really satisfied with my results.

I use PLTB450 B 1.6W Blue Laser Diode with PWM capable driver controlled by 12 Bit PWM at 1KHz

Thanks

«1

Comments

  • edited August 2017
    I've try to engrave some photo but without a real good result..
    See the photo on the end of the blog article...
    http://www.e-tips.it/2017/03/20/incisore-laser/


    Seems that for a gray-scale you have to drive the laser with a higher PWM frequency...
    but in repetier-firmware, if you change the PWM frequency then it will decrease the resolution of the pwm, so you have less duty cycle value, so you cannot have a good result...

    Edit.
    I will add a question...
    In the repetier, the PWM frequency is fixed?
    If the frequency is made by the hardware peripherals and it is a fixed frequency, i will try to increase it with a micro-controller programmed for multiply the frequency...

  • there is a solution out of the box , see
    https://github.com/repetier/Repetier-Firmware/tree/development/src/SampleEventSystems/Laser PWM and DAC

    I´ll post some pictures to my GitHub  to show some pretty good results.
    (may take a cuple of days)





  • edited August 2017

    RAyWB said:
    there is a solution out of the box , see
    https://github.com/repetier/Repetier-Firmware/tree/development/src/SampleEventSystems/Laser PWM and DAC

    I´ll post some pictures to my GitHub  to show some pretty good results.
    (may take a cuple of days)





    Great! Fantastic work!
    I've ordered two PCA9685 board and two solid state relay (i've got to machine).
    I will tell you the result as soon i receive the parcel :)

    Great work also with the fix:
    Warmup for laser included (to avoid gaps in engraving)

    I've downloaded your firmware and i will configure and try it ;)

    Edit:
    Ops, i've got the MEGA..
  • edited August 2017
    I have it running on a mega/ramps also.

    use dev firmware and add the custom events , warmup and most other features are included in official repetier-firmware
  • RAyWB said:
    I have it running on a mega/ramps also.

    use dev firmware and add the custom events , warmup and most other features are included in official repetier-firmware
    Hi, today I've finally received the PCA9685  board and I'm ready to try your code...

    Can I ask you some confirmation?
    I've copy the CustomEvents.h and CustomEventslmpl.h in the repetier firmware path, then compiled and load into Arduino MEGA...

    Now I've just to connect the PCA9685 board to the i2c bus like described in the PDF file, and connect to it the laser? Right?

    What kind of program have you used to create the G-Code in gray scale mode from a picture? Inkscape? with plugins?

    Thanks a lots for your support,
    Luca.
  • Yes, you copy the files to repetier firmware part.
    in Configuration.h you have to enable Custom events by adding

    #define CUSTOM_EVENTS

    thats all.

    there are multiple programs to generate the gcode .

    i use pic engrave pro , there is a demo version available

  • edited October 2017
    After adding #define CUSTOM_EVENTS  there is some error in compiling:

    exit status 1
    'firstMove' is not a member of 'LaserDriver'

    Edit. solved...just define CUSTOM_EVENTS upper than laser section...of course...

    Problem N°2:
    exit status 1
    'newint' was not declared in this scope

    on row:

    #if defined(GAMMA_CORRECTION) && (GAMMA_CORRECTION==true)
                          newint =(com->S);
                          if (Gamma_on)
                          {
                          Outval=pow(newintens/LASER_PWM_MAX,GAMMA)*LASER_PWM_MAX; //Gamma function
                          LaserDriver::intensity = map((int)Outval,0,LASER_PWM_MAX,LASER_BASE_OFFSET,LASER_LIMIT);// scale gamma function and offset to max
                          Com::printFLN(PSTR("orig:"),(int)newintens);
                          }
                          else
                          {
                          Outval=newintens;
                          LaserDriver::intensity = map((int)Outval,0,LASER_PWM_MAX,LASER_BASE_OFFSET,LASER_LIMIT);// scale offset to max
                          Com::printFLN(PSTR("Gamma off LV:"),(int)newintens);
                          }


    declaring it, it will compile the code, but i don't think that is a good solution...
    Maybe i can declare it at the start of the file?

    int newint = 0;
  • edited October 2017
    you have to use repetier 1.0 from dev branch !
    do not modify the code
  • I've configured and downloaded the 1.0dev firmware from:
    https://www.repetier.com/firmware/dev/index.php

    Then i've add the customevents.h and customeventsimpl.h to firmware folder, and i've add the:
    #define CUSTOM_EVENTS

    after


    #ifndef CONFIGURATION_H
    #define CONFIGURATION_H

    in configuration file...

    The error still the same:
    'newint' was not declared in this scope



  • edited October 2017
    in the github version of repetier the define is included at the end of configuration.h
    (before last #endif)

    when did you download the firmware files?

    downloaded 3 min ago from  https://github.com/repetier/Repetier-Firmware/tree/development

    compiles without error.

    what arduino version do you use?

    EDIT::

    Typo, please change

    newint =(com->S);

    to


    newintens =(com->S);


    thanks for the hint!!!

    do you use only the pca9685  or also the mcp23017 and mcp4725?
  • if you only use the PCA 9685 the settings in CustonEvents.h have to be :

    #define FEATURE_I2C_MACROS false
    #define FEATURE_EXT_PWM true 

    #define FEATURE_PWM_LASER true
    #define FEATURE_ANALOG_LASER false
    #define GAMMA_CORRECTION true


    if not already done you also should set in configuration.h

    #define LASER_PWM_MAX 4095

    to get the 12bit resolution



  • RAyWB said:
    EDIT::
    Typo, please change

    newint =(com->S);

    to

    newintens =(com->S);

    thanks for the hint!!!

    do you use only the pca9685  or also the mcp23017 and mcp4725?
    Thanks to you for the support :)

    Now i can compile without any problem, next week i will try to use the photo engraver with your code and will post the result :)
    But before, i need to setup a mosfet for connect the PCA9685 to the laser...

    Thanks
  • edited October 2017
    Ok, I'm trying your code...
    Seems working, but i cannot connect the laser at the moment (i'm using it with a LED) because i need to invert the signal...

    from the code:

    class PCAPWM
    {
        public:
        PCAPWM(uint8_t address);
        void Init(void);
        void SetFREQ(float freq);
        void SetPWM(uint8_t num, uint16_t on, uint16_t off);
        void SetPIN(uint8_t num, uint16_t val, bool invert=false);
      
        private:
        uint8_t PCA_addr;
    };

    Theoretically if i change the invert=false to invert=true the output signal will be reversed?
    I will power the laser trough a N-Mosfet, so i have to invert the output signal...

    thanks


    Edit.
    Seems the bool invert=true has no effect on laser output status...
    How can invert the output? When the arduino start-up, the output of the PCA should be LOW, and when the laser is powered on, the output should be HIGH



  • NOPE.

    in configuration.h

    Change

    #define LASER_ON_HIGH 0

    to

    #define LASER_ON_HIGH 1


  • Hi, RAyWB
     could you please make a video explaining how to install CustomEvents.h and CustomEventslmpl.h in the firmware, thank you.
  • just read Events.h   its written there
  • When I add (#define CUSTOM_EVENTS)
    in Configuration.h, the commands stop working on the repeat host, what did I do wrong?
  • may be you should tell me what additional hardware you have installed.
    also download source and date
  • I am using a mega arduino 2560, ramps 1.4, with the Repetier-Firmware version 1.0.1dev
  • I'm installing CustomEvents.h and CustomEventslmpl.h on the repeat so, is that right?

  • edited June 2018
  • I am using the PCA9685 card. and a 15w laser
  • so i guess you didnt set up  the files correct

    beginning of custom Events.h  in this case should look like

    #ifndef CustomEvents_H
    #define CustomEvents_H
    #define FEATURE_I2C_MACROS false
    #define FEATURE_EXT_PWM true
    #define FEATURE_PWM_LASER true
    #define FEATURE_ANALOG_LASER false

    #define GAMMA_CORRECTION true





  • I've already made these modifications, but the duplicate host is locked, nothing works.
  • edited June 2018
    when I change the (#define CUSTOM_EVENTS) to (#define CUSTOM_EVENTS _H) in the Configuration.h folder, then the repeater hodt
  • edited June 2018
    But I can not turn on the laser, what command do you use to turn on the laser to test?
  • edited June 2018

    may be you should check first if the i2c bus is running....

    use nick gammons i2c scanner for example.

    "when I change the (#define CUSTOM_EVENTS) to (#define CUSTOM_EVENTS _H) in the Configuration.h folder, then the repeater hodt"

    i never wrote to do that.....




  • you can also check this to see if your Hardware is running

    https://learn.adafruit.com/16-channel-pwm-servo-driver/using-the-adafruit-library


    USE LED FOR TEST NOT THE LASER !!!!

Sign In or Register to comment.