About SKR2 settings

Hi,
I just purchased SKR2 board from BigTreeTech and want to run it with Repetier ver2 firmware. I see in constants.h file that STM32F4 chip is supported however SKR is not explicitly defined:
// STM32F4 based boards (3000 - 3499)
#define MOTHERBOARD_RUMBA32 3000
#define MOTHERBOARD_STACKER3D_SUPER_MINI 3001
Should I use any of these 2 motherboards in my settings, or do I need a different setup?
If somebody is already running Repetier on SKR2 and could share config, that would help immensely.

Thanks


«1

Comments

  • None of them will work. Checking the new board I see it uses a STM32F407VGT6 with 168MHz. Both boards use the F406 with 180MHz. Don't think difference are big enough to make changes necessary, but you need to set the correct cpu frequency and have a board description with the correct pin assignments for the board.

    If you are up to some testing I can try to copy some required files and make changes to the firmware so it theoretically should then work at the weekend, but it will be untested as I do not own that board. I would then post progress here for testing.
  • Sure, I can test. Hopefully it won't take more than 3 weeks, because then I will be out of town for 1 month.

    I am upgrading my old printer that currently has 8bit CPU controller running on Repetier 1.0.x. It is CoreXY H-bot with closed loop stepper drivers on XY motors, regular stepper on Z and single Hemera extruder. I have ABL enabled with Z-max sensor configured as Z-probe. Also have Zmin, Xmax and Ymax sensors. LCD is really old one - 4 lines with 20 characters in each but with SD card reader.

    Thanks!

  • At least the board configuration would be no problem. Features should all work ok. LCD type is supported but you might need to provide the driver/pins manually if there is no official connector for that format, but I will see then.
  • Ok, I have include dit all and it compiled a test config well.
    Set MOTHERBOARD to MOTHERBOARD_SKR_2 
    and in platformio.ini default_env to SKR2

    The board uses 3 different hardware SPI so hope spi devices work correctly. See skr.h for definitions and comments. By default the sd card on the board is used which has an own spi.
  • edited August 2021
    Wow! You even added all pin numbers! I was doing the same but will rather use your file. :)

    I downloaded the latest dev2 version and was able to successfully compile it with the changes you suggested. Unfortunately PC cannot "see" the board. Baudrate is set correctly. I tried to change BLUETOOTH_SERIAL value from 101 to -1 and then to 1 (not sure if this is even relevant). Did not see any difference in behavior with -1, and got compilation errors when set to 1. The same error appeared in several files saying - "undefined reference to `Serial1'"

    Just to make sure the board is functional I loaded Marlin and was able to connect to it and run G-codes via Pronterface.

    I'll keep looking into the issue, but decided to post this update in case you've seen this problem and have a quick solution.

    Thanks

  • Just to be sure uploading is working and only after compilation it is not working? I ask because windows has problems seeing board in dfu mode at least without some drivers if I remember right (no real windows user).
  • edited August 2021
    Compilation ends with SUCCESS status. Then using Windows Explorer's "Sent to" function I send firmware.bin file to SD card. After clicking Eject SD and removing SD card from PC I insert it into SKR2 and power it on via USB cable from PC.
    One red and one green LEDs light up and another red LED flushes several times and then comes up in half brightness. PC does not detect new serial port and Pronterface has nothing to connect to.

    Then if I disconnect SKR2 from USB and put SD card into PC's card reader I can see that firmware.bin file was renamed into FIRMWARE.CUR.

    I am comparably new to VSC and following Youtube instructions describing how to compile Marlin firmware and upload it to SD card. When repeating the exact same steps with Marlin code - it works. PC adds COM3 port and Pronterface can communicate with it. The file, btw, gets renamed into FIRMWARE.CUR as well.

    I think if missing driver would be an issue, it won't work with Marlin as well.

    Apart from this, when I set Z_PROBE_TYPE to 1 (1 = default z probe) I got the following compilation errors:
    Compiling .pio\build\SKR2\src\io\io_temperature.cpp.o
    src\drivers\zprobe.cpp: In static member function 'static float ZProbeHandler::runProbe(uint8_t, bool)':
    src\drivers\zprobe.cpp:278:27: error: redeclaration of 'RememberedEndstopMode oldMode'
      278 |     RememberedEndstopMode oldMode; // RAII does restore on return
          |                           ^~~~~~~
    src\drivers\zprobe.cpp:132:27: note: 'RememberedEndstopMode oldMode' previously declared here
      132 |     RememberedEndstopMode oldMode; // RAII does restore on return
          |                           ^~~~~~~
    *** [.pio\build\SKR2\src\drivers\zprobe.cpp.o] Error 1

    Thanks
  • Not sure if you are familiar with Marlin code and if this is helpful at all, but here is the video showing how to set up ports for it. You can watch from time stamp 7min 20sec


    And here is another link. It is for SKR PRO and I don't know if this applies, but may give you some ideas https://github.com/bigtreetech/BIGTREETECH-SKR-PRO-V1.1/issues/18

  • Z-Probe is fixed. Was just deleting line 278.

    Not sure if the sd card upload is something that comes from the chip or not. The STM32 on rumba have a DFU mode that I use for uploading. But that is one mode used by some chips so it can be and as long as it also works after marlin has been replaced it is ok to use that.

    Unlike marlin I use the provided serial solution from STM32 for usb. This gets influenced by the special board definition in stm32f4.ini in this part:

    [env:SKR2]
    # src_filter = ${common.default_src_filter} +<boards/STM32F4> +<boardFiles/skr2>
    src_filter = ${common.default_src_filter} +<boards/STM32F4>
    extends = stm32f4_common
    board = skr2
    board_build.offset = 0x8000
    board_upload.offset_address = 0x08008000
    board_build.variants_dir = src/boardFiles
    board_build.ldscript = src/boardFiles/skr2/ldscript.ld
    build_flags = ${common.build_flags} -DSTM32F4xx -DARDUINO_ARCH_STM32 "-DBOARD_NAME2=\"BTT_SKR2\"" -DUSBCON -DUSBD_VID=0x8000 "-DUSB_MANUFACTURER=\"BTT\"" "-DUSB_PRODUCT=\"BTT_SKR2\"" -DUSBD_USE_CDC -DDISABLE_GENERIC_SERIALUSB -DUSBD_PID=0x5740 -DHAL_UART_MODULE_ENABLED -DSERIAL_RX_BUFFER_SIZE=256 -DSERIAL_TX_BUFFER_SIZE=256
    -Isrc/boardFiles/skr2
    -DINI_SKR2
    -O3


    Fixed settings are -DUSBCON -DHAL_UART_MODULE_ENABLED -DUSBD_USE_CDC which are needed to enable usb drivers.
    The part that is unsure is
    -DUSBD_VID=0x8000 "
    -DUSB_MANUFACTURER=\"BTT\"" 
    "-DUSB_PRODUCT=\"BTT_SKR2\"" 
    -DUSBD_PID=0x5740

    These define how it is named and might windows make not detect it. Can you check in hardware manager if you see it as unknown device. I just copied it from rumba32 settings where it works, but there Manufacturer has name "Unknown" so that might be a significant difference making it fail detecting on windows.
  • Device Manager cannot see it at all - the entire Ports branch is missing.
    Then I tried Marlin once again. In Device Manager under Ports (COM & LPT) I got USB Serial Device (COM4).
    It says Manufacturer "Microsoft" and uses device driver from Microsoft.

    Under Details there are lots of fields that unfortunately is impossible to copy all together, but here are few that you may be interested in seeing:

    Device instance path: USB\VID_0483&PID_5740&MI_00\6&2FF63EB9&0&0000
    Hardware IDs: USB\VID_0483&PID_5740&REV_0000&MI_00
                           USB\VID_0483&PID_5740&MI_00
    Bus reported device description: MARLIN_STM32F407VGT6_CCM CDC Config
    Last known parent: USB\VID_0483&PID_5740\3559345F3439

    So, looks like -DUSBD_VID should be 0x0483 and -DUSBD_PID value is correct.

    I tried  -DUSBD_VID=0x0483 and even tried to set Microsoft in Manufacturer field but that did not change anything.

    Thanks

  • Actually you always should copy VID and PID. VID is vendor ID and PID is product id of that vendor, so only combination of them make sense. What I have entered is the VID/PID I have working with rumba32.

    But I have now ordered the skr 2 to see myself. It is hard to do remote debugging and having it locally for tests is much easier especially since I see some things other might not mention or even notice to be important. So lets hope I see something then so it works quickly.
  • It is hard to do remote debugging and having it locally for tests is much easier

    You are absolutely right. Meanwhile I will focus on hardware changes, will need to do lots of crimping, replace power supplies, etc.

    Looking forward for your test results and updates.

    Thanks!

  • Some good news. I found why the executeable did not run - its start address needed to be realocated to 0x8000 to work with bootloader. Latest commit now compiles and I can connect via usb. Have no printe rconnected, but that should be no problem as it is same code as other stm32 use. If you get problems check pins.
  • That’s great news!! I am out of town once again. Will be able to try in 2 weeks. 
    Thanks!
  • edited November 2021
    I finally found time to test the latest build with SKR2 and it worked!! Now I need to convert my 1.x configuration and replace old 8-bit mainboard. Should be a fun project :)

    @Repetier Thanks for you outstanding support and dedication to this project and sorry that it took me so long to test the fix.
  • No Problem. Just be happy it works, because I read they have replaced SKR 2 with different chipset not STM32F407 any more.
  • Sadly, while experimenting with DC power levels for BTT's closed loop steppers, my SKR2 died and I had to purchase a new one that came with STM32F429 CPU. New CPU has 180 MHz clock while the old one had 168 MHz. Do I need to change anything in environment settings prior to compiling the firmware?

    Thanks
  • That won't work as it is a different chip. I don't have it for testing but I added some changes so when you use same but in platform.ini set variant to SKR_2_F429 it should use different chip, same pins. From a look to marlin it seems the same difference they have, so guess it should work with these changes.
  • Thanks,  I introduced your latest changes and compiled the code without issues.

    My first SKR2 died before I got a chance to fully configure my printer, so doing it now. Here are the 2 issues that I am observing.

    - I have RADDS type controller that has RESET button. Controller connects to SKR2 ports EXP1 and EXP2 and reset pin is pin 8 on EXP2. Rather than being wired to SKR's on-board reset button, this pin connects to STM32F4's reset pin NRST (physical pin number 14). Marlin reads this pin and resets firmware when controller's reset button is pressed. Would be nice to implement the same in Repetier.

    - My printer has only one extruder and in Configuration.h file I configured
    #define NUM_TOOLS 1
    #define NUM_EXTRUDER 1
    #define TOOLS \
        { &ToolExtruder1 }
    #define NUM_HEATERS 2
    #define HEATERS \
        { &HeaterExtruder1, &HeatedBed1 }
    Still, after powering up, the printer shows error about malfunctioning temperature sensor on the second extruder and halts. If I comment out the following lines in Configuration_io.h the error goes away
    HEAT_MANAGER_PID(HeaterExtruder2, 'E', 1, TempExt2, PWMExtruder2, 260, 255, 1000, 10, 20000, 20.0, 0.6, 65.0, 40, 220, false)
    TOOL_EXTRUDER(ToolExtruder2, 16.775, 0.615, -0.97, HeaterExtruder2, /*AL2Motor */ E2Motor, 1.75, 147.0, 5, 30, 5000, 40, "M117 Extruder 2\nM400\nM340 P0 S1500 R600\nG4 P300", "M340 P0 S800 R600\nG4 P300", &Fan1PWM)
    JAM_DETECTOR_HW(JamExtruder2, E2Motor, IOJam2, ToolExtruder2, 220, 10, 500)
    Looks like missing "if ... then" somewhere in the code.

    Thanks




  • For the kill button I have to check.

    Regarding second extrude note that everything activated in configuration_io.h gets compiled, so just removing it from one array does not mean it gets not compiled in. You really need to delete the lines for second extruder then.
  • Repetier said:
    Regarding second extrude note that everything activated in configuration_io.h gets compiled, so just removing it from one array does not mean it gets not compiled in. You really need to delete the lines for second extruder then.
    Good to know. Thanks!

  • Slowly moving forward... Right now having the following issues:

    *** FANS ***
    I want to use all 3 fans. Fan0 for filament cooling, Fan1 for e3d hotend cooling, Fan2 for SKR2 board cooling but only when motors are enabled.
    Issues:  Fan0 works when activated using M106 P0 [0..255], however if P0 is omitted, which should default to Fan0, Fan1 is activated instead.
    Fan1 goes on and off when e3d heats up or cools down, i.e. works as expected.
    Fan2 goes on at power-up, while all motors are off and never stops running.

    Apart of this, skr2.h file contains note
    // Note: In schematic fan0 goes to fan1 and fan1 to fan0. We use numbering printed on board.
    which was probably copied from rumba32.h or from somewhere else. SKR2 has no issue with pin numbering and I'd suggest to remove this note to avoid confusion.

    *** HOMING ***
    My printer is CoreXY (H-bot) homing towards Xmax then Ymax. Both stop sensors are hardware, configured identically and M119 returns correct H and L values depending on endstop state.
    Issue: By some reason homing towards X works as it should but Y-endstop is ignored and extruder keeps pushing towards printer's side panel. LCD keeps saying Homing... and eventually says Homing error and the board resets itself.

    *** STEPPERS ***
    Printer has 4 steppers: X, Y, Z and E. X and Y motors are BTT's Closed loop steppers with build in stepper drivers similar to DRV8825. I configured them as shown below and they are working fine:
    STEPPER_SIMPLE(XMotor, IOX1Step, IOX1Dir, IOX1Enable, endstopNone, endstopNone)
    STEPPER_SIMPLE(YMotor, IOY1Step, IOY1Dir, IOY1Enable, endstopNone, endstopNone)

    Z and E motors have TMC2209 drivers that I'd like to use in Hybrid mode, without Sensorless homing, with Current control and Microstepping. I found this page https://docfirmwarev2.repetier.com/config/motors#introduction but still not sure which syntax to use.

    Any help will be very much appreciated.
    I don't see a way to attach files to this post, so pasting in my entire Configuration.h and Configuration_io.h files. Sorry about that.

    Thanks
    ---------------
    /*
        This file is part of Repetier-Firmware.

        Repetier-Firmware is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        Repetier-Firmware is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with Repetier-Firmware.  If not, see <http://www.gnu.org/licenses/>.

    */

    #pragma once

    /**************** READ FIRST ************************

       This configuration file was created with the configuration tool. For that
       reason, it does not contain the same informations as the original Configuration.h file.
       It misses the comments and unused parts. Open this file file in the config tool
       to see and change the data. You can also upload it to newer/older versions. The system
       will silently add new options, so compilation continues to work.

       This file is optimized for version 1.0.0dev

       If you are in doubt which named functions use which pins on your board, please check the
       pins.h for the used name->pin assignments and your board documentation to verify it is
       as you expect.

    */

    // The following variables are required early to decide on the right modules.
    #define NUM_TOOLS 1
    #define NUM_EXTRUDER 1
    #define NUM_SERVOS 0                  // Number of serves available
    #define MOTHERBOARD MOTHERBOARD_SKR_2 // 3002
    #define EEPROM_MODE 1
    #define RFSERIAL Serial
    //#define EXTERNALSERIAL  use Arduino serial library instead of build in. Requires more RAM, has only 63 byte input buffer.
    // Uncomment the following line if you are using Arduino compatible firmware made for Arduino version earlier than 1.0
    // If it is incompatible you will get compiler errors about write functions not being compatible!
    //#define COMPAT_PRE1
    #define BLUETOOTH_SERIAL 101
    #define BLUETOOTH_BAUD 115200
    #define WAITING_IDENTIFIER "wait"
    #define JSON_OUTPUT 1
    #define FEATURE_WATCHDOG 0
    #define FEATURE_RETRACTION 1
    #define NUM_AXES 4 // X,Y,Z and E for extruder A,B,C would be 5,6,7
    // #define STEPPER_FREQUENCY 153000     // Maximum stepper frequency.
    #define STEPPER_FREQUENCY 100000     // Maximum stepper frequency.
    #define PREPARE_FREQUENCY 1000       // Update frequency for new blocks. Must be higher than PREPARE_FREQUENCY.
    #define BLOCK_FREQUENCY 500          // Number of blocks with constant stepper rate per second.
    #define VELOCITY_PROFILE 2           // 0 = linear, 1 = cubic, 2 = quintic velocity shape
    #define Z_SPEED 10                   // Z positioning speed
    #define XY_SPEED 150                 // XY positioning speed for normal operations
    #define E_SPEED 2                    // Extrusion speed
    #define G0_FEEDRATE 0                // Speed for G0 moves. Independent from set F value! Set 0 to use F value.
    #define MAX_ROOM_TEMPERATURE 25      // No heating below this temperature!
    #define TEMPERATURE_CONTROL_RANGE 20 // Start with controlling if temperature is +/- this value to target temperature
    #define HOST_RESCUE 1                // Enable host rescue help system
    //#define DEBUG_RESCUE                 // Uncomment to add power loss entry in debug menu while printing
    #define POWERLOSS_LEVEL 0       // How much time do we have on powerloss, 0 = no move, 1 = short just raise Z, 2 = long full park move
    #define POWERLOSS_UP 5          // How much to move up if mode 1 is active
    #define Z_PROBE_TYPE 1          // 0 = no z probe, 1 = default z probe, 2 = Nozzle as probe
    #define Z_PROBE_BORDER 10        // Safety border to ensure position is allowed
    #define Z_PROBE_TEMPERATURE 170 // Temperature for type 2

    // 0 = Cartesian, 1 = CoreXYZ, 2 = delta, 3 = Dual X-Axis
    #define PRINTER_TYPE 1
    // steps to include as babysteps per 1/BLOCK_FREQUENCY seconds. Must be lower than STEPPER_FREQUENCY/BLOCK_FREQUENCY and be low enough to not lose steps.
    #define BABYSTEPS_PER_BLOCK \
        { 10, 10, 10 }
    // If all axis end stops are hardware based we can skip the time consuming tests each step
    #define NO_SOFTWARE_AXIS_ENDSTOPS
    // Normally only a delta has motor end stops required. Normally you trigger using axis endstops.
    #define NO_MOTOR_ENDSTOPS

    #define FEATURE_CONTROLLER CONTROLLER_RADDS  //  CONTROLLER_FELIX_DUE
    // Use more memory to speedup display updates
    #define DISPLAY_FULL_BUFFER 1
    // Direction 1 or -1
    // #define ENCODER_DIRECTION -1
    // Encoder speed 0 = fastest, 1 or 2 = slowest - set so 1 click is one menu move
    // Default is 2 if not set by controller. Use only to fix wrong setting
    #define ENCODER_SPEED 1

    // Dynamically increase the speed at which we step through the menus/change values.
    // Set ENCODER_MAX_REPEAT_STEPS to 1 to disable this. EEPROM/Runtime configurable. (Set to 0 to compile out entirely for extra RAM)
    #define ENCODER_MAX_REPEAT_STEPS 5            // Max. extra steps we can gain.
    #define ENCODER_MAX_REPEAT_TIME_MS 40         // Max. time we have before our extra steps reset.
    #define ENCODER_MIN_REPEAT_TIME_MS 15         // At this repeat rate we accumulate to the max step speed.
    #define ENCODER_APPLY_REPEAT_STEPS_IN_MENUS 1 // Set to 0 to only affect changing config values.

    // Default materials in temperature menus. First value is extruder temp, then bed and chamber temperature. 0 = do not show.
    #define DEFAULT_MATERIALS \
        DEFAULT_MATERIAL(Com::tMatPLA, 215, 65, 0) \
        DEFAULT_MATERIAL(Com::tMatPET, 240, 85, 0) \
        DEFAULT_MATERIAL(Com::tMatASA, 260, 105, 0) \
        DEFAULT_MATERIAL(Com::tMatPC, 275, 110, 0) \
        DEFAULT_MATERIAL(Com::tMatABS, 255, 100, 0) \
        DEFAULT_MATERIAL(Com::tMatHIPS, 220, 100, 0) \
        DEFAULT_MATERIAL(Com::tMatPP, 254, 100, 0) \
        DEFAULT_MATERIAL(Com::tMatFLEX, 240, 50, 0)

    /* Ratios for core xyz. First index denotes motor and second axis.
    For each motor you can set the ratio of x,y,z position that adds
    to the position. 0 = no contribution. */
    // X motor = x + y
    #define COREXYZ_X_X 1
    #define COREXYZ_X_Y 1
    #define COREXYZ_X_Z 0
    // Y motor = x - y
    #define COREXYZ_Y_X 1
    #define COREXYZ_Y_Y -1
    #define COREXYZ_Y_Z 0
    // Z motor = z
    #define COREXYZ_Z_X 0
    #define COREXYZ_Z_Y 0
    #define COREXYZ_Z_Z 1

    // Special geometry definition if printer type is delta
    /*  =========== Parameter essential for delta calibration ===================

                C, Y-Axis
                |                        |___| Carriage horizontal offset
                |                        |   \------------------------------------------
                |_________ X-axis        |    \                                        |
               / \                       |     \  DELTA_DIAGONAL (length)    Each move this Rod Height
              /   \                             \                                 is calculated
             /     \                             \    Carriage is at printer center!   |
             A      B                             \_____/--------------------------------
                                                  |--| End effector horizontal offset (recommend set it to 0)
                                             |----| DELTA_HORIZONTAL_RADIUS (Horizontal rod pivot to pivot measure)

        Column angles are measured from X-axis counterclockwise
        "Standard" positions: alpha_A = 210, alpha_B = 330, alpha_C = 90
    */
    #define DELTA_DIAGONAL 350.0f
    #define DELTA_HORIZONTAL_RADIUS 210.0f
    #define DELTA_PRINT_RADIUS 200.0f
    #define DELTA_ANGLE_A 210.0f
    #define DELTA_ANGLE_B 330.0f
    #define DELTA_ANGLE_C 90.0f
    #define DELTA_CORRECTION_A 0.0f
    #define DELTA_CORRECTION_B 0.0f
    #define DELTA_CORRECTION_C 0.0f
    #define DELTA_RADIUS_CORRECTION_A 0.0f
    #define DELTA_RADIUS_CORRECTION_B 0.0f
    #define DELTA_RADIUS_CORRECTION_C 0.0f
    #define DELTA_HOME_OFFSET_A 0.0f
    #define DELTA_HOME_OFFSET_B 0.0f
    #define DELTA_HOME_OFFSET_C 0.0f

    #define DISABLE_X 0
    #define DISABLE_Y 0
    #define DISABLE_Z 0

    #define FEATURE_AXISCOMP 1
    #define AXISCOMP_TANXY 0
    #define AXISCOMP_TANYZ 0
    #define AXISCOMP_TANXZ 0

    // Next 7 lines are required to make the following work, do not change!
    #include "boards/pins.h"
    #undef IO_TARGET
    #define IO_TARGET 4
    #undef CONFIG_EXTERN
    #define CONFIG_EXTERN extern
    #include "drivers/drivers.h"
    #include "io/redefine.h"

    // Define ZProbe by referencing an endstop defined
    CONFIG_VARIABLE_EQ(EndstopDriver, *ZProbe, &endstopZprobe)

    /** Axes are homed in order of priority (0..10) if homing direction is not 0. */
    #define X_HOME_PRIORITY 1
    #define Y_HOME_PRIORITY 2
    #define Z_HOME_PRIORITY 0

    // All fans in this list list become controllable with M106/M107
    // by selecteing the fan number with P0..P<NUM_FANS-1>
    #define NUM_FANS 3
    #define FAN_LIST \
        { &Fan1PWM, &Fan2PWM, &Fan3PWM  }

    #define NUM_HEATED_BEDS 1
    #define HEATED_BED_LIST \
        { &HeatedBed1 }

    #define NUM_HEATED_CHAMBERS 0
    #define HEATED_CHAMBER_LIST \
        { }

    #define SERVO_LIST \
        {}
    #define TOOLS \
        { &ToolExtruder1 }

    // Heaters enumerate all heaters, so we can loop over them
    // or call commands on a specific heater number.
    // Suggested order: extruder heaters, heated beds, heated chambers, additional heaters
    #define NUM_HEATERS 2
    #define HEATERS \
        { &HeaterExtruder1, &HeatedBed1 }

    // Array to call motor related commands like microstepping/current if supported.
    // Id's start at 0 and depend on position in this array.
    #define NUM_MOTORS 4
    #define MOTORS \
        { &XMotor, &YMotor, &ZMotor, &E1Motor }
    #define MOTOR_NAMES \
        { PSTR("X"), PSTR("Y"), PSTR("Z"), PSTR("E0") }

    // Some common settings for Trinamic driver settings
    /**
     Chopper timing is an array with
     {toff, hend, hstrt}
     See TMC datasheets for more details. There are some predefined values to get you started:
     CHOPPER_TIMING_DEFAULT_12V = { 3, -1, 1 }
     CHOPPER_TIMING_DEFAULT_19V = { 4, 1, 1 }
     CHOPPER_TIMING_DEFAULT_24V = { 4, 2, 1 }
     CHOPPER_TIMING_DEFAULT_36V = { 5, 2, 4 }
     CHOPPER_TIMING_PRUSAMK3_24V = { 3, -2, 6 }

    */
    #define TMC_CHOPPER_TIMING CHOPPER_TIMING_DEFAULT_12V
    // true = interpolate to 256 microsteps for smoother motion
    #define TMC_INTERPOLATE true
    // Current used when motor stands still
    #define TMC_HOLD_MULTIPLIER 0.5
    // Reduce current on over temperature warnings by x milli ampere, 0 = disable
    #define TMC_CURRENT_STEP_DOWN 50
    // Define which data should be stored to eeprom
    #define STORE_MOTOR_MICROSTEPPING 1
    #define STORE_MOTOR_CURRENT 1
    #define STORE_MOTOR_HYBRID_TRESHOLD 1
    #define STORE_MOTOR_STEALTH 1
    #define STORE_MOTOR_STALL_SENSITIVITY 1

    #define X_HOME_DIR 1
    #define Y_HOME_DIR 1
    #define Z_HOME_DIR 1
    #define X_MAX_LENGTH 228
    #define Y_MAX_LENGTH 240
    #define Z_MAX_LENGTH 100 // 215
    #define X_MIN_POS 0
    #define Y_MIN_POS 0
    #define Z_MIN_POS 0
    #define BED_X_MIN X_MIN_POS
    #define BED_X_MAX (X_MIN_POS + X_MAX_LENGTH)
    #define BED_Y_MIN Y_MIN_POS
    #define BED_Y_MAX (Y_MIN_POS + Y_MAX_LENGTH)

    // Park position used when pausing from firmware side
    #if PRINTER_TYPE == 2
    #define PARK_POSITION_X (0)
    #define PARK_POSITION_Y (70)
    #define PARK_POSITION_X (X_MIN_POS + X_MAX_LENGTH)
    #define PARK_POSITION_Y (Y_MIN_POS + Y_MAX_LENGTH)
    #define PARK_POSITION_Z_RAISE 5

    #define MAX_ACCELERATION_UNITS_PER_SQ_SECOND_X 1100
    #define MAX_ACCELERATION_UNITS_PER_SQ_SECOND_Y 1100
    #define MAX_ACCELERATION_UNITS_PER_SQ_SECOND_Z 10 // 100
    #define MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_X 1100
    #define MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_Y 1100
    #define MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_Z 10 // 100
    #define XAXIS_STEPS_PER_MM 410.214
    #define YAXIS_STEPS_PER_MM 410.214
    #define ZAXIS_STEPS_PER_MM 99.7 /// 1592.0

    // ################## EDIT THESE SETTINGS MANUALLY ################
    // ################ END MANUAL SETTINGS ##########################

    #undef X_MIN_PIN
    #define X_MIN_PIN -1
    #undef X_MAX_PIN
    #define X_MAX_PIN ORIG_X_MAX_PIN
    #undef Y_MIN_PIN
    #define Y_MIN_PIN -1

    #undef Y_MAX_PIN
    #define Y_MAX_PIN ORIG_Y_MAX_PIN
    #undef Z_MIN_PIN
    #define Z_MIN_PIN -1
    #undef Z_MAX_PIN
    #define Z_MAX_PIN ORIG_Z_MAX_PIN

    #define KILL_IF_SENSOR_DEFECT 0
    #define RETRACT_ON_PAUSE 2
    #define PAUSE_START_COMMANDS ""
    #define PAUSE_END_COMMANDS ""

    #define AUTORETRACT_ENABLED 0
    #define RETRACTION_LENGTH 3
    #define RETRACTION_LONG_LENGTH 13
    #define RETRACTION_SPEED 40
    #define RETRACTION_Z_LIFT 0
    #define RETRACTION_UNDO_EXTRA_LENGTH 0
    #define RETRACTION_UNDO_EXTRA_LONG_LENGTH 0
    #define RETRACTION_UNDO_SPEED 25
    #define FILAMENTCHANGE_X_POS 5
    #define FILAMENTCHANGE_Y_POS 5
    #define FILAMENTCHANGE_Z_ADD 2
    #define FILAMENTCHANGE_REHOME 1
    #define FILAMENTCHANGE_SHORTRETRACT 2.5
    #define FILAMENTCHANGE_LONGRETRACT 50
    #define JAM_METHOD 1
    #define JAM_ACTION 1

    #define RETRACT_DURING_HEATUP true
    #define PID_CONTROL_RANGE 20
    #define EXTRUDE_MAXLENGTH 160

    // ############# Heated bed configuration ########################

    #define SKIP_M190_IF_WITHIN 5
    #define MIN_EXTRUDER_TEMP 180
    #define MILLISECONDS_PREHEAT_TIME 30000

    // ################ Endstop configuration #####################

    #define DOOR_PIN -1
    #define DOOR_PULLUP 1
    #define DOOR_INVERTING 1
    #define ENDSTOP_X_BACK_MOVE 3
    #define ENDSTOP_Y_BACK_MOVE 3
    #define ENDSTOP_Z_BACK_MOVE 1
    #define ENDSTOP_X_RETEST_REDUCTION_FACTOR 2
    #define ENDSTOP_Y_RETEST_REDUCTION_FACTOR 2
    #define ENDSTOP_Z_RETEST_REDUCTION_FACTOR 2
    #define ENDSTOP_X_BACK_ON_HOME 0.5
    #define ENDSTOP_Y_BACK_ON_HOME 0.5
    #define ENDSTOP_Z_BACK_ON_HOME 0
    #define ALWAYS_CHECK_ENDSTOPS 1
    #define MOVE_X_WHEN_HOMED 0
    #define MOVE_Y_WHEN_HOMED 0
    #define MOVE_Z_WHEN_HOMED 0

    // ################# XYZ movements ###################

    #define PREVENT_Z_DISABLE_ON_STEPPER_TIMEOUT 1

    // ##########################################################################################
    // ##                           Movement settings                                          ##
    // ##########################################################################################

    #define FEATURE_BABYSTEPPING 0
    #define BABYSTEP_MULTIPLICATOR 64

    // Delta settings
    #define DELTA_HOME_ON_POWER 0

    #define STEPPER_INACTIVE_TIME 360L
    #define MAX_INACTIVE_TIME 1200L
    #define MAX_FEEDRATE_X 250
    #define MAX_FEEDRATE_Y 250
    #define MAX_FEEDRATE_Z 5
    #define HOMING_FEEDRATE_X 40
    #define HOMING_FEEDRATE_Y 40
    #define HOMING_FEEDRATE_Z 2
    // Raise z before homing (1)
    #define ZHOME_PRE_RAISE 1
    // How much mm should z raise before homing
    #define ZHOME_PRE_RAISE_DISTANCE 2
    #define ZHOME_MIN_TEMPERATURE 0
    #define ZHOME_HEAT_ALL 0
    // Height in mm after homing.
    #define ZHOME_HEIGHT 10
    // Home Z at a fixed xy position (1)
    #define FIXED_Z_HOME_POSITION 0
    #define ZHOME_X_POS 140
    #define ZHOME_Y_POS 45
    // Raise extruders before switching tools. Used to prevent touching objects while switching.
    #define RAISE_Z_ON_TOOLCHANGE 2

    #define ENABLE_BACKLASH_COMPENSATION 0
    #define X_BACKLASH 0
    #define Y_BACKLASH 0
    #define Z_BACKLASH 0
    #define MAX_JERK 5
    #define MAX_ZJERK 0.3
    #define PRINTLINE_CACHE_SIZE 32
    #define MOVE_CACHE_LOW 10
    #define EXTRUDER_SWITCH_XY_SPEED 100
    #define FEATURE_DITTO_PRINTING 0

    // ################# Misc. settings ##################

    #define BAUDRATE 115200
    #define ENABLE_POWER_ON_STARTUP 1
    #define POWER_INVERTING 0
    #define KILL_METHOD 1
    #define ACK_WITH_LINENUMBER 1
    #define KEEP_ALIVE_INTERVAL 2000
    #define ECHO_ON_EXECUTE 1
    #undef PS_ON_PIN
    #define PS_ON_PIN -1

    // #################### Z-Probing #####################

    #define Z_PROBE_COATING 0
    #define Z_PROBE_Z_OFFSET_MODE 1
    #define UI_BED_COATING 0
    #define EXTRUDER_IS_Z_PROBE 0
    #define Z_PROBE_DISABLE_HEATERS 0
    #define Z_PROBE_BED_DISTANCE 4
    #define Z_PROBE_X_OFFSET -34.4
    #define Z_PROBE_Y_OFFSET 10.6
    #define Z_PROBE_SPEED 4
    #define Z_PROBE_SWITCHING_DISTANCE 1.5
    // How often should we test a position 1 .. x. Averages result over all tests.
    #define Z_PROBE_REPETITIONS 2
    // 0 = use average, 1 = use middle value after ordering z
    #define Z_PROBE_USE_MEDIAN 0
    // Nozzle distance to bed when z probe triggers
    #define Z_PROBE_HEIGHT 3.7
    // Delay in ms before we go down again. For BLTouch so signal can disable
    #define Z_PROBE_DELAY 0
    #define Z_PROBE_START_SCRIPT ""
    #define Z_PROBE_FINISHED_SCRIPT ""
    #define Z_PROBE_RUN_AFTER_EVERY_PROBE ""
    #define Z_PROBE_REQUIRES_HEATING 0
    #define Z_PROBE_MIN_TEMPERATURE 150
    #define Z_PROBE_PAUSE_HEATERS 0         // Pause all heaters when probing to reduce EMI artifacts
    #define Z_PROBE_PAUSE_BED_REHEAT_TEMP 5 // Stop and reheat the bed if we leave the target temp by this much.

    // How to correct rotated beds
    // 0 = Software side by rotating coordinates
    // 1 = Move bed physically using 2 motors
    #define LEVELING_CORRECTOR 0
    // Bed fixture coordinates for motor leveling
    #define LC_P1_X 55
    #define LC_P1_Y 130
    #define LC_P2_X 137
    #define LC_P2_Y 45
    #define LC_P3_X 137
    #define LC_P3_Y 210
    #define LC_P2_MOTOR AL1Motor
    #define LC_P3_MOTOR AL2Motor
    #define LC_STEPS_PER_MM 3382
    #define LC_Z_SPEED 0.2
    // > 0 will move bed down and wait for removal (heater removed) and will pause another LC_WAIT_BED_REMOVE seconds
    #define LC_WAIT_BED_REMOVE 2
    // Uncomment to limit correction per autoleveling iteration. Value is the max. correction in mm
    // #define LIMIT_MOTORIZED_CORRECTION 0.5

    // Leveling method
    // 0 = none, 3 = 3 points, 1 = grid, 2 = 4 point symmetric
    #define LEVELING_METHOD 1
    #define L_P1_X 23
    #define L_P1_Y 12
    #define L_P2_X 190
    #define L_P2_Y 12
    #define L_P3_X 23
    #define L_P3_Y 230
    #define MAX_GRID_SIZE 5                   // Maximum grid size allocation in memory, imported grid can be smaller
    #define ENABLE_BUMP_CORRECTION 1          // CPU intensive, so only activate if required
    #define BUMP_CORRECTION_START_DEGRADE 0.5 // Until this height we correct 100%
    #define BUMP_CORRECTION_END_HEIGHT 2      // From this height on we do no correction
    #define BUMP_LIMIT_TO 0                   // Maximum allowed correction up/down, <= 0 off.

    #ifndef SDSUPPORT // Some boards have sd support on board. These define the values already in pins.h
    #define SDSUPPORT 1
    #undef SDCARDDETECT
    #define SDCARDDETECT ORIG_SDCARDDETECT
    #define SDCARDDETECTINVERTED 0
    #define SD_EXTENDED_DIR 1 /** Show extended directory including file length. Don't use this with Pronterface! */
    #define SD_RUN_ON_STOP ""
    #define SD_STOP_HEATER_AND_MOTORS_ON_STOP 1
    #define ARC_SUPPORT 0
    #define FEATURE_MEMORY_POSITION 1
    #define FEATURE_CHECKSUM_FORCED 0
    #define UI_PRINTER_NAME "Vertex-HHR"
    #define UI_PRINTER_COMPANY "Repetier"
    #define UI_PAGES_DURATION 4000
    #define UI_SPEEDDEPENDENT_POSITIONING 0
    #define UI_DISABLE_AUTO_PAGESWITCH 1
    #define UI_AUTORETURN_TO_MENU_AFTER 30000
    #define FEATURE_UI_KEYS 0
    #define UI_ENCODER_SPEED 2
    #define UI_REVERSE_ENCODER 0
    #define UI_KEY_BOUNCETIME 10
    #define UI_KEY_FIRST_REPEAT 500
    #define UI_KEY_REDUCE_REPEAT 50
    #define UI_KEY_MIN_REPEAT 50
    #define CASE_LIGHTS_PIN 25
    #define CASE_LIGHT_DEFAULT_ON 1
    #define UI_START_SCREEN_DELAY 2000

    //#define CUSTOM_EVENTS



    /*

    This file defines io solutions used. This is the lowest level and is the base
    for all higher level functions using io operations. At several places we need
    subsets of these list of operations. To make configuration easy and easy to
    understand, we use a technique called "x macros". This requires that only
    predefined macro names for IO are used here. Do NOT add anything else here
    or compilation/functionality will break.

    Rules:
    1. Each definition will create a class that is named like the first parameter.
    This class is later used as input to templates building higher functions. By
    convention the names should start with IO followed by something that helps you
    identify the function.
    2. Do not use a semicolon at the end. Macro definition gets different meanings
    and will add the semicolon if required.

    */

    /* Define motor pins here. Each motor needs a setp, dir and enable pin. */

    ENDSTOP_NONE(endstopNone)
    // For use when no output is wanted, but possible
    IO_OUTPUT_FAKE(fakeOut)

    // X Motor

    IO_OUTPUT(IOX1Step, ORIG_X_STEP_PIN)
    IO_OUTPUT_INVERTED(IOX1Dir, ORIG_X_DIR_PIN)
    IO_OUTPUT_INVERTED(IOX1Enable, ORIG_X_ENABLE_PIN)

    // Y Motor

    IO_OUTPUT(IOY1Step, ORIG_Y_STEP_PIN)
    IO_OUTPUT_INVERTED(IOY1Dir, ORIG_Y_DIR_PIN)
    IO_OUTPUT_INVERTED(IOY1Enable, ORIG_Y_ENABLE_PIN)

    // Z Motor

    IO_OUTPUT(IOZ1Step, ORIG_Z_STEP_PIN)
    IO_OUTPUT_INVERTED(IOZ1Dir, ORIG_Z_DIR_PIN)
    IO_OUTPUT_INVERTED(IOZ1Enable, ORIG_Z_ENABLE_PIN)

    // E0 Motor

    IO_OUTPUT(IOE1Step, ORIG_E0_STEP_PIN)
    IO_OUTPUT_INVERTED(IOE1Dir, ORIG_E0_DIR_PIN)
    IO_OUTPUT_INVERTED(IOE1Enable, ORIG_E0_ENABLE_PIN)

    // E1 Motor

    // IO_OUTPUT(IOE2Step, ORIG_E1_STEP_PIN)
    // IO_OUTPUT(IOE2Dir, ORIG_E1_DIR_PIN)
    // IO_OUTPUT_INVERTED(IOE2Enable, ORIG_E1_ENABLE_PIN)

    // Autolevel Motor 1

    // IO_OUTPUT(IOAL1Step, 51)
    // IO_OUTPUT(IOAL1Dir, 53)
    // IO_OUTPUT_INVERTED(IOAL1Enable, 49)

    // Autolevel Motor 1

    // IO_OUTPUT(IOAL2Step, 39)
    // IO_OUTPUT(IOAL2Dir, 13)
    // IO_OUTPUT_INVERTED(IOAL2Enable, 40)

    // Servo output

    IO_OUTPUT(Servo1Pin, 5)

    // Define your endstops inputs

    //IO_INPUT(IOEndstopXMin, ORIG_X_MIN_PIN)
    // IO_INPUT_INVERTED(IOEndstopXMin, ORIG_X_MIN_PIN)
    IO_INPUT(IOEndstopXMax, ORIG_X_MAX_PIN)
    IO_INPUT(IOEndstopYMax, ORIG_Y_MAX_PIN)
    // IO_INPUT_PULLUP(IOEndstopZMin, ORIG_Z_MIN_PIN)
    IO_INPUT(IOEndstopZprobe, ORIG_ZPROBE)
    IO_INPUT(IOEndstopZMax, ORIG_Z_MAX_PIN)

    // IO_INPUT(IOJam1, 35)
    // IO_INPUT(IOJam2, 33)

    // Controller input pins

    #if defined(UI_ENCODER_CLICK) && UI_ENCODER_CLICK >= 0
    IO_INPUT_INVERTED_PULLUP(ControllerClick, UI_ENCODER_CLICK)
    IO_INPUT_DUMMY(ControllerClick, false)
    #if defined(UI_ENCODER_A) && UI_ENCODER_A >= 0
    IO_INPUT_INVERTED_PULLUP(ControllerEncA, UI_ENCODER_A)
    IO_INPUT_DUMMY(ControllerEncA, false)
    #if defined(UI_ENCODER_B) && UI_ENCODER_B >= 0
    IO_INPUT_INVERTED_PULLUP(ControllerEncB, UI_ENCODER_B)
    IO_INPUT_DUMMY(ControllerEncB, false)
    #if defined(UI_BACK_PIN) && UI_BACK_PIN >= 0
    IO_INPUT_PULLUP(ControllerBack, UI_BACK_PIN)
    IO_INPUT_DUMMY(ControllerBack, false)
    #if defined(UI_RESET_PIN) && UI_RESET_PIN >= 0
    IO_INPUT_PULLUP(ControllerReset, UI_RESET_PIN)
    IO_INPUT_DUMMY(ControllerReset, false)

    // Define our endstops solutions
    // You need to define all min and max endstops for all
    // axes except E even if you have none!

    ENDSTOP_NONE(endstopXMin)
    ENDSTOP_SWITCH_HW(endstopXMax, IOEndstopXMax, X_AXIS, true)
    ENDSTOP_NONE(endstopYMin)
    ENDSTOP_SWITCH_HW(endstopYMax, IOEndstopYMax, Y_AXIS, true)
    ENDSTOP_NONE(endstopZMin)
    ENDSTOP_SWITCH_HW(endstopZprobe, IOEndstopZprobe, Z_AXIS, false)
    ENDSTOP_SWITCH_HW(endstopZMax, IOEndstopZMax, Z_AXIS, true)

    // Define fans

    IO_OUTPUT(IOFan1, ORIG_FAN_PIN)  // filament fan
    IO_PWM_SOFTWARE(Fan1NoKSPWM, IOFan1, 0)
    IO_PWM_KICKSTART(Fan1PWM, Fan1NoKSPWM, 20, 85)

    IO_OUTPUT(IOFan2, ORIG_FAN2_PIN)  // e3d cooler fan
    IO_PWM_SOFTWARE(Fan2NoKSPWM, IOFan2, 0)
    IO_PWM_KICKSTART(Fan2PWM, Fan2NoKSPWM, 20, 85)
    COOLER_MANAGER_SENSOR(ExtruderCooler1, TempExt1, Fan2NoKSPWM, 90, 200, 150, 255)

    IO_OUTPUT(IOFan3, ORIG_FAN3_PIN)   // mainboard fan
    IO_PWM_SOFTWARE(Fan3NoKSPWM, IOFan3, 0)
    IO_PWM_KICKSTART(Fan3PWM, Fan3NoKSPWM, 20, 85)
    COOLER_MANAGER_MOTORS(MotorCooler1, Fan3NoKSPWM, 127, 255, 15)

    // IO_OUTPUT(IOCoolerFan1, ORIG_FAN2_PIN)
    // IO_OUTPUT(IOBoardFan, ORIG_FAN3_PIN)

    // IO_PWM_SOFTWARE(CoolerFan, IOCoolerFan1, 0)
    // IO_PWM_HARDWARE(Fan1PWM, 37,5000)
    // IO_PDM_SOFTWARE(Fan1NoKSPWM, IOFan1) // alternative to PWM signals
    // IO_PWM_SOFTWARE(BoardFan, IOBoardFan, 4)
    // COOLER_MANAGER_MOTORS(BoardFanController, BoardFan, 0, 192, 10)
    // For debugging - reports new values and then calls real pwm
    // IO_PWM_REPORT(Fan1Report, Fan1PWM)
    // Define temperature sensors

    // IO_PWM_HARDWARE(Fan2PWM, 37,5000)
    // IO_PDM_SOFTWARE(Fan2NoKSPWM, IOFan2) // alternative to PWM signals
    // For debugging - reports new values and then calls real pwm
    // IO_PWM_REPORT(Fan2Report, Fan2PWM)
    // Define temperature sensors


    // Typically they require an analog input (12 bit) so define
    // them first.

    IO_ANALOG_INPUT(IOAnalogBed1, TEMP_1_PIN, 5)
    IO_ANALOG_INPUT(IOAnalogExt1, TEMP_0_PIN, 5)
    // IO_ANALOG_INPUT(IOAnalogExt2, TEMP_2_PIN, 5)

    // Need a conversion table for epcos NTC
    IO_TEMP_TABLE_NTC(TempTableEpcos, Epcos_B57560G0107F000)

    // Now create the temperature inputs

    IO_TEMPERATURE_TABLE(TempBed1, IOAnalogBed1, TempTableEpcos)
    IO_TEMPERATURE_TABLE(TempExt1, IOAnalogExt1, TempTableEpcos)
    // IO_TEMPERATURE_TABLE(TempExt2, IOAnalogExt2, TempTableEpcos)

    // Use PWM outputs to heat. If using hardware PWM make sure
    // that the selected pin can be used as hardware pwm otherwise
    // select a software pwm model whcih works on all pins.

    #if MOTHERBOARD == 405
    IO_PWM_HARDWARE(PWMExtruder1, HEATER_0_PIN, 1000)
    IO_PWM_HARDWARE(PWMExtruder2, HEATER_2_PIN, 1000)
    IO_PWM_HARDWARE(PWMBed1, HEATER_1_PIN, 1000)
    IO_OUTPUT(IOExtr1, HEATER_0_PIN)
    // IO_OUTPUT(IOExtr2, HEATER_2_PIN)
    IO_OUTPUT(IOBed1, HEATER_1_PIN)
    IO_PWM_SOFTWARE(PWMExtruder1, IOExtr1, 1)
    // IO_PWM_SOFTWARE(PWMExtruder2, IOExtr2, 1)
    IO_PWM_SOFTWARE(PWMBed1, IOBed1, 1)
    // IO_OUTPUT(IOCooler1, FAN2_PIN)
    // IO_PWM_SOFTWARE(PWMCoolerExt1, FAN2_PIN, 0)

    // Define all stepper motors used
    STEPPER_SIMPLE(XMotor, IOX1Step, IOX1Dir, IOX1Enable, endstopNone, endstopNone)
    STEPPER_SIMPLE(YMotor, IOY1Step, IOY1Dir, IOY1Enable, endstopNone, endstopNone)
    STEPPER_SIMPLE(ZMotor, IOZ1Step, IOZ1Dir, IOZ1Enable, endstopNone, endstopNone)
    STEPPER_SIMPLE(E1Motor, IOE1Step, IOE1Dir, IOE1Enable, endstopNone, endstopNone)
    // STEPPER_TMC2209_HW_UART(ZMotor, stepPin, dirPin, enablePin, serial, rsense, microsteps, currentMillis, stealth, hybridSpeed, slaveAddr, stallSensitivity, fclk, minEndstop, maxEndstop)
    // STEPPER_TMC2209_HW_UART(E1Motor, stepPin, dirPin, enablePin, serial, rsense, microsteps, currentMillis, stealth, hybridSpeed, slaveAddr, stallSensitivity, fclk, minEndstop, maxEndstop)
    // STEPPER_OBSERVEABLE(E1Motor, E1MotorBase)
    // STEPPER_SIMPLE(E2MotorBase, IOE2Step, IOE2Dir, IOE2Enable, endstopNone, endstopNone)
    // STEPPER_OBSERVEABLE(E2Motor, E2MotorBase)
    // STEPPER_SIMPLE(AL1Motor, IOAL1Step, IOAL1Dir, IOAL1Enable, endstopNone, endstopNone)
    // STEPPER_SIMPLE(AL2Motor, IOAL2Step, IOAL2Dir, IOAL2Enable, endstopNone, endstopNone)

    // Servos
    // SERVO_ANALOG(Servo1, 0, Servo1Pin, 500, 2500, 1050)

    // Heat manages are used for every component that needs to
    // control temperature. Higher level classes take these as input
    // and simple heater like a heated bed use it directly.

    HEAT_MANAGER_PID(HeatedBed1, 'B', 0, TempBed1, PWMBed1, 120, 255, 1000, 5, 30000, 12.0, 33.0, 290.0, 80, 255, true)
    HEAT_MANAGER_PID(HeaterExtruder1, 'E', 0, TempExt1, PWMExtruder1, 260, 255, 1000, 10, 20000, 20.0, 0.6, 65.0, 40, 220, false)
    // HEAT_MANAGER_PID(HeaterExtruder2, 'E', 1, TempExt2, PWMExtruder2, 260, 255, 1000, 10, 20000, 20.0, 0.6, 65.0, 40, 220, false)

    // HEAT_MANAGER_DYN_DEAD_TIME(HeaterExtruder1, 'E', 0, TempExt1, PWMExtruder1, 260, 255, 100, 10, 20000, 150, 7, 7, 200, 7, 7, false)
    // HEAT_MANAGER_DYN_DEAD_TIME(HeaterExtruder2, 'E', 1, TempExt2, PWMExtruder2, 260, 255, 100, 10, 20000, 150, 7, 7, 200, 7, 7, false)

    // Coolers are stand alone functions that allow it to control
    // a fan with external sensors. Many extruders require a cooling
    // fan pointer to the extruder to prevent heat rising up.
    // These can be controlled by the cooler. Since it is
    // independent you just tell what part needs cooling.
    // Other use cases are board cooling and heated chambers.

    // Define tools. They get inserted into a tool array in configuration.h
    // Typical tools are:
    // TOOL_EXTRUDER(name, offx, offy, offz, heater, stepper, resolution, yank, maxSpeed, acceleration, advance, startScript, endScript)


    TOOL_EXTRUDER(ToolExtruder1, 0, 0, 0, HeaterExtruder1, /*AL1Motor */ E1Motor, 1.75, 147.0, 5, 30, 5000, 40, "M117 Extruder 1", "", &Fan2PWM)
    // TOOL_EXTRUDER(ToolExtruder2, 16.775, 0.615, -0.97, HeaterExtruder2, /*AL2Motor */ E2Motor, 1.75, 147.0, 5, 30, 5000, 40, "M117 Extruder 2\nM400\nM340 P0 S1500 R600\nG4 P300", "M340 P0 S800 R600\nG4 P300", &Fan1PWM)
    // TOOL_LASER(Laser3, 0, 0, 0, Fan1NoKSPWM, fakeOut, fakeOut, 3000, 1, 100, 150.0, 1.5, "", "")
    // TOOL_CNC(CNC4, 0, 0, 0, Fan1NoKSPWM, fakeOut, fakeOut, fakeOut, 7000, 3000, "", "")

    // Use a signal that changes while extruder moves
    // JAM_DETECTOR_HW(JamExtruder1, E1Motor, IOJam1, ToolExtruder1, 220, 10, 500)
    // JAM_DETECTOR_HW(JamExtruder2, E2Motor, IOJam2, ToolExtruder2, 220, 10, 500)

    // Use a signal that is high, when filament is loaded
    //FILAMENT_DETECTOR(FilamentDetector1, IOJam1, ToolExtruder1)
    //FILAMENT_DETECTOR(FilamentDetector2, IOJam2, ToolExtruder2)





  • First the simple one. Board cooling is controlled by this fan setting that you commented:
    // COOLER_MANAGER_MOTORS(BoardFanController, BoardFan, 0, 192, 10)
    plus the above settings defining BoardFan and the fan. The first 2 define a pin while COOLER_MANAGER_MOTORS is the logic that controls the fan. But I see the description is bad, meaning wrong.

    When you omit Px in M106 it selects the fan associated to the active extruder. In your case
    TOOL_EXTRUDER(ToolExtruder1, 0, 0, 0, HeaterExtruder1, /*AL1Motor */ E1Motor, 1.75, 147.0, 5, 30, 5000, 40, "M117 Extruder 1", "", &Fan2PWM)
    If you look at your fan list
    #define FAN_LIST \
        { &Fan1PWM, &Fan2PWM, &Fan3PWM  }
    you see you assigned the second fan to extruder 0 so that is why omitting P0 chooses Fan2. Replace by Fan1PWM. The FAN_LIST is just for controlling fans with Px - you should omit fan 2 and 3 anyway as they are controlled automatically by firmware logic and should not be overwritten as that gets reset anyway.

    y max homing.
    ENDSTOP_SWITCH_HW(endstopYMax, IOEndstopYMax, Y_AXIS, true)
    looks correct. At least if pin is correct. So check M119 with y triggered and untriggered if it shows correct signal.
    Also text if homing y moves towards y max. Have often seen that users tricked them self by placing end stop to wrong side or changed home dir to -1 to get move to y max direction. Better check if moves go to correct direction and otherwise change core factors to do this correct.

    2209 drivers, see
    https://docfirmwarev2.repetier.com/config/motors#stepper_trinamic
    You need
    STEPPER_TMC2209_HW_UART(name, stepPin, dirPin, enablePin, serial, rsense, microsteps, currentMillis, stealth, hybridSpeed, slaveAddr, stallSensitivity, fclk, minEndstop, maxEndstop)
    which means you also need a hardware uart connector modified to 1 pin communication (rx and tx are bound to same cable with I think a extra resistor, but not sure. It's a long time ago i did the test. There is also a software UART solution
    STEPPER_TMC2209_SW_UART(name, stepPin, dirPin, enablePin, rxPin, txPin, rsense, microsteps, currentMillis, stealth, hybridSpeed, slaveAddr, stallSensitivity, fclk, minEndstop, maxEndstop)
    but not sure it works with STM processors. You need to try. If you onyl want to use one uart for both drivers one gets slaveAdr 0 and one slaveAdr 1 and you need to modify the driver board accordingly. MS1 and MS2 define the address.

    Use M122
    https://docfirmwarev2.repetier.com/GCodes/motion_gcodes#m122
    to debug if the drivers are working correctly. They normally only work when main power is also enabled. At least some other TMC drivers have that issue.
  • Thanks for the detailed answers.

    With fans it was my fault - I did not pay attention to the note saying
    // All fans in this list list become controllable with M106/M107
    // by selecting the fan number with P0..P<NUM_FANS-1>
    Since I have only one extruder I should define NUM_FANS as 1 and have single entry in FAN_LIST.  All 3 fans are working as expected now, although mainboard fan switches off only after STEPPER_INACTIVE_TIME expires plus whatever delay is set in COOLER_MANAGER_MOTORS, but does not switch off if motors were disabled using M18 command. Not sure if this was missed or was done intentionally.

    Y-stop issue went away after correcting XAXIS_STEPS_PER_MM and YAXIS_STEPS_PER_MM values. They both had to be set to a half of what was assigned.

    As for TMC2209, I had no time to look at them tonight. Will continue tomorrow after work.

    Thanks again!




  • It only works if we know all motors are disabled. The flag gets set in kill function e.g. when you disable motors with M84. I have added an extra case for M18 without parameter. M18 will named motors will not work as we do not know if it is enabled or not and then you need to wait until timeout.
  • Yes, I meant the case of M18 without named motors. Octoprint has "Motors Off" button on Control tab that sends M18. That's how I wanted to test board fan and it did not work.


    With TMC2209 I first tried  software UART settings.
    STEPPER_TMC2209_SW_UART(ZMotor, IOZ1Step, IOZ1Dir, IOZ1Enable, MOSI_PIN, MISO_PIN, 0.11, 32, 900, true, 80, 2, 0, 12500000, endstopNone, endstopNone)
    STEPPER_TMC2209_SW_UART(E1Motor, IOE1Step, IOE1Dir, IOE1Enable, MOSI_PIN, MISO_PIN, 0.11, 32, 900, true, 80, 3, 0, 12500000, endstopNone, endstopNone)
    That did not work. SKR2 would not start at all and LCD was blank. Then I tried HW option
    STEPPER_TMC2209_HW_UART(ZMotor, IOZ1Step, IOZ1Dir, IOZ1Enable, Serial3, 0.11, 32, 900, true, 80, 2, 0, 12500000, endstopNone, endstopNone)
    STEPPER_TMC2209_HW_UART(E1Motor, IOE1Step, IOE1Dir, IOE1Enable, Serial3, 0.11, 32, 900, true, 80, 3, 0, 12500000, endstopNone, endstopNone)
    But here I don't know what value to use as serial.  I found another post here where user used Serial3, but that was for DUE board. SKR2 does not have Serial3 definition so I got compilation error. I tried to change BLUETOOTH_SERIAL value from 101 to 3, but got the same compilation error.

    Also, not quite sure about slaveAddr value. I have only 2 TMC drivers. Should I use addresses 0 and 1? Or, since slots X and Y have non-TMC drivers and TMCs are in Z and E0, I should set addresses to 2 and 3?

    Final question - is there a relationship between
    // true = interpolate to 256 microsteps for smoother motion
    #define TMC_INTERPOLATE true
    and microsteps parameter  in  STEPPER_TMC2209_HW_UART ?

    Thanks

    P.S. In SKR2 UART pins have direct connections and do not need additional wires with resistor.








  • > P.S. In SKR2 UART pins have direct connections and do not need additional wires with resistor.
    Where and which pins? Here is the schematic:
    https://github.com/bigtreetech/SKR-2/blob/master/Hardware/BIGTREETECH SKR 2-SCH.pdf

    There you also see which pins belong to which uart serial. According to datasheet it has 4 hardware uart.

    Slave address only depends on the setting on the driver chip where you configure it, it does not depend on socket connected to. I think the jumpers below should set it - the one I checked used at least 2 of them to set it.

    TMC_INTERPOLATE only defines if the driver should increase internal microsteps to 256 or not. You normally want that on as it is the most quiet solution. Chip will then interpolate smooth even when externally 16 microsteps are set it uses internally 256.

    M18 fix on github should fix the motor off problem.
  • I just followed this video guide (except sensorless homing section), setup jumpers as shown there and without additional wires and resistor with Marlin firmware was able to get M122 printout shown below (taken from Octoprint terminal).
    Send: M122
    Recv: Z E
    Recv: Address 0 0
    Recv: Enabled false false
    Recv: Set current 800 800
    Recv: RMS current 795 795
    Recv: MAX current 1121 1121
    Recv: Run current 25/31 25/31
    Recv: Hold current 12/31 12/31
    Recv: CS actual 12/31 12/31
    Recv: PWM scale
    Recv: vsense 1=.18 1=.18
    Recv: stealthChop true true
    Recv: msteps 16 16
    Recv: interp true true
    Recv: tstep max max
    Recv: PWM thresh.
    Recv: [mm/s]
    Recv: OT prewarn false false
    Recv: triggered
    Recv: OTP false false
    Recv: pwm scale sum 14 14
    Recv: pwm scale auto 0 0
    Recv: pwm offset auto 36 36
    Recv: pwm grad auto 14 14
    Recv: off time 3 3
    Recv: blank time 24 24
    Recv: hysteresis
    Recv: -end -1 -1
    Recv: -start 1 1
    Recv: Stallguard thrs 0 0
    Recv: uStep count 8 8
    Recv: DRVSTATUS Z E
    Recv: sg_result 0 0
    Recv: stst
    Recv: olb
    Recv: ola
    Recv: s2gb
    Recv: s2ga
    Recv: otpw
    Recv: ot
    Recv: 157C
    Recv: 150C
    Recv: 143C
    Recv: 120C
    Recv: s2vsa
    Recv: s2vsb
    Recv: Driver registers:
    Recv: Z 0xC0:0C:00:00
    Recv: E 0xC0:0C:00:00
    Recv:
    Recv:
    Recv: Testing Z connection... OK
    Recv: Testing E connection... OK
    Recv: ok
    Now just trying to configure Repetier firmware to get the same result and still struggling with Serial definition :(

    Thanks for updating M18. It is switching off board fan now. :)



  • Checking marlin board definition for skr2 rev B I see this:
    #if HAS_TMC_UART
    /**
    * TMC2208/TMC2209 stepper drivers
    *
    * Hardware serial communication ports.
    * If undefined software serial is used according to the pins below
    */
    //#define X_HARDWARE_SERIAL Serial1
    //#define X2_HARDWARE_SERIAL Serial1
    //#define Y_HARDWARE_SERIAL Serial1
    //#define Y2_HARDWARE_SERIAL Serial1
    //#define Z_HARDWARE_SERIAL Serial1
    //#define Z2_HARDWARE_SERIAL Serial1
    //#define E0_HARDWARE_SERIAL Serial1
    //#define E1_HARDWARE_SERIAL Serial1
    //#define E2_HARDWARE_SERIAL Serial1
    //#define E3_HARDWARE_SERIAL Serial1
    //#define E4_HARDWARE_SERIAL Serial1

    //
    // Software serial
    //
    #define X_SERIAL_TX_PIN PE0
    #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN

    #define Y_SERIAL_TX_PIN PD3
    #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN

    #define Z_SERIAL_TX_PIN PD0
    #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN

    #define E0_SERIAL_TX_PIN PC6
    #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN

    #define E1_SERIAL_TX_PIN PD12
    #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN

    // Reduce baud rate to improve software serial reliability
    #define TMC_BAUD_RATE 19200

    So as you see they are using software serial for all chips. For Z axis it would then look somehow like this
    STEPPER_TMC2209_SW_UART(name, stepPin, dirPin, enablePin, rxPin, txPin, rsense, microsteps, currentMillis, stealth, hybridSpeed, slaveAddr, stallSensitivity, fclk, minEndstop, maxEndstop)

    resulting in

    STEPPER_TMC2209_SW_UART(ZMotor, IOZ1Step, IOZ1Dir, IOZ1Enable, ORIG_Z_CS_PIN, ORIG_Z_CS_PIN, 0.1f, 16, 550, 1, 0, 0, 0, 12, endstopNone, endstopNone)

    check for rsense value to be the one used on your driver! So slave addresses needed as all have their own serial.
  • Thanks again. The following configuration worked:
    STEPPER_TMC2209_SW_UART(ZMotor, IOZ1Step, IOZ1Dir, IOZ1Enable, ORIG_Z_CS_PIN, ORIG_Z_CS_PIN, 0.1f, 16, 900, true, 0, 0, 0, 12, endstopNone, endstopNone)
    STEPPER_TMC2209_SW_UART(E1Motor, IOE1Step, IOE1Dir, IOE1Enable, ORIG_E0_CS_PIN, ORIG_E0_CS_PIN, 0.1f, 16, 900, true, 0, 0, 0, 12, endstopNone, endstopNone)
    Here is M122 printout:
    Recv: Motor 2: Z
    Recv: Status: ok
    Recv: Enabled: No
    Recv: RMS Current [mA]:894 set: 900
    Recv: Max. current [mA]: 1264
    Recv: Microsteps: 16 mres: 4
    Recv: StealthChop: On
    Recv: Hybrid mode disabled
    Recv: StallGuard Result: 0
    Recv: 
    Recv: Motor 3: E0
    Recv: Status: ok
    Recv: Enabled: No
    Recv: RMS Current [mA]:894 set: 900
    Recv: Max. current [mA]: 1264
    Recv: Microsteps: 16 mres: 4
    Recv: StealthChop: On
    Recv: Hybrid mode disabled
    Recv: StallGuard Result: 0

    I was able to successfully complete test print :) , but few outstanding issues still remain:

    - Occasionally Octoprint disconnects from the printer with the following message "Error: Too many consecutive timeouts, printer still connected and alive?" I increased timeout in Octoprint and will need to check if that helped.
    - Sometimes while using encoder, LCD goes blank and the mainboard becomes unresponsive. It recovers only after power cycle. I am under the impression that this happens during fast scrolling through menu. Need to collect more data and see if there is anything to tune in settings.
    - Bed Leveling (G32) does not work. It positions extruder at 1st measurement point then moves bed away from the probe and reboots the mainboard. Again, I need to double check all the settings and retest.

    Thanks



Sign In or Register to comment.