ESP-12E ESP8266 NodeMCU with ULN2003 Darlington IC provides PWM for 12Vdc devices like LED Lantern and DC Fan |
In Part 1, we saw that it was fast and easy to test Pulse Width Modulation (PWM) using an ESP8266-based NodeMCU ESP-12E development kit. To control a real device we increase the power rating of the ESP-12E's output pins D5 and D6 from 3.3V to 12V using darlington transistors.
Since we are all about fast and cheap prototyping, a handy darlington is the ULN2003. It is actually 7 darlingtons in a 16-pin package but is rated 50Vdc at 500mA and is cheaper than many single (ie discrete) darlington transistors.
ULN2003 is actually 7 Darlington Transistors |
Prototyping PCB |
Bob "My favorite programming language is solder" Pease |
Notice I have used an IC socket for the ULN2003- when dealing with motors and high voltages, mishaps are to be expected; it may need to be changed in a hurry. Notice the socket is only a 6-pin DIP originally meant for optical isolator ICs. This means I am only using 2 out of the 7 darlingtons. Feel free to cut off the dangling IC legs or even better simply turn them up out of harm's way. The extra metal helps to dissipate heat from the darlingtons.
Live bugs: ULN2003 and ESP-12E assembled on prototype board |
Same board, solder-side. |
Also I only soldered 3 pins of the ESP-12E board, plus an extra 3 pins at each corner for mechanical strength. This makes it easy to de-solder the ESP-12E for other projects.
There are 3 pairs of wires: one for 12V DC power supply, and one each for each of the two PWM outputs. The idea is to tie one end of the load (fan, LED, etc) to 12V and the other to the darlington output so that the ESP8266 and turn it off and on at will.
I really should have used different colored wires for each pair but I did not have enough wires of the correct gauge, so had to make do with a little duct tape and marker pen.
PWM output wires are 12V (red) and darlington collector (black) |
For a long and happy life for the ULN2003 while driving inductive loads like DC motors, I have also connected a 12V 1W zener diode, forward-biased from 12V to pin 9. It is a little counter-intuitive but you are strongly encouraged to read Douglas W Jones' venerable work on stepper motor drivers, using among others the ULN2003.
Douglas W Jones: his kung-fu is strong ... |
To minimize damage from wiring mistakes and the like, first check the unpowered, unconnected board for short-circuits, especially between 3.3V and GND, 5V and GND and 12V and GND. Next check for ESP-12E and ULN2003 shorts to 3.3V, GND and 12V.
When testing, it is advisable to first not to connect to 12V power and just test with a power bank. Then test with 12V on. If it works well enough test with a powered USB hub rather than directly from your laptop/desktop. If you must test with a desktop try using a USB port from a PCI daughter card rather than from the mainboard. This is to avoid damaging expensive kit like laptops, desktops and servers.
There you have it, a PWM board you can build in half a day. It can control DC devices up to 50V at 500mA like CPU cooling fans, LED lights, and alarm sirens.
Happy trails.
No comments:
Post a Comment