Mega RAMPS Marlin gcode & TTL laser

I have been piecing together a machine that I hope will one day become a 3D printer, but for now am just wanting to get the X Y axes to enable a laser engraver/cutter to function. All the framework, steppers, and assorted electrical bits have come from repurposed parts, old scanners, photocopiers, printers, etc.

I did buy the Arduino Mega2650 with RAMPS board and LCD, as well as a laser module, which included the 450nm laser, lens assembly, driver board, with 3 wires for power supply and TTL control.

I've read a lot, on the Marlin pages, gotten the gcode plugin to work with Inkscape, and browsed through this forum, and found many useful tips.

However, I'm now at a loss for how to make the laser work once I give it a file to engrave.

The laser module's power source can use +12V, so it is connected to the RAMPS D9, and the TTL wire is connected to the servo pin 6. I've modified my marlin files to reflect the hardware I've set up. On the LCD module there is a controller that lets me set fan1 from 0-255 and fan2 from 0-255, and the laser comes on at full power. By reducing the value for fan2, I'm able to control the power output of the laser. However, when using a file on the SD card, the gcode is apparently not addressing those pins correctly, and the laser does not light up at all.

I'm not certain if I need to make further modifications to the Marlin firmware, or edit the gcode. Or perhaps I ought to use a different pin for the TTL, and use the M42 function in the gcode file to turn on a pin and adjust the power level there.

... I'm using the encoder motor step pin for TTL pulsing -- but too, with a small Arduino (Pro Mini clone) to set the pulse-width depending on wished power: mostly 5 to 30 Microseconds pulse duration for engraving, up to 300 Microseconds and slower speed for cutting ...

I see what you say about the M106 command. In the window for the Laser tool I have set M106 S0 to turn laser off, m106 S255 to turn it on, and then in the laser power 120. I'm not sure why it puts the S0 on the line twice, but when I edit the gcode file to remove the duplicates, it still doesn't turn the laser on. Gcode is not controlling the laser.

tevo tarantula, running marlin.
reassigned fan control to pin 11 (one of the servo outputs on the mks base v1.4 the tarantula uses)

i just saw this issue on the repetier forum, and it made me realise something...

when you run as a 3d printer...

if you enter the m106 s*** command via host, the laser comes on, m107 turns it off. or the fan in a standard configuration.

but when you are printing from g-code...it can take a few MINUTES for the fan to respond to the m106 command.

this appears to be the problem with the event timers or something, as well as the way the PWM is implemented.

coding for me is still like reading gobbledy gook...

as far as i can tell, you have to have the laser controlled by its own event timer that takes priority and responds to the m106 command instantly rather than having this several line lag like the fan does.

as a cooling fan, its not terribly critical to have it come on instantly to the required speed. (except for bridging moves?)

as a laser driver, it does.

then the PWM of marlin is way too low to be useable... at 500mm/min feed, i get almost a millimeter between pulses. i end up with a cool pattern but not a continuous line...

... hmmm ... it's as simple, as feeding the pin for the extruder STEP to the TTL-input pin of the laser driver ... eventually you have to add a "level changer" (e.g. a TTL line driver or transistor circuit), if the TTL input of the lser driver won't run with the 3,3V from an ArduinoDue ...

QuoteVDX
... hmmm ... it's as simple, as feeding the pin for the extruder STEP to the TTL-input pin of the laser driver ... eventually you have to add a "level changer" (e.g. a TTL line driver or transistor circuit), if the TTL input of the lser driver won't run with the 3,3V from an ArduinoDue ...

how do you change the pwm to change the laser power? (assuming it's still running as a 3D printer but with the laser).

i'm thinking speed up the X and Y and the extruder speed speeds up to match?

... I'm using a small Arduino (Arduino Pro Mini clone) as an "intelligent" controller in my laser modules or as driver-interface.

The input signals are e.g. the STEP pulses, meant for the extruder stepper and an analogue voltage 0V-5V, regulated either by the CNC-controller (e.g. 12Bit-DAC of the ArduinoDue, "up-shifted" from 0-3,3V to 0-5V) or set with a trimpot ... and a "laserON" signal, to define, if the pulses have to be converted to laser output ...

With startup (or a reset-pulse) this "intelligent" laser controller reads the analogue voltage and defines the pulse-length between 5 microseconds at 0V to 300 microseconds at +5V.

Then, with the input "laserON"=+5V, every detected pulse will create a laser pulse with the set length (5 to 300µs) ...

QuoteVDX
... I'm using a small Arduino (Arduino Pro Mini clone) as an "intelligent" controller in my laser modules or as driver-interface.

The input signals are e.g. the STEP pulses, meant for the extruder stepper and an analogue voltage 0V-5V, regulated either by the CNC-controller (e.g. 12Bit-DAC of the ArduinoDue, "up-shifted" from 0-3,3V to 0-5V) or set with a trimpot ... and a "laserON" signal, to define, if the pulses have to be converted to laser output ...

With startup (or a reset-pulse) this "intelligent" laser controller reads the analogue voltage and defines the pulse-length between 5 microseconds at 0V to 300 microseconds at +5V.

Then, with the input "laserON"=+5V, every detected pulse will create a laser pulse with the set length (5 to 300µs) ...

Thank you, I am interested in controlling the TTL laser power with dir and step signals via arduino. I am looking for a working scheme and charge to the microprocessor.
Unfortunately, I can not program the microprocessor myself.

... a simple hint - search for a sample to the interrupts -- then every level change on the interrupt pin will result in a call of a routine, which can set a pin for a specific time to HIGH and release it again ... so a short STEP-pulse (or simply the level change) routed to an interrupt pin will output a pulse with the set time to another pin

Sounds to me like I have a similar setup as you, but with a 2.5w laser.... I want to have the TTL control the laser.. so far I have tried the D9 with 7805 to TTL.. the remapping to pin 44 and I can't get the laser to do anything it just comes on a full power..no control..remapping didn't work either!

With your 12V connected to RAMPS D9 and TTL to pin 6 what Marlin firmware changes did you need to make? do you have a wiring pic you could show? what version of Marlin? I have 1.1.9 - I can also use the LCD to set fan from 0-255 under temperature - control - fan...I've done so much reading my head hurts!.. but I still can't figure it out hope you may be able to assist...