I'm road testing Trinamic TMC2300 EVAL KIT (2-PH Stepper Motor). It's their latest design that targets battery powered devices. In this post: part 2 of a custom program to control the driver over UART. This series of posts is an attempt to use the TMC2300 in a real design. I'm using a Hercules microcontroller in stead of the Landungsbrücke to control a motor. Firmware is in C++ |
Wiring from Hercules to Eselsbrücke
When using the TMC2300 in UART mode, the MODE pin has to be pulled to GND.
I'm also pulling STEP and DIR to GND, because I'll only use Trinamic's TMCL commands to drive the motor.
Both address pins are tied to GND, setting the address to 0.
VIN/~STBY and EN are connected to a GPIO pin. We'll controle those form the Hercules microcontroller.
The RX and TX pins are wired to the Hercules SCI peripheral.
STEPPER is connected to VIO. It's used together with MODE to set the IC to UART or Step/Dir operation.
The Hercules is a 3V3 device, so I've wired VIO to 3.3 V. This takes care that the I/O of the board doesn't exceed 3.3 V.
In summary, this table shows the wiring between the microcontroller and the Eselsbrücke:
Driving the GPIO and UART Signals
I've chosen to use classes to control GPIO and UART.
For the GPIOs, I reused the port of the MBED DigitalOut class that I did earlier.
#include "platform/DigitalOut.h" DigitalOut vin(GIOA4); DigitalOut en(GIOA7); void CPPMain::main() { gioInit(); vin = 0; en = 0; // ... }
The UART communication was developed in the previous post.
#include "trinamic/HerculesTMCLDatagram.h" HerculesTMCLDatagram datagram(1U); void CPPMain::main() { // ... sciInit(); HerculesSciInit initStruct; initStruct._sci = scilinREG; datagram.init(&initStruct); // ... }
The datagram and UART based classes have gone through a big change though. I've attached the reworked Code Composer Studio to the end of this post.
I'm going to use the low level TMC2300 datagrams instead of the functional TMCL datagrams. There's already an example of TMCL datagram operation running on the Landungsbrücke.: the firmware from Trinamic on GitHub.
I've ported the CRC calculation from Trinamic's sources. The C example in the datasheet didn't return the correct value.
The example is now in a good enough state to send valid datagrams to the TMC2300 over UART. Time to first capture some evaluation kit communications that can serve as examples.
Analyse Evaluation Kit Example UART DataGram Dialogs
I've captured a series of exchanges with a protocol analyser connected to the UART.
The capture starts when turning on the TMC2300 by setting VIO and EN high.
You can ignore the Rx signals in the captures below. Because the 1-line UART used and the capabilities of my analyser, I can't show what's sent and what's received on different lines. But because we know what a datagram is supposed to look like, we can interpret what's coming from the Landungsbrücke and what from the TMC2300. |
First conversation:
Write from Landungsbrücke
This is a write of the value 0 to register 0x01
Second conversation:
Query from Landungsbrücke that seems to not receive an answer
then a Write from Landungsbrücke
This is a request to read register 0x06.
Then a write of value 0 to register 0x03
Third conversation:
This is the first one where I see an answer from the TMC2300:
First a request to read from register 0x06.
Then an answer from TMC2300, 32 bit data 0x40 0x00 0x00 0x62
Fourth conversation:
A write conversation again
Here, the 32 bit value 0x00 0x07 0x03 0x01 is written to register 0x10
Registers Used:
Now that I understand this communication, I should be able to mimic this conversation on the Hercules. That's for the next blog.
The current version of the project is attached here.
Top Comments