Skip to content
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

Implement in the 2FOC a filter for rejecting the current ripple due to the PWM voltage feeding the motor phases #98

Closed
nunoguedelha opened this issue Sep 3, 2019 · 1 comment
Assignees

Comments

@nunoguedelha
Copy link
Contributor

nunoguedelha commented Sep 3, 2019

This results from the analysis described in https://github.com/dic-iit/element_torque-control-via-current/issues/20 and https://github.com/dic-iit/element_torque-control-via-current/issues/61.
A filter should implement a filter at low level (at best in the current controller running on the 2FOC, for rejecting the current ripple due to the PWM voltage feeding the motor phases. The "ripples" main frequency is 20kHz, amplitude 100mA to 200mA.

This filter would actually have two effects on the measurements

PWM freq = 20 kHz (single phase case)

pwm2currentRipple-20khz-pwm20perc
Current ripple amplitude = 2 A

and the plot from the oscilloscope in https://github.com/dic-iit/element_torque-control-via-current/issues/61#issuecomment-497319647
oscillo-current-on-2phases-icub3motor-PWMp10-Iq-oscillo-zoom

The current can be at it's lowest value or close at the instant the ADC samples the current measurement. The sampling occurs at the very beginning or end of the PWM period, so during the current ramp-down (refer to #87 (comment)):

• PxSECMP: Special Event Compare Register
This register provides the compare value at which the analog-to-digital conversions are to
be synchronized with the PWM time base. Comparison can be either during up-count or
down-count in Center-aligned mode depending on the setting of the SEVTDIR bit in this
register.

(Phase of ADC capture set relative to PWM cycle: when arrive to PTPER offset and counting down to avoid ripple on the current measurement)
SEVTDIR - Special Event Trigger Time Base Direction bit: 1 = Special Event Trigger will occur when the PWM time base is counting down
SEVTCMP <14:0> - Special Event Compare Value bits: 0x00 = at the bottom of the current ripple

So, even if we average the current across multiple calls of the main routine _DMA0Interrupt() (reads current measurements and computes the quadrature current), we might be averaging always the lowest level in the current ripples. This can induce an undesired offset.

The solution would be to trigger at each start of the PWM period a sequence of multiple sampling/conversion cycles (as many as possible, probably between 5 and 10), and average it for that period.

We would then get an average per PWM period, i.e. for each DMA interrupt prrocessing in _DMA0Interrupt(). Additional averaging across several calls of that interrupt wouldn't be necessary.

@ale-git , as we discussed earlier, please refer to the ADC manual here:
Section 16. Analog-to-Digital Converter (ADC)
16.13 SPECIFYING CONVERSION RESULTS BUFFERING

(I gathered the links to the documentation on the current measurement and conversion in #89).

@valegagge
Copy link
Member

old issue. Nobody is working on this for a long time. closing

@valegagge valegagge closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants