Uncategorized

tmc2130 notes

Q: TMC2130 Stepper Motor on Raspberry Pi. SPI issue?

johnFor the last few days I’ve been struggling to get a NEMA17 (1.5 rated current) stepper motor to function with TMC2120 driver (vref = 1.0) and I’m all out of options now to try, so I’m here looking for some help. I think it may be SPI related due to me not getting back expected results on statuses…stepper-motorstepper-driver

tlfong01

tlfong011. I think your SPI hardware and software looks more or less OK. 2. But why frequency set so low? 3. Have you ever tried to use a square wave sig gen to move the motor?4. Of course you also need to use jumper wires to manually config the driver first. 

john

john1. thanks, it’s nice to know that matches what I think it should be. 2. The frequency is low because that’s all that seemed to get the correct output on PISCOPE, but I think that might be an issue with Piscope than anything else from what I’ve read recently. 3. I haven’t tried this no, I presume it’s software based so I’ll give it a google to try today (feel free to point me to any scripts/resources on it if you have any handy) 

tlfong01

tlfong01Ha, when I started playing with my tmc2209 a while ago, I skimmed the data sheet and used jumper wires to config, and a sig gen to send the steps, and the motor started moving happily.You might like to go to Rpi SE and search tmc2209 to find my tldr answer!Two more things. (1) You seem to forget to initialize the ENABLE pin. (2) When you clean up GPIO, all GPIO output pins would automatically return to INPUT mode. This is a trap to many newbies. 

john

johnThanks. I’ve been tying the ENABLE pin to ground which is 0 I believe? The SPI screengrab above doesn’t seem to say that though so I’ll double check. I have tried via a GPIO pin too though. The response issue I was having looks like it’s due to it being sent on the next request for reads, so I’m playing with that now to check outputs and errors now I can. 

tlfong01

tlfong01Yes, I am reading the tmc2130 datasheet and now understand why you missed the “pin operation mode”. In tmc2209 datasheet, this “standalone or pin mode” is clearly explained. (4) Ref: TMC2130 DATASHEET (Rev. 1.10 / 2018-MAY-09) Page 5 trinamic.com/fileadmin/assets/Products/ICs_Documents/… Section 1 – Principles of Operation THE TMC2130 OFFERS THREE BASIC MODES OF OPERATION: / to continue, …(1) In Step/Direction Driver Mode, the TMC2130 is the microstep sequencer and power driver between a motion controller and a two phase stepper motor. Configuration of the TMC2130 is done via SPI. (2) In Standalone Mode, the TMC2130 can be configured using pins. In this mode of operation CPU interaction is not necessary, … (3) The third mode of operation is the SPI Driver Mode, …Perhaps what is confusing is that, in standalone/pin mode, no cpu/mpu is necessary, but you do need a square wave pulse/PWM/(Step) signal generator to send the step signal.(1) My enable pin function is something like this: def tmcStartMotor(enblPin): setGpOutPinLow(enblPin) return (2) This is a complete listing of my still buggy Pico MicroPython program: penzu.com/p/6f3b4f94

john

john4:52 PMI’ve tried with the enable pin and still no luck. Running DRV_STATUS after each step is showing s2ga as 1 though? Any idea what that could be?Looking at my chip it’s a SPI version so I should be able to use operation mode 1 or 3 in the datasheet I presume. Another thing to add it that when I run my stepping script, sometimes it ends with the motor being in an active state (hard to move) and sometimes it’s free to rotate. It seems strange that it’d be doing that to me, but I dont know how to debug the issue.

tlfong01

tlfong012:49 AM@john (1) “my chip it’s a SPI version”. Does this mean that it is hardwired only for SPI operation, while the “DIY” version is hardwired for standalone/manual jumper wire pin and cannot be used for SPI?(2) Now I am browsing the BigTreeTech’s shop where they are selling two versions: (a) Step/Dir version, (b) SPI version. So you are sure yours is a SPI one. (3) Can I have the link to your product, hopefully not from eBay? 🙂TMC2130 Version 3 42 stepper motor driver (silent for 3D printer DIY kit) – BigTreeTech, Tmall ¥53
https://detail.tmall.com/item.htm?_u=f3thdsbf3dc&id=654000362477 

tlfong01

tlfong013:20 AM(4) Are you sure your tmc2130 module is hardwire to do SPI operation?

user image

  1 hour later…

tlfong01

tlfong014:40 AMThere are two versions of TMC2130, V1.1 and V3.0. Which one are yours?TMC2130 V1.1 SPI stepper motor driver for 3D printer – ¥28
https://item.taobao.com/item.htm?_u=f3thdsbf232&id=606560562673Version 1.1 a,d 3.0 seems compatible.

user image

tmc2130 datasheet says there are 3 modes of operation: Spi/Dir, (2) standalone, (3) SPI. Modes 1 and 3 uses a “motion controller” TMC429, TMC4369. I assume you are NOT using those controllers. Please confirm.

user image

And you are not using any current sensing resistors. 

tlfong01

tlfong015:24 AMtmc2130 datasheet says to transmit/receive the 40-bit datagram, CS line MUST stay Low for the complete transmission. Are you sure you meet this condition?

user image

  4 hours later…

john

john8:56 AMThanks for the continued help on this, I appreciate it.Here’s the link to the product I bought: amazon.co.uk/gp/product/B07RN7QP7V/…

john

john9:10 AMIt’s v3 version, SPI. I’ve checked the pins on the chip and there doesn’t seem to be a resistor/bridge at the SPI bit, or the CFG4 and CFG5 bits. I’m struggling to work out if that’s correct or not from their docs… grobotronics.com/images/companies/1/…

john

john9:43 AMI’m also not using TMC4… controllers, with no current sensing resistors. It’s straight out of the box config. I’ll upload my wiring diagram shortly just in case. I’ve also tried SPI config wirte/reads and I can change the config, and read it later in the code chain and my changes are saved, so I think SPI is working in that respect.I have a Raspberry PI Zero 2 W now too so I’ll try that later just in case the Pi is to blame. I’m running out of things I haven’t tried at this point. 

tlfong01

tlfong0110:10 AMThanks for the updated info. I am still reading the references, and might give more comments later. I am glad that you are usning V3. It is good that you are not using TMC4xxx controller, and no sensing resistors. It makes things less complicated.Yes, good idea to use RpiZ2W for swap troubleshooting.Now I am making some reading summary.

user image

Ah, locking up supper time. See you later.

tlfong01

tlfong011:12 PMHi there, I am back. Now I am reading this document:TMC2130-V3.0 Module User Manual – Shen Zhen Big Tree Tech
https://grobotronics.com/images/companies/1/TMC2130-V3.0RM.pdf?1600171444657I am reading the following product at the same time:TMC2130 V3.0 SPI Stepper Motor StepStick Mute Silent Driver with Heatsink for 3D Printer Control Board 4 Packs – KingPrint, Amazon, £31 for 4 (£7.8 each)
https://www.amazon.co.uk/gp/product/B07RN7QP7V/ref=ppx_yo_dt_b_asin_title_o02_s01?ie=UTF8&psc=1 

tlfong01

tlfong011:30 PMThe product sheet includes something like an “Evaluation Board”. We might need to read the boards’ documents later:

user image
tlfong01

tlfong011:46 PMThe user manual is not very clear. But I think the most important thing is this:To select Step/Dir mode, short (solder 0Ω across) the SPI jumper.

user image

Ah, bed time. See you tomorrow.  6 hours later…

john

john7:31 PMI have asked the Amazon seller for clarification on which mode I can use. I’ve tried on the new RaspPi Zero 2 and there’s no change.

tlfong01

tlfong012:18 AMI just got this msg: “This account is temporarily suspended to cool down. The suspension period ends in 7 days.” 

tlfong01

tlfong012:40 AMThe following article describe how to wire the TMC2160 to do standalone operation mode:elektormagazine.com/news/tmc2160motordriverboardAnd this tmc2160 board looks good:Makerbase MKS TMC2160-OC Motor Driver for 3D printing, big current, super silent ¥77
https://item.taobao.com/item.htm?spm=a230r.1.14.168.6cf3338eSsuDNT&id=661704209147&ns=1&abbucket=11#detail  5 hours later…

tlfong01

tlfong018:18 AMAnd just now I placed my tmc2160 order.

user image

  2 hours later…

tlfong01

tlfong019:51 AMAliExpress is also selling this MakerBase MKS2160 driver, at US$14:Makerbase – MKS TMC2160 Stepper Motor, 3D Printer Driver, High Torque Parts, Ultra Quiet for Gen L SGen – AliExpress US$14
https://fr.aliexpress.com/item/4001007452776.html?gatewayAdapt=glo2fra 

tlfong01

tlfong0110:06 AMI never heard of MKS Sgen L. So I googled:MKS SgenL – AliExpress
https://www.aliexpress.com/w/wholesale-mks-sgen-l.html

BIGTREETECH – TMC2130 V3.0 SPI TMC2208 UART Stepper Motor 3D Printer Driver Parts For SKR V1.3 V1.4 PRO MKS sGEN L A4988 TMC2209 – US$5.25
https://fr.aliexpress.com/item/32970150483.html?gatewayAdapt=glo2fra&spm=a2g0o.search0304.0.0.b74f3ac3bVmclh&algo_pvid=54efcc21-64be-45d1-b2bf-6f71bacea965&algo_exp_id=54efcc21-64be-45d1-b2bf-6f71bacea965-22 

tlfong01

tlfong0110:27 AMYesterday I wrongly thought that the MKS SGen L board was the TMC2209 official eval board and should be very expensive. Now I know that MKS SGen L board is not too expensive, only US$22.Makerbase 3D Printer Parts MKS Gen_L 2.1 Control Board Support TMC2209 2208 Uart Gen L Mode – AliExpress US$22
https://fr.aliexpress.com/item/32802151924.html?gatewayAdapt=glo2fra

Drivers_MKS_TMC2209 makerbase edited this page on Aug 31, 2020
https://github.com/makerbase-mks/MKS-GEN_L/wiki/Drivers_MKS_TMC2209Ah, locking down supper time! See you later. 

john

johnIt seems 2209 would be a good option but I want to control multiple steppers and be able to select which ones are moving, so SPI seems like the best(only?) way to go.  2 hours later…

tlfong01

tlfong0112:11 PMAh, actually both the 2209 UART and 2160 SPI method can handle at least 512 motors. Let me start with the 2209 and show you how the 2209 datasheet suggests a way to handle more that 4 motors. 

tlfong01

tlfong0112:25 PMThe following two figures from the 2209 datasheet shows how to (a) address 4 motors, (b) address more than 4 motors with one port (GPIO pin) to select one of multiple motors. Actually if you are running out of GPIO pins, you can easily use GPIO port expanders such as MCP23x17 to expand to 16, 32, 64, 128, 256 ports to select one of many motors.

user image

Similarly, for SPI, you can use your own CSn (not Rpi built in) ports (GPIO) pins to select as many motors as you have Cn ports/signal lines. 

john

johnIs there SPI on the 2209? 

tlfong01

tlfong01SPI addressing multiple devices:forums.raspberrypi.com/…Ha, that is the problem. 2209 has only UART, and 2160 has only SPI. One problem with SPI is that you cannot do long distance, perhaps less than 2 meters, over which the system would be unstable. One the other hand, UART can usually do 200 feet or longer. 

john

johnYes I’d read that previously. I’m happy to use UART but it’s slower, right? I want to be able to control 4 motors independantly. Is UART quick enought to make this possible? 

tlfong01

tlfong01Ah almost bed time. Call it a day, see you later. 

john

johnSEe you later, thanks agin for the help here. I might order the 2209 to try it out, I’m getting nowhere with the TMC2130 and it’s incredibly frustrating 

tlfong01

tlfong0112:38 PMWell, Page 15 pf the datasheet says the following:A minimum baud rate of 9000 baud is permissible, assuming 20 MHz clock (worst case for low baud rate). Maximum baud rate is fCLK/16 due to the required stability of the baud clock.So the upper baud limit is fCLK/16, much much faster than you would like. 

john

johnI’ll try them and look through the datasheet and see how I get on. It’s frustrating not knowing why the TMC2130 isn’t workinth though.Are the analogue switches you mention above seperate parts?  7 hours later…

john

john8:05 PMI’ve ordered an analogue switch and the 2209. It seems like the best way to go at the moment, and even using UART with the analog switches might be better all round anyway. Better than SPI.

tlfong01

tlfong013:38 AM@john Let us look closely at the (a) tmc2130 datasheet and see if we have missed something important. (b) Silent Stepper Sick Schematic (the breakout/board/module) and find out the function of the jumpers (SPI, CFn).References:https://www.trinamic.com/products/integrated-circuits/details/tmc2130/

(2) TMC2130 Datasheet R1.1 – Trinamic 2021jun17
https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2130_datasheet_Rev1.13.pdf

(3) TMC2130 SPI SilentStepStick SPI Schematics- Trinamic 2017dec22
https://www.trinamic.com/fileadmin/assets/Products/Eval_Drawings/TMCSilentStepStick_SPI-TMC2130_v10.pdfNow the schematic:

user image

@john I more or less agree that tmc2209 is the best way to go now. For me, SPI cannot do long distance (> 30cm) so UART is my only choice. I have a couple of analogue switches (multiplexors) in my junk box, but I am not sure if using digital mux is a better way. My first step is just 4 motors without need for analogue switches.And my first step consists of 3 little steps: (a) fiddling/messing in standalone mode, using manual jumper wires/pins only, but no Rpi Pico, (b) Use Pico GPIO pins to replace manual operation, but no UART (c) UART mode to config and diagnostics, removing all jumper wires, but still need Step, Dir pins/jump wiring. 

tlfong01

tlfong014:19 AMI got confused with all the jargons of the tmc2xxx/3xxx stuff, because I came from the A4899/TB6600 world. So I need to read a FAQ:SilentStepStick FAQ – Watteroot
https://learn.watterott.com/silentstepstick/faq/  2 hours later…

tlfong01

tlfong016:48 AMI also found that I misunderstood/misinterpreted many tmc things I read, including the following:(1) I told you that tmc can only do SPI or UART, but not both. I was wrong, tmc5xxx can do both SPI and UART, though 5xxx is a bit expensive, and commercial modules seems can do SPI only. Unluckily I cannot edit my old chat record. Perhaps when we finish our chatting, I will write a summary, including a long errata list.Some more references:TMC5160 Datasheet – Trinamic
https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC5160A_Datasheet_Rev1.14.pdf

TMC2226 Datasheet – Trinamic
https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2226_Datasheet_V106.pdf

TMC2209 and TMC5160: Guide for MKS Gen L and SKR V1.3
https://www.youtube.com/watch?v=dOJbSrWVu_Q

TMC2100 guide Part 1 Stepper driver upgrades – How to set VREF & firmware – Teaching Tech 2019feb23
https://www.youtube.com/watch?v=H41hIXdB6js&t=0s

TMC2208 guide Part2 Stepper driver upgrades – Teaching Tech, 2019feb26(see full text)

tlfong01

tlfong017:38 AMSo, TMC5160 can address up to 256 slaves, and no analog switch/mux is required.  2 hours later…

tlfong01

tlfong019:18 AMThe time has come to test TMC2130. As said earlier, I will test in 3 steps:Step 1 – Standalone mode – No Rpi Pico, only manual jumper wires, and a square wave sig gen.

user image

  2 hours later…

john

john11:03 AMLet me know how you get on with the TMC2130. I’ll be sending mine back anyway I think to avoid any trouble. 5160 doesn’t seem too badly priced if it’s a better option eventually but the 2209 will do for now. I just need something to run so I can code the rest. 5160 does need external MOSFETS apparently, so keep that in mind if you are thinking of buying those. The step controlling looks better though 

tlfong01

tlfong0111:17 AMAh, I did not notice that 5160 need external MOSFETs, that is a big problem for me doing prototyping. I only plan to use 5160 later, perhaps 2 years from now. I am keeping in mind 5160 things for future plans (SPI/UART 2 in 1, can address 256 motors etc). For now I will be messing with 2130/2160 SPI, and 2209 UART. I think almost all 2130/2209 knowledge and skills can easily be ported to 5xxx.I have started 2130, going very slowly. I am using the following motor:

user image

Ah, locking down supper time. See you later.  1 hour later…

tlfong01

tlfong0112:28 PM

user image
tlfong01

tlfong0112:50 PMNow I am using this stepdown voltage regulator to test the stepper motor:XL4015 1.25 to 36V DC-DC 5A Stepdown Module
https://components101.com/modules/xl4015-dc-dc-converter-module 

tlfong01

tlfong011:09 PM

user image

« first day (3 days ea

tlfong01

tlfong012:37 AMNow I am browsing other forums to see how other guys a playing with TMC2130. I found many questions have no reply. Here is an example: stackoverflow.com/questions/67856624/….The question is to set the stepper motor’s speed, which is proportional to the step rate.I guess I might try this using my TMC2130 testing rig.  4 hours later…

tlfong01

tlfong016:48 AMOther tm2130 hobbyists seem not quite understand the relationship between step rate and motor speed, so I am thinking of using a square wave signal generator to explain how we can dreive the motor speed from step rate.For the standalone mode testing I am doing now, I will be using a sig gen to send the step signals to the tmc2130 driver. In other words, no Pico software now. It is the next step I will be using Pico generated stop pulses to replace the external, manually adjusted frequency sig gen.

user image

Reference of the step/sig gen:How can Rpi4B python UART talk to XY PWM Signal Generators? – Rpi SE, Asked 2019oct20, Viewed 813 times
https://raspberrypi.stackexchange.com/questions/104779/how-can-rpi4b-python-uart-talk-to-xy-pwm-signal-generatorsI forgot to mention that this cheapy PWM sig gen is only US$2. 

tlfong01

tlfong017:07 AMNow I am staring at the tmc2130, and thinking of how to select:(a) manual hardware pin config mode, or(b) software UART config mode.

user image
tlfong01

tlfong017:24 AM@john Ha, it is only now that I have a chance to look at the real thing then I understand why you said why you could not find the “SPI jumper”. The reason is that the photo we are looking at does not match the real thing we are looking at. I need to find if it is a version difference.The tmc2310 I just received is version 1.1. What is your version?

user image
tlfong01

tlfong017:38 AMAh, locking down afternoon tea time. See you later. 

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.