To find K40 conversion information use the "INDEX", "SEARCH" or "LABELS" sections in the sidebar.

Saturday, June 11, 2016

K40-S Laser Power & Control Interface


One design task as part of the conversion of the K40 to a Smoothie is to determine how to best, safely and predictably interface a PWM control with the stock laser power supply. This post documents that research  design, test and implementation.




I need a Laser Power Supply (dead) to test:

I wish I at least had a typical schematic for these LPS so I could verify the LPS-IN and "FIRE" function characteristics. My concern is the interface to the LPS and what its response would be to a PWM signal. The expectation is that the input to the LPS-IN is AC coupled through a low pass filter network that will integrate the PWM signal but that expectation is unverified.

If anyone has a LPS schematic or a blown LPS that we can use to better understand its interface please contact me at: or comment below.

Reverse engineering Information: 

From Scott Marshall on G+:

This is the manufacturers page there's specs and such there, minimal, but some info.

Inputs P+ and K+ directly drive these optos:

Driving this PWM Controller by good old Texas Instruments

Inputs are speced at 5v, but look to work on 3,3v (show 3v logic High)

It's pretty conventional switching supply stuff from there. The Hv circuit seems to be a flyback running at about 440hz (awful low) with a tripler output.
300W 11kv nominal 4-20ma (26kv insulation breakdown)

Results of research:

This design is complicated and confusing since: There are two or more prevailing places to connect the PWM control and multiple variations of implementation with at lease two vintages of power supplies.

Below are a couple of links to K40 builds showing others approach:

Connecting PWM to the LPS:

The goal of this design is to connect the PWM signal from the Smoothie to the LPS.  
There are three places to interface the PWM signal to the LPS, INFIRE & "L";

"IN" control:

The IN signal: both A and B configuration of LPS have an IN signal which by all evidence is intended to be an analog and digital means of controlling the laser power supply. This signal in the manual case is the center tap on a 2K potentiometer that is mounted on the control panel labeled "Current Regulation". The only evidence that both PWM and Manual controls can be present at the same time is that the specs from some vendors say: "PWM and Analog" control of the LPS. This interpretation of the use of "AND" may be to specific for translated documentation. 
The IN signal requires a 0-5VDC signal to get the full range of power. The PWM signal therefore must be a TTL like signal, various LPS documentation supports that specification. This means that a +3 VDC PWM signal must be translated to a +5 VDC level. It is also important to insure that the PWM signal is positive. +5 VDC is full power and ground is no power.
Using IN with the "Current Calibration" pot installed will result in a DC shift of the PWM signal. As a minimum this configuration is likely to create power levels that are hard to accurately correlate to duty cycle controls from the driving G/M codes. It could also create DC errors preventing reaching full power levels. 
There are NO schematics available and without knowing the exact input configuration of the LPS only trial and testing can confirm that IN control is optimum. It seems that most Smoothie users are configured this way using a Level Shifter (Ls).

Here is how the Light Objects controller is connected notice that the PWM output on the controller is connected to "IN" on the LPS.

Laser "FIRE" control:

Different "FIRE" functions are used in type A and B LPS configuration. The main theory for using a "FIRE" control function is to simulate the modulation of the "Test Switch" using the PWM signal
Using this configuration is more rational for controlling the LPS with a logic level derived PWM signal. That said and unlike the IN signal I found no evidence in the LPS documentation that "Fire" signals are intended for PWM control. The key concern is that there may be LPS internals (filters/ caps) that do not allow the response necessary for a PWM signal especially at low PWM duty cycles where the pulse width is small. This could create strange laser power problems if the input circuitry is filtering higher speed inputs than a switch closure would provide. I have seen a few K40 configured using a "Fire" function.

  • The Smoothie PWM in K40 configurations are typically configured for 50 Hz operation.
  • The signals used as the "FIRE" function is:
    • Type A: +K
    • Type B:  TH or TL.  TH (high) and TL(LOW).

One discussion that often crops up in forums is if the "Current Regulation" pot should be left connected to serve as a "MAX" limit control when using the IN signal as a PWM input. I think that is a good idea but am unsure if it creates any interface or reliability problems with the PWM control.

"L" Control

In this configuration the PWM signal from a controller is connected to the "L" pin on the LPS's power connector. Most evidence suggests that this is a "laser on" function. 
The logic is that the M2 Nano must control the laser some how? The only connection between the M2Nano and the LPS is the "LO" connector which connects to the "L" on the LPS's power connector.

The LO signal is a low true enable to the LPS. At this point I suspect the L signal is the power on/off control in the stock K40 controller. 
Some have reported successfully using the LO signal for PWM, but others have told me that if LO is not statically held low the "Laser Test" SW will not fire. Clearly the upcomming tests will remove the confusion.

M2Nano Pinouts:

This is the best outline of the M2Nano controller pin-outs I have found:

I traced the LO signal on the M2Nano and found that it is connected to a transistor (see pencil point) and the upper left 2 pin connector. Notice the LO label on the left side of the power connector and on the left side of the two pin connector at the top right. This tracing at least suggests it is a used function.
M2Nano controller LO signal 

L Control Conflict:

According to some reported tests it seems that the "L" signal on the LPS must be kept at ground for the laser to fire at all and therefore cannot be used for PWM control. To make matter more confusing some posts were confusing this "L" with the "TL" on Type B supplies.

This configuration suggests using LO for PWM input will work: 

LPS Power Connector:

The Power connector on the LPS typically contains these signals:
  • 5VDC (Yellow)
  • GND (Black)
  • 24VDC (Green)
  • L (Pink) [the M2 Nano LO pin connects to this pin in stock K40's]

Power Supply Configurations:

LPS with white connectors:

Label on back of my LPS supply, I got to it with a video borescope :)

MYJG40W [S/N: 2015090481]

Mine looks like this (I think this type is out of production): 

Ebay: MYJG40 (first time I have seen one like mine for sale)

LPS with all Green Connectors: 

  • LPS part #: MYJG40W [S/N: 2015090481]
  • Suppliers website: ( mine does not look like this): MYJG40W


General LPS specs:

Taken from ebay site

DC output specs:
  • 24v@ 1 amp
  • 5V @1 amp

Laser Power Supply (LPS) Interfaces

I arbitrarily labeled the two types of interfaces "A" and "B" to simplify the documentation. 

Type "A"  LPS control interface:

Current regulation

  • Ground: signal ground
  • IN: laser current control 0-5VDC
  • 5VDC: 5V power [** 5.02 VDC]
Note: the "Current Regulation" pot is connected across these three signals with the center tap connected to IN.

Test Switch ("FIRE")

  • K+: Test switch [**4.28 VDC]
  • K-: gnd return for laser [connected to gnd]

Laser Switch (enable)

  • P+ Laser Switch [**4.28VDC]
  • P- gnd return for Laser Switch [connected to gnd]
** voltage measured with connectors removed
Showing the interface equivalent circuit.

Type "B" LPS control interface:

I think this is the configuration that ships with newer K40's.

Terminal Definition as follows:

THInput SignalOn-Off laser control,TH≥3V, emitting laser; TL≤0.3V, no laser.
TLInput SignalOn-Off laser control,TH≥3V, no laser; TL≤0.3V, emitting laser
WPInput SignalOn-Off laser control,TH≥3V, no laser; TL≤0.3V, emitting laser
GGNDThis foot must be connected well with the laser machine shell and the ground of control board.
INInput SignalThe control of laser power: Both 0-5V analog signal and 5V PWM signal can control the laser power.
5VOutput PowerOutput 5V, the maximum output current is 20mA.

Note: WP = water protection, assume this is an interlock loop for the water pump.

Manual K40 Laser Power Control

The front panel has a knob called "Current Regulation". Its a 2K ohm pot that is wired across 5VDC. The wiper is connected to the Laser Power Supply's IN signal. This configuration provides the stock K40 a 0-5VDC signal on the LPS-IN to adjust the power to the laser.

LPS PWM Interface Design 

Smoothie Open Drain Approach

After posting the level shifter approach below I got advice that the Smoothie could have on of its output configured for "Open Drain" connection to the LPS. 

This approach would completely eliminate the level shifter... YaY!

This approach uses two of the connectors to connect to the Smoothie. One (x10) to connect to the drain of Q6 (a AOT240L MOSFET) and one (X6) to pick up ground.

This schema uses P2.5 in the "Laser" configuration section of the configuration file to set up the PWM but P2.4 can also be used. 

Q6 is high current MOSFET, and if we wanted to reserve it for later use P2.4 and Q9 could be employed instead but the configuration would have to be set accordingly. 

An untested sketch of how that might work is below. I still do not like that the "Current Regulation" pot is the pull-up in this design and when adjusted to zero grounds the driver. Just does not feel clean.

Still working this design. It may be that a pull-up and a low pass filter is needed on the "IN" to isolate the DC and the series resistor is unneeded. This would need testing.

Open Drain Design

"FIRE" with Open Drain

In this configuration the open drain and a correctly sized pull-up is connected to the +K which is the signal used to turn on the laser with the "Test Switch". The PWM would need ground to be the full power level, since the open drain inverts the PWM signal no configuration changes are not necessary. With the right size pull-up the "Test Switch" can remain.

IN with open drain

In this configuration the open drain is connected to the IN port with or without the "Current Regulation" pot installed. The PWM would need 5 VDC to be the full power level, since the open drain inverts the PWM signal configuration changes are necessary.

Level Shifter (LS) Approach

We are going to connect the PWM signal to the LPS-IN or "FIRE" function for power control. The output coming from the Smoothie's PWM swings from 0-3.2VDC and the LPS-IN or "FIRE" expects a 0-5VDC swing to get to full laser power.
I decided to use one channel of a level shifter breakout from Adafruit. Yes it is overkill but even if you do build a equivalent shifter in discrete components it will require a breakout of some sort. The Adafruit breakout is just a few $.

4-channel I2C-safe Bi-directional Logic Level Converter - BSS138

LS connected to FIRE

In the type A case the output of the level shifter is connected to the +K or "FIRE" function with or without the "Test" switch installed. which is the signal used to turn on the laser with the "Test Switch". The PWM would need to be ground true so the PWM would need to be inverted in the configuration.
In the type B case the TH input could be used and no inversion or configuration changes are necessary.

TODO: need to evaluate the impact of grounding the output of the LS when "Test" switch pushed.

LS connected to IN:
In this configuration the output of the level shifter is connected to the IN port with or without the "Current Regulation" pot installed. The PWM would need 5 VDC to be the full power level, since the LS does not invert the PWM no PEM configuration changes are necessary.
TODO: evaluate methods for DC isolation of PWM and pots dc offset.

Level Shifter

The level shifter design is shown below including a model of the input to the LPS. Ideally this would be on the middleman or built into a smoothie version.

Level shifter breakout and LPS input model

Smoothie PWM characteristics and configuration:

See this configuration file for duty cycle and frequency settings:

# Laser module configuration
laser_module_enable                          true             # Whether to activate the laser module at all. All configuration is 
                                                              # ignored if false.
laser_module_pin                             2.5              # this pin will be PWMed to control the laser. Only P2.0 - P2.5 
                                                              # can be used since laser requires hardware PWM
#laser_module_max_power                       0.8             # this is the maximum duty cycle that will be applied to the laser
#laser_module_tickle_power                    0.0             # this duty cycle will be used for travel moves to keep the laser 
                                                              # active without actually burning
#laser_module_pwm_period                      20              # this sets the pwm frequency as the period in microseconds

Smoothie configuration for open drain

The open drain will invert the PWM signal from the Smoothie therefore the configuration file would have to change the output polarity by appending <<!>> to the pins definition.
Smoothie pin Invert parameter.


Parked: header file for laser control. Come back later and explain.

Smoothie control of Laser

Link to additional discussion regarding controlling of laser with two control pins:

PWM frequency

Note that the period in the above configuration file is 20 us (.000002 sec). 
That is a frequency of 1/.000002 = 500,000 cps or 500 KHZ

Design problems?

Looking at the model of the input to the right of the picture reveals a few situations that I need to investigate. When the pot is turned all the way down it will essentially be shorting the level shifter to ground. Will this cause enough current draw to burn out the BSS138, who's max current is 220 ma? 

I also wonder how the changing DC offset + PWM will effect the integrated IN signal. It may be necessary to remove the level shifters output pull-up (it is in parallel with the pot) and add a series resistor to the output.

At this point this is all untested......
After building a test set up I will test for these cases and report here.

Design Musings

Something about using the "Current Regulation" pot as the pullup in the open drain configuration still bothers me. Theoretically this will adjust the max voltage the PWM pulse can achieve giving the effect of a lower power offset. I can't decide if this is a cleaver approach or a ugly hack that will come and bite me later.

Seems like the "right" approach is to insert a PWM to voltage converter. Then again, in its simple form is just a low pass filter anyway, which is what we are expecting is on the input of the LPS.

I would still like to isolate the PWM from DC offsets created by the Current Regulation pot.

I like the open drain approach the best as it is simple and eliminates the LS breakout. 

Enjoy, and leave comments. 
Maker Don.