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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
Blog TMC2300-IOT-REF - Remote controlled Stepper Motor - Getting your motor running
  • Blog
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
  • Share
  • More
  • Cancel
  • Author Author: Workshopshed
  • Date Created: 7 Feb 2021 8:31 AM Date Created
  • Views 4288 views
  • Likes 11 likes
  • Comments 35 comments
Related
Recommended

TMC2300-IOT-REF - Remote controlled Stepper Motor - Getting your motor running

Workshopshed
Workshopshed
7 Feb 2021

As mentioned in the last post TMC2300-IOT-REF - Remote controlled Stepper Motor - Getting to blink there was an issue with the connector on the motor. I found a grove connector was about the right size if I trimmed it slightly so I soldered that on.

 

Get your motor running

The next thing to try is to have the motor running. For this there are a few steps needed. Firstly to provide some power then to send the right serial commands to the controller chip and the finally to enable motor output.

 

The supply to the motor is connected to +VBAT, this in turn is connected to the charger circuit. The AN058 tech note suggests you can use a power supply to power the motor.

 

image

Serial communication is covered in section 4 of the tmc3200 data sheet and Jan Cumps also did a detailed look at the serial comms for a previous road test, Trinamic Stepper Motor Controller TMC2300 - UART Interface  Jan also references a library which looks like it could be useful https://github.com/trinamic/TMC-API

 

The key part of the serial communications is that the commands to send to the motor are wrapped in a special data structure for error checking and addressing. The address is configured via AD0 and AD1 pins, in this reference design these are both tied to ground so it would be address zero. The algorithm for the CRC is also included in the notes but the is a practical example for the code in the blynk example. https://github.com/trinamic/TMC2300-IOT-REF/blob/master/Blynk/Stepper_Mode

image

The enable pin can also be found in the schematic on pin 32 and this is confirmed by the code example.

 

I copied in the TMC_2300.ino, CRC.ino and include files from the Blynk example. I was initially puzzled why the libraries were named with the INO suffix, but that allows the Arduino IDE to compile the files with the right headers so TMC_2300.ino can find Serial1 without needing to reference the Arduino header files. You just need to ensure you open the right ino to for your project. In my case "MotorRun.ino"

image

Checking the Blynk document we can see that the speed value is between 500 and 9000, and the current is between 9 and 31. So I plugged those values straight into the code.

#include "include/Functions.h"
#include "include/TMC2300.h"
#include "include/CRC.h"


#define LED_STATUS 18
#define MOTOR_EN 32


void setup() {
  pinMode(LED_STATUS, OUTPUT);
  pinMode(MOTOR_EN, OUTPUT);


// Debug console
  Serial.begin(115200);


// TMC2300 IC UART connection
  Serial1.begin(115200);


// Initialize CRC calculation for TMC2300 UART datagrams
  tmc_fillCRC8Table(0x07, true, 0);


// Set the speed to 7000
  tmc2300_writeInt(TMC2300_VACTUAL, 7000);


// Set the current limit to 31 (default)
  uint32_t value = 1 << TMC2300_IHOLDDELAY_SHIFT | ((31 << TMC2300_IRUN_SHIFT) & TMC2300_IRUN_MASK) | 8 << TMC2300_IHOLD_SHIFT;
                 
  tmc2300_writeInt(TMC2300_IHOLD_IRUN, value);


// Enable the motor
  digitalWrite(MOTOR_EN, HIGH);   


  Serial.print("Initialisation Complete");
}


void loop() {
    // Toggle the status LED while the motor is active
    digitalWrite(18, HIGH);
    delay(250);
    digitalWrite(18, LOW);
    delay(250);
    digitalWrite(18, HIGH);
    delay(250);
    digitalWrite(18, LOW);


  // Re-write the CHOPCONF register periodically
  tmc2300_writeInt(TMC2300_CHOPCONF, 0x14008001); 
}

 

The LED is still flashing nicely but no response from the motor. Possible causes include the motor wiring, power supply, Trinamic's code, my code.

 

I cross checked the wiring and confirmed that there was one coil of the motor connected to pins 1 and 2 and the other to pins 3 and 4. However, looking at the datasheet in more detail vs the pinouts on the board, I spotted that the A coil was reversed, I'd still expect some kind of motion from the motor with that configuration but I swapped the connectors just to check. And still no motor movement.

imageimage

To check if power was an issue, I plugged in the board directly to a charger. Again, flashing lights but no motion. Looking at the schematic the diag pin is connected to a white led and would illuminate when there was a driver error or stall. This was not the case.

 

So my next thought was to use the serial interface to query the state of the chip and see if I could diagnose what was going on.

 

Serial Reading

Looking at the datasheet there were 3 registers that seemed of interest. GSTAT, GCONF and IOIN. So I updated the code to read these using the read int function and a simple display function

 

void printByte(uint8_t var) {
  for (uint8_t test = 0x80; test; test >>= 1) {
    Serial.write(var  & test ? '1' : '0');
  }
  Serial.println();
}


void loop() {
    delay(1000);
  
    result = tmc2300_readInt(TMC2300_GCONF);
    Serial.print("GCONF:");
    printByte(result);    


    result = tmc2300_readInt(TMC2300_GSTAT);
    Serial.print("GSTAT:");
    printByte(result);  


    result = tmc2300_readInt(TMC2300_IOIN);
    Serial.print("IOIN:");
    printByte(result);  
}

 

These all returned zero which made me suspect that it wasn't communicating with the TMC2300 correctly, but I double checked by adding IHOLD_IRUN and CHOPCONF which also came back as zero.

Next up I set the speed for the serial communication lower to 57600, that also made no difference.

One thing I didn't try was to see if there was an issue with the CRC. Looking at the code in TMC2300.INO there is a line that returns zero if the CRC does not tally. So that might be something to try.

 

Back to basics

Scouring the data sheet for the reference board, I spotted that the step and direction pins were connected to the ESP32. So I tried a simple sketch that pulsed the step pin and the motor did turn. However the motor got quite warm, quite quickly so I reflashed to a simple blink sketch.

So this does demonstrate that at least the motor is wired up correctly.

CAUTION: Do not simply pulse the step pin, that can overload the board.

At this point I decided to take a break as the board had got quite warm too.

 

Damaged?!

After leaving it an hour, I decided to try it again. If I power it up either from the battery or from USB the LED blinks so the ESP32 is obviously getting power. But the board is no longer detected as a serial port by the computer. The area ringed below gets very hot. One of the other roadtesters mentioned an under voltage condition which got me thinking that I may have just discharged the battery. So I checked that and the battery voltage seems a little high, am getting 3.9v on the connector on the edge of the board. The overheating happens regardless of if the battery is attachd or the USB or both. Also the the board is not recognise by the PC.

 

It is possible that this is caused by software e.g. the TMC2300 is still trying to draw a massive current on startup. Or it could be that the previous experiments damaged the battery charge/power regulation stage?

image

Backup Plan

I've devised a backup plan. It might not look so similar but the combination of an off the shelf ESP32 module and the TMC2300 from a previous test should allow me to prove out the communication between the ESP32 and TMC2300. And the results from this should be reproduceable on the IOT reference design.

image

  • Sign in to reply

Top Comments

  • Gough Lui
    Gough Lui over 4 years ago +4
    Unfortunately, I don't have one of these boards, but if there is some schematic, that would usually be quite helpful. I haven't got the time to go and dig up documentation at this moment, but some basic…
  • Workshopshed
    Workshopshed over 4 years ago +4
    Gough Lui , trinamic_lisa thanks for to help. The 3.3v line is reading 3.3v when powered from battery. I think I have a USB isolator which should allow me to measure the current draw from the port. Gough…
  • Jan Cumps
    Jan Cumps over 4 years ago in reply to Gough Lui +4
    In lieu of a thermal camera, there is always the nose and finger. You can often smell what got hot after the facts (carbon or silicon burn smell). Or put some spit on your pinky and touch each component…
  • Jan Cumps
    Jan Cumps over 4 years ago in reply to Workshopshed

    Great that you kept on biting until you found what was wrong.

    It had to be the evaluation kit. We used the same Trinamic driver IC in anger before - in another evaluation design - without damaging anything.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 4 years ago

    I managed to get things working by using the data only USB cable and battery along with some active cooling (me periodically blowing on the board). But the key issue was that the slave address needs to be configured.

     

    https://www.element14.com/community/groups/roadtest/blog/2021/03/29/tmc2300-iot-ref-

     

    Note that setting the current to 10 and running the motor did not make the overheating issue go away.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Gough Lui
    Gough Lui over 4 years ago in reply to navadeepganeshu

    Well, I couldn't see anything "wrong" per-se about the schematics themselves at a glance. That's a fairly typical way to run something that's USB/battery operated. My suspicion is that some damage may have occurred - all reviewers seem to have some complaints, but I suspect somehow maybe the TP4054 which is usually quite indestructible has somehow become damaged.

     

    Put it this way - the only thing that's different between powering by USB is the TP4054's input side. The AP2112K regulator runs regardless of battery or USB because of the diode arbiter. The TMC2300 is always pulling from battery. That being said, as it's a linear regulator, it would dissipate some heat during normal charging operation (e.g. fully discharged battery at 3V, input at 5V = 2V drop across the charging IC at the programmed charge current (guessing about 300mA) so 0.6W dissipated. Shouldn't smoke, but a bit of warmth is not unusual.

     

    But smoke ... that suggests to me something went wrong somehow. What damages ICs would often be ESD or transient voltages/spikes above their ratings. Motors and large inductances usually are a "risk" because they are liable to develop back-EMF ... but I would have expected the driver to possibly take care of that? Perhaps damage in manufacture, handing, wrong components installed, counterfeits ... I couldn't tell for sure.

     

    - Gough

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • navadeepganeshu
    navadeepganeshu over 4 years ago in reply to Gough Lui

    Lit now. My bad. Thanks for explaining Gough!

     

    The surge from motor,..... probably. But, I am wondering why USB + Vbat plugged together brings overheating at first power-up.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Gough Lui
    Gough Lui over 4 years ago in reply to navadeepganeshu

    No, that is incorrect. The VBUS supply from USB and the Battery supply are "diode OR-ed" into the 3.3V linear regulator. They do not "add" - it will merely preferentially draw from the one with the higher voltage while preventing current from flowing from VBUS directly into the battery. This is a common multi-source arbitration arrangement. The maximum that VIN will see will be 5V (assuming you have a 5V USB input).

     

    Your failures are more likely due to other causes in my opinion - perhaps there are spikes of voltage from the motor somehow making its way back here, ESD-related component damage, etc ...

     

    - Gough

    • Cancel
    • Vote Up +2 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 © 2025 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