Laser with inverted signal

hi,
I have installed a laser on my Cnc, but the driver (cheap chinese stuff)  reverts the ttl signal (5v).
This means +5v = laser off and 0v= laser on.

i’ve changed some code in printer.cpp and ui.cpp to revert it logically’ and it works, but when I run a G0 command, laser is on... (as  repetier disables the laser with G0 commands, which is inverted for me)
my questions are :
is there a way to invert the G0 function (where is it in repetier ?)
when I start my CNC, how can I reverse the fan speed value (100% instad of 0% which will switch off the laser)

for info, I use M106 and M107 commands and the laser is plugged on D9 pins in a ramps 1.4 

the best would be to find a better driver (for 5.5w laser) but seems complicated to find or revert the TTL signal (i don’t know how to do)


thanks in advance
seb 

Comments

  • Why don´t you use Repetier Laser feature and  M3 / M5 commands as usual?
    with laser feature you can reverse signal qiute easy
  • Thank RAyWB for your answer,

    so, even if my laser is connected to D9 and I want to use M3/M5, I have to enable the laser mode in the gcode (M452) which is sufficient ?
    my first try didn't work. laser keeps running at 100%
    sample : 
    >>test.gcode<<
    ;start cnc/laser - laser 100%
    M400
    M452
    M5  ;--> laser 100%
    G4 S4
    M3 S10     ; --> laser 100%
    G4 S4
    M3 S255    ; --> laser 100%
    G4 S4
    M3 S0    ; --> laser 100%
    G4 S4
    M4 S255    ; --> laser 100%
    G4 S4
    M4 S0    ; --> laser 100%
    G4 S4
    M5    ; --> laser 100%
    >><<
    Then, how to reverse the signal for M3/M5 commands ? through changes in the code, through a single option somewhere. this is really not clear for me

    thanks again.
    attached my configuration.h file
  • edited September 2018
    no file attached , you have to upload somewhere and attach the link.

    also add informations about your hardware , which controller etc.
  • ok how did you connect TTL-Input to D9 on your ramps ?
  • that´s the section :

    #define SUPPORT_LASER 1  <------ needed to support Laser
    #define LASER_PIN ORIG_FAN_PIN  <--- I suggest to use One of the servo pins on Radds f.e. No.5
    #define LASER_ON_HIGH 0 <<---    Set to 1 to invert Signal
    #define LASER_WARMUP_TIME 0
    #define LASER_PWM_MAX 255
    #define LASER_WATT 5.5

    anyway, standard implementation in Repetier does not support PWM for Laser, just On/Off
    so Values below 200 are Laser Off, Values>=200 are Laser On.
    On G0 moves Laser gets switched OFF, on G1 Moves Laser is ON

    to get PWM you have to modify this section in drivers.cpp

    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


  • edited September 2018
    hello,

    here the wiring.

    I didn't use the servo pins as I think they don't support the power of the laser (5.5w)
    and I use this +5V pin and D9- to get 5V and not 12V provided by D9.
    but I'm still not sure if M3/M5 can be used with D9. I don't see any changes when I use these commands.

    https://drive.google.com/open?id=1o6bAFwLzvAGo2fzHk23Lr6_bQNJStCVr
  • edited September 2018
    well, you can do that, but TTL input takes no power it´s just control signal ;-)

    the problem using Fan Pin is that it is "double used"  and responses to the M106 so it cannot work on the M3/M5 commands.

    If you use the servo pin as i suggested it will work on the M3/M5  and be shure you´ll be grateful to have the blowerPin
    free for a blower when engraving wood

    if you really want to keep the D9  change in your configuration.h

    #undef FAN_PIN
    #define FAN_PIN 9 <---  change to 5




    #define LASER_PIN 9



    so test code could be :

    M452      <- switch to Laser Mode
    M3 S255 <- Laser on (no change as Laser needs a move to switch on)
    G1 x100 F300  <- move to x100 with Laser on
    G0 x0 <-move back to x0 with Laser off
    M5 <- switch Laser off
    G1 x100  <- move to x100 with Laser Off



  • so if I understand well (sorry for the idiot question),
    I wire the +5v TTL signal from the Laser directly to the TTL data  signal of the servo (or the +5V ??)  and gnd together right ?

    i've put a picture here.
    https://drive.google.com/open?id=1hfRorIyYjzoyLZQEisX2DU0l76X9PzXc
  • yes, that´s what i mean
  • ok... lot of tests here... and I'm getting crazy...
    I've so changed the pin from D9 to D11 (servo) and also tried with D6 (servo)
    the behavior is identical for all tests, and I was only able to use M42 commands. nothing happends with M3/M5 commands. I don't understand how to enable these commands.

    I'm attaching the last configuration.h file. no other files were customized

    with M42 P6 Sxx commands :
    if I set LASER_ON_HIGH 1  
    Switch on machine :  laser starts with state OFF
    run a gcode Without any move commands : M42 P6 Sxx works fine
    run a gcode With  G0/G1 moves : M42 P6 Sxx ->  laser always OFF 

    if I set LASER_ON_HIGH 0 
    Switch on machine :  laser starts with state ON
    run a gcode Without any move commands : M42 P6 Sxx works fine
    run a gcode With G0/G1 moves : M42 P6 Sxx ->  laser always ON

    for information, with Marlin, it works fine with M106 commands  when it's connected to D9, but I don't use Marlin because of precison and buffer issues. not as reliable as repetier on my point of view.

    https://drive.google.com/open?id=1yP_NIHkQq0Wq5rLXvLsvSVXlWzVGiGc6
  • edited September 2018
    i guess you didn´t send the M452 before test as i suggested

    in you configuration.h you have

    #define DEFAULT_PRINTER_MODE 2

    this is CNC mode

    for Laser you have to set

    #define DEFAULT_PRINTER_MODE 1




  • sorry, forgot to click on POST yesterday...

    M452 was included in my codes. the thing I was not aware is : 

     M3 only works with move commands, that was the trick !!

    I'm also able to send M3 Sxxx commands with the small change in the code to allow analogwrite.


    thanks again a lot RayWB for all your time and effort. this resolution would not have been possible without your help !



  • well, i wrote the " trick " a couple of posts above :


    M452      <- switch to Laser Mode
    M3 S255 <- Laser on (no change as Laser needs a move to switch on)
    G1 x100 F300  <- move to x100 with Laser on
    G0 x0 <-move back to x0 with Laser off
    M5 <- switch Laser off
    G1 x100  <- move to x100 with Laser Off

    good to read that it works now for you ;-)

    take care and use the safety googles !!!




  • RAyWB said:
    that´s the section :

    #define SUPPORT_LASER 1  <------ needed to support Laser
    #define LASER_PIN ORIG_FAN_PIN  <--- I suggest to use One of the servo pins on Radds f.e. No.5
    #define LASER_ON_HIGH 0 <<---    Set to 1 to invert Signal
    #define LASER_WARMUP_TIME 0
    #define LASER_PWM_MAX 255
    #define LASER_WATT 5.5

    anyway, standard implementation in Repetier does not support PWM for Laser, just On/Off
    so Values below 200 are Laser Off, Values>=200 are Laser On.
    On G0 moves Laser gets switched OFF, on G1 Moves Laser is ON

    to get PWM you have to modify this section in drivers.cpp

    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


    How should I modify it to make PWM regulation work?
    I have a PIN output of 4
Sign In or Register to comment.