robotology / icub-firmware

iCub Firmware
Other
12 stars 30 forks source link

Improve the rotor/stator calibration in 2FOC #499

Closed valegagge closed 4 months ago

valegagge commented 5 months ago

After some tested carried on in https://github.com/icub-tech-iit/ergocub2-design-upperbody/issues/43, we noticed that sometimes joint couldn' t complete the calibration because it doesn't find the index before the timeout of 30 seconds exipre.

We noticed that the motor does 3 or 4 complete tourns but the index interrupt isn't t triggered. So we need to create a setup with the oscilloscope to verify the index signal.

Moreover, in the procedure, some time constants need to be updated (or parametrized) since the 2foc now runs at 20KHz and not 40 KHz.

For more details please see this comment.

Dod The new procedure runs correctly both on the robot and on ergocub2 joints

MSECode commented 5 months ago

After some knowledge transfer done with @ale-git, we understood that some changes should be done to the heuristic use in the method of the 2FOC where we perform the stator-rotor calibration looking for the index of the quadrature encoder mounted at the motor side of the joint.

The whole portion of code we are interested in is at this lines: https://github.com/robotology/icub-firmware/blob/master/emBODY/eBcode/arch-dspic/board/2foc/appl/2FOC-V3/src/2FOC.c#L353-L520

Here a brief explanation of what should we modified and what probably was the cause of the failing of the calibration procedure.

In conclusion, I did some tests by reducing the value of the timer for our setup where the number of motor poles is more than the double with respect to the motor in the robot and I was able to always finding the index. Thus, we need to revise together the heuristic used and parametrized the timing so that we are good in all hw configurations

cc: @valegagge @ale-git

valegagge commented 5 months ago

Hi @MSECode , thanks for the explanation and tests.

Which value of the timer did you use in the test on the ergocub2 joints?

Moreover, I suggest to go on in two steps:

  1. double the velocity according to the new 2foc frequency and test it on ergocub.
  2. find a first attempt of "formula" that parameterizes the number of polar couples and the 2foc frequency.

what di you think?

MSECode commented 5 months ago

On our joints I just changed the value of the timer to 50. In this manner I should be able to complete the full state machine calibration in 27 seconds. Considering that if I need to complete the 1,5 revolution to one side and to the other with joints with 3600 electrical deg per revolution and considering that the 2foc loop is running at 50 us. We have that, with 50 cycles per loop, we can make the 10800 electrical deg in 27 seconds. So I'll try with this value, which should be more than enough for the robot too and then we can parametrized it to make it scalable with respect to the number of motor poles different joints have. So the step you have defining are good.

valegagge commented 4 months ago

Hi @MSECode , please add here the reference to the updated code.

Is your code already tested?

MSECode commented 4 months ago

I'm gonna re-check it since I've done some tests but that was some weeks ago

valegagge commented 4 months ago

PR opened here: https://github.com/robotology/icub-firmware/pull/503

valegagge commented 4 months ago

PR merged. Closing