Welcome! Log In Create A New Profile

Advanced

Step Motor Speed at Microstepping

Posted by veysel_olgun 
Step Motor Speed at Microstepping
September 12, 2023 06:52AM
Hello,

First of all thank you for Marlin software

I am using MKS Robin Nano v3.0 card

I am controlling Step Motor (Nema 17 0.47 Nm)

My Step motor driver card is TMC2209

Steps Per unit for Z axis is 25600

I am making autofocus operation on digital microscope project. Most of the time in autofocus operation, motor movement taking much more time.

Here is the simple python code to move step motor and wait for its finish

device.serial.write("G91\n".encode())
while 1:
    data = device.serial.readline()
    if data == b"ok\n":
        break

s=time.perf_counter()
for i in range(25):

    device.serial.write(b"G1 Z0.001\n") # move up 1 micrometer (0.001 mm)
    device.serial.write(b"M400\n")      # wait for current move finish
    c = 0
    while 1:
        data = device.serial.readline()
        print(data)
        if data== b'ok\n':
            c += 1
        if c == 2:  # "ok" message will return after "G1 Z0.001" and "M400" command
            break
print(time.perf_counter()-s)


output: 2.56 seconds. Total time is 2.56 second for 25 step (25 micrometer)

It is taking 0.1 seconds for 1 micrometer and I think it is very slow. Also single 100 micrometer movement takes about 0.15 seconds


I also tried this code without M400 command

like this;

device.serial.write("G91\n".encode())
while 1:
    data = device.serial.readline()
    if data == b"ok\n":
        break

s=time.perf_counter()
for i in range(25):
    device.serial.write(b"G1 Z0.001\n")     # move up 1 micrometer (0.001 mm)
    time.sleep(.02)                         # just sleep for 0.02 seconds, I did not use M400 
print(time.perf_counter()-s)

This one is working and I can do fast autofocus but it moves weirdly, sometimes it is doing autohome in Z axis and sometimes it moves X and Y axis wronly if I give X or Y commando after autofocus operation (Z axis commanded without M400, like above code) . I mean if I don't use M400 command, autofocus operation is fast but happening unexpected movement in all axis

My questions is :

1-) How fast can i move 1 micrometer for this step motor and TMC2209 driver without missing a step ? or How to achieve this command take 0.02 sec(or lower) to complete 1 micrometer movement ? For example can it be 0.02 seconds or more fast without missing step ?

I also increased all speed configuration like M203 M201 vs. but it did not work. What is your advise to handle this issue ?

This is the basic configuration, I can also upload configuration files if it required
>>> m503
SENDING:M503
echo:; Linear Units:
echo:  G21 ; (mm)
echo:; Temperature Units:
echo:  M149 C ; Units in Celsius
echo:; Steps per unit:
echo:  M92 X800.00 Y800.00 Z25600.00
echo:; Max feedrates (units/s):
echo:  M203 X1200.00 Y1200.00 Z1200.00
echo:; Max Acceleration (units/s2):
echo:  M201 X60.00 Y60.00 Z60.00
echo:; Acceleration (units/s2) (P R T):
echo:  M204 P60.00 R60.00 T60.00
echo:; Advanced (B S T X Y Z):
echo:  M205 B20000.00 S0.00 T0.00 X0.30 Y0.30 Z0.30
echo:; Home offset:
echo:  M206 X0.00 Y0.00 Z0.00
echo:; Stepper driver current:
echo:  M906 X1200 Y1200 Z1200
echo:  M906 I1 X1200 Y1200
echo:; Driver stepping mode:
echo:  M569 S1 X Y Z
echo:  M569 S1 I1 X Y
echo:; Backlash compensation:
echo:  M425 F1.00 X0.00 Y0.00 Z0.00

Edited 1 time(s). Last edit at 09/13/2023 05:49PM by veysel_olgun.
Re: Step Motor Speed at Microstepping
September 12, 2023 09:37PM
Quote
It is taking 0.1 seconds for 1 micrometer and I think it is very slow. Also single 100 micrometer movement takes about 0.15 seconds

I can believe that. 25 start-accelerate-cruise-decelerate-stop cycles plus loop overhead vs. one cycle makes a big difference.

I don't have a good explanation as to why you're seeing X & Y movement when only Z is commanded. The only things that come to mind are communication channel errors or buffer overrun. Switching to the "line number, command, checksum" format of sending commands should fix that. If a command is garbled or out of order, then Marlin requests the command immediately after the last accepted command.

As to maximum speed - you need to look at both acceleration and feedrate. To do this you can do the following:
  1. Create a command that has one movement that is long enough that you can accurately measure it. Include feedrate in it.
  2. Set the DEFAULT_ACCELERATION and DEFAULT_MAX_ACCELERATION to a low value.
  3. Increase the feedrate until the actual movement starts to shorten.
  4. Use half the failing feedrate from now on
  5. Increase the two acceleration settings until the actual movement starts to shorten.
  6. Use half the failing feedrate and half the failing acceleration as your defaults.
Re: Step Motor Speed at Microstepping
September 13, 2023 05:30PM
Hi, thank you for answer. I will try your advices and i will share the result here

By the way sorry for that I just give wrong information about weird X and Y axis movement. X or Y axis not move if I only give command for Z axis. if I commando for Z axis about 25 (can be lower or upper) times without M400 command and after that if I give commando for X or Y axis (with M400) device moving to home direction quickly. This is not happen every time but happen mostly. I think that this is caused of buffer overrun(as you said). I will try to increase buffer for this problem but I do not know which code should I update, do you have idea ?

Edited 1 time(s). Last edit at 09/13/2023 05:37PM by veysel_olgun.
Sorry, only registered users may post in this forum.

Click here to login