Wildlife Cameras

Installed some new wildlife cameras. Haven’t seen anything new/unusual yet other than this “non-typical” deer:

Christmas Lights 2018

They are (finally) sort of working. There seems to be a wiring problem with some of the strings; consequently they are “out of sync” (e.g., red when the rest are green, etc). I am hopeful that will be fixed Friday… in the meantime, I just choose to interpret the cacophony of color as “festive” 🙂

 

 

Christmas Lights 2017

This is an update on the technology being used to drive my Christmas light display this year.

QUICK OVERVIEW

I have about 1100 feet of Red/Green/Blue LED strip around the perimeter of my roof. Because of length limitations, this is implemented as eight separate sections, each with its own separate controller. There is also a separate section on the observation tower, with its own controller.

These controllers can receive infrared (i.e., standard remote-control) commands. To control them I built an IR repeater circuit using an Arduino and wrote some python code to drive everything.

Last year’s detailed write-up is still generally correct, aside from anything new I write about here.

THIS YEAR’S IR REPEATER CIRCUITRY

At the end of last year I prototyped a modification for controlling the roof perimeter (8 strands / 8 controllers) separately from the observation tower. With this modification I can have the roof perimeter all be one color while the observation tower is another color, or blink the tower but not the roof, and vice versa. I still can’t control individual strands on the roof perimeter (entire perimeter will always display identical color); however, since the boundaries of these strands are haphazard (they occur wherever one strand ends and another begins) and coarse (there are only 8 strands across the entire 1100 feet of perimeter), it’s not clear that viable effects could be had by controlling those individually. Though I may try that next year anyway (haha of course).

This year I implemented a new version of the IR repeater circuitry to let me control the roof perimeter (as a whole) separately from the tower. The new circuit looks like this (click image to open it full size if you want):

 

 

This is just a refined version of the modification I performed last year.

To control the roof perimeter, I have eight individual infrared emitters taped onto the receiving area of each of the eight controllers (one controller per strand) scattered around my roof perimeter. The leads from these emitters are connected to wires that all run back to one spot at my house where I have connected them all in series, with additional components as shown in the above circuit diagram.

The advantage, in my application, of connecting them all in series is that if any one of them fails, I’d rather have all eight of the lighting strands become non-responsive, rather than having all but one of them responding to commands. That would look wrong; it’s better to have them all stuck on one color plus that would make me notice the problem right away. This is all theoretic, as no IR emitter (or wire leads to them) has failed this year or last.

Power for the IR emitters is supplied this year by a 12V regulated power source.  Last year I used an unregulated wall-wart; this year I am using a scavenged PC board power supply.

The 38KHz IR digital PWM signal comes out of my Arduino on pin3, all as described in last-year’s article write-up. This signal drives a MOSFET gate to modulate the power to the entire string of IR emitters (which together require more power than the Arduino can drive directly; hence the 12V supply for that part of the circuit).

However, rather than feeding the 38KHz signal directly to the MOSFET gate, it is split into two and fed into two separate AND gates from an SN74HCT08 quad dual-input AND chip. The two “enable” lines – ENA1 and ENA2 – are just simple digital outputs from the Arduino and allow me to separately enable the signal on its way to the two different MOSFETs. By turning ENA1 and ENA2 on/off in my code, I can determine whether IR commands will go out to just the roof perimeter, the tower, or both.

Although we might casually think of the HIGH and LOW inputs on logic chips as being 5 volts vs zero, the TTL spec is broader than that and allows a HIGH to be as low as 2.7 volts. It turns out the SN74HCT08 AND gate output is higher than that, but it is still not high enough to drive the MOSFET gate directly like I was doing when it was being driven directly from the Arduino output pin. For this reason I also inserted a TC427 MOSFET gate driver into the MOSFET gate path. This chip converts a TTL-level input into a rail-to-rail signal (5V/0V in this case) suitable for driving a MOSFET gate input. In general it’s probably a best practice to use a driver chip like this for MOSFETs anyway, even if you are coming directly out an Arduino with sufficient voltage for the 4.5V logic-level requirement of this particular MOSFET gate.

SOFTWARE

I wrote about my software extensively before and put a repository,  arduino-json-IO on github that implements a tiny web server in an Arduino and allows you to send it commands to perform various digital I/O operations. One of those commands allows you to send PWM-modulated IR codes. This makes extensive use of the Arduino IRRemote library to do the actual PWM control.

The IRRemote library outputs these PWM waveforms on pin 3, which becomes the “IR” signal in my circuit diagram above.

The new question, with the enable lines, becomes how to manage those. I could just have used the existing capabilities of arduino-json-IO and explicitly managed the enable lines by writing pseudo-code like this:

# to do something with just the tower
POST "set ENA1 low" command to arduino
POST "set ENA2 high"
POST "IR command for a tower color"

but this is cumbersome and, more importantly, it requires multiple HTTP transactions between the python code driving all this and the poor little arduino generating the IR codes (and enables). Of course, this could be factored out since we only need to send the enable line commands when they need to change from their current state, but that would then require keeping track of the output enable states, and also would be subject to getting “out of sync” if, for example, the arduino server rebooted due to a bug, or a power glitch.

To avoid all that, I decided to customize the generic arduino-json-IO library to add the enable lines directly into the JSON structure sent along with each POST request to the IR emitter code. The way it works now is that the enable lines are set high when an “enable: xxx” directive is encountered in the JSON (“xxx” being the pin to set high) and any pin that was set high as a result of doing that is returned to LOW when the POST request processing is finished. This makes the management of the enable pins be, essentially, an “atomic” operation tied in with each individual POST request that sends IR codes.

The revised code is available here:

neilwebber.com/files/xmas-led/IR-enables.ino

Admittedly this isn’t as “generic” as it could be, but the beauty of something like Arduino is that it’s not unreasonable to customize the embedded software for a specific application, which is exactly what is going on here with this modification.

Given all that let’s review the old way a “heartbeat” effect was created with the arduino-json-IO IR POST command. The JSON I sent looked like this:

[{"codes":
  [{"protocol":"NEC","bits":32},
   {"code":16718565,"delay":525000},
   {"code":16732335,"delay":175000},
   {"code":16718565,"delay":525000},
   {"code":16732335,"delay":1050000}
  ],
 "repeat":10}]

The minimum gap that I found reliable between IR commands was 175msec (175000 microseconds). Call that period of time a “beat”. The above JSON commands the lights to be RED (16718565) for 3 “beats” (about half a second – 525msec), OFF for one beat (175msec), RED for 3 beats, OFF for 6 beats, and then repeats that entire cycle 10 times. This creates a “heart beat” like effect on the lights, all with one POST operation to the arduino server.

With the enable-line modification, that POST request now looks like this:

[{"codes":
  [{"enable":6},
   {"enable":7},
   {"protocol":"NEC","bits":32},
   {"code":16718565,"delay":525000},
   {"code":16732335,"delay":175000},
   {"code":16718565,"delay":525000},
   {"code":16732335,"delay":1050000}
  ],
 "repeat":10}]

Where pins 6 and 7 are my ENA1 and ENA2 pins (roof perimeter enable and tower enable). The arduino server will drive those pins HIGH when the “enable” element is encountered in the “codes” sequence, and will return them to LOW at the end of the “codes” sequence. In this way the management of the enable pins becomes atomic and stateless with respect to any given POST operation.

I wrote some python library code to encapsulate all this into an “XMASLED” object, with methods such as “heartbeat” that would generate the above JSON code and post it to the server. The question then became how to control which enable lines to turn on/off in any given request. I decided to use python context managers for this, instead of explicit “enable” / “disable” method calls. Conceptually the XMASLED object contains two state variables for the enables – “enable_tower”, and “enable_perim”, and the various methods such as heartbeat() use them to form the above JSON. The only thing the context managers do is provide a syntactic sugar allowing these variables to be saved/restored and automatically returned to the prior values on return (or exception) from a nested structure. Thus, the python code to run the heartbeat routine only on the tower, while having the roof be green, looks something like this:

# "X" is the XMASLED object
X.send(X.GREEN)    
with X.tower_only():
    X.heartbeat()

Arguably this is overkill, it wouldn’t have been the end of the world to write:

# (assume both enables are ON already)
X.send(X.GREEN)
X.disable(X.PERIMETER)
X.heartbeat()
X.enable(X.PERIMETER)

but the context manager way seemed a lot prettier, and it is robust against any exceptions (e.g., network down) that might throw us out of heartbeat and up to some higher level without knowing that the internal state for the perimeter enable was still “off”.

It’s hard to know where to stop with this idea of using a JSON data structure as a primitive programming language to have the arduino drive the IR emitters on its own. I’ve drawn the line at the spot we see here; enable pin management, sequences of individual codes, intra-code delays, and repeat counts can all be specified in a single POST command. Anything else requires multiple posts to the Arduino and management by higher-level code (i.e., python in my case).

NEXT YEAR

As I wrote about last year, these cheap controller boxes for the LED strands are really the wrong solution for this application. It’s fun that I’ve managed to build an integrated control system to operate 9 of them in unison via wifi and a baby web server interpreting JSON POSTs,  but every now and then one of the controllers misses a code (just like sometimes your TV seems to miss a button press on your remote control) and shows the wrong color. Plus there are other features people clamor for (“Can the lights change with the music?”) that can never be pragmatically implemented so long as my only control mechanism is limited to imitating an IR remote control.

So, I’m not sure about next year; I think I will be investigating higher-end commerical-grade control systems that already have integrated networking capability and are meant to be controlled “at scale” with multiple units at once. We’ll see…

Redeploying the Christmas Lights!

Almost ready to go again this year. I had a case from my now-dead soekris system; took everything out except the regulated 12V power supply and repurposed the case to hold all this nonsense (including the new “control the tower separately from the roof perimeter” circuit design).

Working in the lab – now to hook it up to the real LED strings (they went up on the roof this week but are currently dark until I hook this back up). Hoping nothing explodes!

My Lutron Experience

I have three Lutron home automation controllers in my house. They operate the motorized window shades and the exterior landscape lighting. My architect wanted me to have many more of these – to control all of the interior lighting. I vetoed that idea and insisted on regular, “you can buy them at home depot” switches for all my interior circuits. I am so glad I did that!

Here’s my Lutron installation with the covers off:

Three Lutron Automation Processors

The reason the covers are off today is because two of them died in a recent power failure. This happens “often”, this is the third time in nine years of owning these that I’ve had to call the automation company in to replace them.

Maybe you don’t think three times in nine years is “often” – but let me ask you this. When was the last time you replaced your microwave oven because of a power failure? How about your TV? Look around your house at all the equipment these days that has a computer inside it – pretty much every appliance you own has one. How many of them have you ever had to replace simply because the voltage fluctuated during a storm and killed the device?

I’m sure it happens from time-to-time, but the consumer-grade appliance manufacturers know that they would have a very bad reputation if their equipment died all the time in power failures. Lutron? Apparently doesn’t care. These processors must have little or no input voltage protection and any glitch on the power lines burns them out. Then, even if just one of them burns out, you end up having to replace all three because the company is constantly obsoleting old versions of these processors when new ones are released. New ones won’t interoperate with old ones.

It’s outrageously bad engineering and it’s hard not to point out that this bad engineering increases sales of the Lutron devices and the billable-hours of the installation/programming service providers.

I “fixed” the “one failed, but you have to replace all three” dilemma by stocking several additional processors the first time I got hosed by that. Unfortunately, today I am having the last spare installed and the next power-glitch will force an upgrade of all three even if just one dies. I am now investigating front-ending the power inputs on these devices with some server-room grade power conditioning instead.

Never, ever, ever, ever, ever allow anyone to talk you into installing this product in your house.

Netgate SG-4860 installed

Finally got rid of the last soekris/pfsense router in my empire. This sg-4860 replaces a net6501-70 that had 8 intel interfaces. I “need” (well, use) five, and have plans for a sixth subnet. The Netgate box has six interfaces so it suffices both for the current needs and the planned one-additional subnet. I don’t anticipate ever going beyond the sixth subnet, and if I do there’s always VLAN trunking options to get more interfaces out of the existing box (and/or multi-hop routing via a secondary router)

Installation went without any glitches. Still running pfsense in basically the same configuration; just had to update the interface names in the configuration XML file.

Now the question is what to do with an old, but perfectly functional, nanoBSD/freeBSD box…

pfsense router – almost 1 year uptime

I’m running a pfsense router on a (somewhat obsolete now but still serviceable) dedicated soekris box as the router for my (40 acre) hilltop “empire”. I have a somewhat complicated network topology: my Time Warner cable modem is in a building at the bottom of my hill but my house is uphill about a quarter-mile (as the wires run) away. I have a multi-mode fiber connection between the cable modem downhill and the router uphill, from which four internal networks emanate:

  • HILLTOP: my internal network.
  • GARAGE: runs back down the hill (on another fiber pair) to a separate maintenance equipment garage building.
  • DMZ: a true, isolated, DMZ topology for a few servers I want to allow access to from the network at large.
  • PUBLICWIFI: a no-password open-WiFi network for my guests; it is also appreciated by maintenance personnel working on stuff up here on the hill. Access control for this otherwise-open WiFi access point is provided primarily by the fact that the signals don’t reach the edge of my property line (at least in all the places I’ve tested for this). If you can get the signal the presumption is you should probably be allowed to surf the internet on my dime 🙂

The pfsense software makes it easy to configure these networks with appropriate firewall rules; for example no traffic is routed between the PUBLICWIFI network and any of the other networks (other than the WAN network to the outside world of course).

About a year ago I put the router on a UPS just because the mean time between power failures up here is about 2-3 months. Anecdotally, thunderstorms are the primary source of periodic, short, power outages/glitches.

Here’s the network statistics report:

Statistics for the hilltop network

As always, you may wish to click to view the image full size.

During the 322 days of uptime:

  • 2.5 terabytes have arrived at my router from the internet. That’s about 7-8GB per day, most of which is presumably netflix or porn (for network tests of course).
  • Of the 2.5TB, 2TB went to the house network and 0.5TB went to the maintenance building where my property manager works.
  • The DMZ served out 5.6GB (a whopping 17MB per day). There are some status servers on this network that my property manager and I periodically surf to check in on things if I’m not here.
  • The public WiFi pulled 20GB down from the internet (about 62MB/day). The maintenance workers don’t seem to surf very much porn 🙂

I had a 12-pair multi-mode fiber installed to run up/down the hill and I am using two of the pairs. One pair runs from the cable modem up to my router. Another one runs back down the hill to the GARAGE to carry the (internal) network back down into the maintenance building. These runs are each about 1300 feet, or about 400 meters. The fiber transceivers I’m using (StarTech MCMGBSC055) are supposed to be good for 550m at 1Gb and appear to be functioning well. There are zero errors across the board except for one output error recorded in the entire year. My guess (and it is purely a guess) is that the output error occurred during a power failure. My router is on a UPS but the transceivers are not, so a power failure that happens during a packet transmission might show up as an output error. Otherwise I’m at a loss to explain how there could be an *output* error detected by the router; I’m guessing what really happened is that the ethernet connection between the router and the fiber transceiver went down when the power failed in the middle of a packet transmission. The router is on the UPS but other network gear is not; the only point of the UPS here is to shield the router from the strain of unnecessary power-glitch reboots; it is not intended to keep my network up during outages.

Knowing a little bit about the waveforms and the technology that makes all this stuff work, I am always impressed that stuff like this actually *does* work.

So far the 1Gb link is faster than my cable modem connection. I’m not going to be able to go to 10Gb without laying new (single mode) fiber. The fiber run is in a conduit with periodic access/pull points, so supposedly this will be possible, but it won’t be especially cheap or easy. Since I have some spare pairs I may be able to get more bandwidth in the future with link aggregation; I’ll worry about that technical problem when/if my internet connection exceeds 1Gbps from the ISP (when is google fiber coming here?!!!)