element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Community Hub
Community Hub
Member Blogs Clem's Stepper Motor Puzzle!
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Community Hub to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: mayermakes
  • Date Created: 2 Feb 2023 4:07 PM Date Created
  • Views 27533 views
  • Likes 16 likes
  • Comments 43 comments
  • stepper motor
  • puzzle
Related
Recommended

Clem's Stepper Motor Puzzle!

mayermakes
mayermakes
2 Feb 2023
Clem's Stepper Motor Puzzle!


Developing electronic circuits often feels like solving a puzzle. And solving this puzzle could win you a Multicomp Pro Tablet Oscilloscope!


And while finding the basic application to make an IC do its magic is often quite easy, some questions often remain.
Among the crucial skills of makers and engineers is interpreting a datasheet and this will come in very handy for the following puzzle:

This time we are looking at a staple of the 3d printing and CNC world:  the TMC2130 stepper motor driver.


imageimage

The photo and schematic show a basic circuit that allows the user to control the movement of a bipolar stepper motor with simple button pushes.
For practical reasons the built circuit has the enable pin(EN) pulled low to activate the circuit.  The Arduino is only used to pass on 12V, 5V and GND to the tmc2130, it has not other connections to the circuit.
Pulling the DIR pin high or low determines the direction of the motor movement.
Pulsing the STEP pin makes the motor move.
But how far does the motor move?

The pins MS1, MS2,MS3 (also known as CFG0,CFG1,CFG2) determine the movement settings; the most widely used configuration is to pull all 3 of them low.
CFG2 determines where to get the voltage reference from. Low level sets it to internal.
The other two pins are much more interesting.
By pulling MS1/CFG0 and MS2/CGF1 low, we set the driver to "Full step," no interpolation and spreadcycle mode.
The most common stepper motors need to do 200 steps per revolution (1,8° angle change per full step).
So for a full rotation we need to press the step button 200 times.

So far so good.

Here is the puzzle:
What happens if you just leave MS1/CFG0 and MS2/CFG1 floating (open) -- how often would you have to push the STEP button for a full rotation?

Or do you think the motor would just not turn at all?

You can find the solution in theory and practice!  We are interested in not only getting the answer right but in seeing the work you did to arrive at this answer.

Tell us if you tried you try it out practically (show us pictures). Or did you study datasheets or video tutorials (share the links you found helpful)?

The member who provides the best detail on how he or she solved the puzzle wins the prize!

Terms and Conditions  Multicomp Pro Tablet Oscilloscope

  • Sign in to reply

Top Comments

  • mayermakes
    mayermakes over 3 years ago +4
    https://youtu.be/4N-O1IzRSfc Lets go over the main aspekts of the entries for this competition and find out who is the winner!(TLD:DR skip to the end if you just want to know who won) The element14 community…
  • beacon_dave
    beacon_dave over 3 years ago +3
    The motor won't turn at all as Clem appears to have forgotten to plug the Arduino into a power supply...
  • misaz
    misaz over 3 years ago in reply to mayermakes +3
    Thank you for sending it. Yesterday it arrived and I am playing with it. Fundamental signals are well shown. More details I will post in blog soon.
  • misaz
    misaz over 3 years ago +2
    Hello Element14 community. Today I completed my practical part of this puzzle, and I would like to post my solution. In recent two weeks I did theoretical analysis and two practical experiments. The…
  • mayermakes
    mayermakes over 3 years ago +2
    thank you all for your Entries! it has been a blast seeing how this puzzle challenge played out with a lot of different approaches to finding the solution! We will carefully review all the entries, even…
  • Siana
    Siana over 3 years ago +1
    Trick question! Pololu does not manufacture a TMC2130 breakout. Pololu SKU 2130 is an entirely different thing, a brushed driver module. So that's a Waterrott 2130 stick there. The pins are connected…
  • rsjawale24
    rsjawale24 over 3 years ago in reply to dougw +1
    I would love to do the experimental analysis as theory often needs to be validated using experiments. But I do not have the resources and currently I'm running on a tight schedule. Maybe someone can do…
  • rsjawale24
    rsjawale24 over 3 years ago in reply to misaz +1
    Nice! I always love to see practical applications!
  • mayermakes
    mayermakes over 3 years ago in reply to misaz +1
    Hope you get great use out of your shiny new gadget!
  • misaz
    misaz over 3 years ago in reply to dougw

    Of course It is always slightly different. When I was testing it for a first time (outside view of camera) it was about 960 real presses and about 3300 total rising edges.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes over 3 years ago in reply to dougw

    the practical testing seems to confirm your suspicion!
    going backwards would mean the pulse just happened to be exactly lining up with a interpolation pulse.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 3 years ago in reply to misaz

    Going backwards was interesting.

    I am a little surprised there weren't more guesses given the nice prize.

    As I indicated I wasn't going to weigh in, but my preliminary analysis would have guessed you would probably get a different number of button pushes each time you tried to do a full rotation test.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • misaz
    misaz over 3 years ago

    Hello Element14 community.

    Today I completed my practical part of this puzzle, and I would like to post my solution. In recent two weeks I did theoretical analysis and two practical experiments. The first of them failed. Here I will describe my journey with TMC2130 and stepper motors. It is my first experience with stepper motors. I already used basic DC motors, but stepper motor I used for a first time. I split my solution to several parts as described in following list:

    • Theoretical analysis
    • Building my own module with TMC2130
    • Buying and experimenting with Trinamic module

    Theoretical analysis

    At first, I of course start to find answer in datasheet. But at the beginning I need to find datasheet. Finding datasheet of TMC2130 chip was easy but I had troubles with datasheet of the module which has some important details about connection of the chip.

    In schematics it is mentioned as Pololu module but unluckily I did not find any Pololu module containing TMC2130. I opened large view of the photo, copied its URL address, downloaded it and in local viewer I over-zoomed it. Then rotated 180 deg for getting text in right direction instead of upside down.

    image

    As you can see on the module is something which look like URL address. I originally did typo and missed double t in URL. Then tried to open it and website without double t redirected me to some dangerous site and adblock prevented me to open it:

    image

    So, I gave it but later I found the correct page. Instead, I went for the chip datasheet in meantime and noticed that Trinamic site in Related products contains eval board referred as SilentStepStick which have similar form factor like module on Clem’s photo.

    image

    Trinamic SilentStepStick is available in multiple variants with several different chips. Variant with TMC2130 have no datasheet but there is schematics which replaces datasheet.

    image

    At this moment I had schematics of the module, schematics of the circuit and TMC2130 datasheet which should be everything needed for theoretical analysis.

    Floating pins analysis

    The first thing which interested me was letting config pin floating. I remember rule of thumb that no pin of any chip should be left floating, and this violates this rule. So, at first, I was searching what floating config means and found that in case of TMC2130 it is valid situation. Most relevant information about this I found in section number 24:

    image

    Then I searched for meaning of all 7 configuration pins. CFG4 and CFG5 are on the module directly connected and there is no (easy) way to change them. I basically skipped them. CFG6 is enable/disable pin:

    image

    Remaining important configuration options are CFG0, CFG1, CFG2, CFG3. Note that there is numbering shift. MS1, 2, and 3 are numbered starting at 1 while CFG names are numbered starting at 0. Pay attention that MS2 != CFG2 and instead MS2 == CFG1. Later I found that MSx naming convention comes from different stepper motor driver chip and designer of TMC2130 made it compatible.

    CFG0 is not very attractive and important for this puzzle. It configures timing of driver operations:

    image

    Most important for this puzzle are pins CFG1 and CFG2 which configures mode.

    image

    In this table is hidden answer to the puzzle question. With both pins let in open state each step consists of 16 micro steps which are internally interpolated to 256 micro steps by the chip. Mode of operation is StealthChop which is the more advanced mode of operation of this chip and there are also mentioned some other register configurations which generally do not impact answer to the puzzle question.

    Because I am stepper motor newbie, I had to learn what the microstep means. I found answer in several other articles on internet including some explanation of internal details. Basically, I understood it is technology which splits one step of stepper motor to smaller steps by properly applying right current to the motor thus letting motor in position between two full steps. From practical point of view, it means that with 16 micro step configurations for making one full step I need to toggle STEP pin 16 times. This means that for 200 steps (full rotation of my stepper motor) I need to toggle it 200 * 16 = 3200 times.

    The last configuration option CFG3 is important but do not change previously deduced answer. It configures way the TMC2130 use for measuring current flowing through motor and allowing limiting it. Changing these settings requires hardware modifications, so I let this pin open for making it working with setup which is used on module (current limit can be adjusted by potentiometer which is connected to AIN).

    image

    Button bouncing

    The previous answer saying that we need to press button 3200 times for doing one full rotation is only theoretical and in practise actual number of button presses depends on some other factors. The biggest issue which I realized in theoretical phase was button bouncing. When you press or release button it may bounce for a short period of time after the button “status” changed. This duration depends on button. Usually, it is up to 10 ms long. In this time button status oscillate and can generate several pulses. Even before I started playing with TMC2130 I connected logic analyser to my button and found that every press generates 1 to 8 rising and falling edges. Of course, this comes from experiment, and you should not suppose that you never get 9 edges. Then I wrote program using STM32G031 MCU with I2C OLED display which show number of detected edges and also debounced number of presses. After about hundreds of presses, I found that number of detected edges is about 3 to 4 higher than the (debounced) actual one.

    Following outcome means that every press move motor about three to four times in average and thus required number of buttons presses reduces significantly from 3200 to somewhere between 800 and 1066.

    Practical experiments later shown that there are more issues with button bounces. When the glitches are too fast, the motor may skip the step or even worse it may do step in reverse direction. This can move number of required button presses in both positive and negative directions. Datasheet contains detailed section about timing requirements (in standalone configuration which we use dedge=0):

    image

    Also note that there is filter which removes very fast glitches.

    After theoretical analysis I went to practical one.

    Designing my own TMC2130 module

    For saving money I decided to request free same of TMC2130 and building my own module for evaluating it. Trinamic (now ADI) confirmed my sample order, but DHL needed some papers and later I had to pay VAT for it, but it was still cheaper than buying it on my own expense and paying full shipping (and it was very fast of couser). I ordered TQFP variant of the chip for easier soldering. QFN and TQFP are exactly the same parts in terms of internal logic but because of larger pins TQFP variant can handle 1.4A motor coil current instead of 1.2A limit of QFN part. After few days I received it:

    image

    There was no time to make proper PCB so I used generic TQFP to pinhead adapter from AliExpress which I bought several years ago and some pieces remained in my cabinet:

    image

    At first, I soldered chip and some SMD parts to it. I used SMD parts for passives which are connected to the place between two sibling pins. As a base for soldering I used schematics of the SilentStepStick module which I mentioned at beginning.

    image

    Then I soldered first THT passive and some pinheads. Here are pinheads for connecting motor soldered:

    image

    In schematics there were CSA shunt resistor. I had only chip SMD resistor. I soldered it rotated by 90deg and used wire for connecting second (flying) terminal to non-sibling pin.

    image

    I did several mistakes when placing parts, so I had to rework it. The biggest issue was that when reworking I destroyed one pin and had to connect capacitor directly the pin of chip. But luckily it was the first pin on the side, so it was easy to soler. At the end my module look as follows:

    image

    And some wires and caps are also at bottom side:

    image

    With soldering and reworking I spend about 3 hours, then I connected it to the circuit and tested it. On the photo below you can see (from left to right) STM32G031 disco with display counting button presses, logic analyser, breadboard with buttons, pull-up, and power LED. The rightest board on the breadboard is my own DC/DC module converting 12V input to 6V for motors. Above breadboard is motor and below is the most important part: my TMC2130 module which I described above.

    image

    And unluckily it did not work.

    So, I spend additional 10 hours with debugging and reworking the module again. But unluckily it did not work. My outcomes from experiments and debugging were following:

    • Connection did not burn, all parts survived, so it was not so bad.
    • TMC was alive. Using logic analyser I have seen that generating diagnostic interrupt work.
    • TMC received all my step rising edges and after every 64th edge it drove interrupt signal as expected.
    • Motor did not move
    • Motor was not held by TMC2130
    • On motor pins there were only short glitches when step was regularly driven otherwise motor pins were held high

    Because TNC2130 respond to my step edges by at least diagnostic interrupt I think it was alive. My theory is that experiment failed because of over-current detection. For sensing currents there is CSA and shunts with very low value, but my DIY approach most probably added resistance on wires which is most probably significantly higher that it should be and then when TMC2130 trigger motor it immediately detects overcurrent due to large voltage drop on higher resistance path and stop motor due to overcurrent.

    In previous theoretical analysis you have seen that there are several options for sensing current. I tried rework board for using different approach (reworks required for example bypass shunt, remove voltage divider and changing value of remaining resistor in original voltage divider) but all my attempts were without success.

    Experimenting with bought module

    Previous experiment was mostly waste of time. It did not work. I saved some money but lost lot of time. But I do not give up and decided to go more common (and slightly more expensive) way. Because I was interested in stepper motors and want to learn it, I bought TMC2130 SilentStepperStick module and go in standard (expected) way. After few days I received it (with many other components from wishlist which are unrelated to this experiment):

    image

    image

    As you can see my module also have watterott domain written on it so I think it is exactly the same module as Clem have. Pin headers were bundled with module but I had to solder them manually. Note that it is not clear which side of the module is top at the first look. Usually, chips are on top side of breakout boards but in this case chip is at bottom side.

     image

    The first mistake was that I of course forget to solder bridge for selecting standalone mode (instead of SPI mode). So, I had to select very thin soldering tip and solder it later with paying attention to nearby pinhead. But I succeeded this time.

    image

    Then I connected module to the circuit. It is significantly simplified in comparison with previous circuit. I also bought and changed second stepper motor for testing that my previous failure was not cause by motor instead of my module :D

    For new motor I used higher voltage about 7.2 volts, and it work.

    image

    On the picture you can see that I had connected logic analyser to the circuit. I have connected “signals” of one motor coil and the button.

    When the motor is not moving motor signals looks as follows. Note that this is view form logic analyser but in real signals are analog. I do not have oscilloscope so this the most advanced view which I can provide.

    image

    All pulses are same length. Motor is held in fixed position.

    After applying step signal (for tests I used the attached microcontroller instead of buttons) signal changed. On following screenshot from logic analyser, you can see one step pulse (the last line).

    image

    As you can see the first signal consist of short pulses of mostly the same length, but the second signal has pulses with changing length (in real it is sine I think, but logic analyser can’t show it). We can see that at beginning there were long pulses which were later shortening and extending again. In next step cycle signals switched roles and the same pattern was visible on first signal.

    image

    I think these signals are cause by interpolating micro steps.

    So now I have working circuit, so I started making experiments.

    Experiment with grounded CFG1 and CFG2

    At first, I tried experiment with grounded CFG1 and CFG2. I use this mode:

    image

    It is the simplest mode making one full step per step cycle. I have motor with 200 steps per rotation, so I should click the button 200 times. But according to theory research it should be less because of button bounces. Let’s see:

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    As you can see motor several steps skipped, and sometimes it turned back. This behaviour I mentioned in theoretical section. At the end counter ended on 220 real presses and 393 rising edges including bounces.

    Experiment with open CFG1 and CFG2

    Now let’s try configuration asked by this puzzle. It is this configuration:

    image

    Let’s see on video:

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    As you can see steps were significantly smaller and some of them were efficiently invisible. In theoretical part I estimated button presses count required for full rotation in range 800 to 1066 when bounces taken in account. At the end counter stopped at 1016 real presses and 3562 detected rising edges (which includes button bounces). Expected value of rising edges was 3200 but as we have seen some steps were not very clear, some were skipped. In this mode motor very rarely moved back. These issues most probably caused deviation of missing 362 edges. But generally, values are very near expectation.

    The last experiment which I will show is with STEP signal driven by MCU. This can prove theoretical values 200 for grounded CFG1 and CFG2 and 3200 for open CFG1 and CFG2. In these experiments I reconfigured MCU pins from input to open-drain output and drove signal low. When driving TMC2130 by MCU there are no glitches so one turn should exactly match 200 and 3200 steps.

    Here is video for CFG1 and CFG2 grounded (SpreadCycle mode with one full step per step cycle):

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    Here is video for CFG1 and CFG2 open (StealthChop mode with 16 micro steps and interpolation):

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    As you can see StealthChop mode work very well under normal conditions and movement is very smooth.

    Summary

    This is all from my datasheet analysis and experiment. The answer is that for full rotation with all CFG0, CFG1, CFG2 and CF3 open It is needed to generate 3200 rising edges but when used with mechanical button there is no exact answer because of random spurious events and practically using my button it is about 1000 presses.

    For me it was nice two weeks spend with TMC2130 datasheet reading, planning, soldering, measuring, and learning stepper motors in generals. I learnt that stepper motor drivers are hot while I was burning my finger when touching module. I learnt many other useful information about stepper motors and their drivers. I consider last two weeks as well spend.

    Thank you for reading my answer (especial thank you for your patience if you watched full video with over 1000 button presses :D) and have a nice day.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes over 3 years ago in reply to rsjawale24

    yes, I also like to do things practically, but a look in the datasheet is always a good idea especially when the practical application does not behave just as expected.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube