bdring / Grbl_Esp32

A port of Grbl CNC Firmware for ESP32
GNU General Public License v3.0
1.69k stars 529 forks source link

Trinamic Drivers #220

Closed bdring closed 4 years ago

bdring commented 5 years ago

Recently the TMCStepper library has been upgraded to support ESP32 better and handle daisy chaining.

I was previously using my fork of TMCStepper for some testing of these features. Now that everything I need is in the original library, I am going to update the devt (then master) branch to use the official TMCStepper library. It was using the TMC2130Stepper library. That will bring in support for lots of drivers and daisy chaining.

I like the CPU_MAPs being one of the only things a users needs to touch to define a machine. That gets a little messy with the dozens of things you can do with these drivers. I'll start with support for the major features, like micro stepping and motor current.

Advanced users may need to edit other files until I figure out a solution.

ewidance commented 5 years ago

Well done! I've recently updated my ultimaker with 32 bits LPC1768 + Trinamic + Marlin 2. Trinamic are really impressive... I'm goind t buy some more to test with GRBL/ESP32...

alfredanil commented 4 years ago

Please do add support for tmc 2209/8 and tmc 5160 too.

bdring commented 4 years ago

@alfredanil

TMC5160 is already there. I don't have any of those other drivers and it will take some time to add the code. I'll add it to the roadmap.

shreeramlive commented 4 years ago

Hi, TheTMC5160 SPI drivers have driven me crazy enough for almost a week :relaxed: I'm not able to check the driver SPI connection with the ESP32. Still not able to make them move. Please suggest some way to debug the SPI connection of drivers.

bdring commented 4 years ago

What controller board are you using?

shreeramlive commented 4 years ago

Hi @bdring, I'm testing a custom made board. bdring/4_Axis_SPI_CNC#3

bdring commented 4 years ago

I always use a logic analyzer I have a Logic 4 from Saleae.

shreeramlive commented 4 years ago

Thanks for the suggestion. I don't have any Logic analyzer yet:satisfied:, Anyway I will try my best to make it work.

shreeramlive commented 4 years ago

Hi, After searching about those TMC5160 drivers. I realized that the TMC5160 stepsticks have their internal motion control disabled since the STEP/DIR interface is used.

These drivers have the ability to be controlled with SPIalone using their integrated motion controller, this can be beneficial in freeing up some pins on ESP32. http://blog.trinamic.com/2017/04/05/how-to-use-tmc5130-eval-with-your-arduino-mega/ http://blog.trinamic.com/2018/02/19/stepper-motor-with-tmc5160/

Moreover the simple encoder interface on TMC5160/TMC5130 can be used to get positions directly from the driver's SPI itself. So closed loop control is also a possibility since ESP32 has good processing power. @uStepper's uStepperS board uses TMC5130 with an encoder interface for closed loop control. https://github.com/uStepper/uStepperS

So this kind of control would be beneficial for large CNC mills, Laser cutters, etc. This probably can be an awesome choice where StepSticks are a no go. It can help to reduce the cost of the electronics ( ESP32 has already reduced the cost a lot by removing the need for a host ).

Resources:

Concerns:

Please share your opinions!

bdring commented 4 years ago

This has been on my mind for a while now. I have even discussed this with Sonny, the developer of Grbl.

It would be dozens of hours of work and require some expensive custom designed hardware.

Right now the SPI is shared with the SD card. This has no penalty because the stepper driver SPI commands are only used at startup or in idle.

Daisy chain mode might also need to be tested to see if it is viable.

The current TMCStepper library probably would need some major updates.

Ramp vs step/dir. This would require a major rewrite of Grbl. There may be some edge cases where there are problems, like Grbls realtime overrides and fast freehold.

Closed loop. I think this would need to be done in Grbl with step and dir or direct PWM control.

Encoders. It is possible encoders could be used for verifying no steps are lost and allowing manual moves (pushing axes) to be allowed and position updated.

Bottom line. I am not ready to spend so much time and money on this experiment at this time.