Trinamic TMCM-0960-MotionPy SBC + Stepper Motor - Review

Table of contents

RoadTest: Trinamic TMCM-0960-MotionPy SBC + Stepper Motor

Author: redcharly

Creation date:

Evaluation Type: Development Boards & Tools

Did you receive all parts the manufacturer stated would be included in the package?: True

What other parts do you consider comparable to this product?:

What were the biggest problems encountered?: This is a kit that uses the new approach with MicroPython and therefore there is few material on the net and few examples of applications already made. Trinamic is making many application notes to simplify the work of developers.

Detailed Review:

 

Introduction

Hi, my name is Carlo Russo and today I will tell you about the "Trinamic TMCM-0960-MotionPy SBC + Stepper Motor" roadtest. Last year I already carried out a roadtest on a Trinamic kit ( Trinamic TMC2300 EVAL KIT (2-PH Stepper Motor) - Review ) and I still remember the good impression it gave me. The positive experience I had with Trinamic products prompted me to participate in this roadtest.

My roadtest was posted with a delay due to problems in the board configuration. In the following I will describe what I have done with the kit in recent months, the problems I have had and the results I have obtained.

 

Unboxing

Opening a box that comes from the other side of the world and that contains things you love is always a very strong emotion. I have already praised Trinamic for the quality level of the packaging and above all of the materials used.

The board TMCM-0960 is a magnificent example of quality electronic components, optimal distribution of connections and easy accessibility to the four buttons and 4 LEDs.

The PD42-1-1270-TMCL is a real gem. When you hold it in your hand you can see its build quality and, from an aesthetic point of view, it is also beautiful to see. The control board, that is integrated into it, is well positioned at the base of the motor and the all-metal construction allows for good heat dissipation.

 

{gallery} Unboxing

image

image

image

image

image

image

 

 

The kit

The kit consists of two components:

  1. the TMCM-0960-MotionPy board;
  2. the smart stepper motor PD42-1270.

 

The TMCM-0960-MotionPy board

The TMCM-0960-MotionPy board ( TMCM-0960-MotionPy_HW_Manual_V10 (6).pdf ) is an open-source running MicroPython board that can use several communication protocols such as CAN, RS485, UART.

The power supply voltage is included in a very large range, from 6V to 50V and this makes the board easy to use in any application context even if it is a board that was created for industrial automation and robotics.

When reading the manual, you must immediately pay attention to some aspects that require special precautions:

  • Do not mix up signals or short-circuit pins
  • Do not exceed the maximum rated supply voltage
  • Start with the power supply off

It is possible to power both components, both the board and the motor, with the same power source.

The board is rich of connectors that are easy to be recognized and used because the names of the individual pins are printed on the board.

The TMCM-0960-MotionPy power supply is provided by a USB-C female connector; this board offers three separated input/output headers, directly connected to the MCU (STM32F405RGT6), four buttons, one reset and the other software-defined, and four LEDs (white, blue, red, and green), which can also be managed via software.

The manual on the first page says that to use this board you need to have the latest version of the TMCL-IDE but this is one of the things that drove me crazy for several days and that I solved only after several contacts with Trinamic assistance. At the moment (June 2021) the TMCM-0960-MotionPy board does not interface directly with Trinamic's TMCL-IDE. This is, in my opinion, a pity as the environment created by Trinamic is really simple to use and graphically very pleasant.

The board we are testing was created instead to use a different technology, not linked to any particular IDE but which makes use of the increasingly widespread MicroPython in order to be used by everyone. The MicroPython, in fact, is used in many hardware platforms (esp32, esp8266, pic16but, arm, stm32, windows, etc.) and this makes it a universal way to manage and control your IoT devices.

 

The smart stepper motor PD42-1270

PD42-1-1270-TMCL is an easy-to-use smart stepper motor. The module is controlled by a CAN bus interface and is produced using two firmware options, the TMCL and the CANopen. This board features different technologies, like stealthChop for a silent PWM mode, the spreadCycle for a smart mixed decay, stallGuard2 for load detection and coolStep for automatic current scaling.

 

 

image

 

 

As the manual (PD-1270_hardware_manual_hw1.00_rev1.11_01 (1).pdf) says: "The PANdrive™ PD42-1270 is a full mechatronic solution with state of the art feature set. It is highly integrated and offers convenient handling via CAN interface. The PD42-1270 includes a stepper motor, driver electronics, and a fully-featured hardware motion controller. It can be used in many decentralized applications and has been designed for 0.20...0.47 Nm maximum holding torque and 24V DC nominal supply voltage. With stealthChop™, the PD42-1270 offers absolutely silent and smooth motor operation for lower and medium velocities. With spreadCycle™, the PD42-1270 offers a high-performance current-controlled chopper mode for the highest velocities with perfect zero crossing performance. With stallGuard2™, a sensorless load detection feature is provided for an automatic end step detection and load monitoring. stallGuard2 is also used for the automatic current scaling feature coolStep™. The PD42-1270 comes with a CAN bus interface and four (4) digital IOs".

General features are:

  • Supply Voltage +24V nom. (+6V to +28V DC)
  • 1.0A RMS phase current (ca. 1.4A peak phase current)
  • Highest micro-step resolution, up to 256 micro-steps per full step
  • Available with enclosure and mounted to NEMA17 / 42mm flange size motor
  • Permanent onboard parameter storage
  • Advanced sixPoint™ ramp hardware motion controller
  • Home and reference switch inputs
  • Enable input to power-on/-off driver H-bridges
  • Optionally configurable analog input
  • Optionally configurable incremental encoder inputs (quadrature channels A and B only, no N channel)
  • Standard CAN Bus Interface for control and configuration
  • CAN bit rate from 20 to 1000kBit/s
  • TMCL-based protocol with TMCL firmware option
  • CANopen protocol with DS402 device profile with CANopen firmware option

There are also Trinamic's unique features:

  • stealthChop™: an extremely quiet mode of operation used in low and medium velocities. During standstill and low velocities, the motor is absolutely noiseless and free of vibrations so it's perfect for home or office applications.
  • spreadCycle™: The spreadCycle chopper is a high-precision, hysteresis-based, and simple to use chopper mode, which automatically determines the optimum length for the fast-decay phase.
  • stallGuard2™: stallGuard2 is a high-precision sensorless load measurement using the back EMF of the motor coils. It can be used for stall detection as well as other uses at loads below those which stall the motor. The stallGuard2 measurement value changes linearly over a wide range of load, velocity, and current settings. At maximum motor load, the value reaches zero or is near zero. This is the most energy-efficient point of operation for the motor.
  • coolStep™: coolStep is a load-adaptive automatic current scaling based on the load measurement via stallGuard2. coolStep adapts the required current to the load. Energy consumption can be reduced by as much as 75%. coolStep allows substantial energy savings, especially for motors that see varying loads or operate at a high duty cycle. Because a stepper motor application needs to work with a torque reserve of 30% to 50%, even a constant-load application allows significant energy savings because coolStep automatically enables torque reserve when required. Reducing power consumption keeps the system cooler, increases motor life, and allows for cost reduction.
  • sixPoint Motion Controller: is a new type of ramp generator, which offers faster machine operation compared to the classical linear acceleration ramps. The sixPoint ramp generator allows adapting the acceleration ramps to the torque curves of a stepper motor and uses two different acceleration settings each for the acceleration phase and for the deceleration phase

 

Dimension: 42 x 42 x 45.5

Weight: 260g

 

 

     imageimage

 

 

 

 

Connectors

The PD42-1270 offers two connectors - one 10-pin connector for power supply, communication (CAN) and four Inputs, and one four-pin connector for connecting the motor.

 

          imageimage

 

image

 

Trinamic, in the motor manual, recommends a few things:

  • do not use a supply voltage greater than 28V;
  • add a 470 microFarad electrolytic capacitor to the power lines and near the motor;
  • connect pin 10 (ENN) to GND to enable the motor driver in hardware mode. To be able to move the motor using the appropriate software commands, it is necessary to connect ENN to GND;
  • do not connect or disconnect the motor during operation! Motor cable and motor inductivity might lead to voltage spikes when the motor is connected/disconnected while energized. These voltage spikes might exceed the voltage limits of the driver MOSFETs and might permanently damage them. Therefore, always switch off or disconnect the power supply before connecting or disconnecting the motor.

 

LEDs

The PD42-1270 includes two LEDs: one green status LED and one red error LED.

 

       

     image

 

 

 

Typical Application Wiring

The PD42-1270 driver/controller’s wiring is straightforward as shown in the following figure.

  • Power supply must be connected to V+ and GND.
  • CAN - use appropriate CAN interface adapter
  • ENN - connect ENN signal to GND in order to enable driver stage

 

 

image

 

As for the software part, the TMCM-0960-MotionPy board requires the installation of Micropython and PyTrinamic, a python library that allows communication with TRINAMIC modules and evaluation boards. It allows you to automate all operations that were previously only available using the TMCL-IDE manually.

Configuring the software is a rather complex operation and is described in the guide (https://www.trinamic.com/fileadmin/assets/Products/Modules_Documents/AN061-TMCM-0960-MotionPy.pdf published on 2021 May 07).

 

Software installation

This is a brief guide on how to get started using the MotionPy with a TMCL-Module. First, check out the required hardware:

  • TMCM-0960-MotionPy Board
  • USB-C cable
  • TMCL-1270 Module
  • Cables for power and bus signals

 

First, you have to build the PYBv11 STM32 firmware. The description of the operation is done in the MicroPython repository.

Before building the firmware for a given board the MicroPython cross-compiler must be built; it will be used to pre-compile some of the built-in scripts to bytecode. The cross-compiler is built and run on the host machine, using:

$ make -C mpy-cross

This command should be executed from the root directory of this repository. All other commands below should be executed from the ports/stm32/ directory.

In the kit I'm analyzing, this has already been done, so the kit is ready to use after simply installing the SD card.

 

 

First use (problems, problems...)

After reading the roadtest forum and understanding that the board was already configured with MicroPython by TRINAMIC, it became easier to play with the board.

 

First you need to install the software that can be found on GitHub ( https://github.com/trinamic/PyTrinamicMicro ) on the SD card. The operation is very simple and generally should not give any problems but, in my case, I had many problems that made it impossible to use the kit for many days.

In the Getting Started you can read:

  1. Invoke the installation script install.py. For full installation, run the command python install.py D:\, assuming python is properly linked to your python binary and D:\ is the installation directory for the target platform. As installing incrementally is not supported atm, invoke python install.py D:\ -c if you have already an installation in that target directory.
  2. Move the main.py and boot.py scripts for the desired platform manually out of PyTrinamicMicro/platforms/x to the platforms root.
  3. Soft-Reset MicroPython by restarting it, or, if it is a microcontroller, hard-reset the microcontroller with a low signal on the NRST pin, or power cycle.
  4. If the target system is a microcontroller, connect to the corresponding serial port via terminal. This might be COMX for Windows (determine X in the Device Manager), or /dev/ttyACMX (determine X in the mounted devices in /dev) for Linux.
  5. Now, being in the Python shell, any MicroPython compatible statement can be interpreted. The PyTrinamicMicro package can be used. Examples can be executed by e.g. exec(MP.script("blinky")).

 

In practice, the install.py file was executed but was unable to create the complete structure on the SD. Even some folders on the SD card had to be created manually and there were also problems with some libraries, for example the "logging" library.

 

          imageimage

 

First I connected the motor to a power supply of 18V and I powered the board with a USB C cable.

I then used Putty, in portable version, to connect to the board. To find out the COM port to which the board is connected, just, on Windows 10, open "device manager" and look for which serial port is active in our PC. In my case the active port is COM3 so I connected using Putty to the COM3 serial port.

I repeated the installation procedure many times but always getting errors and I asked the Trinamic technicians for help who were very kind and very helpful in helping me to solve some of the problems encountered. Unfortunately my kit still didn't work.

When I read the roadtest created by . and I saw that he had not had any problems I asked for his help to be sure that the problems I encountered were not due to hardware problems and he helped me!.

So the board worked!   At this point, I believe that the errors I encountered depend only on some Python problems in my PC and I intend to solve the problem as soon as possible.

Now I can finally start seeing my kit at work.

 

Warning: you may have errors in executing simple scripts taken from the "Getting started" file as in some examples there is a path containing the "motionpy" folder instead of "motionpy1" or "motionpy2", for example you have to correct:       "exec(open("PyTrinamicMicro/platforms/motionpy/examples/io/blinky.py").read())"     in:                                    "exec(open("PyTrinamicMicro/platforms/motionpy1/examples/io/blinky.py").read())".

 

 

The first step was to see the board do something, after weeks of unsuccessful attempts. For this reason I loaded the blinky.py script. Running the script was really very simple. The only drawback is that, in the board manual, the path is wrong (it is MotionPy1 instead of MotionPy), as I said before.

               "PyTrinamicMicro/platforms/motionpy1/examples/io/blinky.py"

After making a small change to main.py, the script will be loaded when the board boots.

 

'''
MicroPython main file.
Place as main.py at the root of the Flash memory.


Created on 12.10.2020


@author: LK
'''


# Imports
from PyTrinamicMicro.platforms.motionpy1.MotionPy import MotionPy as MP


# Initialize main configuration
MP.init()


#blinky code
exec(MP.script("blinky"))

 

Finally I saw my board do something!

In the video you can see the script running.

 

 

 

 

The next step is to study other aspects of the board.

A nice application is to configure the board to act as a bridge and control the motor using Trinamic's TMCL-IDE software. I have already used this software in an old roadtest so I decided to see other aspects of the board.   described this configuration in its roadtest and I invite you to admire the power and ease of use of this software in his roadtest.

 

 

Something about pyb

The TMC1270 board can be managed using the "pyb" class.

 

image

 

Let's see some of the most interesting methods:

  • delay(n) to introduce a delay of "n" milliseconds.
  • millis() returns the number of milliseconds passed since the last hard reset of the board.
  • RTC() allows you to create a useful log of board events. This command can be used both to know information about the time (year, month, day, day of the week, hour, minute, second, millisecond), and to set the settings. The setting can be accomplished by loading the data  manually or using an external RTC card to import time data. In the picture below you can see how to manually configure the date and time on the board.
  • LED(n): Can be used with 3 obvious methods: on(), off() and toggle(). There is also an intensity() method with which I hoped to solve the problem, mentioned by , of the excessive brightness of some LEDs on the board compared to others. Unfortunately it does not seem implemented and turns on the LED when it is set to "0", turns it off when it is different from "0".

 

 

 

... and finally it started spinning ...

The first example I want to show is a simple code. It is one of the many codes released by Trinamic on GitHub.

In particular I will use the code "E:\PyTrinamicMicro\platforms\motionpy1\examples\modules\TMCM1270\TMCM1270_rotate.py"

it is a very simple program that can be a great starting point for working with this kit.

 

'''
Rotate the motor with TMCM1270 using CAN interface.


Created on 05.10.2020


@author: LK
'''


from PyTrinamic.modules.TMCM1270.TMCM_1270 import TMCM_1270
from PyTrinamicMicro.platforms.motionpy1.connections.can_tmcl_interface import can_tmcl_interface
from pyb import Pin
import time


con = can_tmcl_interface()
module = TMCM_1270(con)
en = Pin(Pin.cpu.A4, Pin.OUT_PP)


en.low()


module.rotate(0, 1000)
time.sleep(5)
module.stop(0)


en.high()


con.close()

 

 

As you can see, the code is extremely simple and, after importing the necessary libraries, it initializes the motor, makes it rotate with speed "1000" and, after 5 seconds, stops it.

The execution of the code is very simple, just run the file seen by modifying the boot file "boot.py".

 

 

# boot.py -- run on boot-up
# can run arbitrary Python, but best to keep it minimal


import machine
import pyb
pyb.country('US') # ISO 3166-1 Alpha-2 code, eg US, GB, DE, AU
pyb.main('PyTrinamicMicro\platforms\motionpy1\examples\modules\TMCM1270\TMCM1270_rotate.py') # main script to run after this one


#pyb.main('main.py') # main script to run after this one
#pyb.usb_mode('VCP+MSC') # act as a serial and a storage device
#pyb.usb_mode('VCP+HID') # act as a serial device and a mouse

 

Thanks to the same script we can test the board by commanding it with the serial port thanks to Putty.

Just delete the lines beyond 24 and, once the connection has been initialized, just enter the commands from the serial to control the stepper motor.

 

 

 

 

Using Python and some graphics (really a little bit!)

 

We have seen that our kit is easily manageable using MicroPython directly through the serial connection of the board.

The last application that I would like to cover in this roadtest is the stepper motor command using a few lines of code in python to create a very simple graphical interface to be able to control the motor easily.

 

image

 

The code is very simple and the graphics are minimal. My goal was just to demonstrate how the electric motor can be controlled using a graphics program.

Obviously it is only a draft and could be enriched with absolute position information or it could implement the "moveTo" and "moveBy" commands.

Other commands that would be nice to try are "analogInput" and "digitalInput".

We can say that thanks to MicroPython, we can control the stepper motor with ease.

 

 

 

Future developments

I would like to show this work to my students in order to see a stepper motor in action and understand how to control it using MicroPython.

An interesting thing to study thanks to this kit would also be the CAN protocol.

You can find all the contents in this roadtest in the following video.

 

 

Thanks to  navadeepganeshu. for his help.  

Thanks to Trinamic and Element14 community.

Anonymous