FluidNC and MKS TinyBee

Hey everyone,

Figure I would do a quick write-up to help anyone else that might be looking for this information. I wanted to make the switch to GRBL, but was having issues with the Rambo 1.4 board. I tried a few Fusion360 post-processors and everything would start off fine, then all of a sudden the cutting tool would fly off in the positive x-axis direction uncontrollably which essentially destroyed the workpiece.

I bought an MKS TinyBee along with 5 TMC2209 stepper drivers. I was able to flash FluidNC without any issues, and could connect wirelessly to the FluidNC web portal. The trouble came when trying to get the configuration file dialled in so that I could get the correct movement from the CNC, as well as use gSender which I have preferred for controlling my MPCNC. I didn’t have any luck with the sample config files, whether it was for the TMC2209 steppers, or specifically the example for the TinyBee.

A few notes that I only figured out after several days of trouble shooting, in the hopes that it will help others.

  1. When you look at the board diagram here you can see that there are six motor outputs: X, Y, Z1, Z2, E0, E1. What took me a while to realize is that Z1 and Z2 are run by a single stepper driver, meaning that you can drive two stepper motors with a single stepper driver, but you can’t control these independently. This is why the Z1 and Z2 plugs are both the same colour.

  2. I don’t understand the details behind all of this, however it seems that GPIO pins over and above around 32 or 36 (I can’t remember which one) have to be addressed through the I2SO system, instead of the GPIO referencing. The following are the I2SO pins to use for each motor port:

X Disable Pin: I2SO.0
X Step Pin: I2SO.1
X Direction Pin: I2SO.2

Y Disable Pin: I2SO.3
Y Step Pin: I2SO.4
Y Direction Pin: I2SO.5

Z1 and Z2 Disable Pin: I2SO.6
Z1 and Z2 Step Pin: I2SO.7
Z1 and Z2 Direction Pin: I2SO.8

E0 Disable Pin: I2SO.9
E0 Step Pin: I2SO.10
E0 Direction Pin: I2SO.11

E1 Disable Pin: I2SO.12
E1 Step Pin: I2SO.13
E1 Direction Pin: I2SO.14

Other important pins required if you’re using dual endstops for the auto squaring feature:

X Endstop: GPIO.33
Y Endstop: GPIO.32
Z Endstop: GPIO.22
MT_DET: GPIO.35

The way I have my MPCNC physically wired is as follows:

X0 Stepper: Wired to the X-Motor plug.
X1 Stepper: Wired to the Y-Motor plug.
Y0 Stepper: Wired to the Z1-Motor plug.
Y1 Stepper: Wired to the E0-Motor plug.
Z Stepper: Wired to the E1-Motor plug.

X0 Limit: Wired to the X end stop plug S and G pins.
X1 Limit: Wired to the Z end stop plug S and G pins.
Y0 Limit: Wired to the Y end stop plug S and G pins.
Y1 Limit: Wired to the MT_DET plug S and G pins.

I’ll add my configuration file at the bottom. Again, this is using TMC2209 stepper drivers (5 of them). I am able to auto-square in both the X and Y axes. I haven’t tried implementing a Z zeroing tool, however I would imagine if you wired it up to the 3D Touch plug and used GPIO.2 it should work.

board: MKS TinyBee V1.0_001
name: MPCNC

kinematics:
  Cartesian:

stepping:
  engine: I2S_STATIC
  idle_ms: 255
  pulse_us: 4
  dir_delay_us: 1
  disable_delay_us: 0

axes:
  x:
    # X
    steps_per_mm: 100.000
    max_rate_mm_per_min: 2000.000
    acceleration_mm_per_sec2: 500.000
    max_travel_mm: 325.000
    soft_limits: true
    homing:
      cycle: 0
      positive_direction: false
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 5000.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.33
      hard_limits: true
      pulloff_mm: 2.000
      stepstick:
        step_pin: I2SO.1
        direction_pin: I2SO.2
        disable_pin: I2SO.0

    motor1:
      limit_neg_pin: gpio.22
      hard_limits: true
      pulloff_mm: 2.000
      stepstick:
        step_pin: I2SO.4
        direction_pin: I2SO.5
        disable_pin: I2SO.3

  y:
    # Y
    steps_per_mm: 100.000
    max_rate_mm_per_min: 2000.000
    acceleration_mm_per_sec2: 500.000
    max_travel_mm: 220.000
    soft_limits: true
    homing:
      cycle: 1
      positive_direction: false
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 5000.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.32
      hard_limits: true
      pulloff_mm: 2.000
      stepstick:
        step_pin: I2SO.7
        direction_pin: I2SO.8
        disable_pin: I2SO.6

    motor1:
      limit_neg_pin: gpio.35
      hard_limits: true
      pulloff_mm: 2.000
      stepstick:
        step_pin: I2SO.10
        direction_pin: I2SO.11
        disable_pin: I2SO.9

  z:
    # Z
    steps_per_mm: 1400.000
    max_rate_mm_per_min: 200.000
    acceleration_mm_per_sec2: 300.000
    max_travel_mm: 80.000
    soft_limits: false
    homing:
      cycle: 0
      positive_direction: false
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1000.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      hard_limits: false
      pulloff_mm: 1.000
      stepstick:
        step_pin: I2SO.13
        direction_pin: I2SO.14
        disable_pin: I2SO.12

i2so:
  bck_pin: gpio.25
  data_pin: gpio.27
  ws_pin: gpio.26

spi:
  miso_pin: gpio.19
  mosi_pin: gpio.23
  sck_pin: gpio.18

sdcard:
  cs_pin: gpio.5
  card_detect_pin: NO_PIN

control:
  safety_door_pin: NO_PIN
  reset_pin: NO_PIN
  feed_hold_pin: NO_PIN
  cycle_start_pin: NO_PIN
  # EXP1 BTN_ENC
  macro0_pin: gpio.4:low:pu
  macro1_pin: NO_PIN
  macro2_pin: NO_PIN
  macro3_pin: NO_PIN

macros:
  startup_line0:
  startup_line1:
  macro0: $SD/Run=lasertest.gcode
  macro1: $SD/Run=home.gcode
  macro2:
  macro3:

coolant:
  flood_pin: NO_PIN
  mist_pin: NO_PIN
  delay_ms: 0

Laser:
  pwm_hz: 5000
  # EXP1 BTN_ENC
  output_pin: gpio.13
  # FAN1
  enable_pin: I2SO.16
  disable_with_s0: false
  s0_with_disable: false
  tool_num: 0
  speed_map: 0=0.000% 0=12.500% 1700=100.000%
# 135=0mA 270=5mA 400=10mA 700=16mA
user_outputs:
  analog0_pin: NO_PIN
  analog1_pin: NO_PIN
  analog2_pin: NO_PIN
  analog3_pin: NO_PIN
  analog0_hz: 5000
  analog1_hz: 5000
  analog2_hz: 5000
  analog3_hz: 5000
  digital0_pin: NO_PIN
  digital1_pin: NO_PIN
  digital2_pin: NO_PIN
  digital3_pin: NO_PIN

start:
  must_home: false

The Laser portion, coolant, macros, etc can probably all be deleted, I just didn’t bother trying to cut that out yet.

As for gSender, apparently FluidNC does not send a $$ command upon connecting like plain GRBL does. In order for gSender to be able to work:

  1. Connect to the board with gSender.
  2. Access the FluidNC web portal.
  3. Reset the firmware through the web portal (under the middle GRBL panel, red square logo with a turn over arrow.).
  4. gSender should now work allowing you to jog. You still have to use the web portal to home each axis for some reason, but you can load gCode files through gSender to visualize and run.
7 Likes

All useful info…thanks

The reason is there are not enough hardware GPIO pins available on the ESP32 for all the functions required.

From expressif -

With further expansions of the ESP32 chip family, more application scenarios with diverse demands are being introduced, including some that have more requirements on GPIO numbers. The subsequence release of ESP32-S2 and other products have included up to 43 GPIOs, which can greatly alleviate the problem of GPIO resource constraint. If this still could not meet your demand, you can also add GPIO expansion chips to ESP32 to have more GPIO resources, such as using the I2C-based GPIO expansion module MCP23017, which can expand 16 GPIO ports per module and mount up to 8 expansion modules simultaneously thus expanding additional 128 GPIO ports totally.

I don’t see any port expander IC’s on my Tinybee but I do see three shift registers so I assume MKS achieve the same functionality as a port expander, just with cheaper IC’s :slight_smile:

3 Likes

Thank you for taking the time to put this together and post it.

relytjames just wondering if you have any feedback on FluidNC and/or this board.

Finally got around to giving this board a try and so far it has passed all the checks and successfully made some cuts on my Primo. A bit more tuning to go, but overall I think this is a great option. I’ve got the probe working using the TB input (with the help from some folks at FluidNC).

Config is mostly based on what @ relytjames has above and some things taken from fluidnc wiki.

board: MKS TinyBee V1.0 XXYYZ
name: MPCNC-PRIMO

kinematics:
  Cartesian:

i2so:
  bck_pin: gpio.25
  data_pin: gpio.27
  ws_pin: gpio.26

spi:
  miso_pin: gpio.19
  mosi_pin: gpio.23
  sck_pin: gpio.18

sdcard:
  cs_pin: gpio.5
  card_detect_pin: NO_PIN

stepping:
  engine: I2S_STATIC
  idle_ms: 255
  pulse_us: 4
  dir_delay_us: 1
  disable_delay_us: 2

axes:
  x:
    steps_per_mm: 100.000
    max_rate_mm_per_min: 8000.000
    acceleration_mm_per_sec2: 80.000
    max_travel_mm: 600.000
    soft_limits: true
    homing:
      cycle: 0
      positive_direction: false
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1500.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.33:high
      hard_limits: true
      pulloff_mm: 4.000
      stepstick:
        step_pin: I2SO.1
        direction_pin: I2SO.2
        disable_pin: I2SO.0

    # use E0 driver for 2nd X axis motor
    motor1:
      limit_neg_pin: gpio.22:high
      hard_limits: true
      pulloff_mm: 4.000
      stepstick:
        step_pin: I2SO.10
        direction_pin: I2SO.11
        disable_pin: I2SO.9

  y:
    steps_per_mm: 100.000
    max_rate_mm_per_min: 8000.000
    acceleration_mm_per_sec2: 70.000
    max_travel_mm: 440.000
    soft_limits: true
    homing:
      cycle: 0
      positive_direction: false
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1500.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: gpio.32:high
      hard_limits: true
      pulloff_mm: 4.000
      stepstick:
        step_pin: I2SO.4
        direction_pin: I2SO.5
        disable_pin: I2SO.3

    # use E1 driver for 2nd Y axis motor
    motor1:
      limit_neg_pin: gpio.35:high
      hard_limits: true
      pulloff_mm: 4.000
      stepstick:
        step_pin: I2SO.13
        direction_pin: I2SO.14
        disable_pin: I2SO.12

  z:
    steps_per_mm: 400.000
    max_rate_mm_per_min: 8000.000
    acceleration_mm_per_sec2: 60.000
    max_travel_mm: 80.000
    soft_limits: false
    homing:
      cycle: 0
      positive_direction: false
      mpos_mm: 0.000
      feed_mm_per_min: 300.000
      seek_mm_per_min: 500.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      pulloff_mm: 3.000
      stepstick:
        step_pin: I2SO.7
        direction_pin: I2SO.8
        disable_pin: I2SO.6

relay:
  direction_pin: NO_PIN
  output_pin: i2so.17
  enable_pin: NO_PIN
  disable_with_s0: false
  s0_with_disable: true
  spinup_ms: 0
  spindown_ms: 0
  tool_num: 0
  speed_map: 0=0.000% 0=100.000% 1=100.000%
  off_on_alarm: false

probe:
  # this is the TB input
  pin: gpio.39:low

control:
  safety_door_pin: NO_PIN
  reset_pin: NO_PIN
  feed_hold_pin: NO_PIN
  cycle_start_pin: NO_PIN
  macro0_pin: NO_PIN
  macro1_pin: NO_PIN
  macro2_pin: NO_PIN
  macro3_pin: NO_PIN

user_outputs:
  analog0_pin: NO_PIN
  analog1_pin: NO_PIN
  analog2_pin: NO_PIN
  analog3_pin: NO_PIN
  analog0_hz: 5000
  analog1_hz: 5000
  analog2_hz: 5000
  analog3_hz: 5000
  digital0_pin: NO_PIN
  digital1_pin: NO_PIN
  digital2_pin: NO_PIN
  digital3_pin: NO_PIN

start:
  must_home: false

Motors are X1, Y1, X2, Y2, Z.
Limit switches are x1, y1, x2, y2 and use the S and G pins (left two pins).
P is the z probe.

The spindle relay is still untested.

2 Likes

Good info :+1: The spindle relay looks like it should work fine off HE0 and an opto-isolated relay board

Hi quick question, I am new to this (sorry), but I am trying to figure out the Yamal code that you posted. I can not find what stepsticks that you used on it, I have 5 of the 2209 drivers but have no idea how to add them to your file? Any help would greatly appreciated. Thanks a lot!!!

The config I’ve posted is also for the TMC2209 stepstick (as well as relytjames). If you were to use something else I believe the steps_per_mm would need to be adjusted and possibly some of the attributes under stepstick for each motor*.

Thank you so much for all of your hard work, this helps me a lot!!!

There is a wiki on using FluidNC, it is very good. There is a section on the type of stepstick driver here, it gives examples of the code needed.

You can simply use a 2209 in legacy mode or UART mode if you want to configure the settings on the fly

I was able to to further test this out and can confirm the spindle relay works.

Also added a fan on i2so.19

#fan
user_outputs:
  digital0_pin: i2so.19

I played around with a 4wire fan too, but still haven’t got the pwm part worked out (as of now using this as a reference).

RONALD J MCKENZIE, one thing I should mention, the motor connections were not straight forward for me… I needed to plug X2 and Y2 in reversed/flipped of X1 and Y1, see EDIT below. I’m not sure why this is, but I’d be interested if anyone else runs into this.

EDIT: here’s how I’ve wired the motors so that each motor moves in unison with its twin…

UPDATE: taking a step back and looking at the mechanics of the machine, the two motors for each axis will need to turn in opposite directions. I’m coming from a RAMPS board where all motors were plugged in with the same orientation… so I’m thinking the RAMPS firmware must have been accounting for this in the background.

2 Likes

The info in this topic is perfect as I too have a Tinybee and MKS TMC2209 drivers. So while I plod through the printing, I thought I’d start playing with the controller, drivers and FluidNC, but I’ve run into a few brain squeezes …

(First off, apologies as I’m still a relative beginner re controlling steppers etc but my background is electronics and I play with programming microcontrollers so I kinda bumble my way through….)

I’ve found the available info on the Tinybee to be a bit lacking and wondering if anyone can fill in the blanks for me.

The spec sheet on the TMC2209 tells me

Step/Dir Drivers for Two-Phase Bipolar Stepper Motors up to 2.8A peak – StealthChop™ for Quiet

Movement – UART Interface Option – Sensorless Stall Detection StallGuard4.

But as far as I can ascertain, the Tinybee doesn’t do UART… so that means the current needs to be set manually using the trimpot and adjusting the V ref. (ok so far…)

I found the calculation for working out the Vref value


And also the schematic for the MKS brand TMC2209 that came with the TinyBee….this is where confusion sets in…

As can be seen in the schematic, R4 and RP1 form a voltage divider, meaning the Vref can only be a value between 0-2.5v.

image

Even the text on the schematic indicates that if the Vref is 2.5v, the RMS current will be 1.77A

image

Using the formula confirms that a Irms of 1.7 equals a Vref of 2.5v.
So how do you set the Vref to achieve the 2A rms stated in the specs? It appears you can’t because using the formula, the Vref value would have to be higher than 2.5v and that is not possible with the voltage divider circuit.

I also looked at the TinyBee documents and schematics to try and figure out what settings the DIP switches control.

image

It appears that when the DIP switches are in the ‘On’ position, they put a logic High onto MS1,MS2 & MS3.
When I check these pins against the MKS TMC2209 schematic…

image
image


It appears the 3 DIP switches are connected to MS1, MS2 and the PDN/UART pins
So if left in the “all ON” configuration as shown in the TinyBee user manual under “TMC2208, TMC2209, TMC2226 common mode Settings” .

image

The board is set to Steps – 16, Interpolation – yes to 256, ChopperMode – stealthChop2
With PDN set as “automatic standstill power down disable”.
Do we want automatic standstill powerdown disabled?

I have 2A stepper motors stepperonline steppermotors (P/No 17H19-2004S1) so am capable of using the 2A drive.

I’m interested to know.
1: What drive current and Vref are you folks using with your TMC2209 drivers?
2. How do you set the Vref to get the 2A rms from the drivers if I wanted to push them. (I had planned to start slightly lower at 1.8-1.9A to see if anything got hot or skipped etc, but it doesn’t look like you can even do that)
3. What DIP switch settings are you using? ie do you have the automatic standstill power down disabled? And if so, why?

Cheers!

From the sound of it, automatic power down would “let go” of each axis when not moving, so if you are cutting a rectangle, say cutting in the +X direction, the machine would not hold the +Y/-Y axis firm. It would also let go of the Z axis and from the vibrations it would probably descend.

It makes sense to me that you don’t want automatic power down.

You may be right…I was thinking the power down mode was when it reduced the current to the stepper when the stepper wasn’t moving…more investigation required!

Found this in the datasheet…

1.7 Automatic Standstill Power Down
An automatic current reduction drastically reduces application power dissipation and cooling
requirements. Per default, the stand still current reduction is enabled by pulling PDN_UART input to
GND. It reduces standstill power dissipation to less than 33% by going to slightly more than half of
the run current.
Modify stand still current, delay time and decay via UART, or pre-programmed via internal OTP.
Automatic freewheeling and passive motor braking are provided as an option for stand still. Passive
braking reduces motor standstill power consumption to zero, while still providing effective
dampening and braking!

950mA or so. The limit isn’t the specs on the steppers. The limit is the steppers getting so hot, they make the plastic soften and deform. You want to keep your steppers under 50C or so.

The tmc 2209 needs some tiny pads soldered to put them in standalone mode.

You might consider getting some drv8825 drivers. They would be much simpler to configure and they are pretty solid. It would help you get the tinybee set up before trying to mess with the tmcs in standalone.

Just received my tinybee too, but I think I’m begining to fear it was a bad impulse buy… :stuck_out_tongue:
Just starting to realize the TMC2209’s support might be a bit lacking here… is it possible to use sensorless homing and current setting through uart with the tinybee… I grew accustomed to this kind of thing… :slight_smile:

Mark_Kiwi, I’m using the DIP settings per the MKS manual (all up)… I’m thinking the up position for PDN_UART turns the auto-power-down feature off (GND turns it on), but I could be wrong.

I started with a Vref value of 1.5v for my 2A stepper motors. As of now I’ve only run brief tests so not sure if I’ll need to reduce this.

Edit… Looking at the datasheet it seems like 2A is NOT possible with Rsense=110 (which is what my stepstick has)…

I’m almost finished wiring and configuring my TinyBee on the LR3
I still have one problem left though: I’m trying to connect a LaserTree 24V laser, but there is no 3 pins plug providing pwm/GND/12-24V one the TinyBee

i tried wiring the J6 12-24V/GND plug to the two power pins of the laser, and IO2 signal from the “3DTouch” plug to the signal
When powering the machine, the laser is on at full blast and won’t turn off…

I have an adapter board I can use but I wonder what’s the best way to wire this, and if I can skip the adapter board…

LaserTree laser board

Adapter board:

Laser configuration in FluidNC

Laser:
  pwm_hz: 5000
  # on 3D Touch connector (has pdwn + PWM)
  output_pin: gpio.2:high:pd
  s0_with_disable: true
  tool_num: 0
  speed_map: 0=0.000% 1000=100.000%
  off_on_alarm: true