Welcome! Log In Create A New Profile

Advanced

Using SPI only for stepper control

Posted by NforcerOH 
Using SPI only for stepper control
December 11, 2017 12:21PM
First off I'm not a control board designer but I'm thinking about a system, could we use more compact boards with less pins by using SPI/I2C to control steppers and read the inputs needed? It seems that if you remove the pin limitation on the atmega or the Due by taking advantage of the SPI/I2C buses you can control more sensors/devices. Why not use some ADS1115 for reading the temps and some CD74HC4067 or the likes to controller the stepper drivers. With the TMC2130 that support SPI, seems it's feasible. and allows for more steppers that a FDM printer would need for now.
VDX
Re: Using SPI only for stepper control
December 11, 2017 12:50PM
... check first the timing limits - how fast can you aquire sensor data and (synchronized) control steppers with SPI/I2C?


Viktor
--------
Aufruf zum Projekt "Müll-freie Meere" - [reprap.org] -- Deutsche Facebook-Gruppe - [www.facebook.com]

Call for the project "garbage-free seas" - [reprap.org]
Re: Using SPI only for stepper control
December 11, 2017 06:11PM
SPI interfaces are too slow to send individual step commands to stepper drivers at the speeds needed in 3D printers. You would need to use a more intelligent stepper driver that can do complete moves by itself - preferably including segmentation-free delta printer moves - and you would need an common clock signal to synchronise them.

I2C is rather limited because of its high latency, but OK for some things such as temperature control.

In fact the SAM3X processor used in the Arduino Due has quite a lot of extra I/O pins that are not made available on the Due. So all-in-one controller boards are less constrained by I/O than controllers based on Arduinos.

Btw the ATSAM3X8E processor used on the Arduino Due is heading towards obsolescence, just like the atmega2560. Price wise, the sweet spot right now in the Atmel/Microchip range of high pin count microcontrollers is ARM Cortex M4 and M4F processors.

Edited 2 time(s). Last edit at 12/11/2017 06:12PM by dc42.



Large delta printer [miscsolutions.wordpress.com], Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Using SPI only for stepper control
January 10, 2020 03:00PM
TMC2660 can be clocked at 20MHz resulting 10MHz SPI clock.

10000000 / (20*4) = 125000 'steps' per second
16 * 200 = 3200 steps per revolution (with 16 microstepping )
125000/3200 = ~39 revolutions per second
39 * 2mm (GT belt) * 20 (teeth sprocket) = 1560mm / second

780mm/s at 32 microstepping
97.5mm/s at 256 microstepping
Re: Using SPI only for stepper control
January 10, 2020 05:16PM
Yes, but then the processor would spend too much time setting up the DMA transfers to SPI and checking that they were complete. And there are good reasons not to use an external clock with the TMC2660.

Edited 1 time(s). Last edit at 01/10/2020 05:17PM by dc42.



Large delta printer [miscsolutions.wordpress.com], Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Using SPI only for stepper control
January 10, 2020 10:11PM
Trinamic datasheets do not recommend external clock above 16Mhz (and they lowered max clock from 20 to 18MHz with newer ICs). I always assumed this was due to EMI - could you point out the reasons why external clock does not work well with TMC266x?
Re: Using SPI only for stepper control
January 11, 2020 04:03AM
Quote
newbob
Trinamic datasheets do not recommend external clock above 16Mhz (and they lowered max clock from 20 to 18MHz with newer ICs). I always assumed this was due to EMI - could you point out the reasons why external clock does not work well with TMC266x?

It's because of the lack of clock failure detection, which means that of the clock fails then the driver output mosfets could be left permanently on. You could use a dedicated crystal oscillator to generate that clock; but it's not safe to use a processor-generated clock (which is what we used on the prototype Duet WiFi before I realised the problem) in case the firmware fails and the clock ceases.



Large delta printer [miscsolutions.wordpress.com], Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Using SPI only for stepper control
January 11, 2020 01:05PM
EN LOW will power down driver's MOSFETs, so one could attach clock fail detect circuit to EN pin when clock fails.

EDIT: datasheet says to disable MOSFETs with EN before shutting down the clock. Well, if pulling EN low will not work than shutting off VCC_IO will, for sure.

Edited 2 time(s). Last edit at 01/11/2020 04:28PM by newbob.
Re: Using SPI only for stepper control
January 12, 2020 10:07AM
Quote
newbob
EN LOW will power down driver's MOSFETs, so one could attach clock fail detect circuit to EN pin when clock fails.

EDIT: datasheet says to disable MOSFETs with EN before shutting down the clock. Well, if pulling EN low will not work than shutting off VCC_IO will, for sure.

Sure; but that's additional complexity. We decided it was simpler to use the internal clocks.



Large delta printer [miscsolutions.wordpress.com], Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Using SPI only for stepper control
January 20, 2020 06:29PM
The topic about stepper motor drivers is quite interesting. With the new high-speed MCUs – Cortex M7 … , wouldn't be feasible performing the motor control on the MCU and just using external half-bridges ?
Re: Using SPI only for stepper control
January 23, 2020 09:29PM
I think this is what BIGTREETECH S42A closed loop might be doing (knowing bigtreetech, it's probably clone of something else).

Anyway, TMC2660 (TMC26x, and generation prior) lets you apply coil current directly via SPI (newer Trinamic stepper drivers, like the one in Duet 3 or TMC2130 do not).

SPI overhead is large and I'm not sure how feasible it is to communicate with the drivers quickly and reliably, but there's a big incentive to to it: When controlling coil current directly, MCU has much better understanding how much mechanical force is being generated. STEP pulses mask that as MCU does not know if given STEP is a microstep. Microsteps can be up to 4 times weaker than a full step, plus, force is not linear. 3d printers would benefit from only using, say, quarter step resolution for positioning while 'dithering' microsteps in between for smoother operation. Something that Trinamic is already trying to do but not very successfully, in part due to STEP interface and in part because step generating algorithm does not know what is the next move.
Re: Using SPI only for stepper control
January 24, 2020 11:15AM
Quote
newbob
SPI overhead is large and I'm not sure how feasible it is to communicate with the drivers quickly and reliably, but there's a big incentive to to it: When controlling coil current directly, MCU has much better understanding how much mechanical force is being generated. STEP pulses mask that as MCU does not know if given STEP is a microstep. Microsteps can be up to 4 times weaker than a full step, plus, force is not linear. 3d printers would benefit from only using, say, quarter step resolution for positioning while 'dithering' microsteps in between for smoother operation.

I doubt that it would make much difference. Most printers have XY resolution of at least 5 full steps per mm, giving 0.1mm half step resolution. Meanwhile, the extrusion width is usually at least 0.5mm. So differences in the size of individual microsteps are unlikely to make a visible difference.

Z resolution is more important; however it's normally possible to choose a layer height that is a whole number of full steps.

BTW:

1. Some of the Trinamic drivers (e.g. TMC2160 and TMC5160) allow you to define the current vs. microstep table yourself. So if you can be bothered to measure the nonlinearity of microstepping in your motors, you can correct for it while still using the step/dir interface.

2. If it's reducing pin count that you are after, there are a couple of other options:

(a) Use a common DIR signal to all drives. But this limits the extent to which you can generate step pulses to multiple drivers simultaneously, which reduces the maximum achievable step rate.
(b) Use SPI to change the direction and no DIR lines at all. The TMC2160/5160 drivers have a bit in the GCONF register to invert the motor direction. What I don't know is whether you can modify it on-the-fly. I'll ask Trinamic.

Edited 3 time(s). Last edit at 01/24/2020 11:16AM by dc42.



Large delta printer [miscsolutions.wordpress.com], Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Using SPI only for stepper control
January 24, 2020 02:05PM
Microstep table does not work w/o knowing where you are in the rotation so we would need feedback from a step motor indicating zero position. When sending coil current values, MCU can estimate, with high probability, at which part of full step a motor is in w/o motor angle feedback.

Anyway, I think value from SPI control (old 20 bit SPI that TMC2660 uses) comes from knowing microstep count and stall guard data. As a bonus, SG data is free as MCU gets it over SPI, at the same time coil current data is sent out.
Sorry, only registered users may post in this forum.

Click here to login