I²DC

I²DC is an ATTiny-enhanced N-Channel MOSFET with a series inductance and current sensing shunt. Output voltage and current can be read and set through I²C.

Features

  • 72W N-Channel MOSFET
  • ATTiny85
  • Voltage sensing
  • High-side current sensing
  • I²C interface (read values, set voltage & current limit)

Specs

  • Ptotal = 72W
  • Vin = 6…36V
  • Vout = 8…Vin
  • Iout: 5A

Hardware Design

In essence, the hardware consists of the following parts:

  • Switch (MOSFET)
  • Low pass filter (Coil + Cap)
  • Current sensing circuit (Shunt + opamp)
  • Voltage sensing circuit (Voltage divider)
  • I²C interface (ATTiny)

Switch Choice

The choice of an N-Channel MOSFET is quite straight forward. We just pick it from the Fab inventory (RFD16N05LSM Datasheet).

But … we need to consider how to drive it. In other designs i’ve seen the gate driven from a 5V µC through a 100Ω resistor, with a 1kΩ pull-down to ground, so let’s just copy that. The gate on a MOSFET has high capacitance and super high resistance to source, so can use low value resistor to drive it strongly without it drawing any significant current.

The pull-down is there to quickly turn the gate off when the PWM’ed pin on the µC goes low. Also, it prevents the gate from floating freely. A floating gate would lead to unpredicatble switching activity while the µC is off (or in case it fails), which could damage the connected load.

MOSFET circuit

Output Filter Design

As we don’t want to add any resistance to the drain path, a typical RC design won’t work so we’re left with coils for the low-pass filter. The entire filter involves an inductor (coil), a capacitor, and a flyback diode. Roughly speaking, the coil is there to filter out the high PWM frequencies, the capacitor feeds the load during MOSFET’s “off” phases, and the flyback diode allows the coil to discharge at the same time.

Higher switching frequencies allow us to use smaller coils and capacitors. The maximum native PWM frequency we can bang out of that little ATTiny85 is 62.5kHz. Let’s simulate that with an 8Ω load (3A @ 24V):

Video

Dont ask me how i found those values, but a 33µH inductor and a 220µF capacitor seem to provide a smooth enough DC. The settle duration, when changing the duty cycle/voltage is of minor importance for now, we can tweak that later…

The flyback diode must be able to handle the same current that flows through our inductor. And that’s the same as our maximum current rating, 5 amps. As there will be no continuous load on the diode, only pulses, i think it’s fine to choose a diode rated at 5A (continuously) without any additional safety margin. In a “synchrounous” design, the flyback diode would be replaced by a secondary switch, which would be turned “on” during the “off” phase of the main switch, effectively cutting down losses.

So these are the parts for the low-pass filter:

Purpose Part Number Specs
Coil SRP1265A-330M 33uH 8A 58mΩ SMD
Capacitor UCW1H221MNL1GS 220uF 50V 20% (10 X 10mm) SMD 670mA 7000h 105°C T/R
Diode PDU620-13 200V 6A Surface Mount Ultra-Fast Recovery Rectifier - PowerDI-5

Current Sensing

For current sensig we’re gonna use a very small series resistor with an accurately known value. The voltage drop accross this resistor can be measured and converted into a current using the known resistance.

But now comes the problem: our spcifications say we want to support a maximum current of up to 5A. So if we want to convert 5 amps into the maximum sensing range of out ATTiny – let’s assume we’re running at 5V, so 5V – we’d need a 1Ω resistor. One ohm, thats way too much voltage drop and power dissipation. So what’s the solution? An opamp, right! It lets us use a way smaller resistor, say 10mΩ, and “amplifies” the voltage drop into the full range of our µC.

And by the way, as we’re using an op-amp already, let’s sense the current on the high side. This comes for free as a side-effect of using an op-amp and is more reliable because it also covers current drawn through alternative ground paths on the load, that we’re not in control of.

Okay let’s use a special op-amp that’s made for exactly our job, the INA169. It’s also used in a sparkfun breakout board, for which they provide the schematics and further documentation. By the way, Sparkfun, Adafruit et al. are good resources for finding example applications of some common ICs and other components…

Shunt Resistor

What’s gonna be the value of the shunt? According to its datasheet, the INA169 operates best if the upper input voltage is between 50 and 100mV. Let’s choose the lower bound in order to minimize voltage drop and because surely yields a nice 10x resistor value with our 5A spec:

R = 50mV 5A = 10

Perfect, nice value. And just what we guessed earlier. But what power is it gonna turn into heat?

P = I2 × R = 25A2 × 0.010Ω = 14W

So for some safety margin we should probably go with a 12W resistor for the job…

Load Resistor

Sparkfun also tells us in their “hookup guide” how to calculate the values of the additional resistor. We need a seconday resistor at the output of the opamp, that converts the “known current” output into a “known voltage”. The formula goes as follows:

Is = Vout × 1 Rs × Rl

The value we’re looking for is Rl. The value of the shunt resistor is Rs. Tweaking the equation a bit, we get:

Rl = Vout × 1 Rs × Is

Plugging in the value of the shunt and our values for the maximum current of 5A ≘ 5V:

Rl = 5V × 1 10 × 5A = 1kV 10mA = 1 0.010 = 100

Final Parts Choice

As always, I use the digikey search for its excellent filter options to find appropriate parts.

Purpose Part Number Specs
Op-Amp INA169 2.7 - 60V; 0.5%; SOT23-5
Shunt (Rs) LVK12R010DER SMD 0.01 OHM 0.5% 1/2W 1206
Load Resistor (Rl) RC1206FR-07100KL (Fab Inventory)

Pushing 5A through a 1206 component sound unreasonable to me, but well – seems like this is physics. Otherwise i did not yet understand it properly, but hopefully will do so after producing some smoke. But hey, that’s also just a way of learning…

Alternative method

An alternative method would be to use a premade hall-effect based IC, like the Allegro ACS712, but that somehow feels like cheating, though it’s a perfectly valid and accurate solution.

Also, a standard opamp from the fab inventory could be used. But as we don’t have them in stock at the Lab, and i have to order from Digikey anyway, i’ll choose the application-specific solution. Of course, i’ll order some of the standard AD8615AUJZ’s as well – who knows what comes next ;)

Voltage Sensing

For the voltage sensing, we just need to divide down 36V (max output voltage) to 5V (Aref of the attiny), which is a ratio of 0.13889. Using an online calculator, we can easiy find the appropriate values. It suggests 10k and 62k as a perfect match from the E24 series. I don’t know which series that is we have in the lab, but there is a 61.9kΩ, which should be just fine. We can still account for that in the calculation taking place on the attiny later on.

I²C Interface

We need a pull-up on the SDA line. According to what i’ve read elsewhere, a 4.7k should be used. I see Neil use 10k ones in his examples, guessing that’s because they’re in the standard inventory. So anything in between 4.7k and 10k should be fine, assuming short wire lengths and low device count per bus.

http://academy.cba.mit.edu/classes/networking_communications/index.html http://academy.cba.mit.edu/classes/networking_communications/I2C/hello.I2C.45.node.png

Voltage Regulator

Besides all that, we need a small voltage regulator in order to power our microcontroller and opamp. This way we can use the board as a “programmable” step-down converter, where we set the parameters once (it should store them in EEPROM), and then operate it without any external control input.

But which one?

  • The attiny itself takes less than 10mA when operating at 5V (8MHz).
  • The INA169 says “Input current into any pin 10mA MAX”. Let’s take it for that!
  • Our swiching pin will be connected to ground via the 1k gate pull-down. That’s another 5mA at 5V.
  • More current will be drawn when the I²C bus is active

Those should be about the main consumers. So if we choose a 100-150mA linear regulator, we should be quite on the safe side. Our max Vin is 36V. Burning 100mA at 31V causes 3.1W of global warming. Out min Vin is 6V so the maximum allowed dropout is 1V. That’s the specs. Yeah, and don’t forget to add some capacitance.

And the winner is: MIC5233-5.0YM5-TR – I chose by package size because it’ll run on the lower end of its specs and therefore we can trade off worse cooling for smaller footprint. Unfortunately, it’s got an “enable” pin and the datasheed doesn’t mention an internal pull-up, so we’ll have to add an external one to be sure it’s on by default.

Further Lecture