Pages: [1]   Go Down
Author Topic: Shunt Resistors and Input Pins  (Read 2477 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to measure the current going through a DC motor so that I can implement some kind of velocity control, but I'm a bit stuck as to how to implement the circuit.

I have a low resistance resistor in series with the motor which is powered by a motor shield on an Arduino Mega, and I'm trying to measure the voltage across the resistor. The motor shield provides a maximum of 12V and the motor draws up to 1.2A.

However, I'm not sure how to set this up with regards to input pins and grounds. The lowest resistance resistor I have available is 0.47 ohms, is it likely Ill need to go out and find something lower?
Thank you in advance!
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your resistor should drop just over half a volt at 1.2A.
You may want to look at using the internal Aref, which is around 1.2V, IIRC.
Logged

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good idea, I'll use the internal Aref.

I was more stuck on how to wire up the resistor to the arduino however, any ideas?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Resistor to ground other end to the arduino analogue input and the -ve of the motor. Wire the +ve of the motor to the +12V power and the 0V of the power supply to the arduino ground..
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Like this?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes.

You might like to put a bit of protection on the analogue input just in case you get a higher voltage on it.
http://www.thebox.myzen.co.uk/Tutorial/Protection.html
« Last Edit: March 09, 2010, 11:46:27 am by Grumpy_Mike » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot, this works really well.

However, I'm having some odd readings from the analogue inputs. They will often give a reading of 0 volts every other time they are read i.e. when the program is run they give something like 0 40 0 40 0 40 0 40.

Any ideas? This only happens when I use the voltage reading from the resistor for control, it seems fine when the voltage source is constant and I simply print the voltage over the resistor.
The code for the loop loop is
void loop()
{
   VshuntR=analogRead(Ipin);
   error=r-VshuntR;
   Vin=error*K;
  
  digitalWrite (dirA, HIGH);    
  analogWrite (speedA, Vin);
  
      delay(100);
      Serial.println(VshuntR);
      
    }
      
Many thanks
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sampling the "LOW"s of your PWM?
Logged

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some offhand suggestions:

- Add an idling diode across the motor (to catch the backlash from the inductive load) - best use a fast shottky

- Measure the voltage over the shunt using a RC filter (e.g. 1K, 1..10uF, make RC time larger as PWM cycle). This kills the spikes and gives you nice average current, and protects the analog input.

If it is a std commutating DC motor, there will be agressive spikes during PWM switchovers. Connecting a scope can be very instructive..

1K + chip internal clamping diodes will handle most overvoltage spikes if any.

FWIW I connect all off-board wiring from the chip with at least 1K's - it gives the cpu a fighting chance against ESD. YMMV
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5581
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Something also to note about shunts: Unless you are using an actual shunt resistor (specially made from a special allow, with very low resistance), your measurements can and will vary with temperature, run time, etc. It may not be enough to bother you or what you are doing, but it is something to be aware of, all the same.
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That easy,let me find some information to you
Logged

Pages: [1]   Go Up
Jump to: