my problem is the following: I am using two DRV8842 H-bridge ICs to control 2 different brushed DC motors, my intention is to use a PI controller for the current loop. The schematic looks like this:
For the current sensing i am using the INA301 chip from texas instrument for low side sensing and a shunt resistor of 30 mOhm. To measure the current i use an ADC interrupt at the middle of the PWM pulse in order to take a measurement each time the transistors are closed. I noticed that for low duty cycle my current readings were higher than those when i increased the duty cycle (PWM frequency 20 KHz). When i checked the voltage signal in the resistor and after the INA301, i noticed there were oscillations in the signal as shown in the picture:
The blue signal is measured directly at the shunt resistor terminals. And the input signal to the ADC looks like this for the case of 10% and 50% duty cycle:
The blue signals are the resistor voltage amplified by the INA301 and low pass filtered with a RC filter with cutoff frequency of ~1.3 MHz. As i am sampling at the middle of the pulse, for low duty cycles i read this peak value and not the steady state value. For a brushed DC motor i would have expected a current signal with a sawtooth like form, what could be causing this oscillations? Maybe my pcb layout is bad and has parasitic inductance and capacitance or is it due to the PWM modulation and i need to use some snubber circuit? Any ideas on what could be wrong or how to solve it will be appreciated. Thank you all in advance!
Regards, Emmanuel