2 phase current sensing problems

Hello everyone! I am trying to make my own FOC algorithm (because why not?), and i ran into a problem when measuring the current of two of the three phases of the motor.

The schematics are on the image

The motor supply voltage is 12V and VCC is 3,3V. (forgot to add to the schematics)

So, the problem only happens when i connect the second current sensor to the driver. The value of one of the ADC channels of the microcontroller shifts down (to a random value as far as i could tell), and acts all weird. I ve tested both current sensors and both ADC channels separately and they all work perfectly. It is only when i connect the 2 current sensors. My guess is that something somewhere is shorting the phases together with a really high resistance or impedance and messing with my measurements.

Can anyone help me? If something is indeed shorting, what can I do? Isolate the shunts? If yes, any recommendations on how to do it?

I am not sure about your opamp circuit, but are you sure you haven’t exceeded the input voltage range of the opamps? You are powering the opamps with 3.3V, but your supply voltage is 12V which means the input voltage to the opamps could be close to 12V as well, which exceeds the input voltage ratings.

To verify whether this theory is correct, probe the IN- and IN+ pins of the opamps with an oscilloscope and check the voltage. If it is higher than 3.3V (or lower than 0V) then the opamps input voltage ratings have been exceeded.

I suggest you use a proper current sensing chip instead of trying to DIY it with opamps. You can try the ACS712 (Isolated hall effect current sensor) or INA240 (Current sense amplifier) if you want to continue with inline current sensing. Alternatively, some chips such as the DRV8316 come with integrated lowside current sensing. DIYing lowside current sensing circuitry with opamps is also a lot easier than DIYing inline current sensing circuitry.

I will try to check the IN- and IN+ of the opamp like you said and post the results here. But would that cause a shift on the signal ONLY when both current sensors are connected to the driver?

No, that shouldn’t be the cause of a shift in the signal only when both sensors are connected to the driver. The only reasons that would happen is because there is residual charge on the ADC capacitor influencing the measurement of other readings using the same ADC, or because of a software issue configuring the ADC.