Menu

TMC2209 Driver does not move motor

2021-06-16
2021-06-21
  • Eric Schubert

    Eric Schubert - 2021-06-16

    ~~~

    ~~~I finally worked up the courage to upload my MFP2 code for the TMC2209 driver board after hours of staring at it and trying to figure out what to calculate, where to insert values, etc. It appears it was successful in compiling and uploading. The app connects to the Nano and appears to send commands to it, but the motor does nothing. It doesn't even appear to be getting current, as I can move it fairly easily by hand even when the coil power is enabled. The driver chip must be getting power, though, as the heatsink is nice and warm.

    I'm wondering if the address for the driver is incorrect. The documentation from Trinamic calls a 0x00 address, but the provided code uses 0b00. Could this be my issue?

    I double-checked my wiring and it all seems correct. Just to verify, though, here are my connections on the TMC2209:

    Side1:

    • EN->D8
    • MS1->D7
    • MS2->D6
    • MS3->D10 + D11 (with 1k resistor inline)
    • Reset->Not connected
    • Sleep->GND
    • Step->D4
    • Dir->D3

    Side2:

    • VMOT->12VDC
    • GND1->GND
    • 2B->Coil 1
    • 2A->Coil 1
    • 1A->Coil 2
    • 1B->Coil 2
    • VDD->5V on Nano
    • GND2->GND

    • DIAG->D12

    Nano is powered via 5VDC through USB cable.

    mBoardDefs.h values: (Note: no hashtags as SF was turning these lines into giant header text.)
    define BTRX 10 // tmc2209 interface
    define BTTX 11
    define STALL_VALUE 150 // [0... 255] default 40
    define TMC2209CURRENT 400 // 600mA for 8HS15-0604S NEMA8 stepper motor, default 1000
    define TMC2209PORTSPEED 57600 // define tmc2209 serial speed, DO NOT CHANGE
    define TBL 2 // define TBL (blank time) [0...3] default 2
    define TOFF_VALUE 4 // [1... 15] default 3
    define DRIVER_ADDRESS 0b00 // TMC2209 Driver address according to MS1 and MS2
    define R_SENSE 0.11f // Match to your driver

    Customized myBoards.cpp values:
    mystepper->tbl(TBL); // use TMC22xx Calculations sheet to get these (I defined this value in myBoardDefs.h, as shown above.)
    mystepper->hysteresis_end(1); // use TMC22xx Calculations sheet to get these
    mystepper->hysteresis_start(-3); // use TMC22xx Calculations sheet to get these
    mystepper->vsense(1); // vsense=0 for larger resistor, vsense=1 for smaller resistor (I added this to switch to the smaller, more-sensitive sense resistor.)
    mystepper->irun(7); // copied from Calculations sheet, CS value

    So, I'm stuck at this point. The driver appears to get power, but does nothing when I use the move buttons in the program. Anyone have some advice on what to do next here?

    Thanks!

     

    Last edit: Eric Schubert 2021-06-16
  • Eric Schubert

    Eric Schubert - 2021-06-16

    Update #1:
    I re-verified and uploaded the firmware using VS Code + Arduino extension. It uploads, but when I try to connect to the Nano, I get the error in the image and attached text file.

     

    Last edit: Eric Schubert 2021-06-16
  • brownrb

    brownrb - 2021-06-16

    The error text file does not help, sorry

    Start the windows app
    Click the logging tab
    Enable Log Errors
    Go to connection tab and click connect
    after it fails find the log file created by the app and post it here

     
  • brownrb

    brownrb - 2021-06-16

    there is a reason why i rated the tmc boards as "expert" level.

    First a check list
    If you are not using the BIGTREETECH TMC chips then there is zero support. The code only worls on BIGTREETECH chips, not on any other TMC chips. There is plenty of warning in the PDF about this.

    Next, I assume you used the provided spreadsheets to enter values for your stepper motor, that you entered these details into the spreadsheet and that the calculated values you then entered into the firmware.

    Next, you say the Nano is powered via 5VDC through USB cable. You did not mention 12V power though. You need 12V power to make the stepper motor move. It will not move on 5V USB.

    Next, your pin connections all check out

    Side1:
    
        EN->D8 (Y)
        MS1->D7 (Y) 
        MS2->D6 (Y)
        MS3->D10 + D11 (with 1k resistor inline) (Y)
        Reset->Not connected  (Y)
        Sleep->GND (Y)
        Step->D4 (Y)
        Dir->D3 (Y)
    
    Side2:
        VMOT->12VDC (Y)
        GND1->GND (Y)
        2B->Coil 1 (Y)
        2A->Coil 1 (Y)
        1A->Coil 2 (Y)
        1B->Coil 2 (Y)
        VDD->5V on Nano (Y)
    
        GND2->GND (Y)
    
        DIAG->D12 (Y)
    

    Lastly, you queried about 0b00. Yes that is correct. The code again is for the BIGTREETECH TMC chips and will NOT work on any other brand of TMC chip - they are NOt the same and require different code and different libraries. We know the BIGTREETECH chips work because every one in the Beta test group has tested the code throughly and we know it works. We also know it will not work on other TMC chips.

    The log file should provide me with enough information about the Windows application error.

    Regards
    Robert

     
  • Eric Schubert

    Eric Schubert - 2021-06-16

    Thanks, Robert. To help answer a few questions...

    • As noted in the pinout list, I do have a 12V DC power supply providing power to the stepper driver. It should have plenty of power to drive the motor. (200W, 17A, I believe)
    • I specifically made sure to buy the TMC2209 driver boards from BIGTREETECH, and have confirmed they do say BIGTREETECH TMC2209-v1.2 on them.
    • I did use the spreadsheet for TMC2209 to calculate values to enter into the firmware as noted in my first post. Hopefully I entered everything correctly and didn't miss anything.

    I will work on getting you the log file for my error message. I appreciate your help. :)

     
  • Eric Schubert

    Eric Schubert - 2021-06-17

    As requested, here's the error log when I attempt to connect.

     
  • brownrb

    brownrb - 2021-06-17

    I think the problem lies here
    6/16/2021 7:57:28 PM: getconnectvalues: Get Temp-Resolution
    6/16/2021 7:57:28 PM: SendString: ==START====================================================
    6/16/2021 7:57:28 PM: SendString: Connected
    6/16/2021 7:57:28 PM: SendString: sending=:21#
    6/16/2021 7:57:28 PM: SendString: sending=OK
    6/16/2021 7:57:28 PM: SendString: =END===========================================================
    6/16/2021 7:57:28 PM: ReceiveResponse: ==START====================================================
    6/16/2021 7:57:28 PM: ReceiveResponse: Check if client is connected
    6/16/2021 7:57:28 PM: ReceiveResponse: Controller response: Q255
    6/16/2021 7:57:28 PM: getconnectvalues: raw response for get temperature precision was: 255
    6/16/2021 7:57:28 PM: getconnectvalues: temperature resolution = 255

    255 is an invalid response for temp resolution - it should be a value of 9 to 12
    This would indicate that the mtfocuser configuration in the controller is corrupted.
    This often happens when updating from one version to another especially if the previous firmware was older.

    Normall you could resolve this by running the ClearEEPROM program (in the test folder) first then reprogramming the controller.

    But, if you load the arduino IDE, connect the controller with USB cable, top right window, click to open the serial port monitor, at bottom of window set no line ending and then next to that set baud rate to 57600 for the tmc board, then
    in top text bar to left of send type
    :209#

    that is colon followed by digits 209 ending with #
    and click the send button
    That will update the config for temperature precision
    then next type
    :48#
    and click send this is save the setting into eeprom for future use

    Then you can exit Arduino, load up the windows app and it should connect
    Let me know how it goes please

     
    • Eric Schubert

      Eric Schubert - 2021-06-17

      Interesting. This is a barebones focuser built with just the motor. No display, temp sensor, buttons, LEDs, etc. I figured it would ignore anything not included in the configuration. But I realize that's not always possible (or practical) from a coding standpoint.

      I ran those commands and now I'm able to connect to the focuser. However, it does not move, nor does it make any noise.

      I did notice in the application that it seems to be stuck on 1/256 step size. When I select Full step size and click on the "Get step size" button, it reverts to 1/256.

      I'm wondering if I entered something incorrectly or missed something during the configuration stage...

      The only thing I can think of is selecting the driver board type. It says MYFP2TMC2209, but the myBoradDefs.h has a numerical value of 19 after that board. Should I be entering the board number there, rather than board name?

       

      Last edit: Eric Schubert 2021-06-17
  • brownrb

    brownrb - 2021-06-17

    Every focus controller has a range of settings - this is the same for all - and the settings are standard across all focusers - the code has to know if they are enabled or not - hence yes you will have a display setting in your case it is disabled etc

    Yes the tmc2209sg has a board value of 19. This is how we distinguish between boards, each driver type has a unique board number. The number identifies the driver chip. This is an aid in setting up and managing the board drivers. The Wifi version takes this a step further and generates a whole driver board from the board setting, which is all automated at run time. I cannot do that with the Nano as there is just not the space to do anything fancy.

    You can post the focuserconfig.h file for me to check.

    If the stepsize is not being set correctly, then it could be that there is a failure in talking to the TMC chip itself.

    For the TMCxxx the driver chip holds the settings, and so the arduino talks to the tmc chip and reads / sets the various parameters. It could be that it is not communicating and if that is the case also explains why the motor is not moving

    I dont think we created a test version for the tmc2209 though.

    So wiring check
    D10 goes to a 1k resistor AND goes to MS3
    D11 goes to the other end of the 1K resistor
    VIO goes to 5V

    D3 is DIR
    D4 is STEP
    D8 is ENable

    To debug the board,
    goto file myDefines.h
    look for this
    //#define STEPMODE_Debug 1
    //#define TEMP_Debug 1
    //#define SERIAL_Debug 1
    //#define HPSW_Debug 1
    //#define BOARD_Debug 1
    and change it to this

    #define STEPMODE_Debug    1
    //#define TEMP_Debug        1
    //#define SERIAL_Debug      1
    //#define HPSW_Debug        1
    #define BOARD_Debug       1
    

    then reprogram the controller

    YYou cannot use Windows, you have to use the serial monitor to do this -
    speed 57600
    Open up the Arduino Serial Monitor
    Press the rest button on the Arduino
    You will see a number of messages as the controller boots up
    These messages will show if the arduino is talking to the tmc chip
    and can also display stepmode

    To set step mode in the serial monitor, type
    :301#
    and press Send
    You will see a number of messages related to step mode - 1 is full steps, 2 is half step etc
    :304#
    and click Send will try to set the stepmode to 1/4 steps

    To read the step mode using the serial monitor type
    :29#
    and you will see messages related to what the step mode is

    You can capture all the text in the serial monitor window and copy/paste it into a text file.

    Then go back and disable the debug in the myDefines,h so it looks like
    //#define STEPMODE_Debug 1
    //#define TEMP_Debug 1
    //#define SERIAL_Debug 1
    //#define HPSW_Debug 1
    //#define BOARD_Debug 1

    then recompile and send it to the controller - you cannot run windows if any of the debug is enabled

     

    Last edit: brownrb 2021-06-17
  • Eric Schubert

    Eric Schubert - 2021-06-17

    The messages I'm seeing on startup:
    *
    eeprom: stepmode: 256
    call Driverboard with stepmode: 256
    NOT OK
    Motor is ENABLED
    stepMode is 256
    Driverboard::set this->stepmode*

    If I try using :304# or :301# to set the step mode manually, then run :29# to check it, the step mode still says the chip is set to 256.

     

    Last edit: Eric Schubert 2021-06-17
  • Eric Schubert

    Eric Schubert - 2021-06-17

    I forgot to upload my code files, sorry about that. Here they are. I've included all of the files, just in case.

     
    • Eric Schubert

      Eric Schubert - 2021-06-17

      In addition, here's the calculation spreadsheet I used to input values.

       
  • Eric Schubert

    Eric Schubert - 2021-06-17

    I just went back and verified all the wires are soldered to the correct pins. GND for both the Arduino and TMC2209 are tied together.

    Since current is set via the firmware, the potentiometer does nothing, correct?

    I notice in some diagrams, UART is connected to TX/RX. Since that's not in the schematic, I assume UART is not being used, correct?

    Would it be related to connecting the DIAG -> D12? I could remove that to test, since it's optional.

    I'm curious how all of the testers got things working and why it's giving me trouble. I figured it would all at least run, even if speeds were off. Doesn't even make a peep, and I can turn the shaft fairly easily. So, I'm guessing it's not even applying power to the coils.

    EDIT: I tried changing a couple values and uploading again. This time clicking the "Get StepMode" button gives "Error - Format exception trying to convert value". Trying the codes :301# and :304# appear to send the information, but nothing changes.

     

    Last edit: Eric Schubert 2021-06-17
  • Eric Schubert

    Eric Schubert - 2021-06-17

    Something is clearly amiss in my wiring, I think. I don't know what's wrong, but I wired up a second Nano + TMC2209 + NEMA 14 1.8°/step motor, uploaded the same code, and that runs really nicely. It's also really, really quiet, which I love.

    I guess I'll have to go back over my wiring. Maybe I got something too hot. Maybe something's shorted. I have no idea... but the code appears to work just fine in this second Nano.

     
  • Eric Schubert

    Eric Schubert - 2021-06-19

    I tested my breadboard wiring again, this time by attaching the actual stepper motor I want to use (NEMA 14 with 0.9°/step). This also worked fine, and is even quieter than the previous test.

    I ruined the TMC2209 I soldered to the perfboard while trying to remove it. (Accidentally crushed a resistor or capacitor........ sigh.) Fortunately, I have one extra. So, I'll give soldering things up one more go here. I'm debating using different wire, as well. Maybe some flexible, stranded wire, rather than the 18ga solid copper wire I've been using. It might make connections easier as I make things more permanent.

     
  • Eric Schubert

    Eric Schubert - 2021-06-20

    It finally works! I had some soldering or wiring issue. I pulled all the wiring off and resoldered all the connections. Now it works correctly. I still need to fine tune everything, but I'm really exited.

    Last question (for now, lol) @brownrb... To enable the soft "home" included in the TMC2209 features, do I enable the "HOMEPOSITIONSWITCH" in the focuserconfig.h file? I didn't want to enable this without checking in case it was only for physical home switches and not the resistance-based homing that the driver can do.

     

    Last edit: Eric Schubert 2021-06-20
  • brownrb

    brownrb - 2021-06-21

    In firmware
    myFP2_TMC2209SG-310

    focuserconfig.h

    #define HOMEPOSITIONSWITCH 1
    

    is used to enable STALLGUARD
    but then you will need to set up the stall guard values to make it work
    when done you edit myBoardDefs.h and put your value in like

    #define STALL_VALUE         40            // [0... 255]
    
     
  • brownrb

    brownrb - 2021-06-21

    We (inc beta test group) looked at using both a "physical switch" and a "stallguard"

    Stall works and seems to work well when configured properly that there did not seem to be any need for a "physical" switch so the choice/option was not coded into the 310 firmware release.

    That may be possible in future revisions but is not a priority at the moment.

     
    • Eric Schubert

      Eric Schubert - 2021-06-21

      Thanks! I just wasn't sure if that was the correct option to enable the "StallGuard" feature or not. I'll give it a go!

       
  • Eric Schubert

    Eric Schubert - 2021-06-21

    Alright, so I thought that was my last question, but apparently not... sorry to be a pest, @brownrb.

    I enabled the HOMEPOSITIONSWITCh option. When I attempt to test it, I'm not seeing expected behavior with any values I enter for STALL_VALUE. I've tried values from 20 to 250 and it doesn't appear to stall and set the position to Home. It continues turning even after the focuser has racked as far in as it can go. (Fortunately, my Feather Touch just slips when it reaches that point, so no damage is done by continuing to turn.)

    To test the homing feature, I move the focuser out a maybe 1000 steps. Then, I manually override the focuser position to, say, 1500 steps, and click the HOME button and watch what it does. Is this the wrong way to test this feature?

    It's probably not a huge deal, as I'll move the focuser out a fair bit away from Home anyway. I can just manually rack the focuser in and set the position to 0 steps. Then rack out from there to a typical focus position. But I'm curious why it doesn't seem to work.

    EDIT: After further testing, it appears to be unreliable behavior. Sometimes stalling happens immediatey upon first move when I connect to the focuser. If this happens, it may happen even after raising or lowering the stall value in the firmware. Once it starts moving again, it may move regardless of whatever value I enter until it decides to stall again. I have had it both stall and move at the same stall values when numbers were both high (250) and low (20) and anywhere in between (40, 80, 110, etc.). But I cannot reproduce this issue consistently. Disabling the HOMEPOSITIONSWITCH feature seems to move the focuser consistently. So, I'll leave the feature disabled for now.

     

    Last edit: Eric Schubert 2021-06-21
  • brownrb

    brownrb - 2021-06-21

    Please see revised PDF with Additional Summary which outines steps that are needed

     
  • brownrb

    brownrb - 2021-06-21

    And this update for TMC2209 firmware lets you choose either USE_PHYSICAL_SWITCH if you want to use a physical switch or USE_STALL_GUARD to use stallguard instead.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.