FINALLY I found the bug on my code!! The angle interpolation was wrong... I had to try simulate some code and the hall sensors signal on the board, use bluetooth to get the data, etc, etc, took me a lot of time but I got it :-)
Here a screenshot of the wrong values at left side and just after at right side after being correct: motor_rotor_position going from 259º up to 0º, in loop:
Then I got the motor working the best until now and I really think is very robust!!!
On the next image, I accelerated a few time the motor, very fast, in both directions. Id is controlled to be 0 by FOC and it is, just one fast accelerations it is not but we can see the "correction_value" that is the output of the FOC controller that follows fast on the accelerations. Also we can see values of Iq current of max ~-+5 Amps (current firmware code do not limit the max current).
Motor speed also indicates the direction of the rotation. Positive in one and negative in the other. The duty_cycle is the value that I control with the potentiometer.
Now see the video I recorded on a similar test. Can you see how fast is the acceleration and changing rotation direction?
The power supply is suppling 62V, can you see when I decelerate fast that the power supply shows a max of about 90V?? -- that's the regen voltage, the energy that should flow to battery when we brake!!
And the motor asks for about 0.6 amps at max speed without any load, but when I tired to block with my hand, at some duty_cycle value, the motor asked for about 2.8 amps!!
The motor did run at max speed of 24km/h (voltage power supply = 62.2V). For a battery pack of 60V, 16S = 16*4.2 = 67.2V, motor should run at max speed of 26km/h.
Next, move to the balance controller algorithm!!