# ANet A8 running Marlin v1.1.9 Auto Bedlevel with ROKO SN04-N

I'm trying to get the ROKO (SN04-N) sensor to work with my Anet A8. First of all, while trying to screw it to the extruder, I tightened it too much and sort of broke the acrylic plate... sort of. I had to use a very thin steel plate with two holes to enforce the acrylic plate. It still works.

Now, I followed instructions in this video. (Please note that the video is not in English.) After the first "Auto Home" operation, the guy draws on the bed and then measures. My measurements are slightly different.

At the 19-minute mark, the guy is hard-coding the values but I don’t understand how he calculated them? My measured offsets are: X_PROBE_OFFSET_FROM_EXTRUDER 16 and Y_PROBE_OFFSET_FROM_EXTRUDER 58. In his video, his calculations were 18 mm for the X offset and 57 mm for the Y offset. Either way, I’m not able to compile the code as a sanity check fails:

static_assert(FRONT_PROBE_BED_POSITION >= MIN_PROBE_Y, "FRONT_PROBE_BED_POSITION is outside the probe region.");


Here are the sensor limitation values from the configuration file:

// Set the boundaries for probing (where the probe can reach).
#define LEFT_PROBE_BED_POSITION 20 //MIN_PROBE_EDGE
#define RIGHT_PROBE_BED_POSITION 200 //(X_BED_SIZE - MIN_PROBE_EDGE)
#define FRONT_PROBE_BED_POSITION 47 //MIN_PROBE_EDGE
#define BACK_PROBE_BED_POSITION 200 //(Y_BED_SIZE - MIN_PROBE_EDGE)


What am I doing wrong?

Note that I'm using Marlin Firmware v1.1.9

Too bad you broke the acrylic plate (nice temporary fix though), but you can easily print a replacement part once your machine is up and running.

Probe positioning is defined in the Marlin configuration as:

 *      +-- BACK ---+
*      |           |
*    L |    (+) P  | R -- probe (20,20)
*    E |           | I
*    F | (-) N (+) | G -- nozzle (10,10)
*    T |           | H
*      |    (-)    | T
*      |           |
*      O-- FRONT --+
*    (0,0)


This implies that your sensor is located on the back-right when facing the machine and need to have the following constants set:

#define X_PROBE_OFFSET_FROM_EXTRUDER 16   // X offset: -left  +right  [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER 58   // Y offset: -front +behind [the nozzle]
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0    // Z offset: -below +above  [the nozzle]


In order to calculate the correct limits of travel for the sensor, you need to subtract the offset values from the bed size at the max limits.

#define MIN_PROBE_EDGE 10


As the sensor is off-center with respect to your nozzle, one can only assume that you have no extra space to move the whole printhead and therefore need to confine the head within the limits of the max/min bed size (there should be some extra space, this can be seen from the offsets for the origin as in values for X_MIN_POS and Y_MIN_POS, but for the sake of simplicity these will not be taken into account).

Basically, your positive Y and positive X offset result in the following schematic.

Or, if you include the #define MIN_PROBE_EDGE [value]

Bed limits for the sensor then will need to be calculated based on the values of your offset of the sensor. E.g. when your nozzle is at (X=0, Y-0), or (0, 0), your sensor is at (16, 58). If you don't want to move the head further left and forward (to respect to origin as limit!), this is the minimum position of the sensor. When the sensor is at the back-right position of (220, 220), the actual head is at (220-16=204, 220-58=162).

This means that the limits for the sensor without a minimum offset are (16, 58) and (220, 220):

#define LEFT_PROBE_BED_POSITION (X_PROBE_OFFSET_FROM_EXTRUDER + MIN_PROBE_EDGE)
#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE - MIN_PROBE_EDGE)
#define FRONT_PROBE_BED_POSITION (Y_PROBE_OFFSET_FROM_EXTRUDER + MIN_PROBE_EDGE)
#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - MIN_PROBE_EDGE)


would translate with a MIN_PROBE_EDGE = 0 to:

#define LEFT_PROBE_BED_POSITION 16
#define RIGHT_PROBE_BED_POSITION 220
#define FRONT_PROBE_BED_POSITION 58
#define BACK_PROBE_BED_POSITION 220


and would translate with a MIN_PROBE_EDGE = 10 to:

#define LEFT_PROBE_BED_POSITION 26
#define RIGHT_PROBE_BED_POSITION 210
#define FRONT_PROBE_BED_POSITION 68
#define BACK_PROBE_BED_POSITION 210


The assertion in code: FRONT_PROBE_BED_POSITION >= MIN_PROBE_Y would now translate to (58 >= 58) (or 68 >= 58), in your case it was (47 >= 58) which clearly is not true.