-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2FOC current filter implemented. #524
Conversation
ale-git
commented
Oct 8, 2024
- Since PWM and current feedback are transmitted at 1 kHz, but set/measured at 20 kHz, I've introduced a filter acting in a 20 sample wide window.
- The PWM 1 kHz feedback is the average of 20 values in a 1 msec window.
- The current 1 kHz feedback is the average of 14 samples in a 1 msec window because the 3 highest and the 3 lowest values are discarded.
- Moreover, the current signal for current control is the average of two consecutive samples.
- The ADC is calibrated at startup (offset and gain).
- I've removed the assembly routines for current calibration because anachronistic and difficult to maintain, and replaced with two lines of C code.
Since PWM and current feedback are transmitted at 1 kHz, but set/measured at 20 kHz, I've introduced a filter acting in a 20 samples wide window. The PWM 1 kHz feedback is the average of 20 values in a 1 msec window. The current 1 kHz feedback is the average of 14 samples in a 1 msec window because the 3 highest and the 3 lowest values are discarded. Moreover, the current signal for current control is the average of two consecutive samples. The ADC is calibrated at startup (offset and gain). I've removed the assembly routines for current calibration because anachronistic and difficult to maintain, and replaced with two lines of C code.
Hi @ale-git, When this PR is ready can you please explain briefly the tests you did? thanks heaps |
Hi @valegagge, the offset calibration is made at startup since the motors are (and must be) completely OFF in this phase. In practice, you register the current measured by the sensor when the real current is 0 for sure, and you take this value as sensor offset. |
I've operated the small ergoCub joint at constant PWM, free running, at 10% and 15% respectively (the speed increases significantly with the additional 5%). I've recorded the currents running the 3.3.36 version (unfiltered) and the 3.3.37 version (current filter). I've filtered the signals to extract the moving average in a 500 ms window, and then calculated the RMSE between the moving average and the raw measure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ale-git, it seems fine by me.
Hi @ale-git , Thanks! :) |
Done! |
Hi @valegagge, is the change ok? Shall I merge? |
Hi, I will merge so that we can clean up the open PRs. In case, we may produce further code comments in a later PR. Linked PR: |