Project Log: Flickering torch lawn lights - Page 1
Forum section: electronics / projects

author: resistor
author_rank: Regular Contributor
timestamp: February 10, 2014, 06:48:52 am
content: I'm a relative newbie to electronics design, but I thought I'd share my ongoing attempts at my first "big" project attempt: flicker torch lawn lights!My house has a set oftherelawn lights along the driveway. They're powered at 12VAC by a big transformer box in my garage that is pretty much just a big 10:1 (isolation?) transformer with some mains-frequency-driven timer functionality.When I bought them a year ago, those lights came with little incandescent bulbs rather than LEDs, which of course burnt out in a remarkably short period of time. I replaced them withtheseLED modules. I ordered the yellow module, thinking it would make a nice warm lawn light, but it turns out that the filter on the fixtures imparts an orange-ish hue. Not what I was shooting for, but it did inspire the idea that I could build my own modules to put into them to simulate flickering torch light as a Halloween prop!As luck would have it, the place I ordered those modules from has mechanical drawings of the module available on the Specifications tab, and from that it looks like I should be able to interface with the socket via PCB edge pads with some solder build-up to thicken it.

author: resistor
author_rank: Regular Contributor
timestamp: February 10, 2014, 06:55:10 am
content: Starting PointsSince this project is for fun rather than any practical purpose, I'm going to take the opportunity to incorporate some things I've been meaning to play with:WS2812b Smart Tri-Color LEDsTri-colors is probably overkill, but it means I could possibly repurpose them for Christmas lights or something else in the future. Using ones with an onboard controller will let me get away with a very low pin-count MCU. These may end up being a bit of a pain to interface with the MCU, so I might regret this decision.LPC810 DIP8 ARMI got a handful of these from Digikey last time I placed an order, and I haven't had a chance to play with them yet. I'm planning to use them as the MCU in this project, though I might switch to an SMD version once I've got the basics hammered out.LT4320 Ideal Diode BridgeAgain, totally overkill for this project, but I enjoy optimizing my projects for minimal power dissipation, and I don't think I'll end up being space constrained within the housing.

author: resistor
author_rank: Regular Contributor
timestamp: February 10, 2014, 07:15:11 am
content: Week 1I spent some time getting acquainted with my parts this week. I had ordered some WS2812B's mounted on little PCBs from eBay that I thought would be breadboard-friendly, but they actually came with no through holes for leads. I got the first one all leaded-up... and promptly reversed +5V and GND when connecting it. Apparently these things have very little reverse current protection, for future reference.Undeterred, I soldered leads onto a second one, and this time was more careful connecting it to an Arduino Uno I have sitting around. I loaded upAdaFruit's NeoPixel Libraryand was able to run the test program strobing pretty colors.The next day, I set out to do some similar experiments with my LPC810 ARMs. I had ordered a USB<->Serial adapter (again from eBay) that was billed as using 3V3 logic levels... which turned out to be a lie. On the upside, I'm pretty impressed with the over-voltage tolerance of the LPC810s. I was able to program one while powering it from 5V, despite it's maximum rated voltage being 4.7V. The program didn't run properly when powered that high, but it worked properly once I changed the power supply down to something reasonable! For the moment, I'm using the 3V3 regulated output on the Arduino to provide 3V3 power over to my breadboard. I have some LM317s I pulled from a dead oscilloscope that I'll hook up to provide 3V3 regulation when I get less lazy.The next step was to get started with programming the LPC810. I'm a compiler engineer in my day job, and I've worked on compilers for ARM in the past, so I'm generally quite familiar with toolchains, and ARM toolchains in particular. All of that said, I'm pretty underwhelmed with NXP's toolchain offerings. LPCXpresso probably contains everything you need, but it's really poorly organized and documented. After playing around with it for a couple of hours, I gave up and went with an open source toolchain instead.I got aGCC-based ARM toolchainthat's sponsored by ARM, and anopen source codebasefor the LPC810. Just reading the headers from there ended up being much easier than trying to figure out NXP's tools.At the end of the evening, I was able to build and program the blinky test program with some personal tweaks, and watch an LPC810 blink away at a red LED on my breadboard!DigressionI spent one more evening working on this project, but got a bit sidetracked. I wanted to dig deeper into understanding the codebase for the LPC810. I made a test program that did nothing other than call the basic CMSIS initialization routines, and found that I was already using 1KB of the 4KB on my chips!!!I spent a while tearing that down, and found that the codebase comes with pre-written interrupt handlers for the MRT timer (used for delay functions), and for a couple of other things. I was able to rip those out, and got my binary down to about 450 bytes. That still seemed inordinately high to me, so I dug into the remaining code, which was primarily C runtime initialization and core configuration.When I've worked on ARM compilers, it's always been for application class cores, so code size was never the emphasis. I'd always assumed GCC did a pretty good job of generating small code for MCU cores, but what I saw was pretty discouraging. The CRT code is nothing more than two loops through arrays, and GCC completely failed to use ARM's incrementing addressing modes. Hand-writing the CRT code in assembly, I was was able to make it about 20% smaller in about an hour. Eliminating it entirely (since my test app didn't need it), I was able to measure the size of the minimal amount of code to initialize the core about about 200 bytes.