0
\$\begingroup\$

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?

\$\endgroup\$
0
\$\begingroup\$

You are aliasing. You need to filter the output of your current sensor. the parameters of your filter will vary according to

  1. Your sample rate of the ADC
  2. The PWM frequency

You want to filter about an order of magnitude slower than your PWM frequency, or at 40% or less than your sample frequency -- whichever is lower.

If you're sampling quickly, and you sample with a fast time constant, you can see the PWM effects, but this isn't really what you're after. You need a mean current.

\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.