Faster Laser PWM/Fan PWM

Yeah, probably nothing new but I never found an answer.

So, I am using repetier on a RADDS. And the trouble I have is simply the frequency of the PWM output Way too low to control the laser I connected to the fan. I tried looking for it for quite some time but all I found was people saying that I should 1: control intensity by feedrate or 2: write an event thingy
The first one is not what i'm looking for and the second one is nothing i understand. I can code a little bit but that's it.
I know that the fan is connected to a pwm pin of the arduino so in theory it would just be read the Sxxx value and write as analogue from my understanding. But that's already way over what I can do without help.

Hope somebody knows how to help me.

Comments

  • We normally do not use hardware PWM as these require timers which we also need for timing steppers. So this works only in the special case of a pwm pin with unused timer and that differs from board to board, so we skipped that. 

    For laser you should also use the laser driver not fan. Shortly we will get a sample code for solution 2. from a active user which we will include in github to show how to do it right with an external board for fast PWM generation. That sample can easily be modified to use arduino analog write if the pin satisfies the unused PWM timer condition.
  • Like said, looks like I have more than enough useable pwm pins, one of them the fan.
    And I have the laser mode enabled. I just don't use it because of the limitations of the software that seems to work with it.

    It would be really nice if i could get a link to that example. I can work with code a little bit so I probably could make it work eventually.

    Thanks for the answer.

  • The sample is now online on github. Just switch to dev branch and check in samplEventSystems.
  • Yeah...thanks.
    But that's not what I am looking for. I have everything I need. All I don't have is the knowledge on how to use the Sxxx after the command to write a pwm signal.
  • That is also included in the samples. It ises the S value to set laser just to a chip instead of making a analogWrite so change that write to chip with analogWrite and it should do.
  • Sorry, but I can't find anything that makes sense to me. Might be black magic for all I understand.
    Guess I won't have pwm then...
  • what kind  of laser do you use?
    there are so many different laserdrivers out there , some just use a enable pin and are sold as pwm"able" which is nonsens, of coarse they work somehow  , but not as they should. the ones i have are limited  to 1kHz operation,
    better ones start at  250 kHz and work best with true analog modulation.

  • I have one that should work with up to 20kHz.
    Also have a weaker one that is pwm"able" Both don't like the software pwm very much.
  • edited May 2017
    so i guess you want to do something like engraving photos...
    i spent the last two months with that stuff.the only thing i can say about that :
    use an external PWM controller like i do and it´s exactly written in the custom events.


  • Maybe I'll have to do that. 
    It's a stupid solution though if you ask me. I have more than enough free pwm pins.
  • it´s not a stupid, it´s a working solution.
    may be you need more background , it´s explained multiple times here in forum.
    using the pwm pins is based on timers and timers are occupied by other functions so that is the reason for the low pwm
    frequency.
    but feel free to code a solution...


  • I simply don't understand the problem, that's it.

    Guess I'll need that solution then.
    But that raises another question. There are two Laser wires. One analog and one pwm. Does that mean it would work if I were to use only one of those?
    My knowledge of coding is...very simple. I don't really understand what this code is doing
  • cannot say something about that.may be you can post a datasheet of your laser.

  • I don't have one. All I know that it has 12+ gnd and a 0-5V for control. I can figure out if It runs better on analog or pwm myself. My question is if both boards are needed for it to run.

  • only one is necessary. i personally prefer the analogcontrol.
  • Thanks for that answer!
    So simply get the analog thingy, hook it up to power and ic2 ports and laser, and use the custom events, right?

    What about the rest of that code? Can I just leave it in? Do I need to do anything else?

    I have no clue what I'm doing at this point.
  • edited May 2017
    keep rest of the code in , just set in configuration.h  LASER_PWM_MAX 4095

    and in Customevents.h

    #define FEATURE_I2C_MACROS false
    #define FEATURE_EXT_PWM false

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


    as you are using due/radds you have to use level shifter to get from 3.3V to 5V and keep in mind that I2C wiring is
    critical , so keep wires as short as any possible
  • Yeah. Thanks a lot.
  • Someone found a final solution for this?
    I just need a simple PWM output pin to drive my laser.
    I'm using Arduino Mega with RAMPS 1.4
    I have tried that customevents.h without success, but maybe I missed something.
  • edited March 2019
  • Exactly...
    Do you know about any solution for a simple PWM pin to switch the laser TTL?
Sign In or Register to comment.