current sense pin

Hi, I saw a topic of PID control and there is a little part about current sense pin

http://forum.arduino.cc/index.php?topic=8652.0

The motor driver :https://forum.pololu.com/t/using-dual-vnh3sp30-motor-driver-with-arduino/1497

Can any one explain why the author multi 0.77 in the equation? current = int(analogRead(Apin) * 3.22 * .77 *(1000.0/132.0));

I just want to know ,may not use it.

Thanks.

You need to check the product datasheet. I think the CS pin produces a voltage that is proportionate to the current. On this page it is shown as 0.13 volts per amp.

The formula presumably converts the ADC reading to an ampere value. I don't know what voltage reference the Arduino ADC is using. The Aref voltage will impact on the calculation.

...R

No, the CS pin outputs a current which is a ratio of the output current. My copy of the datasheet say it puts out 1/11370th of the current. A resistor will turn this current into a voltage.

Note that current can be negative, so protect your Arduino input with a resistor.

The current will closely follow the PWM, so to measure the DC equivalent current, you need to add a capacitor to filter the high frequency and ‘average’ the voltage suitable for the analog input.

I’ve found this circuit works well, where CS1 goes directly to an Arduino analog input.
Current Sense Filter.jpg

MorganS: No, the CS pin outputs a current which is a ratio of the output current. My copy of the datasheet say it puts out 1/11370th of the current. A resistor will turn this current into a voltage.

That is not at all obvious from the page I linked to.

Can you post a link to the source of your information?

Edit to add ... I think the Pololu board has the circuit you mention already included.

...R

My datasheet is for the VNH*2*SP30. The Pololu page says the "3" doesn't have the current sense.

The capacitor is too small on the Pololu board. It won't filter the standard Arduino PWM frequency. The Sparkfun board also has the same problem. Solder another 1uF over the top of it.

Then,why is 0.77? int(analogRead(Apin) * 3.22 * .77 *(1000.0/132.0))

analogRead(Apin) is voltage of output current*1.5k ohm ,3.22 is 3300/1024 because of the Vref connect to external 3.3v battery,(1000.0/132.0) is the reciprocal of 132 mV/A,can't tell where should exist 0.77.

I don't know. Maybe it was a fudge that made things work on the author's Arduino.

Split up the calculation so you can print the raw analogRead() value and compare it to the voltage on the CS pin as measured by your multimeter.

...R

Aye , I will do the comparison.

MorganS: My datasheet is for the VNH*2*SP30. The Pololu page says the "3" doesn't have the current sense.

The capacitor is too small on the Pololu board. It won't filter the standard Arduino PWM frequency. The Sparkfun board also has the same problem. Solder another 1uF over the top of it.

Change the PWM to 16kHz if possible, finesse the issue and prevent motor whining. Also the motor windings may already be smoothing the current acceptably.