Electrical – Current Sensing problems in PWM-switching circuit

current measurementgroundpwmswitching

I have the following circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

A simple voltage source is connected to a resistor. The current flow is controlled via an NPN switch. I also have the INA169 current sensor (Here is the datasheet).

The current measurement from INA169 is driven to my my microcontroller's analog in, and the ground signal of INA169 is connected to my microcontroller's analog ground.

The NPN mosfet is driven by a pwm signal generated from my microcontroller. To effectively drive the mosfet I am using the ICL7667 Mosfet driver. In order for the circuit to work, I have connected the controllers ground to:

  • the mosfet drivers ground
  • the source of my NPN mosfet.

When the PWM duty cycle is either 0% or 100%, the current measurement is perfect. However, when the duty cycle is between 0% and 100%, I get a completely wrong current reading from my sensor. Is there something wrong with the circuit above or something that is overlooked?

Best Answer

When you control your mosfet and thus current with a PWM, it's either on or off, so your current will either be 100% or 0%.

I guess you are measuring with an ADC in your uC, measurement will be random as you don't know at what point it will sample, it might be when it's on, when it's off, or in between.

Your circuit does not allow to control the current, it is not clear what is the goal of your application.

If it's some sort of step down converter and you need a somewhat constant currant, you will need an inductor and a diode like a step down buck converter.

If you want to drive LED for example, then you can keep this design, but you need to average the output of the INA to have some correct measurement.

You can do so with an Lowpass R-C filter or better a L-C filter between the output of the INA and your uC ADC. The capacitor and resistor / inductor value will depend on your PWM frequency and ADC input impedance.

You can also do a better lowpass filter with an op-amp.

You need to check the ADC pin input impedance to make sure you drive it with enough current.

schematic

simulate this circuit – Schematic created using CircuitLab

Related Topic