Skip to main content

Site Navigation

Your Account

Choose Language

Help

Revision to Laser PWM control

Tony

[title|Laser PWM control]
 
[summary]How to configure RRF to use a PWM driven laser module[/summary]
 
 
 
== Controlling a PWM Laser with the Duet Board ==
 
=== Assumptions ===
 
* Your laser runs on 12v
* Your laser requires a 5v active-high PWM
* You want to control the laser with M3 and M5 commands
* You have a laser module
* You have a Duet board
 
Assuming the above asumptions are correct for you, then you can continue with this guide.
 
=== Preparation ===
 
[image|761]
 
The Duet board will not be able to drive the laser's PWM directly, and will need some interfacing electronics. The circuit diagram for the needed circuit, including protection for shorting of 3v3 line to prevent unintended Laser Power on is shown below.
 
There is an [https://easyeda.com/keyz182/laserpwmduet|EasyEDA project here] with the circuit, released as Open Source to utilise if needed.
 
You will need to provide +12V and GND to the laser module, along with PWM output from the above circuit.
 
==== PWM Circuit ====
 
The circuit uses surface mount components, so bear that in mind if you get a board made. If recreating the circuit with e.g. Veroboard, remember to buy the through-hole version of the applicable components.
 
==== Circuit operational theory ====
 
This circuit is based around the 74HCT02 Quad NOR Gate. The PWM heater output on the Duet acts on the negative side, to pull it low, rather than pulling it high, which is the inverse to what the Laser expects.
 
==== NOR truth table ====
 
[image|760]
 
A simple approach would be to connect the heater PWM to two input pins of the 74HCT02. According to the truth table above, when both inputs are low, output is high, and when both inputs are high, output is low. This gives us both an inverted signal, and a signal that is pulled high, rather than pulled low, which is what the laser wants. This also functions as a level converter, as the output from the 74HCT02 is based on the voltage you feed it (5V in this case).
 
In the above circuit, this is augmented with 3v3 short detection. This simply feeds the 3v3 lines into inputs ``1A`` and ``1B``, such that when 3.3v is present, ``1Y`` (output) is low, and when not present, it is high. This means that if for some reason, the Duets 3v3 is shorted to ground, ``1Y`` will output high. As ``1Y`` is tied to ``2A``, this will present at least 1 high input meaning that NOR gate 2 cannot output high (as seen in the table above).
 
=== Configuration ===
 
In your config.g file, you'll need to add the following:
 
[code]
M307 H3 A-1 C-1 D-1 ; Disable Heater output on H3
M452 P3 R255 F200 ; Enable Laser mode, on output 3 (heater 3), with max intensity being 255, and a PWM frequency of 200
[/code]
 
To have the laser turn on/off based on E values on G1, you'd need to use ``M571 P3 F200 S255`` - note, I've not tested this.
 
==== Notes ====
 
===== M307 =====
 
The M307 command is used to set heating parameters. In this case, we use it to disable all applicable parameters as we'll be using it for PWM, not heating. See the notes [[Gcode#Section_M307_Set_or_report_heating_process_parameters|here]].
 
===== M452 =====
 
The M452 command is used to select the laser mode in RRF, such as PWM that relates to max power, and the PWM frequency. See notes [[Gcode#Section_M452_Select_Laser_Printer_Mode|here]].
 
===== Fans =====
 
If you're using any fans, be sure to remember that as you're not using any heaters, you should probably disable thermostatic control on any fans with the M106 H-1 command. See notes [[Gcode#Section_M106_Fan_On|here]].