Upgrading a K40 Laser Cutter, Part 1: Control Board Upgrade

Get yourself a new laser cutter? Plug it in just to find out that it either doesn’t work or do what you thought it should? Let’s upgrade it!

One of the simplest things you can do to improve the capabilities of your cheap, Chinese laser cutter, sometimes known as a K40, is to upgrade the electronics. The control board it comes with is pretty horrible and not very easy to work with. It is designed to work with proprietary software such as MoshiDraw which is meant namely for raster engraving. This is fine if all you plan on doing are laser-etched phone cases, but not for much else.

By replacing the control board and electronics, you will be able to do accurate vector cutting and engraving as well as raster engraving with the right software.

This how-to is assuming you have the K40 version with the analog ammeter (the “old-fashioned” current meter) and the potentiometer. This how-to would likely be mostly applicable for the version with the digital power selector as well.

Parts and Materials

To follow this tutorial, you will need the following. I’ve included links to less common items that the average person may not already own and can’t find at local shops easily. Feel free to substitute any of these; these are just what I used for my build.

Control Board Upgrade:

General Tools and Supplies:

  • Soldering Supplies
  • Masking Tape
  • Electrical Tape
  • Sharpie/Permanent Marker
  • Computer with the Arduino IDE installed and an internet connection

Downloads and Software You’ll Need

To make a functional laser cutter, the main things you are going to need are below. Everything as follows is free and open source.

  • Arduino IDE
    • This is what we will use to program and configure our control board
  • GRBL Firmware
    • This is what will run on our control board
    • You want to use version v1.1 or higher
  • Laserweb
    • This is optional, but it is what I use to generate the path file (called a gcode file) that tells the laser what to do.
    • This software can also be used to move the laser head for general testing.

Label Your Wires!

Before you take apart your laser, it is important to label a few wires. Simply take a piece of tape and folder over the wire to make a “flag” and use a permanent marker to write on it what it is. You can see in the picture what the board usually looks like with the silk screened connection labels. Find and label the following:

Wires in the Power and Control Bundle

These are usually four blue wires into one connector. You can find out what they are by looking at the silk screened labels on the original control board. If you are unsure, already took the connector of the board (and lost said board), or just want to double check, you can check the voltage between the chassis of the laser power supply and the pin on the connector (or the wire if need be).

  • 24V Wire
  • 0V Wire
  • 5V Wire
  • Laser Control Wire
    • This will measure at or close to 5V. If you are manually trying to figure out if a wire is 5V or the laser control signal you can try the following:
      • Place a thick piece of wood or ceramic tile under the laser head and shut the cutting chamber door.
      • Set the laser power to its highest setting and press the laser enable button (latches down)
      • Connect the wire to the chassis of the laser power supply through a 10k ohm resistor
      • If the laser fires (or you see the current meter jump a small amount), that wire is the laser control wire. Otherwise, it is the 5V wire.

Stepper Motor Wire Bundles

You don’t need to label the individual wires, but you do need to mark out which stepper motor cable bundle goes to which motor. The “X” axis motor is the one that will move the laser head from left to right. Likewise, the “Y” axis motor is the one that will move it back and forth.

Create the Laser Logic Board

When the GRBL firmware (the software running on the Arduino) wants to turn on the laser ON, it sends out a 5V signal. Unfortunately for us, the K40 laser power supply looks for a 0V signal to know when to turn the laser on. Rather than tweak the firmware to reverse the signal (GRBL isn’t exactly user-friendly), we are going to make a simple sinking logic inverter circuit.

The laser firing signal itself is being held to 5V through an internal pull-up resistor. What this means is that to fire the laser, we need to “sink” the signal to ground. We can do this by using the circuit below. When the PWM pin is given 5V by the Arduino, it will cause the transistor to conduct electricity which will cause the laser firing signal to go to 0V (firing the laser). I’ve also added an LED path to the circuit so that we can see when the laser is supposed to be ON.

Connect the PWM pin to D11 on the Arduino, the LASER_ON pin to the laser firing signal wire (on the laser power supply), and GND (ground) to both the 0V of the laser power supply and to ground of the Arduino.

K40 Laser Signal Conditioning

Flash and Configure GRBL

GRBL logo

The heart of our laser lies in the GRBL firmware. While there has been a port of Marlin by a user named “Turnkey Tyranny” for laser cutters for a couple years, I find that the newer version of GRBL (which has a laser mode) works a lot better. The main reasons I prefer GRBL to the Marlin port:

  1. GRBL is 100 times easier to configure. The Marlin port, unless it has been cleaned up recently, has a million 3D-printer specific settings that make it difficult to determine which of the items you actually need to tweak for your system. GRBL on the other hand is designed to be as bare bones as possible and the same applies to the settings.
  2. GRBL doesn’t require any special plugins to work well like the Marlin port does. Simply boot up software like Laserweb and you are ready to go. Marlin, on the other hand, requires a special (and somewhat confusing) Inkscape plugin to function correctly.
  3. Most of the settings you’d want to change are broken out natively in the EEPROM which means you can change all of the required settings for our needs without changing the source code.

If you haven’t done so already, download the GRBL firmware (version 1.1 or higher). You can find that here: https://github.com/gnea/grbl

Follow the instructions on the GRBL wiki (found here) to install it on your Arduino.

After installing it, you will need to change some of the configurations in order to use it with your K40. Below is the configuration that has worked for me on three separate builds (one for myself, one for my makerspace, and one for a friend). To change a setting, open the serial console in the Arduino IDE, set the line ending to “newline” and type $OPTION=VALUE. For example, you might type “$100=158” (without quotes) and then press the enter key. (In the event the table colors don’t render on your browser, the columns are from left to right: Option #, Meaning, Default Value, Our Value).

K40 GRBL EEPROM Configuration

OptionMeaningDefault ValueOur Value
$0Step Pulse (us)10
$1Step Idle Delay (ms)25
$2Step Port Invert mask0
$3Direction Port Invert Mask0
$4Step Enable Invert, bool0
$5Limit Pins Invert, bool0
$6Probe Pin Invert, bool0
$10Status Report Mask1
$11Junction Deviation (mm)0.010
$12Arc Tolerance (mm)0.002
$13Report Inches, bool0
$20Soft Limits, bool0
$21Hard Limits, bool0
$22Homing Cycle, bool10
$23Homing Dir Invert Mask0
$24Homing Feed (mm/min)25.000
$25Homing Seek (mm/min)500.000
$26Homing Debounce (ms)250
$27Homing Pull-Off (mm)1.000
$30Max Spindle Speed/Laser Strenght (1/10 rpm/%)1000
$31Min Spindle Speed/Laser Strength (1/10 rpm/%)050
$32Laser Mode, bool01
$100X Steps/mm250.000158.000
$101Y Steps/mm250.000158.000
$102Z Steps/mm250.000158.000
$110X Max Speed (mm/min)500.00050000.000
$111Y Max Speed (mm/min)500.00050000.000
$112Z Max Speed (mm/min)500.00050000.000
$120X Accel (mm/sec&2)10300
$121Y Accel (mm/sec^2)10300
$122Z Accel (mm/sec^2)10300
$130X Max Travel (mm)200.000
$131Y Max Travel (mm)200.000
$132Z Max Travel (mm)200.000

Hooking Up the Arduino Control Board

K40 with ArduinoWith the laser logic board done and the wires labeled, “all” we need to do is wire things up to the Arduino control board. Most of this is relatively easy, just take your time. UNPLUG YOUR LASER FROM THE WALL BEFORE GOING ANY FURTHER!!!

1) Place the 2.54mm Jumpers on the Stepper Shield and Mount the Stepper Drivers

Under where the stepper drivers go are three pairs of pins. These are the microstepping mode selection jumpers. In a nutshell, if you leave all of these populated, you’ll get a lot of torque on the stepper motors but not great resolution. The end result is some fairly choppy and loud movement that results in jittery cuts and engravings. To fix this, populate all of the jumper pairs with the jumpers. Technically speaking, you only need to populate the X and Y sets, but I personally populate all of them if only to have extras leftover if I need them later.

Add the stepper drivers onto the motor shield. Make sure you line up the Enable/EN pins, otherwise you’ll blow the motor drivers. It wouldn’t necessarily be a bad idea to only mount two at a time (one for X, the other Y) and save the others for a rainy day. If your steppers came with heatsinks, install those as well.

2) Solder in the Laser Logic Board

If you haven’t done so already, solder the three wires to the laser logic board. These would be PWM, LASER_ON, and GND.

The PWM wire gets soldered from the logic board to pin 11 (D11) on the Arduino. I’d recommend soldering this to the stepper shield.

The LASER_ON wire should be connected to the laser control wire you found earlier. Use a bit of electrical tape or heat shrink to protect the connection.

The GND wire can hang free for now. It will eventually go into the GND/0V screw terminal of the stepper shield.

3) Wire in the Stepper Power

The stepper motors take a fair amount of power to move cleanly. Strip the end off the 24V wire from the laser power supply and screw it into the positive/+/Vcc pin of the stepper motor shield. Do the same for the 0V wire on the laser power supply into the 0V/GND terminal, but this time also place the 0V wire from the laser logic board into the 0V/GND terminal as well.

4) Add the Stepper Motors

Fit the X and Y stepper motor connectors into their respective places on the stepper shield. You may need to bend the male headers slightly one way or the other to get these to fit on well. Don’t worry about which direction these go quite yet, just make sure the wire colors are in the same direction for both connectors.

5) Testing

Place the stepper shield onto the Arduino and place the Arduino on a non-conductive surface (like a piece of wood or tile). Double check any of your connections and then close any open doors and plug in the laser. Disconnect any USB connections, turn on the power switch, and wait a few seconds. Listen to make sure there aren’t any pops or miniature explosions. If all seems well, power down the machine and take a quick look at your circuits for anything burned or damaged. If this goes well, you are ready to connect the system to your computer.

Testing the Configuration

With everything mostly complete, it’s time to test out our GRBL configuration and our stepper wiring.

  1. Plug the Arduino into your computer with the Arduino IDE installed.
  2. Connect the serial console and set the line endings to newline.
  3. Manually move the head of the laser about center in both the X and Y directions.
  4. Type the following and press enter: G0X50
    1. The laser should move to the right 5cm. If not, power down the laser, remove the X stepper cable from the stepper shield, and plug it in “backwards”.
    2. If the Y axis moves instead of the X axis, swap the X and Y stepper cables.
  5. Type the following and press enter: G0Y50
    1. The laser should move forward/up 5cm. If not, power down the laser, remove the Y stepper cable from the shield, and plug it in “backwards”

The laser should now have the stepper motors wired correctly. If you typed in any of those commands and it didn’t move, you may need to make sure your stepper motor was wired correctly into the connector in the first place. “Google” stepper motor wire colors to try to get a good idea of what that should look like. One thing to note is that with any cheapo product, the wire colors may not line up, so there may be some experimentation required to get your laser head to move.

The last bit of testing is to make sure your laser head is moving the correct amount and that your steps/mm configurations are correct. One way to do this:

  1. Type the following in the serial terminal and press enter: G0X0Y0
  2. Manually move the laser head to the far left and place a piece of masking tape onto the top of the X axis rail.
  3. Manually move the laser head close to the center of the X axis rail and use a permanent marker to mark its location on the X axis rail.
  4. Type the following in the serial terminal and press enter: G0X100
  5. Mark the new location of the laser head and measure it. You should get 100mm (plus or minus a bit of human marking error).
    1. If your length is more than a couple millimeters off, count the number of teeth on your drive pulley and then use the Prusa calculator to determine what values should go it $100 and $101.

About the Author:

I'm an electrical and controls engineer with experience in C++, C#, Sequencer Programming (ie "Game Loop), a little bit of graphic design, 3D modeling, and bits and bobs of a lot of game design.

6 Comments

  1. […] Looking to upgrade your laser cutter? Check out my post here: http://www.foxrobotics.com/2018/03/19/upgrading-a-k40-laser-cutter-part-1-control-board-upgrade/ […]

    • Jeff June 4, 2018 at 5:34 pm - Reply

      Hello! Great post! There are so few people using the Arduino as a controller for the K40. This is very helpful and I will be using it in my build. I was wondering if you use an LCD screen with this? Could you go over how to wire it into board? I am new to the arduino world. Thanks!!

      • Austin Steingrube July 8, 2018 at 4:47 pm - Reply

        I’m not currently using an LCD screen at all with this, but I do have a mod in mind (and parts for it). I’ll see if I can work that in and do a blog post about it. Are you thinking something like a RAMPS style control screen? Or something else?

  2. Jeff June 4, 2018 at 5:33 pm - Reply

    Hello! Great post! There are so few people using the Arduino as a controller for the K40. This is very helpful and I will be using it in my build. I was wondering if you use an LCD screen with this? Could you go over how to wire it into board? I am new to the arduino world. Thanks!!

  3. sam July 7, 2018 at 5:37 am - Reply

    Thanks for the post Austin. Will be upgrading soon as well as the lens and mirrors. Should do the trick!

  4. Bernardo November 22, 2018 at 7:42 am - Reply

    Would it be possible to post some pictures of how it was after it was done?

Leave A Comment