Implementing LASER INTENSITY

Hi all !
I'm trying to implement laser intensity routine, i have a laser driver with a TTL input so, 
i try to modify source from : 

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

to 

analogWrite(LASER_PIN, newIntensity);


But nothing change ! :/

PWM 255 = ON 
PWM <255 = OFF 

i also try 
m42 p44 s254 = ON 
m42 p44 s254 = OFF


Any ideas ? 

Here the simple code : 

void LaserDriver::changeIntensity(uint8_t newIntensity)
{
    if(EVENT_SET_LASER(newIntensity))
    {
        // Default implementation
#if LASER_PIN > -1
        //WRITE(LASER_PIN,(LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));
// set PWM wave to TTL laser-driver input 
analogWrite(LASER_PIN, newIntensity);
    }
}

Comments

  • (*) typo

    i also try 
    m42 p44 s255 = ON 
    m42 p44 s254 = OFF
  • edited December 2015


  • 1. You should implement it using the event system as described.
    EVENT_SET_LASER(newIntensity) would then change intensity and return false to prevent default code from doing on/off.

    2. You need to learn about PWM. The pin must have a PWM time to use analogWrite with analog value. Moreover it must be one that does not use Timer 0,1 or 2 and eventually 3 if you have beep enabled. These are already used internally.

    3. Make sure to have a high PWM frequency. It will turn laser on/off and to hit every spot you need a light on phase every 50% spot diameter.
  • edited December 2015
    1) Ok no problem , i was in rush so now i have implemented it with this 2 small changes
    https://drive.google.com/file/d/0B7VPQ4zmKBz4Q3VkQTJBdVlLX0k/view?usp=sharing

    i think now the code is clean and correct write , right ? 

    2) ok , got it , i try one precoded library : https://github.com/chipaudette/ArduinoPolySix/tree/master/ArduinoLibraries/Timer5
    and use for safety the pin 44 on timer5 (i think pin44 it will beh good and often free)

    3) ok now i have all i need but the driver specs. So, i can controll frequency , duty cycle, wave form and so on. 
    Someone know wich values are good to use as "m3 s1" and what for "m3 255" ?
    I mean, what kind of wave form, frequency etc... to use as good range ? 

    Thanks

    when i get something good to show i'll do! Until now is a pretty "dirty working code" ;) 


  • No that wa snot what I meant with event system. See on github src/SampleEventSystems/Felix Pro 1

    In configuration.h or in online tool in manual commands you add

    #define CUSTOM_EVENTS
    then it will read the files 
    CustomEvents.h
    CustomEventsImpl.h

    the first file would have your define modified liek
    #define EVENT_SET_LASER(intensity) SetMyLaserIntensity(intensity);

    in the latter you have code like
    bool SetMyLaserIntensity(uint8_t intensity) {
      // Do your work here
      return false;
    }

    That is how the event system works.
    As you see this does not alter the original repetier files at all, so you can simple download latest version and recompile. Your solution still requires modification after each update, which is what we wanted to prevent with the event system

    Just for completeless, best waveform is full power and use feedrate to control power, which is the default implementation.

    If you want to switch choose the wave form with the most switches if the laser can handle it. So for 50% it is better 10000 times on/off per second then 10 times.
  • edited December 2015
    ok perfect i agree with the first part of you post, for this reason i didn't post any code yet :) 

    after that you say : 

    "Just for completeless, best waveform is full power and use feedrate to control power, which is the default implementation." 
    and now start the problem, InkScape plugin , and other laser software support in most case "pwm" instead "feedrate" , so, i think is most important to have a firmware that can handle PWM  than modifiy by hand (read python scripts) an "laser Gcode" file for work with FEEDRATE ! 

    If u know some software that produce gcode with feedrate from a greyscale image, free fell to comment ! I give u a "virtual-beer" ;)  

    So, thanks for all the hint, now if i find spare time i try to write a clean code and show you what i get for work with a TTL driver and use a PWM value [0..255] as input 

    Thanks ! 

  • Speaking about inkscape, have a look here:


    Just made today:-) Creates only contours but creates our gcode how we like it andis super easy to use.

    With the grayscale image - do you have a nice plugin that does it. I'm still searching one that I can modify like the above plugin (which is a existing gpl plugin I modified to our needs). Maybe then you get one that does feedrate based. 
  • edited December 2015
    lol I modified the same python plugin for work with feedrate and analogue value ahahaha
    was based on : J Tech Photonics Laser Tool http://jtechphotonics.com/?page_id=2012

    i noticed same minor bug in gcode creation (some G0 instead G1 and some "F{value}" erroneus next to G1 code... 
    if i find the log i let you know 

    about the greyscale i used this : https://hackaday.io/project/4828-raster-2-laser-gcode-generator

    the code is pretty easy to hack for feedrate and the result is pretty good but maybe need to increase the resolution up to 10pixel/mm, 10 still a bit far , 15/20 maybe will be better.






  • Ok as expected same bug afflict your version : 

    image

    J = original plugin 
    R = your 

    Same F command next to G1 line

    image
  • and here is the gcode interpreted : image
  • And here a quick fix : 


    dirty gcode : 

    image


    Fix the "F" bug 


    image


    I hope this help someone with same problem ! 



  • Still some small difference with visualizzation and actual "print" but is a good and easy plugin 

    image

    About the grayscale ?
    Wich one you like more ? 
    What about this : https://hackaday.io/project/4828-raster-2-laser-gcode-generator ? 
  • edited December 2015
    The F bug is a good hint. Checked the code and it was quite easy to find. Now our plugin does not have that error any more as it seems. Thanks.

    The greyscale plugin will have to wait a bit. I'm currently with a other thing busy, but have it on my todos.
  • No i say thanks all the repetier stuff !!! 
    Also my delta printer say thank to you :D 

    The use of HAL in the firmware put this 10time ahead the classic marlin (y) 
    Really, we push it around 400mm/sec 10'000 accelleration (only for test purpose) and only Repetier can handle the math needed on a poor mega+ramps 1.4 (y) 






  • edited December 2015
    keep talking about your plugin, 
    here my fix : 
    - insert Fcommand before g1 g2 g3 mode 
    - insert G28 and Custom Z on header and footer (please remove) 

    this help me modify the speed from repetier host , if i use your code , every speed modify seems to have no success. 

    http://www.g2kweb.it/public/images/repetier.rar

    in the maintime : Happy holidays ! 

    image




  • I have also worked on this Plugin and found the same errors. At the end, maybe we should compare our improvements :)
    - Peter
  • Is there a link to the completed code for laser intensity? I would love to beable to adjust the lasers power!
  • Repetier said:
    Speaking about inkscape, have a look here:


    Just made today:-) Creates only contours but creates our gcode how we like it andis super easy to use.

    With the grayscale image - do you have a nice plugin that does it. I'm still searching one that I can modify like the above plugin (which is a existing gpl plugin I modified to our needs). Maybe then you get one that does feedrate based. 
    Not working properly on inscake 0.92.
    The script does not respect the object dimension...seems a dpi problem...2
    Can you pls solve? Or you could remove "Install the latest version of Inkscape" from the web page...

    http://forum.inkscapecommunity.com/index.php?topic=486.0


  • I have put it on my long todo list and made a notice to use 0.91 which I think should still be working.
  • I'm so sorry to had add a new task to your todo list :p
    Yes, i can confirm that in 0.91 the plug-in work like a charm ;)
Sign In or Register to comment.