You are here

Current sense SNA/SPA swapped. Where to adjust the code?

2 posts / 0 new
Last post
shaman
Offline
Last seen: 8 months 1 week ago
VESC Free
Joined: 2018-12-09 15:59
Posts: 60
Current sense SNA/SPA swapped. Where to adjust the code?

I am using the integrated current sense amps in the DRV8301 in addition to a seperate low-side current sense ampin order to measure all 3 phase currents. I accidentally swapped the SNA and SPA traces on the DRV8301. TI had actually swapped the names of these pins for the newer DRV8353 and I made the mistake of assuming it was the same for the older DRV. So now I'm looking to compensate for this in the code. Does anyone know off the top of their head where in the code I can simply change the polarity of the measured current for these phases? 

Eric
Offline
Last seen: 1 year 4 months ago
Joined: 2017-08-28 10:27
Posts: 16

Did you manage to fix it?

In  hwconf/your-pcb.h you have a define, for example: #define CURRENT_AMP_GAIN        20.0

In confgeneral.h that is used in:

// Current ADC to amperes factor

#define FAC_CURRENT                    ((V_REG / 4095.0) / (CURRENT_SHUNT_RES * CURRENT_AMP_GAIN))

FAC_CURRENT macro is used in several places and is the same for all three phases, you must put in a negative sign for two phases.

It could be difficult to make it work.