Nikolay-Kha / PyCNC

Python CNC machine controller for Raspberry Pi and other ARM Linux boards
MIT License
593 stars 188 forks source link

`negative or zero time delta` assertion error from circle commands #28

Open abbydupre25 opened 6 years ago

abbydupre25 commented 6 years ago

Some G2 commands are throwing assertion errors. For example:

----- Hardware not detected, using virtual environment -----
----- Use M111 command to enable more detailed debug -----
*************** Welcome to PyCNC! ***************
> G0 X11 Y9
OK
> G2 X10 Y10 I-2 J-1
Traceback (most recent call last):
  File ".\cnc\main.py", line 72, in <module>
    main()
  File ".\cnc\main.py", line 64, in main
    do_line(line)
  File ".\cnc\main.py", line 33, in do_line
    res = machine.do_command(g)
  File "c:\workspace\pycnc\cnc\gmachine.py", line 365, in do_command
    self._move_circular(delta, radius, velocity, CW)
  File "c:\workspace\pycnc\cnc\gmachine.py", line 241, in _move_circular
    hal.move(gen)
  File "c:\workspace\pycnc\cnc\hal_virtual.py", line 139, in move
    assert dy > 0, "negative or zero time delta detected for y"
AssertionError: negative or zero time delta detected for y

I'm using python3. All tests are passing locally.

I experimented with hal_virtual and it looks like the time delta is zero for the last part of the move, but I can't tell why.

Nikolay-Kha commented 5 years ago

That error means that next pulse for stepper should be triggered at the same discrete moment of time as the previous one. Workaround for this issue - decrease movement speed, change motors with less steps per mm or change stepper drivers microsteps for something not so precise. Like 1/32 to 1/16. If you need such speed with such microsteps, then you would need to go into source and increase buffer size for movements and decrease DMA divider. But in this case circular interpolation calculation might go beyond CPU capabilities of RPi.