Monthly Archives: April 2019

WS2811 Expander Part 6: of MOSFETS and voltage drops…

After I wrote the stress test article, I decided to put a voltmeter across the drain and source of the MOSFET and figure out what the voltage drop was. I hooked up the output to an LED ornament, watched the brightness cycle up and down, and put my probes on the MOSFET.

What I expected was pretty simple. In the sweet spot of the MOSFET I’m using, it claims a Rds – resistance between drain and source – of 10 milliohms. That means I should expect a voltage drop at 5 amperes of:

V = 0.01 * 5 = 0.05 volts

That low voltage drop is one of the reasons to use a power MOSFET; a bipolar transistor would have a voltage drop of about 0.6 volts, and therefore waste more power and get hotter.

The voltage jumped around a little, and settled down at full brightness:

0.8 volts

Okay, that is really unexpected; I played around with different voltages, and I still got 0.8 or 0.9 volts.

My first thought was that the MOSFETs that I got from Ebay might be counterfeit, so I waited for my order of real parts to show up from Arrow, built a new board, and it read:

0.85 volts

This is really confusing, so I asked a question on Reddit’s /r/AskElectronics subreddit.

The first answer I got was that it might be the base diode because I had the MOSFET backwards.

So, I pulled out the datasheet for the MOSFETS and looked at my schematic and board in Kicad. As far as I can tell, everything is wired correctly.

A deeper answer suggested that if I was doing PWM (I had been testing at brightness = 250 because I knew that would be more stressful for the MOSFET than always on), I should test with always on. It also talked about gate capacitance.

<digression>

This is one of those cases where real devices diverge from ideal devices. FET stands for “Field Effect Transistor” – current through the source and drain is controlled by the field on the gate. You establish a field by the flow of current to charge it up to an appropriate voltage.  The amount of current it takes depends on the gate capacitance (described as “Input Capacitance” on the datasheet). For the MOSFET to turn on, you need to flow enough current to establish whatever voltage you want on the gate.

Or, if you think of the gate as a capacitor, it takes a bit of time for it to charge. In my case, the time it takes to charge will be controlled by the pull-up resistance and the capacitance.

Let’s say we are running at 5V, and our MOSFET has 1nF input capacitance (pretty close), and we are charging through a 10K capacitor.

This calculator says that the time constant is 0.00001 seconds, or 10 microseconds.

</digression>

So, I went and changed the animation code to run all the way to full on – luckily my code is running on an ESP8266 and animations can be changed over WiFi – and rechecked the voltage drop.

Would it surprise you if I told you it was 0.8 volts? Probably not at this point…

Perhaps it’s my voltmeter; I have a nice Fluke but how about if I try using my oscilloscope (a Rigol DS1102D I picked up a while back)?

So, I powered it up, hooked it up, and looked at the waveform across the load. I showed the a nice PWM waveform…

But wait a second… I had updated the animation.

My debugging rule is that when things seem unexpected, back out a level and retest the assumptions. Usually one of those is wrong.

I started with my controller code. I suspected the gamma mapping code, so I added some Serial.println() statements and verified that, yes indeed, the colors were getting set to 255. So, that part was fine.

I next suspected the support library I use (the rather excellent NeoPixelBus). I read through a bunch of source but didn’t seem to be any issues. The code all looks fine…

Was the data getting to the WS2811 correctly? So, I fired up the scope again and hooked it to the data line. On full on, the data looks like this:

NewFile0

The WS2811 uses an encoding scheme where a short positive pulse means “0” and a long positive pulse means “1”.

That is a full string of ones; you can’t see all 24 of them, but trust me when I say they are there. You can see this switch back all the way to all zeros as the animation progresses.

So, the software is telling the WS2811 to go to full bright, but it is still turning off for part of the cycle. Here’s the output straight from the WS2811:

NewFile4

That little positive spike is 29.4 microseconds, which is about 5% of the 536 microsecond cycle time, so full bright is only 95% bright.

The cursors on the capture show the start of two sequential PWM cycles, and the scope nicely tells me that it’s updating at 1.87 KHz. Which is another weirdity, since every source I’ve seen suggests that WS2811s update at 400Hz.

At this point I’m beginning to wonder if I have a WS2811 clone. I thought it might be the same IC used in the SK6812 ICs, but the claim is that they have a PWM frequency of 1.1KHz which is less than I am seeing.

So, it’s off in search of some real WS2811s. It is really easy to buy cheap ICs made in China but is surprisingly hard to find an authorized source. There are lots of sources on aliexpress, some looking pretty shady. Octopart found me a 10-pack from Adafruit for $4.95. I finally found lcsc.com, which specializes in this sort of thing, and ordered some. They look to be WS2811S chips, but I can’t find any information on what the “S” means. More on that when they show up.

Back to voltage drop…

Since the WS2811 wouldn’t go into “full on” mode, I needed a test setup to do my testing. Here’s what I came up with:

image

In the right middle is the MOSFET, with clips connected to the lead and the body. In the picture, it is running only the LED Star, which pulls 145mA of current.

One of the fun things about MOSFETS is the gate holds onto the charge, so if you just touch the gate to 12v, it turns on and stays on. Touch it to ground, and it turns off, and stays off. I measured the voltage drop across the MOSFET.

I next decided to hook up my test load. I started with a single 50 watt bulb, a 4 amp load. I carefully hooked it up in parallel with the led star, and…

There was a loud “crack” and the led star went out. No magic smoke, but the MOSFET was toast. The gate was floating, and there wasn’t enough charge there to put it firmly into full conduction, so it was in the linear zone and quickly overheated, melting the plastic on one of my clamps. So… replace the MOSFET, make sure the gate is attached to positive, and try again. That worked, and the MOSFET was only mildly warm. Let’s try two bulbs for an 8 amp load. That worked, *but* there is no heatsink and it got hot pretty fast, so I unplugged it before it got too hot.

I collected some data and figured out that the Rds was about 90 milliohms, which is a lot higher than the 10 milliohms I expected. That was a mystery for about 8 hours, until I was writing this up and realized that I was measuring the voltage drop at the ends of the leads connected to the MOSFET. The thin leads.

So, I went back and measured right at the MOSFET, and got a Rds of 7 milliohms, a bit better than the 10 milliohms that was spec’d. So, yay!

Faster switching

Returning to our somewhat slow switching, here is what I saw:

NewFile2NewFile3

The negative transition is when the transistor turns on; notice how effortlessly and quickly it pulls the gate voltage down. And when the transistor turns off, note how long it takes it for the gate voltage to charge back up. It’s roughly 10% of the overall cycle time.

Which is a bit embarrassing; I chose the 10K value as a typical pullup value, not thinking about the fact that this was happening on every PWM cycle. It can only supply about 1 mA of current.

The most obvious thing to try is to replacing it with a 1K resistor. That will result in 10mA of current and should switch roughly 10 times faster. Can the transistor handle it? The datasheet says that the 2N3904 can handle up to 200 mA continuous, so that will be fine. Is the base resistor okay? Well, transistor has a DC current gain of at least 50, so that means we need a base current of 10mA / 50, or 0.2mA. The 5V from the WS2811 will push about 4 MA through the 1K base resistor, so that’s way more than enough. It would probably be fine with a 10K base resistor, actually.

I took one of the boards and replaced one of the 10K resistors with a 1K resistor and then looked at the gate drive:

NewFile5

In case it’s not obvious, the top version is with the 1K resistor and the bottom one is with the 10K resistor. More than good enough for my application.


You meet the nicest people on the Zoo

Yes, “on the Zoo” is a strange wording; the reason for it might become apparent.

This afternoon I went on a bike ride. I go on a lot of bike rides; most of them don’t really warrant mention (got on the bike, rode, went home). This one might have showed up on Facebook as I sometimes do, so that my riding friends can “like” the ride as an indication of their recognition of my awesome cycling prowess (not really), and the rest of my facebook friends can… well, I’m not really sure what they think of those kind of rides, though “what a nutjob” is probably a good start…

You can look at the – which I cleverly named “A Grand Squaky Zoo” after the three hills I climbed (Grand Ridge, Squak Mountain, Zoo hill) – here. 38 miles, 4186’ of up, which is a lot for me in April.

But I digress…

The climb up Squak was a bit more painful than I had hoped, and I planned on skipping the Zoo hill climb, but I had to ride by it on the way home and turned up the hill on the spur of a moment. And immediately thought I’d made a mistake, as the bottom part up to the Zoo is steep. I came around the first turn, and noted a rider up ahead of me.

That’s a good thing; riders up in front of you are rabbits and you can focus on getting closer to them.

As I drew closer, I looked at his bike, because a bike can tell you a lot. Steel frame, fenders, pretty wide tires, and a handlebar bag in the front. That’s a touring setup. But many touring cyclists don’t ride hills, which meant it was most likely a Randonneur. Randonneur is a long-distance cycling discipline with events that are pass/fail based on elapsed time, so a 200 kilometer event (120 miles, or nearly 1000 furlongs) must be completed in 13.5 hours. Which isn’t really that out-of-the-ordinary, except that 200 km is the entry-level distance and the routes tend to be more than a bit hilly.

Where it gets to be a bit nuts is rides of 300, 400, or even 600 km; the local Seattle International Randonneurs 600k route involves nearly 22,000’ of climbing, is 383 miles long, and as a 600k has a time limit of 40 hours. There are also 1200k rides with a time limit of 90 hours; in that time you will climb 38,000’.

I like hills, but that seems a bit excessive…

As I pulled up next to the rider – why am I quite a bit faster than a randonneur rider? – I slow down to talk to him. Any distraction is welcome on a long climb, and this one is going to take me 36 minutes today – so we start talking, and he mentions that this is a training ride for him; he rode over from Freemont and he’s going to ride up this climb 6 times and then go home.

6 times. Well, if I was going to ride it 6 times (for about 7000’ of up total), I guess I’d be riding it fairly slowly as well.

Turns out his name is Doug Migden, and he’s training for the Transcontinental Race, a self-supported race across Europe. In 2015, he rode the 4200 km and climbed 35,000 *meters* in 446.5 hours. There’s a great writeup of his experience here.

I often wondered what you do if a 1200k ride isn’t long enough, and now I know. It’s always nice to run into people that are crazier than you as it lets you feel that you are sane.

We chatted and I learned a lot about long-distance self-supported riders. As we got about 3/4 of the way, I turned left to head to the classic top of the climb. Normally I don’t think you have done the Zoo if you don’t do the top, but a) Doug was going to an alternate top, and b) he was doing it 6 times, so I think I’m going to cut him a little slack.

And damn, was that descent cold.


WS2811 expander part 5: 12V stress test…

One of the points of the expander is to be able to drive bigger loads than the 18mA that the WS2811 gives you directly. Much bigger loads.

To do that, I needed something that would stress the system, and I needed to verify that the design worked with 12V.

First off, I needed to cut a new stencil uses the paste layer:

IMG_9501

That’s a bit nicer than the first one; there is adequate spacing between the pads this time.

Aligned it on the board, applied paste & components, and reflowed it. Here’s the result, still warm from the oven:

IMG_9502

All the components self-aligned nicely, no bridges, no missing wires. Perfect.

The only thing I need to do is get rid of the center pad for the MOSFETs, since they don’t actually have a center pin.

How to test it?

Well, I dug through my boxes and found a 5 meter length of 12V LED strip. It says that will be 25 watts. I hooked it up and verified that all 3 output channels are working. It’s running an animation that ramps from 0 to 255 over 2 seconds, holds for 2 seconds, and ramps down for 2 seconds. I chose that because the quick switching is the hardest for the MOSFET to deal with from a heat perspective.

But 2 amps isn’t quite enough. I dug out a 12V power supply that claims it can do 6 amps and hooked it up to one output channel:

IMG_9504

That’s the NodeMCU board in the upper right, powered by LED, the data and ground running to the board, and then some decently-hefty wires running to the board.

More load, more load, more load. I want something that soaks up the 12V. Incandescent car bulbs are nice but I don’t have any handy. But I do have an extra heated bed for my 3d printer; it’s a nice 6” x 6” pc board. Hooked that up in parallel with the lights:

IMG_9505

Ignore the breadboard…

This worked just fine. The board heated up to about 170 degrees, the lights worked fine, and the MOSFET on the driving board just *barely* heats up. My measurements show that it’s switching about 5 amps of current.

The only one that’s not happy is my cheap power supply, which is putting out a nice 10Khz (ish) whine when under load.

I switched over to run it on all the time to see how that affected things. After 10 minutes, the board is up to about 110 degrees, the printer bed is up to 240 degrees, and the 12V power supply is 125 degrees.

I think I’m going to rate it at 6 amps total; that gives a lot of margin, and frankly 70 watts is quite a lot of power for this application.