Marlin & BLTouch Anet A8

This was my process for installing Marlin and a BLTouch on my Anet A8 3D-printer. With the help of the internet I made some sort of summary.

My first reason for installing Marlin on the Anet A8 is the thermal safety. The stock Anet A8 firmware does not recognise a broken thermistor (for measuring the temperature of the hotend and bed). When the termistor is broken and gives a reading, the hotend/bed doesn’t stop heating and eventually you get a fire. That’s not a thing you want.

About the BLTouch. I always wanted to try out some sort of automatic bed levelling, but therefore you need a firmware upgrade (to for example: Marlin). I’ve read some good reviews about the BLTouch (and also some bad ones) and decided to order it. An inductive/capacitive sensor works for some types. You can also buy an IR sensor for the Anet A8, but there you have problems with reflections. So I went for a mechanical one.

Hardware

There are a lot of BLTouch mounts made by other people, but I couldn’t find the right one for my application, so I made my own using FreeCAD. You can download it here.

Step 1: creating a bracket for the BLTouch.

For the mounting position I checked the distance specified by Antclabs (the manufacturer of the BLTouch). As you can see in the CAD Dimension it needs to be 2.3-4.3mm above the nozzle.

The bracket is designed for mounting between the fan and heatsink of the extruder assembly
Bracket sliced in Cura

Step 2: mounting it to the printer

It took a few iterations
This one is about 3 mm above the bed

Step 3: Electronics

According to the schematic in the picture I made the connections. You need to disconnect the current Z Probe because you don’t need it, also make sure that you lower (or remove) the old Z switch so the printer doesn’t collide with it.

Wiring BLTouch V3.1 with the Anet A8 board

If you want to know what all the wires are doing, check the BLTouch manual.

The orange wire is connected to a servo pin (this is defined later in the software), this pin is not used for the standard Anet A8 display.

You can cut the screen cable for that pin and solder a wire in between to connect the orange wire of the BLTouch. I made a simple board with male and female headers to feed through the wires of the display. I added a single male header to connect the orange wire (in my case this was yellow) to the board.

Female headers to connect to the mainboard
Male headers for the screen cable and BLTouch
Connected to the mainboard

When connecting to the mainboard, make sure you plug the screencable the right way in. Also check the soldered connections with a multimeter. For me the BLTouch firstly didn’t work because of a disconnection.

Software

Disclaimer: this was my process for flashing the Marlin firmware to my Anet A8 board. I can not guarantee that it works for you. You do it at your own risk!

Make sure you have installed the Arduino IDE. I used version 1.8.13.

Download the anet-board-master folder and place the ‘anet‘ (not the whole anet-board-master folder!) folder in your Arduino sketchbooklocation under the ‘hardware’ folder (create if not exist). It will look something like: “…\Arduino\hardware\anet”.

Download the Marlin version you want to use. I went with 1.1.9.1 because they added support for the BLTouch V3.1. Due to some research I found out that most of the time the 2.0 version doesn’t work because of the limited capabilities of the stock Anet A8 controller board. Maybe that’s an upgrade for the future.. I also have the stock Anet A8 display.

Marlin setup

I unzipped the Marlin folder and copied the ‘Configuration.h’ and ‘Configuration_adv.h’ from the “…\Marlin-1.1.9.1\Marlin\example_configurations\Anet\A8” folder and pasted (overwrite!) them in the “…\Marlin-1.1.9.1\Marlin” folder.

‘Configuration.h’ and ‘Configuration_adv.h’ files

After that you can open the ‘Marlin.ino’ file in the Arduino IDE.

Select the ‘Anet V1.0’ board in the board manager.

Anet V1.0 board selected

When compiling I got the following error: ‘non-constant condition for static assertion’. After some research (link1, link2) it turned out that the newer ‘Arduino AVR Board’ versions in the boards manager doesn’t work with this Marlin version. You need to downgrade to version 1.6.23. Now it compiled without any errors.

Downgraded ‘Arduino AVR Board’ to 1.6.23

Activating BLTouch in Marlin

With CTRL+F in the Arduino IDE, you can find the lines discussed in this part.

In the ‘Configuration.h’ file, uncomment the the following line #define BLTOUCH.

You don’t have to add #define SERVO0_PIN 27 //for the Anet A8 display after that as many tutorials show. In Marlin 1.1.9.1 this is already set in the ‘pins_anet_10.h’ file. Also the #define BLTOUCH_DELAY 375 is defined in the ‘Conditionals_LCD.h’ file.

Change the #define Z_MIN_PROBE_ENDSTOP_INVERTING true to #define Z_MIN_PROBE_ENDSTOP_INVERTING false. Otherwise the nozzle will crash into the bed…

Also change the following lines according to your BLTouch mounting position. Here you need to measure with a ruler or calipers. See the code drawn picture for explanation.

/**
 *   Z Probe to nozzle (X,Y) offset, relative to (0, 0).
 *   X and Y offsets must be integers.
 *
 *   In the following example the X and Y offsets are both positive:
 *   #define X_PROBE_OFFSET_FROM_EXTRUDER 10
 *   #define Y_PROBE_OFFSET_FROM_EXTRUDER 10
 *
 *      +-- BACK ---+
 *      |           |
 *    L |    (+) P  | R <-- probe (20,20)
 *    E |           | I
 *    F | (-) N (+) | G <-- nozzle (10,10)
 *    T |           | H
 *      |    (-)    | T
 *      |           |
 *      O-- FRONT --+
 *    (0,0)
 */
#define X_PROBE_OFFSET_FROM_EXTRUDER -19   // X offset: -left  +right  [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER -41   // Y offset: -front +behind [the nozzle]
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0   // Z offset: -below +above  [the nozzle]

I didn’t change anything in the line #define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow but you can go lower to speed up the auto levelling process. Don’t go to low!

Uncomment the line #define AUTO_BED_LEVELING_BILINEAR for enabling the auto leveling. You can also enable other types of bed levelling. They are described in the lines above the mentioned line.

Uncomment the following lines and change the values. They depend on where your BLTouch is mounted. Because the Y-axis cannot move further, my maximum BACK_PROBE_BED_POSITION is around 180. So I set it to 175 to have a bit of a margin.

#define LEFT_PROBE_BED_POSITION 30
#define RIGHT_PROBE_BED_POSITION 190
#define FRONT_PROBE_BED_POSITION 30
#define BACK_PROBE_BED_POSITION 175

Uncomment the #define Z_SAFE_HOMING so the printer homes in the middle of the bed.

Now verify everything with the button on top (in the Arduino IDE) and wait for compiling. The whole sketch uses 98%! of the available program storage space on the Anet A8 main board.

Uploading the Marlin firmware

So connect your Anet A8 main board with your computer via a USB cable. Select the right COM port in the Arduino IDE. And click ‘upload’. The IDE will now compile your code again and upload it to the board. This can take a few minutes!

Select the right COM port

After uploading, your printer will reset with the new Marlin firmware. Congrats!

After plugging the printer in, the Marlin 1.1.9.1 screen comes up

Testing the BLTouch

For testing if everything works, you can use the software called Pronterface. This allows you to send GCode commands to the 3D printer over USB.

Pronterface

First select the right COM port and baud rate, then click connect. Now you can control the printer with the ‘joystick’. For me the printer crashes if I use the middle red button, so be aware of that.

To check the endstop states, send the command M119. You will get something like:

Reporting endstop status
x_min: open
y_min: open
z_min: TRIGGERED

Now send the command M280 P0 S10. This will use the SERVO0_PIN discussed earlier. If everything works alright, the BLTouch deploys it pin and the red LED will turn off.

BLTouch deployed

If you now send the command M119 again. You get:

Reporting endstop status
x_min: open
y_min: open
z_min: open

Send M280 P0 S90 to retract the BLTouch probe.

BLTouch retracted

Autohoming

As you can see, the XYZ values on the screen blink with question marks. This means that the software does not know where the printhead is (source). After autohoming the question marks will go away.

Clicking the middle button (of the display) will bring up the menu. Navigate to menu > prepare > Auto home. Confirm with the middle button. The printer should now autohome itself. This will now happen in the middle of the printing bed. You can also send the G28 command via Pronterface.

Adjusting the Z-height

Now, go into menu > Prepare > Move axis > Move Z > Move 1mm. The distance to move depends on your set height above the bed. For me it’s now on +010.0mm. Change it to +000.0mm and while doing that, make sure you don’t chrash into the hotbed with your nozzle. If everything is alright, the nozzle doesn’t touch the bed at +000.0mm. Otherwise, check your mounting of the BLTouch.

Now go back to the menu and go to menu > Control > Motion > Probe Z Offs. Adjust this value to get the nozzle on a good printing distance from the bed (just as with manual bed leveling). So use a piece of paper or a measuring tool to get the right distance from the bed (I use around 0.10mm). Because the printer will not move when changing this value, you need to go back and autohome a few times and move the Z distance to +000.0mm again. If you are close to the bed, you can use the 0.1mm moving function for better control. Make sure you don’t chrash in the bed. Better more time spend on a few times going back and forth, than ruining your nozzle/print bed.

While printing you can also adjust this setting to get a better adhesion to the printing bed.

After you have a good value, store this value by navigating to menu > Control > Store settings. Otherwise it will lose the setting when you restart your printer.

My first Z offset setting was -2.37. Don’t put it to low because it will scratch the bed…

Scratched the bed because of a to low Z Probe Offset

Bed leveling

To start the auto leveling sequence make sure you first did autohome. Then go to menu > Prepare > Level bed. The procedure will now start. The printer probes 9 times on the bed because of the billinear bed leveling.

If you want more information about the bed levelling, open Pronterface and send the commands G28 (for autohome) and G29 (bed leveling). After completing, the printer will send the Leveling grid data over the USB. It will look something like:

Bilinear Leveling Grid:
      0      1      2
 0 -0.038 -0.100 -0.423
 1 +0.142 -0.023 -0.358
 2 +0.110 +0.060 -0.197

As you can see, I can adjust my bed a little bit. Together with the G29 command, the printer calculates the imperfections and adjust them while printing. Note: the (0,0) position is the first measured point. So in my case this is leftfront (when in front of the printer). Lokster made a very nice visualiser.

Slicer settings

I’m currently using Ultimaker Cura 4.7 as my slicer for GCodes to print. You need to add G29 to the start GCode of each GCode file you want to print to enable the bed leveling every time.

Go to ‘Manage printers’ and choose your Anet A8. And go to ‘Machine settings’. And make sure the G29 command is placed after the G28 command. For me I only had to remove the ; in front of the G29 command (the ; is used to create a comment).

Manage printers in Cura 4.7
Make sure G29 is in the Start G-code after G28

Error handling

If not, check your connections again. For me, the first time the BLTouch did not deploy due to a soldering error. The SERVO0_PIN was not connected to the BLTouch. So take your multimeter and test it.

When autohoming my BLTouch was not in the middle of the bed. I changed the bed variables and uploaded Marlin again to the printer. For me that didn’t overwrite the settings like the Probe Z Offset. Check this before printing again.

Testing

In FreeCAD I designed a square of one layer thick to test the adhesion and to check if the printing was good. With this I also finetuned the Probe Z Offset setting. You can download it here.

Flatbed test piece

My experience is that the right side of my bed is closer to the nozzle (because the testpiece is thinner) despite the BLTouch. Also it’s doesn’t have exactly the same offset to the bed every time, but most of the time it’s okay. You can also choose to not home for every print. Then you should leave out the G-codes from your slicer and use the retreive leveling data from memory G-code.

Let’s see how it goes with the next prints! The upgrade to Marlin 1.1.9.1 was worth it. It’s now more failsafe (I tested this by pulling out a cable of the bed temperaturesensor). Thanks for reading! 😀

Sources

123-3d.nl: BLTouch V3.1

Antclabs: https://www.antaclabs.com/manual

Marlin: https://github.com/MarlinFirmware/Marlin/releases/tag/1.1.9.1 | https://marlinfw.org/meta/gcode/

Skynet: https://github.com/SkyNet3D/anet-board

Pronterface: https://www.pronterface.com/

Crosslink: Anet A8 Marlin Firmware 1.1.9 Upgrade. Comprehensive guide. | How to install Marlin firmware 1.1.9 on your Anet A8 3D printer in 7 easy steps | BLTouch on the Anet A8 – Hardware installation | BLTouch on the Anet A8 – Marlin Firmware 1.1.X configuration and calibration

Stackexchange: How to set Home Offsets and Manual Home definitions in Marlin correctly?

Reprap: Configuring Marlin Bed Dimensions

Thingiverse: Wiring

You may also like...

1 Response

  1. JaneDoeHogleg says:

    Thank you so much for this. I followed a few tutorials on YouTube and was tearing my hair out. Turns out the video I watched had the probe wire attached to the wrong pin on the screen connector. You saved my sanity and now its working perfectly.

Leave a Reply

Your email address will not be published. Required fields are marked *