I’m working on a new display for the upcoming holiday season – actually a couple of them – and I need some new controller hardware to drive them.
Here are the basic requirements that I jotted down:
- 8 outputs (perhaps expandable to 16)
- Each output can drive 1 amp at 12V
- Designed to deal with sequential animation (do this on output 1, do something else on output 2, etc.)
- Dimming support if practical
- Easy setup and and configuration
- Compact & cheap (within reason)…
With those in mind, I started thinking about components…
My go-to microcontroller has been the ESP8266 (in NodeMcu mini d1 form) for a while, because it’s so small and cheap. But it’s a bit weak on output pins; you can get 7 pretty easily, but to get more you may have to play tricks. Supposedly you can get to 11 with those tricks which would be okay for 8 but would make 16 possible without some sort of I/O expander.
Which brings me obviously to the ESP32. Which is honestly a ridiculously capable device; 160 Mhz, 520K of SRAM, dual core (if you need it), Wifi, bluetooth, and pretty much all the I/O support you could want. It’s a little more pricey, about $4 from China in single quantities.
For this project, it has loads of output pins, and 16 independent PWM channels, which fits pretty well into my requirements. And I’m hoping I can adapt my existing controller software – which is optimized to drive WS2812s – to work in this new scenario.
The switching will of course be handled by n-channel MOSFETS. My WS2812 expander uses DPAK (TO-252/TO-263) packages, which work great but take up a lot of real estate. That was okay for a small number of channels, but for 8 channels I’d like something smaller and I don’t need to be driving 10 amps per channel, which was my design goal for the expander.
So, my requirements are:
- 1 amp @ 12V
- Switchable from 3.3V outputs (I could add a transistor to drive, but I’d rather avoid the complexity)
- Low Rds at 3.3V
- Small package
- Enough power dissipation
I started doing some parametric searches in DigiKey and on Octopart, narrowed things down, and came across the BSR202N from Infineon. How does it stack up?
- 3.8 amps @ 12V (25 degrees, 3.1 at 70 degrees)
- Specified behavior down to 2.5V.
- Rds of 33 milliohms at 2.5 V.
- SOT23 compatible package
- 500 mW power dissipation
Those specs are honestly ridiculously good, especially the Rds. If I pull 3 amps through one of the channels, that gives me 0.033 ohms * 3 = 0.1 watts. Just a tenth of a watt to switch 3 amps. If I did that with a bipolar, it would be in the range of 1.8 watts (I’d definitely need a heatsink) and I’d lose 0.6 volts in the process.
In reality, it will likely be a little better than that since the Rds is lower at 3.3V, but I don’t know how much 3 amps will be heating it up and that will make the Rds worse. It will take some testing to see.
My only big concern whether the ESP32 has enough drive to deal with the gate capacitance while doing PWM, as with PWM it’s switching all the time, and slow transitions mean slower switching, more heating, and therefore worse Rds and more heating. I’ll need to do some testing, but my guess is that with a PWM rate of 250 Hz it probably won’t be a significant problem in typical usage patterns.
If it does turn out to be an issue, I’ll add a small bipolar in front of the mosfet. That will give me lots of drive for very fast switching plus a higher Vgs for a lower Rds. It will invert the PWM so I’d have to flip things in software, but that’s simple enough. I’m hoping to avoid it because it will require two resistors per channel, so it’s a nice 8 MOSFETs by themselves or with an added 8 bipolars and 16 resistors, which makes building the boards more of a pain (the cost is of the bipolars + resistors is a few cents per channel).
My current thought is to make the boards stackable like arduino shields, and I think I have a scheme that works.
I have the ESP32 boards in my hot hands, but I need to get my hands on some of the MOSFETS to do testing. In parallel, I’m going to start the board design.