pootle / tripipy

Simple python driver for Trinamic tmc5130 connected to Raspberry Pi
The Unlicense
37 stars 14 forks source link

Testing against a TMC5160 and Pi Zero W #1

Closed AndyThirtover closed 5 years ago

AndyThirtover commented 5 years ago

Hi there!

I've been working through your code trying to get it running on a Pi Zero W with a TMC5160 http://www.farnell.com/datasheets/2786292.pdf

I haven't changed any of the code in tmc5130reg.py

I've switched drvenpin to 5 since 3 is not readily available.

I'm starting pigpiod like this:

sudo pigpiod -c 256

And getting an output of this:

m.goto(1000) 09:13:20 DEBUG (800) MainThread trinamicDriver.enableOutput: output drivers enabled check status 20 loc 0.00 chipVelocity 0.00 ramp status: loc 0.00 chipVelocity 0.00

I have confirmed that GPIO4 has a clock signal on it. The rest of the wiring is:

DIR - N/C STEP - N/C CLK - GPIO4 SDO - MOSO CSN - CE0 (expected 0.V but this sits a 3.3V) SCK - SCK SDI - MOSI DRV_ENN - GPIO5 (is 3.3V during operation - didn't expect this).

Power is 3.3V on the Pi side and 13V on the Nema 17 side. I cannot feel any resistance at the motor shaft.

Starting gives: m = chipdrive.tmc5130() 09:30:53 INFO (631) MainThread trinamicDriver.resetChip: chip reset attempted 09:30:53 DEBUG (631) MainThread trinamicDriver.enableOutput: disabled 09:30:53 INFO (631) MainThread trinamicDriver.init: controller initialised using spi master on channel 1, clock frequency 15,000,000.

Curious about GPIO5 so tried:

import pigpio pg = pigpio.pi() pg.write(5,0) 0

And confirmed it was 0.0V

I was wondering if you could point me in the right direction.

Regards

Andy

AndyThirtover commented 5 years ago

Came to the realisation that SPI chan 1 was being used rather than 0. Now I get these results: m.goto(2) 11:29:00 DEBUG (878) MainThread trinamicDriver.enableOutput: output drivers enabled check status 20 loc 0.45 chipVelocity 86251.00 ramp status: pos reached event loc 1.34 chipVelocity 66813.00 ramp status: pos reached event loc 1.86 chipVelocity 31256.00 ramp status: pos reached event target 2.00 reached, status 29, ramp status pos reached event, pos reached, speed zero 11:29:02 DEBUG (878) MainThread trinamicDriver.enableOutput: disabled

Now the motor is enabled, the shaft is locked, but the shaft does not rotate. Will investigate Registers Regards

Andy

AndyThirtover commented 5 years ago

It would appear that I need to do some keyhole surgery to the 5160 SilentStepStick. This board holds pin 20 (SD_MODE) high. It’s very close in there, so it could be scalpel time. It’ll be a few hours before I can perform the operation.

Regards Andy

pootle commented 5 years ago

Wow glad you're making progress. Seems bizarre to lock the chip into step/dir mode on the board though - but it definitely looks like it's setup that way! The TMC bob board defaults to smart mode, and looks fairly easy to change. Is it a Farnell specific board you are using?

I've driven 2 motors via 2 5130 bobs from a pi zero with no problems

AndyThirtover commented 5 years ago

It seems that these 'SilentStepStick' boards are pretty much aimed a 3D printers as plug in replacements. There's a little bit of weasel wording around SPI configuration and SPI Control. Actually the data sheet does say API control - so I'll prod their technical support on Monday.

It is so tight on the boards not even a scapel will get in there!

In the meantime I've ordered a pair of TMC5160-BOB's - So I'll close this issue.

My only comment is that the hardware specs could be updated to say that SDMODE must be low so that the internal waveform is passed to the motor drive section.

Regards

Andy

servetcoskun commented 4 years ago

Hi @AndyThirtover how did you get this library to work with the TMC5160-BOB? I am considering moving from our C solution to python3 for easier modifications.

AndyThirtover commented 4 years ago

Indeed it works well. I have a nema17 pulling 10Kg around quite happily.

servetcoskun commented 4 years ago

Hey thanks for responding so fast :) did you open-source your version? I would love to continue working with these boards.

gautamjain commented 4 years ago

@AndyThirtover I discovered the same thing about the TMC5160 SilentStepSticks after ordering a couple from Digikey. SPI was only used for configuration and STEP/DIR signals were required.

However, it turns out they have updated the TMC5160 SilentStepStick to version 1.4. It has jumpers that let you pull SD_MODE low. I ordered one from watterott.com and it functions pretty well!