The birth of a design
Table of Contents
The ET-AL01 Analog LED Controller
The process of designing a circuit starts with an idea. Sometimes the idea is based on a question of someone else, and sometimes it is just seeing the need or fun of something 🙂 .
For a design there are always some parameters which need to be specified:
- What will be the function of the design. Where will it be used is a big part of the answer to this question.
- What will the inputs and outputs be? Think in the way of “sensors” and “actuators”.
- How many IOs (channels) are required?
- If there are high power outputs required, what is the expected max. current per output?
- If there are inputs required, what voltage levels will be used?
- Does it need to be low power (USB) fed, or will another form of power supply be used?
- Is there a physical size limitation?
Let’s discuss the parameters of the AL01 design based on the above questions. The AL01 design was the first design I made, before we decided to setup the website espthings.io .
What will the function of the design be?
The question was asked to me if I could design a circuit based on an ESP32 or ESP8266 controller, which allows easy integration with home automation software using the ESPhome framework, with 5 analog outputs to control LED strips with the standard RGB LEDs and Warm White and Cool White LEDs. The reason behind the question was that online there are nice 3 channel dimmers available and some much higher channel count (like 10) dimmers. The 3 channel versions were not usable, while the 10 channel version was too big, and too costly to build. The dimmer needs to be able to dim LED strips which are fed by 5V – 24V power supplies.
Therefore the answer to this question is “A five (5) channel analog dimmer. Input 5 – 24V. Controlled by an ESP32 or ESP8266 WiFi module”
What will the inputs and outputs be?
Initially the design only included 5 PWM driven channels. Later on a few GPIO inputs were added for flexibility.
How many IOs (channels) are required?
Outputs: 5 “analog” PWM channels
Inputs: At least 2 GPIO inputs
If there are high power outputs required, what is the expected max. current per output?
Yes, the outputs need to be high power. A minimum current of 2A per channel needs to be achieved. (10A in total)
If there are inputs required, what voltage levels will be used?
The inputs need to be able to work with 3.3V and 5V input signals.
Does it need to be low power (USB) fed, or will another form of power supply be used?
This design needs to be able to run from the same power supply as the LED strip. Therefore it needs to be able to handle input voltages of 5 – 24VDC.
Is there a physical size limitation?
In this case, the specific request was to make it fit inside a nice looking enclosure, which proved to be a challenge in a different manner than anticipated. But we managed 🙂 .
With these answers I went to the drawing board, which in my case is “Eagle” software, and started to draw the initial circuit.
In this blog post I want to mainly focus on the selection of the MOSFETs for this circuit, and how to drive them in the best possible manner.
MOSFETs and Transistors
In many circuits semiconductors in the form of Bi-Junction-Transistors or (MOS)FETs are used. In digital circuits they are normally used as a switching element. The BJT (like an NPN or PNP transistor) is a current driven / controlled device, and a (MOS)FET is a voltage controlled device.
For this basic, very simplified!, explanation I will use the NPN transistor and a N-channel MOSFET.
In case of the NPN transistor, the current flowing from the Base to the Emitter, controls the current flowing from the Collector to the Emitter. The transistor has a characteristic, called the Hfe, which specifies the relationship between these two currents. The Hfe is just a “gain” factor. For low power transistors this can be 200x, for the higher power transistors this normally drops to under 50x. If we use the NPN transistor as a switch, for which the collector – emitter junction needs to be driven into “saturation”, and since the current we want to be able to switch for the AL01 design is at least 2A, we might end up with a current of at least 40mA through the base – emitter junction. This is a rather large current to be driven by a microcontroller like the ESP series, so we need to use a buffer stage in between the microcontroller and the transistor. Since not all transistors are made 100% the same, we need to make sure that transistor is “fully open” even when the Hfe is not very high. This results in large base currents to overcome the spread in the gain factors. Also, because it is a current driven system, there will be a power loss in the system, defined by the square of the current multiplied by the current limiting resistor feeding the base of the transistor.
An N-channel MOSFET is a voltage driven device. The potential difference (voltage) between the “Gate” and “Source” controls the resistance of the resistor channel between the “Drain” and “Source”. The higher the voltage between the gate and source, also known as “Vgs”, the lower the resistance between the drain and source, also known as “Rds”. The current flowing into the gate is very low. The MOSFET has a “resistance” between the gate and source which runs in the tens of megaohms! The gate will act like a very small capacitor which needs to be charged up to “open” the drain-source path. Once this “capacitor” is charged, the current will be extremely small.
A N-channel MOSFET will have a very high Rds when the Vgs is 0 volt. There will need to be a minimum Vgs voltage for the MOSFET to start to conduct. This voltage is called the “threshold voltage”, Vgs-th. When the Vgs exceeds the Vgs-th, the channel between the drain and source, Rds, will be relatively high in resistance. If we want to use the MOSFET as a switch, we need to ensure that the Rds is as low as possible, to limit the power dissipation (loss) in the MOSFET itself. This will require a much higher Vgs voltage than the Vgs-th voltage.
Due to the fact that the input resistance of the MOSFET is so high, it is a very sensitive device to static charges, or stray voltages. Therefore it is mandatory to clearly define (control) the voltage on the gate. If we would just connect it to the ESP microcontroller, the MOSFET might start conducting when the pins of the ESP microcontroller are not initialized correctly. (Like during the startup process, which can make them high impedance, or “floating”.)
The ESP microcontroller will output either (close to) 0V, or (close to) 3.3V. If we want to drive a MOSFET directly with a voltage of these levels, we need to use a MOSFET with a Vgs-th which is considerably lower than 3.3V.
With the characteristics of the NPN BJT and the N-channel MOSFET in mind, we can make the choice what we would like to use. In general for high power switching it makes more sense to use MOSFETs, since it will require a lot less power to drive. However to drive a MOSFET properly, we will still need to use an intermediate stage between the ESP microcontroller and the MOSFET to increase the MOSFET driving voltage.
The next step is to select the MOSFET we will use for the design.
One of the goals of our projects is to keep the designs as affordable as possible. Therefore we had a good look at AliExpress for cheap high current N-channel MOSFETs, of which many different types are offered. There is a mix of MOSFETs of Asian manufacturers with their own model names, and types which have European or American brand model names. Asian brands tend to be cheaper, but less easy available outside of Asia, while the other European and American brands are available worldwide. I selected about 5 different options, of both Asian and other brands, and had a look at the datasheets. I ended up selecting the IRLZ44N MOSFET, of which I will use the datasheet to explain why I made this choice.
Keep in mind that I mentioned the intermediate stage between the ESP microcontroller and the MOSFET, which will shift the driving level from the 3.3V of the ESP microcontroller to 5V.
Why the IRLZ44N MOSFET?
When reading the datasheet one of the first sections shows this:
The key words are “Logic-Level Gate Drive”. This indicates that the Vgs-th is low enough to be driven by “logic levels”, which generally means by 3.3V or 5V. That is a good start!
Then we read this:
So the minimum Rds(on), which is the minimum resistance between the drain and source connection of the MOSFET, is 22 mΩ! That is a nice low figure, since it indicates that the MOSFET is capable of switching pretty high currents, which is also indicated by the Id of 47A. You might wonder why we are looking at a MOSFET which can switch 47A, when we just want to switch 2A? Well, as you will later find out, this allows an easier thermal side of the design.
Next page we read this:
Here we can see that when we drive the MOSFET with 5V, the Rds(on) will be only 25mΩ, when the current through the drain-source channel is 25A. So another good figure for our use!
Next page we find some curves. Lets look at the curve showing the relationship between the drain-source Voltage (basically the voltage we are going to switch) and the max. current capacity at that voltage, in combination with the gate (Vgs) voltage of 5V;
The graph does not show a specific curve for a Vgs of 5V, but it does show a curve for a Vgs of 4.0V and Vgs of 6.0V. We can assume that the curve for a Vgs of 5.0V will be halfway in between the 4.0V and 6.0V curve. What we can see in the curve is that the MOSFET is fully saturated when we use a Vgs of 5.0V and a Vds of 5V (That is where the possible curve of a Vds will become horizontal) . Since we are going to use a Vds of 12V or 24V, the MOSFET will be fully saturated with the Vgs of 5.0V. Fully saturated means that the channel between the drain and source will be at its minimum value.
All good characteristics for our use!
No matter how good of a MOSFET we will select, the resistance between the drain and source will never reach 0Ω when driven into saturation. That means that we will always have some heat dissipated in the MOSFET. The easy formula to calculate the heat generated is: P = I² x R.
In the previous section we found out that the Rds(on) of the MOSFET is 0.025Ω when driven by a Vgs of 5.0V. If we use 2A as max. current through the MOSFET, then the total power dissipation will be: P = 2² x 0.025 = 0.1W.
What does that mean? Well, in the datasheet there is also a thermal resistance section:
The parameter we will look at is the “Junction-to-Ambient” thermal resistance parameter. It is listed as 62°C/W max. This means that if the MOSFET is not mounted on any heatsink, but just sits in air, for each Watt of power dissipated in the MOSFET, the temperature of the junction will rise by 62°C max. Luckily the max junction temperature is also listed in the first part of the information of the datasheet, which is 175°C for the IRLZ44N. Since we need to take into account the ambient temperature, which we will set to 25°C, we can see that the max. temperature rise of the junction is 175 – 25 = 150°C.
The 2A current through the junction will create a power dissipation of 0.1W, as we previously calculated, and it will create a temperature rise of 62 x 0.1 = 6.2°C. So no problem at all!
If want to calculate what the max. current is what we can switch, without exceeding the 175°C, we do it as follows:
Max. junction temperature rise = 175 – 25 = 150°C. We divide the 150°C by the 62°C/W “thermal resistance”, we find that the max. power dissipation in the junction can be 2.41W. Using the same formula to calculate the power, we find: 2.41 = I² x 0.025 . Therefore I² = 2.41 / 0.025 = 96.77. That means I = √96.77 = 9.83A!
This is of course the maximum current, and will make the case of the MOSFET very hot. But it does show that the 2A can easily be increased to 5A. A current of 5A will give a case temperature of 64°C, with an ambient temperature of 25°C.
The above calculations are based on a “worst case” scenario, which is in this design the situation that the outputs are 100% of the time switched on. Basically lit at max. output power. If the LEDs are driven at 50%, the power dissipation in the junction will also decrease by 50%, which will result in a much lower case temperature.
All in all the IRLZ44N is a very suitable MOSFET for our design. It is capable of switching to saturation at the driving (Vgs) voltage of 5.0V, and the thermal resistance is such that we can easily drive the 2A per channel, without the need for a heatsink to mount the MOSFETs on.
Driving the MOSFET
As mentioned before, an intermediate stage, between the ESP microcontroller and the MOSFET, is required, to shift the voltage from 3.3V to 5.0V. For this use I have selected an octal tri-state buffer. This is just a difficult description of a chip which takes an input voltage level of 0 or 3.3V and will create an output of 5.0V. The chip is capable of going in a mode called “tri-state” which basically makes the output of the buffer high impedance, or floating. This mode can be selected by driving a control pin to > 2.0V. To ensure it is not going into this state, the control pin needs to be connected to a voltage of < 0.8V. This will force the output pins into “defined” states, either at 0V or 5V. If the voltage on the input pin, not the control pin, is < 0.8V, the output will be 0V, and if the input pin is > 2.0V, the output will be 5V. In practical terms this means that the MOSFET connected to the output is either fully closed (high resistance between the drain and source), or fully conducting (low resistance between the drain and source).
The driver of choice is the 74HCT244 . It is very important that the chip is the 74HCT244 version of the chip, and not any of the other available models. The reason behind this is that the “HCT” range of ICs is capable to interface on the input with a 3.3V microcontroller, and will drive the outputs to either (practically) ground or the supply voltage of the chip, which is in our case 5.0V. Other types will not work with the input voltages of the 3.3V microcontroller, or are not able to supply on the output pins enough current to drive the MOSFETs. Remember that the gate acts like a small capacitor which needs to be charged to “open” the drain-source channel, or discharged to “close” the channel again. This requires a small current to do so, which needs to be supplied by the driver.
Build the ET-AL01
Make sure to subscribe to our YouTube channel so you won’t miss any of our upcoming project videos!