Blog

You are filtering on tag 'cnc'. Remove Filters
RSS

Running a laser with Marlin and the Ender 3 board

December 26th, 2021 (edited November 3rd, 2022)

I recently started working on building a laser cutter/engraver. I wanted to use the Ender 3 v1.1.4 board and Marlin firmware because I already had them and was familiar with them. This didn't end up being too complicated, but it did require a few unexpected changes, which I'll document here. This isn't a step-by-step, just a summary of what worked for me.

I'm not an electrical engineer. This process worked for me, but I don't know if it will work you. Electricity is dangerous. Lasers are dangerous. Wear appropriate laser eye protection before powering the board with a laser connected.

You'll need to know how to build and upload firmware to the Ender 3 board to follow this. I have a little bit of info about that here.

I started with Marlin configured to run the Ender 3 Pro as a 3D printer. It's possible to run a laser in this configuration by plugging it into FAN1, the header for the part cooling fan. This is a 24V PWM signal with a pretty low frequency that you can probably increase by uncommenting FAST_PWM_FAN. However, I wanted Marlin to actually understand that this is a laser to improve the LCD interface and make sure I'm getting anything Marlin can do to optimize the results. So the first thing I did was just take a pass through 'Configuration.h' and 'Configuration_adv.h' making the obvious changes (diffs):

  • Commenting/disabling the extruder axis
  • Disabling the heaters and temperature sensors
  • Disabling the status screen images except STATUS_CUTTER_ANIM
  • Most importantly, enabling LASER_FEATURE and LASER_POWER_INLINE

This will actually work just work as far as Marlin is concerned, but I didn't know that at this point, because Marlin is actually no longer sending the laser PWM signal to the FAN1 header. This is because it would like to use the chip's faster hardware PWM for the laser instead of the slower software PWM it uses for the fan. Instead, it's actually moved the X stepper to the E stepper header, and it's sending the laser signals to the X stepper driver. For more info on this, see the bottom of 'pins_SANGUINOLOLU_11.h'.

Unfortunately we can't pick those signals up from the X stepper header because there's a stepper driver between the header and the board, and we can't easily remove the driver on this board (unlike some other boards that have socketed drivers). We have to follow the traces and find another spot on the PCB to pick it up. The laser PWM is configured in 'pins_SANGUINOLOLU_11.h' to come from pin 16 (PD7) on the microcontroller. I used the microcontroller datasheet to locate that pin, then used the PCB images from GitHub to follow the trace. I highlighted the trace in green below, and chose the via marked in red as the best place to insert a wire.

Diagram of the traces of Ender 3 mainboard.

Power up the board with just the LCD attached and use a voltmeter to test the voltage between the via and ground with the laser on and off to make sure you have the right one. I cut the end off a female Dupont connector (28 AWG) and soldered it through the via.

Photo showing laser power and control wires attached to the Ender 3 mainboard.

I'm using a 24V laser, so I'm giving it 24V from the FAN1 header. I commented the FAN_PIN definitions from Marlin in order to get an always-on 24V from the fan headers. You could probably pick up 5V from an unused two-pin header or 12V from the bed terminals if that's what your laser requires.

Photo showing laser power and control wires attached to the laser module.

I tested the laser using this wiring, and it was on when enabled, off when disabled, and respected the configured power output percentage, so I think the electronic configuration is good to go.


Permalink

Troubleshooting Ender 3 Pro Firmware Update

February 6th, 2021 (edited December 11th, 2021)

I recently installed Marlin firmware on my 3D printer (an Ender 3 Pro, 1.1.4 mainboard) so I could increase the size of the build space. You can find several step-by-step guides on how to do this online, and I used this one from Howchoo. It was, on the whole, very helpful, but I had to troubleshoot several unexpected issues along the way (and you should definitely expect to, also). I'm documenting them for anyone else who wants to follow the linked guide with an Ender 3 Pro. I was using a Windows 10 computer.

Wiring the Arduino (Howchoo step 5): don't forget to wire the Reset pin on the printer board to the ~10 pin on the Arduino. This isn't super clearly depicted in the pictures. If you don't do this, you'll see an error like this when burning the bootloader:

avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

Error while burning bootloader.

Compiling Marlin (Howchoo step 8): when I did this, the current version of the Arduino IDE was incapable of linking the current version of Marlin. This was because it was attempting to make a long shell call to the linker that exceeded Windows' maximum length. You'll see the following error message in the Arduino IDE after clicking "Verify" or "Upload" if this happens:

fork/exec C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc.exe: The filename or extension is too long.
Error compiling for board Sanguino.

As the call was largely using relative paths, I saw no way to easily reduce its length. Fortunately, there are plenty of other ways to compile and upload firmware (all of them are essentially wrappers around a compiler such as gcc and the uploader, avrdude, by the way), so at this point, I ditched Arduino and switched to following this guide from Marlin using Visual Studio Code.

PlatformIO Environment (Marlin step 2): the default_envs for the Ender 3 Pro in this configuration is melzi_optiboot. If you get this wrong you might see a series of errors like this on upload (the trailing hex value will vary):

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

Uploading firmware (Marlin step 2 [okay, like this entire tutorial is in step 2]): If you haven't (successfully) connected your printer to a computer via USB before, you might need to install drivers. If that's the case, you won't see the Ender in Device Manager (under Ports) or under the Arduino IDE's Ports list. PlatformIO might give you an error like this on upload:

Error: Please specify upload_port for environment or use global --upload-port option.

All the Ender 3 Pro boards use the CH340 drivers, which you can find here. Always restart your computer after installing drivers.


Permalink


Previous Page
2 posts — page 1 of 1
Next Page