My EleksMaker laser CNC machine setup

Belt holders and adjustable X-axis
Small dot laser module
Trinamic stepper drivers
Wiring
1. Snip SPI pins
2. Connect DIAG0 pins to limit switch inputs D9 and D10
3. Connect both SDO pins with D12
4. Connect CS pins separately to D9 and D10
5. Connect both SCK pins to D13
6. Connect both SDI pins to D11
7. Connect VCC and GND



Grbl configuration

Update to the newest GRBL version according to their Wiki: https://github.com/gnea/grbl/wiki/Flashing-Grbl-to-an-Arduino

Open a serial terminal and check the configuration by sending $$. Here’s my config, I have added // comments to the settings that are of special interest:

$0=10
$1=25
$2=0
$3=7 //Direction port invert, mask
$4=0
$5=0
$6=0
$10=3
$11=0.010
$12=0.002
$13=0
$20=0
$21=1
$22=1 //Homing cycle, boolean
$23=0
$24=1000.000 //Homing feed, mm/min
$25=2000.000 //Homing seek, mm/min
$26=250
$27=10.000 //Homing pull-off, mm
$30=1000
$31=0
$32=1 //Laser mode, boolean
$100=80.000 // X steps/mm
$101=80.000 // Y steps/mm
$102=80.000
$110=5000.000 // X Max rate, mm/min
$111=5000.000 // Y Max rate, mm/min
$112=5000.000
$120=100.000 // X Acceleration, mm/sec^2
$121=100.000 // Y Acceleration, mm/sec^2
$122=100.000
$130=5000.000
$131=5000.000
$132=5000.000

Secondary Arduino Sketch:

There were a few false positive stall detections, so this only a starting point for fine tuning as described in the datasheet.
Use the Arduino IDE library manager (Sketch -> Include library -> Manage libraries…)
Search for TMC2130Stepper and then install.
Or download the zip file fromĀ https://github.com/teemuatlut/TMC2130Stepper

#include <TMC2130Stepper.h>
TMC2130Stepper X = TMC2130Stepper(2, 3, 4, 9); //Only param 4 (CS pin) matters
TMC2130Stepper Y = TMC2130Stepper(5, 6, 7, 10);

void setup() {
 X.begin(); // Init
 X.rms_current(500); // Current in mA
 X.microsteps(16); // Behave like the original Pololu A4988 driver
 X.interpolate(1); // But generate intermediate steps
 X.shaft_dir(1); // Invert direction to mimic original driver
 X.diag0_stall(1); // diag0 will pull low on stall
 X.diag1_stall(1); 
 X.diag1_active_high(1); // diag1 will pull high on stall
 X.coolstep_min_speed(25000); // avoid false stall detection at low speeds
 X.sg_stall_value(14); // figured out by trial and error

 Y.begin();
 Y.rms_current(1000);
 Y.microsteps(16);
 Y.interpolate(1);
 Y.shaft_dir(1);
 Y.diag0_stall(1);
 Y.diag1_stall(1);
 Y.diag1_active_high(1);
 Y.coolstep_min_speed(25000);
 Y.sg_stall_value(15);
}

void loop() {

}

Test PCB Layout