analogdevicesinc / TMC-API

TRINAMIC's IC API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Encoder Initialization by Hall sensors

Ayoub-pixe opened this issue · comments

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

Hella @trinamic .
I am working with @Ayoub-pixe.
We are asking this question because, we discovered that some encoder initialization were bad. Leading to a big error between phi-e and encoder.
This big error leads to higher current in the motor (and the regulation) to drive it with the same load.
We have identified that the high current is linked to offset error.
So before trying to modify the Encoder initialization function. We wanted to understand why this equation was used.
thanks.