VNH2SP30 Current Sense is not working properly

I am using the VNH2SP30 to control two 50:1 Geared motors with 64CPR Encoder. I have connected the CS1 and CS2 pins to A1 and A0 of Arduino. The current reading is very erratic and the one side is too low. Here is a screenshot from the motor running. As you can see the current of the right motor is too low even though both are running at the same speed according to the encoder. I checked using multimeter and the right motor is drawing 160-170mA.
All these values are at free run without any load.


Here is the code I am using.

[code]
//#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>
#include <DualVNH5019MotorShield.h>

#define COUNTS_PER_REV 3200
//As per Pololu website 1200 ticks is to one revolution of motor shaft but experiments shows 2400

//Left Motor Pin Definitions

#define ENDIAG1 6
#define InA1 7
#define InB1 8
#define PWM1 9
#define CS1 A1
#define encA1 5
#define encB1 3

//Right Motor Pin Definitions

#define ENDIAG2 11
#define InA2 13
#define InB2 12
#define PWM2 10
#define CS2 A0
#define encA2 4
#define encB2 2

DualVNH5019MotorShield md(InA1,InB1,ENDIAG1,CS1,InA2,InB2,ENDIAG2,CS2);
Encoder en1(encA1,encB1);
Encoder en2(encA2,encB2);
int enc1_rpm,enc2_rpm;

void setup() {
md.init();

Serial.begin(115200);
Serial.println("Motor Driver and Encoder Test \n --------------------------");

}
void stopIfFault()
{
if (md.getM1Fault())
{
Serial.println(“M1 fault”);
while(1);
}
if (md.getM2Fault())
{
Serial.println(“M2 fault”);
while(1);
}
}

void loop() {
// put your main code here, to run repeatedly:

stopIfFault();
md.setSpeeds(200,200);

if (en1.read()>COUNTS_PER_REV|| en1.read()<-COUNTS_PER_REV)
{
//1 Revoultion complete
enc1_rpm++;
Serial.print("Left Motor(Revs): ");
Serial.print(enc1_rpm);

if (en1.read()<0)
Serial.print(" anti-clockwise");
else
Serial.print(" clockwise");

Serial.print("\t Current(mA): ");
Serial.print(md.getM1CurrentMilliamps());

en1.write(0);

Serial.println();

}

if (en2.read()>COUNTS_PER_REV|| en2.read()<-COUNTS_PER_REV)
{
//1 Revoultion complete
enc2_rpm++;
Serial.print("\t Right Motor(Revs): ");
Serial.print(enc2_rpm);

if (en2.read()<0)
Serial.print(" anti-clockwise");
else
Serial.print(" clockwise");

Serial.print("\t Current(mA): ");
Serial.print(md.getM2CurrentMilliamps());

en2.write(0);

Serial.println();

}

}[/code]

More information on my hardware setup is given in my previous post: https://forum.pololu.com/t/solved-pwm-not-working-in-vnh2sp30-motor-driver/8742/1

I noticed some time ago that the gain of the current-sense outputs are not the same for forward and reverse in the VNH5019 driver, so that the two directions need to be individually calibrated. Perhaps this is a related issue. VNH5019 current sense -- unequal gains fwd/rev

Hello.

To elaborate on what Jim said, 170mA is a fairly small current and I would not expect the current sensing portion of the circuit to be that accurate for small currents like that. If you look at Table 11 in the datasheet for the VNH2SP30, you will see that there can be (approximately) ±20% variation in the constants (K1 and K2) that determine the voltage on the CS pin for a given current. As Jim mentioned, these constants are different for different driving directions (as is illustrated in Figure 1 in the datasheet). Also, the constants can change with temperature.

-Nathan

I understand but it was working properly before. Since both motors have the same current sensing circuits, if there was an error, it would be same on both since the operating conditions are same for both. Why would there be such a high difference between both half bridges ?

Hello.

Why do you expect them to be the same? As I mentioned in my last post, the datasheet indicates that the portions of the circuitry inside the IC package used for current sensing are different for current flow in different directions and that there is independent variability in the properties of the two different current sensing circuits.

When you say “it was working properly before”, it sounds like the current sensing returned results that seemed more consistent previously. If so, has anything in your system changed since then?

-Nathan