Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Christmas Village Control System, Using ESP32

Status
Not open for further replies.

For The Popcorn

Well-Known Member
Most Helpful Member
[Not trying to steal MrDEB's thunder....]

Last year, a very short time before Christmas, a friend asked if I could add some bang to his large Christmas village scene. "Sure.... oh wait, you mean THIS Christmas!" Fortunately, I had some boards I had made to drive LED strips and the parts to assemble them, and we were able to 32 groups of lights on a semi-random basis. My friend was thrilled with the results of the quickly created system.

There were a few shortcomings to the system, including the need to run a multitude of wires back to a central location and making all of the connections to 5mm terminal blocks.

I have been thinking of ways to make a more distributed system, where 'local' controllers would connect back to a central controller over some kind of network, possibly RS-422. Then the thought hit to use wifi-connected local controllers. This is even better than a wired network, as it would allow separate installations with no need for wires between them. I'm not sure what the control system between the boards will be yet – possibly MQTT, which is used for home IoT device control.

The Bah Hum board has an ESP32 NodeMCU devkit 1 module, an MCP23018 16-bit peripheral expanded and 16 N-channel mosfets to control the LEDs. The ESP32 module does have 18 I/O pins available, all of which support PWM, but many of the pins have shared functions and restrictions, so there always seem to be less pins available then you plan on. Using the port expander may also simplify control a bit. Sending a 16-bit word to each local controller will control the on/off state of all of the LEDs.

I did want some provision for twinkling/flashing/dimming some of the channels, so four of the port expander's 16 lines are connected to the mosfets via a quad AND gate with four of the ESP's I/O lines (capable of PWM). Global on/off control with the option of special effects.

In the upper left corner of the board is a DC-DC converter to supply ~300 mA to the ESP32 – it can draw a lot of current. The AP1509 can handle 24 volts maximum but I am planning on 12 volt power supplies.

The mosfets can each handle several amps. The entire board is limited to 10 amps, by the series reverse-polarity-protection diode. Reverse polarity protection is a good idea since the user is inexperienced. The downside of this arrangement is the maximum current draw of the board is limited by this diode.

If anybody has OCD, the rotated labels on R21 and R22 will be annoying. I didn't forget to align the labels. R21 and R22 are the 4.7k pullup resistors for the IC2 SDA and SCL lines. All of the remaining resistors are 10k pullup resistors, primarily for the open drain outputs of the MCP23018. Rotating those labels is a reminder when I assemble the boards. The PWM lines have pullup resistors to ensure the AND gates are enabled even if the PWM lines are not initialized.

Schematic_ESP Christmas Village V1_2022-08-04.png



PCB_PCB_ESP Christmas Village V1_3_2022-08-04.png


Notes_220805_093213_908.jpg
 
I did make one change – instead of the series diode for reverse polarity protection, I changed to a p-channel mosfet circuit. The long and short of it is less voltage drop and power dissipation, and a beefier mosfet is cheaper than a higher-current diode. This increases the board current limit to upwards of 20 amps from 10 – this shouldn't be much of a limitation as finding a 20 amp supply would be tough.
 
It sounds like you are well on the way to recreating DMX512, the standard protocol for lighting effect control??

Isn't the ESP32 fast enough to do software PWM? I'd have expected it to be able to do a lot more than that.

Note that simple shift registers would be far faster for controlling low-side FETs; you can run them easily from an SPI port.

eg. a 74HCT595 can run at 20MHz+, compared to 400KHz (?) for the I2C expanders. The I2C expanders are nice if you need mixed I/O or special or configurable functions, but for simple banks of inputs & outputs you can't beat shift registers.
 
I wasn't expecting to be able to find one of these - a [rather battered] custom four channel AC mains light controller we did some time back. These run software PWM (phase control) at 256x half cycle frequency with a software PLL lock to 50/60Hz, on a 20MHz PIC16C73.

I'm pretty sure the ESP32 is more than four times faster, to do 16 channel software PWM? Challenge yourself!

IMG_7523.jpg
 
The ESP32 will do 18 channels of hardware PWM. But if you've used the ESP8266 or ESP32, you will have found that the stated number of I/O pins can be misleading. Some of them, if connected during boot halt the process. Some of them output signals during boot. And some of them are used for flash memory.

I don't need to do anything very fast here – just control and flash some lights in a Christmas village scene (where 'some' might reach a hundred or more).
 
I wasn't expecting to be able to find one of these - a [rather battered] custom four channel AC mains light controller we did some time back. These run software PWM (phase control) at 256x half cycle frequency with a software PLL lock to 50/60Hz, on a 20MHz PIC16C73.

I'm pretty sure the ESP32 is more than four times faster, to do 16 channel software PWM? Challenge yourself!

View attachment 138125

Serious heatsink - did it need it?, or was it something you had to hand?.

I suspect the ESP32 is considerably more than 4 times as fast, they are pretty speedy things, but as 'For The Popcorn' said, they do have a number of I/O restrictions and limitations.
 
Serious heatsink - did it need it?, or was it something you had to hand?.
They were a long run we did for a customer to drive arrays of filament lamps, up to 500W or more per channel with phase control in some products, though most were used with much lower loads.

The heatsink is not all that big, it's an "L" shape with the opto triac drivers etc. hidden underneath; same series as this one:

Heatsink.jpg
 
The ESP32 will do 18 channels of hardware PWM. But if you've used the ESP8266 or ESP32, you will have found that the stated number of I/O pins can be misleading. Some of them, if connected during boot halt the process. Some of them output signals during boot. And some of them are used for flash memory.
That's why I never suggested hardware PWM, purely software.
The only hardware peripherals you need are a timer to create fast interrupts and the SPI port (or I2C) to output to the drivers.

If you make the software compatible with DMX512 at the most basic level, even if via another ESP on a serial port to buffer or broadcast for WiFi, there is a vast range of free lighting control software you can use to set up sequences, random changes or even music-reactive etc.

This is one of the classic christmas light show videos & that's done using DMX512 stuff:

 
They were a long run we did for a customer to drive arrays of filament lamps, up to 500W or more per channel with phase control in some products, though most were used with much lower loads.

The heatsink is not all that big, it's an "L" shape with the opto triac drivers etc. hidden underneath; same series as this one:

View attachment 138134
It's still a pretty big heatsink, losses in triacs are pretty low, so they don't usually need big heatsinks, and 500W per channel isn't a great deal. I used to replace a LOT of triacs in light units used in discos, when bulbs fail they commonly take out the triac on that channels. It was a nice little earner :D
 
They are convenient, and it makes the overall unit less prone to handling or shipping damage than with smaller flimsier ones.

It's also fused everywhere so pretty bombproof - and we always try to rate things way above the basic requirements to avoid failures in (mis)use.

We never had any warranty returns due to failed outputs as far as I remember.
 
They are convenient, and it makes the overall unit less prone to handling or shipping damage than with smaller flimsier ones.

It's also fused everywhere so pretty bombproof - and we always try to rate things way above the basic requirements to avoid failures in (mis)use.

We never had any warranty returns due to failed outputs as far as I remember.
PAR38's in particular were extremely prone to taking out TRIAC's, as with most incendescent bulbs they commonly go S/C as they blow - and special fuses (which 'might' protect the TRIAC's) cost considerably more than the TRIAC's did.

Nice heatsink though, and I'm fine with the extra mechanical protection it affords.

Oh, and the video was pretty spectacular! :D
 
After talking to my friend, who explained "that several channels died and the ICs were too hot touch with only a few LEDs, but they worked fine when we switched them to another channel" (a few LEDs that should have drawn 10mA or less powered by motor drivers that could supply an amp or more), I decided I needed to add some additional protection.

First, I changed the reverse polarity protection to a p-channel mosfet that will support 25 amps, instead of the series diode that could only handle 10 amps. This should exceed the capacity of any power supply he might us.

Next, I added a TI INA219 power monitor chip to monitor current being delivered to the 16 channels. It will monitor current delivered to all the channels, but since I can control which channels are on, I can measure current supplied to each channel. During setup, I can monitor each channel and warn that a channel has too many LEDs connected. During use, I can periodically run through the channels, and shut off any that have developed excessive current draw.

Of course, a "simple addition" is never all that simple and a lot of things had to be moved to make room. The picture below is from a neat add-on to EasyEDA called iBom. On one side of the screen is a picture like this of the front and/or back of the board. On the other side of the screen is the BOM. As you click each row the part(s) are highlighted on the picture to make assembly easier.

PCB_ESP Christmas Village V1_3.0.F.png
 
I got the ship notice from JLCPCB for my boards. The included a picture of the of board (I don't think it's an actual photograph, just a rendering of the Gerbers) and the solder paste stencil. I hope they have just mixed up the pictures.... I don't think that stencil will work very well for my board!

Before the comments start, I don't have a board design that looks anything like this stencil, and the stencil and board are generated from the same set of Gerber files.

SmartSelect_20220813-010310_Email.jpg
 
I've never any issues with JLCPCB, and as they do inspect the boards during production, I'm sure they would have caught such a glaring and obvious fault.

However, if not, please post a picture of the boards you get :D
 
I did have a pair of boards made a few years ago. One of the boards had four 8mm holes to slide down switch shafts and the other board, instead of those holes, had a socket for the switch in each location. The board outlines were identical as far as mounting holes in the corners and a notch out of one side of the board.

Imagine my surprise when the first board fit perfectly around the four switches, and the second board had 8mm holes where the sockets were supposed to go! Putting a large hole at the same position as a component is a pretty difficult mistake to make, and checking the Gerber files showed no errors there.

It was explained to me that setting up the milling for the large holes was a manual operation for the fab house, and the technician saw two boards with the identical outline, so he copied the setup from the first to the second without much thought.

Now the long wait for a couple weeks to see the results! I did email support asking if they could verify the correct stencil was shipped and if not to send the correct one.

Somewhere, there's a guy who will be wondering why he has a stencil that doesn't fit his triangular arrangement
 
JLC support replied. The picture is in error. Here's the stencil as built:

SmartSelect_20220814-102628_Email.jpg
 
I'm *almost* sure the right stencil will be included.
 
An update on shipping.....

I ordered parts from LCSC and had them shipped via 'Global Direct Standard Line', which was about 2/3 the cost of DHL. The package arrived yesterday, 2 weeks to the day from when it was shipped.

My boards from JLC were shipped via 'Global Direct Line Saver' last Friday, and should arrive this Saturday, so 8 day service. Again the cost was roughly 2/3 the cost of DHL.

The 'last mile' of both shipments is via the Postal Service, so there's not one point of contact using this shipping method and more opportunity for shipments to go astray, but I am satisfied with the service.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top