Coder Social home page Coder Social logo

tmc-api's People

Contributors

chrisidema avatar huskier avatar jonahammer avatar lionheart1810 avatar riggs avatar trinamic-asu avatar trinamic-dh avatar trinamic-ed avatar trinamic-jh avatar trinamic-jm avatar trinamic-lh avatar trinamic-sw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmc-api's Issues

u16 typedef multiple declaration

I am not sure if the problem is in Arduino core library or TMC_api, but in order to compile, I had to comment out line 34 in helpers/Types.h:

typedef uint8_t  u8;
// typedef uint16_t u16;
typedef uint32_t u32;

Error message otherwise:

In file included from .pio\libdeps\nanoatmega328\TMC-API/tmc\helpers\Config.h:12:0,
from .pio\libdeps\nanoatmega328\TMC-API/tmc\helpers\API_Header.h:11,
from src\SPI_TMC.h:11,
from src\main.cpp:5:
.pio\libdeps\nanoatmega328\TMC-API/tmc\helpers\Types.h:34:18: error: conflicting declaration 'typedef uint16_t u16'
typedef uint16_t u16;
^
In file included from C:\Users\jareckir.platformio\packages\framework-arduinoavr\cores\arduino/Arduino.h:233:0,
from src\main.cpp:1:
C:\Users\jareckir.platformio\packages\framework-arduinoavr\cores\arduino/USBAPI.h:30:24: note: previous declaration as 'typedef short unsigned int u16'
typedef unsigned short u16;
^

Also, I needed to remove other ICs except one that I am using (TMC5160) because there were too many errors within them.

TMC429 & TMC2660 XActual Response

When reading back xactual for a motor while its moving to a target position there are large negative numbers that do not make any sense and then finally it will reach its position and return the correct value.
What is wrong here?

Some RegisterField definitions are wrong in TMC5272_HW_Abstraction.h, contains itself, must use SHIFT

https://github.com/analogdevicesinc/TMC-API/blob/f276b3e94894494009a1c44e3eb21512ad0ab320/tmc/ic/TMC5272/TMC5272_HW_Abstraction.h#L109C118-L109C152
https://github.com/analogdevicesinc/TMC-API/blob/f276b3e94894494009a1c44e3eb21512ad0ab320/tmc/ic/TMC5272/TMC5272_HW_Abstraction.h#L439C1-L439C54

Must use FIELD definition, not its own name

// wrongly uses its own definition
#define TMC5272_GCONF_M0_DIAG0_ERROR_FIELD                    ((RegisterField) { TMC5272_GCONF_M0_DIAG0_ERROR_MASK,  TMC5272_GCONF_M0_DIAG0_ERROR_FIELD,  TMC5272_GCONF, false })
// instead use SHIFT
#define TMC5272_GCONF_M0_DIAG0_ERROR_FIELD                    ((RegisterField) { TMC5272_GCONF_M0_DIAG0_ERROR_MASK,  TMC5272_GCONF_M0_DIAG0_ERROR_SHIFT,  TMC5272_GCONF, false })

Same for TMC5272_RAMP_STAT_STATUS_LATCH_L_FIELD

TMC6100 api is using int type assuming it's 32 bit

int should be changed to int32_t explicitly
`
int tmc6100_readInt(uint8_t motor, uint8_t address) -> int32_t tmc6100_readInt(uint8_t motor, uint8_t address)

void tmc6100_writeInt(uint8_t motor, uint8_t address, int value) -> void tmc6100_writeInt(uint8_t motor, uint8_t address, int32_t value)
`

Assumed datatype in CAST_Sn_TO_S32 in Macros.h

Hi there,
using Arduino, and the datatype the compiler assumes is too short (int?) for the operation if the shift is bigger than 16.

Seems to work as intended as
"#define CAST_Sn_TO_S32(value, n) ((value) | (((value) & (1L<<((n)-1)))? ~((0x1L<<(n))-1) : 0 ))"
but i'm far from a good C programmer.

Some definitions are missing in TMC5272_HW_Abstraction.h compared to the data sheet

I did not do a full review, but I stumbled over missing definitions in the header file compared to the data sheet. The header file should contain for all registers all field definitions as defined in the data sheet.

E.g.

#define TMC5272_ENCMODE_NBEMF_ABN_SEL_FIELD(motor) ((RegisterField) { TMC5272_ENCMODE_NBEMF_ABN_SEL_MASK, TMC5272_ENCMODE_NBEMF_ABN_SEL_SHIFT, TMC5272_ENCMODE(motor), false })
#define TMC5272_ENCMODE_BEMF_HYST_MASK 0x00007000
#define TMC5272_ENCMODE_BEMF_HYST_SHIFT 12
#define TMC5272_ENCMODE_BEMF_HYST_FIELD(motor) ((RegisterField) { TMC5272_ENCMODE_BEMF_HYST_MASK, TMC5272_ENCMODE_BEMF_HYST_SHIFT, TMC5272_ENCMODE(motor), false })
#define TMC5272_ENCMODE_BEMF_BLANK_TIME_MASK 0x00FF0000
#define TMC5272_ENCMODE_BEMF_BLANK_TIME_SHIFT 16
#define TMC5272_ENCMODE_BEMF_BLANK_TIME_FIELD(motor) ((RegisterField) { TMC5272_ENCMODE_BEMF_BLANK_TIME_MASK, TMC5272_ENCMODE_BEMF_BLANK_TIME_SHIFT, TMC5272_ENCMODE(motor), false })

lacks the definition for the fields:

  • qsc_enc_en
  • BEMF_FILTER_SEL

In addition - at least for the TMC5272 - the header file does not define field values as defined in the "Decode" column in the data sheet. This would be very helpful to have all of them in the header file as there are really a lot of them. E.g.:

#define TMC5272_ENCMODE_POL_B_NEGATIVE (0)
#define TMC5272_ENCMODE_POL_B_POSITIVE (1)

TMC5160 and Raspeberry PI

Hi! I'm trying to follow this blog post, but applied to the TMC5160 BOB. I cloned the latest version of the API, and made a few adjustments in the code, but I'm having problems with the init function.

The signature presented in the blog post, void TMC5130_init(unsigned char motor) is different from the API void tmc5130_init(TMC5130TypeDef *tmc5130, uint8_t channel, ConfigurationTypeDef *config, const int32_t *registerResetState)

I've limited knowledge on C, and in electronics. I searched around the web for examples of this new signature, and how to use/call that, but unfortunately did not find.

Follow my current project.c file:

#include "SPI.h"
#include "tmc/ic/TMC5160/TMC5160.h"
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

static void myStateDemoMachine(int steps, int velocity);

int main(int argc, char **argv)
{
	// start  SPI
		printf("Initialize SPI..\n");	
		SPI_init();
		printf("..done\n");	
	
	remove("demo.s"); // exit demo mode	

	int value;
	switch(argv[1][0]) // process arguments, first argument is the command, others are values
	{
		case 'i': // initialize
			printf("Initialize driver..\n");	
			tmc5160_init(0);			
		break;
			
		case 'r': // rotate
			printf("Rotate with %ipps..\n", atoi(argv[2]));	
			tmc5160_rotate(0, atoi(argv[2]));
		break;
		
		case '0': //stop
			printf("Stop motor..\n");	
			tmc5160_rotate(0, 0);
		break;
		
		case 't': // move to position
			printf("Move to absolute absolute %d with velocity %ipps..\n", atoi(argv[2]), atoi(argv[3]));	
			tmc5160_left(0,0);										// stop motor
			tmc5160_writeInt(0,TMC5160_VMAX, abs(atoi(argv[3])));	// set velocity
			// tmc5160_moveTo(TMC5160TypeDef *tmc5160, int32_t position, uint32_t velocityMax)
			tmc5160_moveTo(0, 0,  atoi(argv[2]));						// set target
		break;
		
		case 'b': // move by number of steps
			printf("Move to by %d steps with velocity %ipps..\n", atoi(argv[2]), atoi(argv[3]));	
			tmc5160_left(0,0);										// stop motor
			tmc5160_writeInt(0,TMC5160_VMAX, abs(atoi(argv[3])));	// set velocity
			tmc5160_moveBy(0, 0,  atoi(argv[2]));						// set target
		break;
		
		case 'g': // get register value
			value = tmc5160_readInt(0,atoi(argv[2]));			//read from address
			printf("Read from address 0x%2x =%i[int] = %08x[hex] = %f[double])\n", atoi(argv[2]), (int) value, (int) value, (double) value);
		break;
		
		case 's': // set register value
			tmc5160_writeInt(0,atoi(argv[2]), atoi(argv[3]));			//write to address
			printf("Write to address 0x%2x<=%i[int] = %08x[hex] = %f[double])\n", atoi(argv[2]), (int)  atoi(argv[3]), (int)  atoi(argv[3]), (double)  atoi(argv[3]));
		break;
		
		case 'd': // start demo
			printf("Demo: Move back and forth by %d steps with velocity %ipps..\n", atoi(argv[2]), atoi(argv[3]));

			close(open("demo.s", O_RDWR | O_CREAT, 0777)); // generate semaphore-file
			
			while(access("demo.s", F_OK ) != -1) // as long as demo semaphore-file exists
			{
				myStateDemoMachine(atoi(argv[2]),abs(atoi(argv[3]))); // call demo code
				usleep(500); 
			}			
		break;
		
		default:
			printf("Unknown command\n");	
		break;
	}
	
	// end SPI
		printf("De-initialize SPI..\n");
		SPI_deinit();
		printf("..done\n");	
}

enum { DEMO_STATE_INIT, DEMO_STATE_MOVE_RIGHT, DEMO_STATE_WAIT_RIGHT, DEMO_STATE_MOVE_LEFT, DEMO_STATE_WAIT_LEFT};

static void myStateDemoMachine(int steps, int velocity)
{ // simple state for moving back and forth
	
	static int state		= DEMO_STATE_INIT;
	static int nextState	= DEMO_STATE_INIT; 

	
	switch(state)
	{
		case DEMO_STATE_INIT:
			tmc5160_moveBy(0, 0, 0);
			tmc5160_writeInt(0,TMC5160_VMAX, velocity);
			nextState = DEMO_STATE_MOVE_RIGHT;			
		break;
		
		case DEMO_STATE_MOVE_RIGHT:
			printf("Move right by %d steps with velocity %ipps..\n", steps, velocity);
			tmc5160_moveBy(0, 0,steps);
			nextState = DEMO_STATE_WAIT_RIGHT;
		break;	
		
		case DEMO_STATE_WAIT_RIGHT:
			usleep(20000);
			if(tmc5160_readInt(0,TMC5160_RAMPSTAT) & (1<<9)) // if bit 9 in RAMPSTAT is set (position_reached)
			{
				nextState = DEMO_STATE_MOVE_LEFT;
			}
		break;		
		
		case DEMO_STATE_MOVE_LEFT:			
			printf("Move left by %d steps with velocity %ipps..\n", -steps, velocity);
			tmc5160_moveBy(0, 0,-steps);
			nextState = DEMO_STATE_WAIT_LEFT;
		break;

		case DEMO_STATE_WAIT_LEFT:
			usleep(20000);
			if(tmc5160_readInt(0,TMC5160_RAMPSTAT) & (1<<9)) // if bit 9 in RAMPSTAT is set (position_reached)
			{
				nextState = DEMO_STATE_MOVE_RIGHT; 
			}
		break;		
	}	
	state = nextState;	
}

Thank you!

How to perform full steps or half steps with the TMC5130-EVAL board ?

Hello,

I am struggling to configure the standard TMC5130-EVAL board to run a stepper motor with full steps or half-steps, but so far I could not do that.
Is it somehow "nailed" that the standard EVAL board (together with the standard Landungsbrücke) works with 256 microstepping only?
Do I need to modify something on the board, in order to be able to configure the MRES register to a smaller microstepping number?
Some help/code example would be highly appreciated!
I cannot create an account on the trinamic official blog (the Registration option does not seem available, unfortunately).

Best regards,
Paul

Inconsistent variable initialization

Here is a 32bit signed integer field:

typedef struct
{
	uint8_t address;
	int32_t value;
} TMCRegisterConstant;

Which gets several values assigned that do not fit into this data type:

{ 0x60, 0xAAAAB554 }, // MSLUT[0]
...
{ 0x64, 0xFBFFFFFF }, // MSLUT[4]
{ 0x65, 0xB5BB777D }, // MSLUT[5]
...

The compiler rightfully complains about this:

TMC2130.h:92:1: error: narrowing conversion of '2863314260' from 'unsigned int' to 'int32_t' {aka 'long int'} [-Wnarrowing]
   92 | };

Could the field be changed to unsigned, or a cast added to the initializer value to avoid this?

typo in TMC5160_Constants.h

#define TMC5160_SW STOPL_POLARITY 0x0004

In TMC5160_Constants.h line 29, there is a space between SW and STOPL instead of an underscore.

Documentation says user needs to implement wrong function for TMC4671

The documentation in README.md states:

To use the TMC-API, perform the following steps in your code:

  • Implement the tmcXXXX_readWriteArray() function in in your code. This function provides the necessary hardware access to the TMC-API.

But in the TMC4671 IC driver this function does not exist. Instead, it seems that the code wants you to implement tmc4671_readWriteByte()

// => SPI wrapper
extern uint8_t tmc4671_readwriteByte(uint8_t motor, uint8_t data, uint8_t lastTransfer);
// <= SPI wrapper

Additionally, looking at other ICs, each function has a differently named wrapper implementation. This should be made uniform, or at least documented to the user so they know where to look (e.g. "Every IC has a function prototype marked as extern that the user needs to implement in order for the driver to communicate with the chip...` or something like that).

tmc-603

Is there an c api for tmc-603 ? I am using tmcm-1640 and i was searching for a c library.

Why isn't ConfigurationTypeDef just embedded in TMC2130TypeDef?

Just a general API question I was wondering about: Why doesn't the device struct just embed the generic config struct instead of the currently used pointer to it?

Users need to declare both independently and they get connected internally by calling init(). Both structures are mandatory, must be writable, are always a 1:1 relation, and cannot be shared independently; therefore conceptually they appear to be the same entity.

From a user perspective, it would be simpler to just deal with one device structure.

Ramping down in velocity mode using TMC5160

Hi all,

I am using TMC5160 in my project. I am using velocity mode and I have acceleration and deacceleration profiles.

In Velocity mode it accelerates using the acceleration profile. However, when I send VMAX=0 to stop, it does not stop according to the deacceleration profile. Deacceleration profile is respected only in Position mode. How can I correctly use it in the Velocity mode?

How I start movement in Velocity mode for ex:
VMAX = 5000

How I stop:
VMAX = 0

Thank you in advance
Samir

Make the SPI *_readInt and *_writeInt weak symbols

I am using the TMC4671, but I suppose that my issue is valid for most other target chips.

The current version of the API requires the user to implement tmc*_readwriteByte. It implements its own tmc*_readInt and tmc*_writeInt, which in turn calls to that user-defined function.

This implies that the firmware is involved and makes calls between each byte of the datagram.

MCUs often offer the possibility to send multiple bytes at once (one API call, maybe even one peripheral trigger), allowing to send a whole datagram with much fewer operations.

To do that, I would like to be able to override the _readInt and _writeInt functions with my own functions, written appropriately for the MCU I am using.

I understand that it is a good idea to let the current functions be there, for simplicity. However, making them weak would also let the user write their own, more efficient, version.

I have just tested that in my personal clone of TMC-API, with great success:

__attribute__((weak)) int32_t tmc4671_readInt(uint8_t motor, uint8_t address)
{
    // ...
}

Please consider making these functions weak, so that users can use your library without modifications.

Note: attributes to make weak symbols are not part of the C standard, so this might require some kind of pre-processor-fu. But I don't think that this is very difficult.

TMC-API structural migration #1

The TMC-API is getting a rework of its core structure. This is to make the direct accessing of chip registers as easy as possible.

For detailed descriptions of how to use the updated TMC-API, see here: README

Migration step 1: Add new register access method

Migration progress:

  • TMC5272
  • TMC5271
  • TMC2209 (WIP)
  • TMC5240 (WIP)
  • TMC5160 (WIP)
  • TMC5130 (WIP)

Migration step 2: Move caching, reset and restore logic to TMC-EvalSystem

  • TMC5272 (WIP)

If you'd like us to prioritize a specific chip feel free to comment in this issue

Build Python Library for Ubuntu?

Hello,

I'm using TCM drivers to control Stepper motors on my project. I'm using Ubuntu 20.04 on Jetson Nano dev board. I'd like to build a Python library or package so that I can utilize the TMC-API in my environment. Could you please advise the procedure? And if there is a ready Python lib for use or a work in the plan? I searched quite a while and couldn't find one.

Thanks,
Terry

Which document should I use under the ramp folder

There are 6 files in the X:\TMC\TMC-API-master\tmc\ramp folder, including two sets of files, one set of author is created by ed on 07, 23, 2018, and the other set of author is created by LK on 09 11, 2018. I think the newer the date, the more complete the function will be, but I only see the comment but not the content in LK's document.
(// We're still too fast, we're going to miss the target position
// Let the deceleration continue until velocity is zero, then either
// home when within homing distance or start a new ramp (RAMP_DRIVING)
// towards the target.)
Which author's linear ramp generator file do I need to use? Please help me to use the ramp generator in my project

Redefinition of ARRAY_SIZE macro

Hello everyone,

while working on integrating the TMC2300 into one of our projects, we got a redefinition warning of the above mentioned macro, because our microcontroller sdk implements this too. After a quick glimpse into your code, it turns out there is a missing #ifndev...#endif around ARRAY_SIZE.

Velocity typecasting.

https://github.com/trinamic/TMC-API/blob/8e53c85679a7ed8b047c77e97282e7f9d8e62fcd/tmc/ic/TMC5130/TMC5130.c#L226C33-L226C33
https://github.com/trinamic/TMC-API/blob/8e53c85679a7ed8b047c77e97282e7f9d8e62fcd/tmc/ic/TMC5130/TMC5130.h#L28

I think there should be (int32_t) instead of (uint32_t) like:
tmc5130->velocity = (int32_t) ((float32_t) ((XActual - tmc5130->oldX) / (float32_t) tickDiff) * (float32_t) 1048.576);
Because tmc5130->velocity is int32_t and it gave me 0 for negative velocity when testing.

TMC429 & TMC2660

Could you provide an example of setting XTarget & VTarget for the TMC2660 from the TMC429 please?

(setup)
I have two TMC429 each connected to 3 TMC2660.
TMC429 have called init429.
TMC2660 have called initConfig and reset.

Tried Write429U16(TMC429_IDX_VTARGET(some motor), some value) but I can not get any output.

Further details if required:
Machine: Raspberry Pi 4
Using MCP23008 to expand io allowing connection to the 8 devices (two 429 and 6 2660)
Using SPI to talk to TMC429. Want to run the 6 drivers in step & direction mode.
Actual boards: TMC429-LA-BOB v 1.1, TMC2660-BOB v 1.2

Access to 'device' in platform SPI function?

The platform glue currently looks like this:

extern void tmc2130_readWriteArray(uint8_t channel, uint8_t *data, size_t length);

Could it be changed to carry the device object instead of just the uint8_t? I want to support multiple SPI buses, and it's a bit awkward to need to maintain an entirely separate mapping of objects to channel numbers, just because the object is lost a single call earlier in the chain to this function.
The channel number is easily reachable from the object, so everything would work the same way; just without losing this information.

I copied the API files without any modifications to this driver: https://github.com/versioduo/V2Stepper/blob/master/src/V2Stepper.cpp#L3

Apart from this issue, I'm happy, and everything seems to work as expected. Thanks!

Autogenerated files in the repository

Some files have a comment like "Autogenerated C header for registers in TMC2160". Where can I find the generator that was used to generate these files, and what they were generated from?

Here is the list of files with such comment:

  • MAX22216_Fields.h
  • MAX22216_Register.h
  • TMC2160_Fields.h
  • TMC2160_Register.h
  • TMC5271_Fields.h
  • TMC5271_Register.h
  • TMC5272_Fields.h
  • TMC5272_Register.h
  • TMC7300_Fields.h

Proposal: Create read the docs Documentation

Hi,
I would like to propose to create an official documentation using Readthedocs.
This would certainly help others working with your API and bring more contributions to this platform.

Why readthedocs (rtd) ? It is widely used for documenting projects and is highly customizable and works with multiple languages.

I created a basic example how the TMC-API documentation could look like, using rtd, sphinx doxygen for generating the documentation.
This workflow allows automated generation of documentation based on the doxygen comments in the code itself and therefore version controlled docs. Additionally, sphinx is used to write more descriptive with reStructuredText than plain doxygen comments, and can create a more user-friendly documentation.

The documentation I made is mostly autogenerated with a few doxygen styled comments for a few functions for testing, but this is nearly fully autogenerated and can be generated by clicking one button or automated via GitHub actions.

I hope this idea is of interest to you and helps develop this amazing hardware platform!

Best,
Fabian

Incomplete TMC2240 and TMC5240?

Hello!

I'm currently working on a project where I want to utilize TMC5240. I currently only have my hands on some TMC2240 and it looks like the API is incomplete for this IC or am I missing something? I'm planning to use SPI.

TMC5160 FACTORY_CONF register set to 0 during initization

Hi,

After calling

  • tmc5160_init(..., tmc5160_defaultRegisterResetState) and
  • tmc5160_reset(), I realized when
  • tmc5160_periodicJob() runs next,
  • FACTORY_CONF register is set to 0, effectively slowing down the internal oscillator of my TMC5160-BOB.

I can workaround this by reading the nominal value from OTP_READ register and putting it manually into the array with reset values, but actually expected the TMC code to not mess with the FACTORY_CONF "by default". Or maybe I'm not expected to call tmc5160_reset() at that stage?

Thanks for comments
Kolja

Cases where int is assumed to be 32 bits and two's complement

I've come across a few cases where you've written code that assumes int is 32 bits and/or two's complement, I think it would be reasonable to use int32_t in most of these cases as it's already used in other parts of the library. Here's a few examples I've come across but this obviously doesn't cover everything:

https://github.com/trinamic/TMC-API/blob/fd6a5378b2157bf115b8126c9183364b899fa27f/tmc/ic/TMC2160/TMC2160.c#L20

https://github.com/trinamic/TMC-API/blob/fd6a5378b2157bf115b8126c9183364b899fa27f/tmc/helpers/Macros.h#L33 (Here the shifts can overflow if the values are not cast to uint32_t first, additionally int32_t is passed to these macros where uint32_t should be used as >> and << are undefined behaviour on negative values and on some platforms perform sign extension of negative values which leads to the wrong result being returned)

https://github.com/trinamic/TMC-API/blob/fd6a5378b2157bf115b8126c9183364b899fa27f/tmc/ramp/LinearRamp.c (Here int is being used to store int32_t values, I haven't looked at this enough to know if it's an issue or not, additionally abs is being used on int32_t values)

Ramping examples?

Hi there!

Is there examples of how to use the ramping implementation?
I have been through a few different approaches, but can't seem to make it work correctly.

Bit shifting causing intermittent bit corruption

https://github.com/trinamic/TMC-API/blob/3da0cec86d2f14c3f1b6f29950df6fe2cc41624b/tmc/ic/TMC5160/TMC5160.c#L53

Sometimes when reading a spi value the upper 16 bits are all 1's. I noticed this line of code and changed it like so and the problem was resolved.

Shifting bits with types smaller than the shift can cause undefined behavour. At least on our processor, the msp430 it needs this fix.

	uint32_t v[5] = {0};
	for (uint32_t i = 0; i < 5; i++) {
		v[i] = data[i];
	}

	uint32_t value = (v[1] << 24) | (v[2] << 16) | (v[3] << 8) | (v[4]);
	return value;
	```

Encoder Initialization by Hall sensors

Hello @trinamic,

I was examining the tmc4671_doEncoderInitializationMode2 function and I came across the following line of code:

int16_t hall_phi_e_estimated = *hall_phi_e_old + tmc4671_getS16CircleDifference(*hall_phi_e_new, *hall_phi_e_old)/2;

I was curious as to why this equation is not applied to the encoder abn_phi_e_actual. Specifically, I'm wondering why we don't calculate an abn_phi_estimated using a similar formula:

abn_phi_e_estimated = abn_phi_e_old + (abn_phi_e_new - abn_phi_e_old)/2

Then we could set the TMC4671_ABN_DECODER_PHI_E_PHI_M_OFFSET register to hall_phi_e_estimated - abn_phi_e_estimated. Can you please explain why the offset average is only calculated for the hall sensor and not the encoder?

https://github.com/trinamic/TMC-API/blob/4ced0291c5cdae49f54e7f082c3c651d03ca19e7/tmc/ic/TMC4671/TMC4671.c#L406

#define TMC5272_MSLUT_START_OFFSET_SIN90_FIELD wrongly defines the field value as unsigned.

https://github.com/analogdevicesinc/TMC-API/blob/f276b3e94894494009a1c44e3eb21512ad0ab320/tmc/ic/TMC5272/TMC5272_HW_Abstraction.h#L295C1-L295C196

// is
#define TMC5272_MSLUT_START_OFFSET_SIN90_FIELD                ((RegisterField) { TMC5272_MSLUT_START_OFFSET_SIN90_MASK,  TMC5272_MSLUT_START_OFFSET_SIN90_SHIFT,  TMC5272_MSLUT_SEL_START, false })
// should be signed according to datasheet ("Signed offset for CUR_B ±127 microsteps")
#define TMC5272_MSLUT_START_OFFSET_SIN90_FIELD                ((RegisterField) { TMC5272_MSLUT_START_OFFSET_SIN90_MASK,  TMC5272_MSLUT_START_OFFSET_SIN90_SHIFT,  TMC5272_MSLUT_SEL_START, true })

platformio library

I'm wondering if this is something in the pipeline?
I've been using the TMC-API for quite some time now with the platformio environment and I like to keep the reference to the full repo tree (for the sake of keeping it up to date) instead of fishing out only the code I need.
However doing it this way platformio always compiles all the files in the lib, needless to say throwing a lot of errors.

I've made a fork where I created a library.json so that using the platformio library manager ( lib_deps = ) I get the desired behavior (see https://github.com/cooked/TMC-API/blob/master/library.json where I included only the files needed to work with the TMC2209)
The approach is not "flexible" yet, more of a proof of concept, so I'm wondering if there's interest in supporting it or someone else is facing similar situation.

Issues with reading XACTUAL from TMC5160

Hi,

I have a situation that when I write 0x05 0x07 0x21 0x9E data package to my stepper driver through UART I read nothing. I confirm this through Logic Analyzer.
TMC issue

Any ideas?

Thanks in advance
Samir

Simpler READ/WRITE macros?

A purely cosmetic issue. Could we change the current macro, or add additional ones? Like this:

#define TMC2130_READ(tdef, address, field) \
		FIELD_GET(tmc2130_readInt(tdef, address), field ## _MASK, field ## _SHIFT)
#define TMC2130_WRITE(tdef, address, field, value) \
		(tmc2130_writeInt(tdef, address, FIELD_SET(tmc2130_readInt(tdef, address), field ## _MASK, field ## _SHIFT, value)))

It turns the current long lines with repeated names:

TMC2130_FIELD_WRITE(d, TMC2130_COOLCONF, TMC2130_SGT_MASK, TMC2130_SGT_SHIFT, 15);
TMC2130_FIELD_WRITE(d, TMC2130_GCONF, TMC2130_EN_PWM_MODE_MASK, TMC2130_EN_PWM_MODE_SHIFT, 1);

Into something easier to read and less prone to errors while typing:

TMC2130_WRITE(d, TMC2130_COOLCONF, TMC2130_SGT, 15);
TMC2130_WRITE(d, TMC2130_GCONF, TMC2130_EN_PWM_MODE, 1);

https://github.com/versioduo/V2Stepper/blob/master/src/tmc/ic/TMC2130/TMC2130.h#L22
https://github.com/versioduo/V2Stepper/blob/master/src/Motor.cpp#L21

Invalid values for TMC5072

According to datasheet:
the following fields are incorrect: TMC5072_DC_TIME_MASK , TMC5072_DC_SG_MASK and TMC5072_DC_SG_SHIFT

Should be
#define TMC5072_DC_TIME_MASK 0xFF // DCCTRL_M2 // Upper PWM on time limit for commutation (DC_TIME * 1/f CLK ). Set slightly above effective blank time TBL.
#define TMC5072_DC_TIME_SHIFT 0 // min.: 0, max.: 1023, default: 0
#define TMC5072_DC_SG_MASK 0xFF00 // DCCTRL_M2 // Max. PWM on time for step loss detection using dcStep stallGuard2 in dcStep mode. (DC_SG * 16/f CLK); Set slightly higher than DC_TIME/16; 0=disable
#define TMC5072_DC_SG_SHIFT 8 // min.: 0, max.: 255, default: 0

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.