Giter Site home page Giter Site logo

tmcserial's Introduction

TMCSerial

Arduino-style library to communicate with Trinamic's single-wire UART based ICs.

Supported ICs include :

  • TMC7300
  • TMC2300
  • TMC516X Series
  • TMC22XX Series

This library abstracts writing/reading to/from the chip registers, without hiding functionality behind another layer.

Including in projects

This library depends on the TMCField library. The two can be easily included in a platformio project by just cloning into the /lib folder as such:

cd /lib
git clone https://github.com/A-Bielefeld/TMCField.git
git clone https://github.com/A-Bielefeld/TMCSerial.git

The better way is to add these two as submodules in a git repository of the project :

git submodule add https://github.com/A-Bielefeld/TMCField.git lib/TMCField
git submodule add https://github.com/A-Bielefeld/TMCSerial.git lib/TMCSerial
git commit -m "Added TMCSerial and its dependencies to project."
git push

Then pulling updates is as easy as running :

git submodule update --recursive --remote

Basic usage

Terminology :

Trinamic chip have a register based interface made up of 32 bits-wide registers, mapped to a 7 bits address space (For a maximum of 128 registers). A register often holds more than one functionality, and the 32 bits can be portionned into several fields. This library abstracts registers away and allows direct reading and writing of fields.

Setup :

Include the TMCSerial header, as well as the needed _Fields header for the chosen IC.

#include"TMCSerial.hpp"
#include"TMCXXXX/TMCXXXX_Fields.hpp"

One just needs to create a TMCSerial object, and call the begin() method to initialize it.

Outside setup():

TMCSerial TMCxxxx(Serial, 115200, 0);
  • Serial port : Any serial port can be used as long as the hardware is set up correctly (see hardware section).
  • Baudrate : The library was tested from 9600 bauds to 500 kbauds.
  • Address : The Chip address is defined by the AD0 and AD1 pins, and is between 0 and 3.

Inside setup()/loop():

TMCxxxx.begin();

Up to 4 chips can be placed on the same bus, in which case the TMCSerial.begin() function needs only be called once per UART bus used since it only hides a call to the Arduino Serial.begin() function.

Reading and writing to/from registers

Use the writeField and readField methods using the objects defined in the included TMCxxxx_Fields.h.

Field objects follow the naming conventions from the Trinamic datasheets.

void writeField(TMCField field, uint32_t value);
uint32_t readField(TMCField field);

Example :

/* Use the external capacitor mode for TMC7300 */
TMCxxxx.writeField(TMC7300_EXTCAP, 1);

/* Check if driver is in error state */
if (TMCxxx.readField(TMC7300_DRV_ERR) == 1)
{
    /* Do something... */
}

Hardware setup

This library is meant to be used with classical full duplex uart ports. This requires some setup to work with Trinamic single-uart system.

  • A 1K resistor needs to be placed between Rx and Tx, with the Rx pin directly connected to the single-wire line, and the Tx pin connected through the resistor.
  • The AD0 and AD1 pins need to be set to determined voltage, simplest way is to connect both to ground to use default address 00.
  • The driver Enable pin can be pulled to ground for first tests, but some registers won't allow write access if the driver is not enabled.
  • The driver won't answer at all if it doesn have VM power. For most stepper drivers, this means at least 12V on the VM pin!
  • Of course the driver needs its VCC_IO supply, 3.3V is the default, sometimes the drivers are 5V compliant.

ToDo:

Documentation:

  • Add illustrations for Hardware setup
  • Document advanced usage
  • Scope shots for advanced features (Timing)
  • Document use with RS485
  • Document multi-chip use

Tests :

  • Test on Teensy LC
  • Test on Teensy 4.0
  • Test on Arduino Uno
  • Test on Feather M0 Express
  • Test with RS485
  • Test SlaveMaster delay update
  • Test IFCNT Checks

Code :

  • Add registers for remaining supported ICs
  • Add map for TMC516X
  • Add map for TMC2300
  • Add examples for TMC7300
  • Add examples for TMC2209
  • Restructure into submodulable library
  • Publish as Arduino library?

tmcserial's People

Contributors

bread-wolf avatar joshua-8 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.