I need to drive a DC motor @ 24V, 6A with a MOSFET. How can I sense the current that the motor is drawing with a microcontroller? I have to know when the motor is stalled.
|
You place a small sense resistor (typically < 100m\$\Omega\$ for the voltage and current involved) in series with the motor and measure the voltage drop. There are two methods: high-side and low-side, depending on the position of the sense resistor. Low side is easiest, as the voltage drop you want to measure is directly related to ground, but it lifts the low side of the motor's voltage a few tens of millivolts above ground too, and not everybody likes that. If it's no more than these few tens of mV it shouldn't be a problem though, and you can use an opamp to amplify the voltage in a simple non-inverting amplifier configuration. A 10m\$\Omega\$ resistance will give you a 60mV drop, which is acceptable, and at the same time high enough to measure properly. You don't necessarily need a physical component for this; a 1cm PCB trace 0.5mm wide has a 10m\$\Omega\$ resistance. For high-side measurement you have to use a difference amplifier to measure the voltage drop. There are special ICs for that, some of which have the shunt resistor integrated, for maximum accuracy.
But you can also construct your own difference amplifier with an opamp. If you just want to detect a stall you probably don't need the A/D converter but can use a simple comparator. Be sure to filter the measured voltage with a capacitor. A (not very thorough) search turned up the SiLabs Si8540 high-side sensor, available from Mouser from USD 0.65 quantity one. edit Further reading: |
|||||||||
|
|
People who think the only way to measure DC current is to use a shunt resistor may be surprised to learn that a variety of current sense techniques exist. Hall effect sensors are nice for measuring large high-side DC currents. Some have analog out, eating up one of the analog inputs on your microcontroller. Others have an integrated internal ADC, with digital pins that directly connect to your microcontroller. A few also have an integrated power FET driver, and are smart enough to unconditionally turn off the FET when it measures over-current. In many cases, I don't really need to know exactly what the current is, I just want to keep things from getting permanently damaged when the motor stalls out. It makes the rest of the system much simpler to use a "smart switch" that automatically turns itself off when the motor stalls. The Allegro Hall effect sensor chips look nice. The IR intelligent power switches look nice. Related: Best shunt resistor for power meter application? and High-bandwidth current measurement |
|||||||||
|
|
As Andrew Kohlsmith corrected me here's the edit: For DC, the only way to sense current is by a Shunt Resistor. This method is derived by the Ohm Law: \$I=\dfrac{V}{R}\$ Where 'I' stands for current and will be the only variable solved by the µC. In the same way, 'V' stands for Voltage, which will be measured by an ADC (Analog-Digital Converter) inside the µC. Finally, 'R' stands for the resistor you must know for calculating the ecuation. There are two ways of designing the shunt resistor:
\$R=\rho \times \dfrac{L}{t \times w}\times(1+Tc \times (T-25))\$
Some, ommit the temperature product part [2]. There are plenty of webs you can use for generating the aproximate resistor of the PCB trace, for example in [3] and [4]. Anyway, I would measure the value with a multimeter with a \$m\Omega\$ capability. If you want more information, check [5]. On the other hand, the only way to measure the voltage of that Resistor is using an Instrumental Amplifier, just as Stevenvh suggests. [1] AN894 - Motor Control Sensor Feedback Circuits by Microchip. [2] AP144 - Calculating PCB Track Resistance by Polar Instruments. [3] Trace Resistance Calculator by EEWeb. [4] PCB Thermal Copper Area by The CircuitCalculator.com Blog. [5] Contructing your Power Supply - Layout Considerations by Robert Kollman [TI]. |
|||||||||||||||
|
|
As current, voltage, and resistance are all related (Ohms law), you can measure current by measuring the voltage drop across a known resistance and calculating it: \$I=\frac{V}{R}\$ Put a small (\$<0.1\Omega\$) resistor in series with the motor. The microcontroller can measure the voltage drop across it (you may want to amplify it through an op-amp) using ADC. This is something I have wanted to do myself for a while, and I understand the theory - just haven't worked out how to measure the voltage difference yet |
|||||||||||||||||
|
