analogdevicesinc / TMC-API

TRINAMIC's IC API
MIT License
198 stars 89 forks source link

Velocity typecasting. #48

Open Villyam opened 1 year ago

Villyam commented 1 year ago

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.