# Convert 12VDC fan controller output to TTL signal of laser?

I'm adding a laser cutter to my 3D printer. I want to repurpose the cooling fan output to control the laser. My laser has a power supply which accepts a 5V TTL signal to turn the beam on/off.

The fan output is as follows: Fan OFF - both red and black wires are held at 12VDC. Fan ON - Red wire 12VDC, Black wire pulled to GND. (also supports PWM output at various levels, black wire is used for PWM signal while red wire is held at 12VDC.)

I had wrongly assumed the black wire would be held at GND while the 12VDC wire would be used to control the fan. So I assumed I had a GND reference available, so I built this level shifting circuit (which, of course, doesn't work due to black wire being pulled to 12VDC when off). Its purpose was to simply ground the TTL+ pin to the TTL- pin when 12VDC was present on the input, effectively inputting a logic 0 to the laser controller, or allow TTL+ pin to float high when 0VDC was present from the fan controller, inputting a logic 1 to the laser. I realize this inverts the fan output (fan off = laser on) but that's not a problem. And it did work when testing with a 12VDC power supply.

simulate this circuit – Schematic created using CircuitLab

However, since the outputs of the fan controller both go to 12VDC when the fan is off, this doesn't work. How can this circuit be re-designed in the simplest way possible (hopefully without requiring outside power) to shift this strange 12VDC signal to 0/5VDC TTL signal, or effectively short/open the connection between TTL+ and TTL- pins? I guess a relay would work for simple ON/OFF controls, but that would preclude using PWM to control the laser...

Thanks for any insight.

• Spitballing, all you need to do is connect the fan black wire to the NPN base resistor, and use a common ground for the emitter. It will be inverted from the fan logic, but that's it. Commented Aug 3, 2017 at 6:18
• That base resistor is way too high though. 12v - 0.7v ) / 100 ohms = .11 A or 110 mA. You risk burning out the transistor. A 1k or 470 ohm resistor is more appropriate. Commented Aug 3, 2017 at 6:20
• I'll answer this tomorrow if no one else has. Don't have access to the schematic tool right now. Commented Aug 3, 2017 at 6:20
• What was the purpose of the cooling fan? Why don't you need one anymore? Commented Aug 3, 2017 at 6:33
• The fan in a 3D printer cools the newly extruded filament so that it solidifies quickly before it deforms under gravity. The OP is unlikely to try to use the machine as a 3D printer and a laser cutter at the same time. Commented Aug 3, 2017 at 7:36

Why don't just solder two wires straight to the Gate and Source pins of the fan MOSFET on RAMPS board? So you will get 5V PWM signal straight from ATMega controller.

That is what I did - soldered two-wire JST-connector to the pins to make it unplugable. Works like a charm.

I solved this with a very simple circuit, which avoided the need to run extra ground or +5/12V lines. I used a simple optocoupler and resistor.

Again this is an inverted control: when the fan is ON, the laser will be OFF. Anything less than 100% output on the fan will result in the laser pulsing at the fan PWM frequency.

I have a Monoprice Maker Select 3D printer which uses RepRap compatible g-code. To turn the laser ON, issue M106 S0, and to turn the laser OFF, issue M106 S255 gcode commands.

I am using the J Tech Photonics Inkscape plugin to generate laser g-code, and it doesn't support this type of inverted output. So it's necessary to do a search/replace in the gcode file to swap the M106 S255 and M106 S0 commands.

YMMV - hopefully helpful to someone!

simulate this circuit – Schematic created using CircuitLab

If you are certain that the black wire gets pulled to 12VDC and the red wire sticks to 12VDC the entire time, you can just use a inverter to drive the whole thing - an inverting buffer like something in the 74xx series parts could work fine as a level translator.

• I wanted to avoid needing to run extra 5V/GND wires to the printhead. Commented Aug 3, 2017 at 17:19