Current Sensing

Introduction

While working on the magnetic levitation project, I came across the problem of needing to measuring the current through the electromagnet so I could feed it back into the control system. The techniques here will apply to a wide variety of applications.

The idea behind current sensing is very simple. I will use the magnetic levitation circuit as an example. In the magnetic levitation circuit, I am applying a PWM signal (V1) to the gate of an NMOS transistor with the electromagnet as the load. The circuit is shown below.

pwm_mosfet

Using a Resistor to Measure Current

A resistor is commonly described as a “voltage-to-current converter”. This is because there is a linear relation between the voltage drop and the current going through a resistor, thanks to Ohm’s law. By inserting a small resistor in series with the electromagnet, the voltage across the resistor can be measured and converted to current.

pwm_mosfet_sense

 

It is essential to choose a resistor with a very small resistance. Current sense resistors come in values from 0.001 Ω up to 1 Ω. A small resistance is necessary for two reasons: 1) to minimize the effects on the load and 2) to minimize power loss in the resistor. If the resistance is small relative to the load resistance, there will be minimal voltage drop across the resistor. Power consumption in the resistor is proportional to the square of the voltage drop across it (P = V^2/R).

Measuring Voltage

The voltage across the current sense resistor is measured via a differential amplifier. R_SENSE has a very small voltage drop, so an amplifier is amplify the signal to a reasonable level. The final schematic is shown below

PWM_MOSFET_opamp.PNG

U1 is set up as a differential amplifier with a gain of 100. Below is the simulation of the above circuit. V1 is a 32 kHz PWM signal with a 50% duty cycle. The voltage across the current sense resistor tracks the current through the electromagnet perfectly. The current through the inductor is easily obtained by L_EM = (1/GAIN) × (V_SENSE / R_SENSE) where GAIN is the gain of the amplifier.

pwm_mosfet_simulation

High-Side vs. Low-Side Sensing

In the circuit I have shown above, the sense resistor is placed between the load and the supply voltage. An alternative is to place the sense resistor between the load and common ground. In that case, a PMOS transistor would be used.

PWM_MOSFET_LOW_SIDE.PNG

There are some trade-offs to consider when deciding which topology to use. It may be that you only are have an NMOS/PMOS transistor at your disposal.

A less obvious example is the type of driving circuitry you need. Most microcontrollers operate at +3.3V or +5V. If you are driving a MOSFET with a large drain-source voltage, you may need to incorporate level shifting circuitry in between the microcontroller and MOSFET to reach the desired gate-source voltage. This can be mitigated by choosing logical level MOSFETs in your project.

One advantage of low-side sensing over high-side sensing is that the sensing portion is easier to design. Rather than using a differential op-amp, a non-inverting amplifier can be used instead. In addition, the op-amp used for high side sensing must be designed to withstand input common mode voltages very close to the supply rails. The resistors must be precisely matched as well to prevent any inaccuracies in the measurement.

There are other advantages to each method that I haven’t covered here. If you want more information, I highly suggest searching the web for more detailed discussions to see which topology is right for your application.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s