Well now. I see that I haven't posted on this blog for several years! Time flies when you're having fun, I guess. There's lots that's happened since 2008: The death of my father and Michele and I getting married for starters. Having my indentures sold to another company is another. We'll see if I can get into the swing of blogging -- if I can, then I'll cover some of those.
Today's post is about a new project that I've started. Or maybe it's a new incarnation of an old project. You can be the judge.
Over the years, I've had an interest in some special-purpose computers called Programmable Logic Controllers (PLCs.) The interest stems from a job that I really, really, really wanted, but didn't get, in part because I lacked experience with PLCs as well as real-time embedded systems. I still want that job although the possibility of it happening diminishes with every passing year.
Be that as it may, PLCs are very interesting to me. They're used in many applications, mostly in industrial control. That silver box at the street corner that controls the traffic lights? It's got a PLC inside. Elevators, big refineries and car washes? PLCs control them.
I'll be blogging lots about the architecture of PLCs. For the moment it's sufficient to know that they typically consist of a controller running a program, along with a set of peripheral interfaces (usually called "modules") that connect to the things that are being controlled. Modules can be very diverse, ranging from simple control of low-voltage DC circuits to high-voltage, high-current motor drivers.
The language the PLCs are programmed in is generically called Ladder Logic. Many (most? all?) PLC systems support higher level abstractions such as Sequential Function Charts or even C/C++ and Java. True to its name, ladder logic programs look like ladders, with vertical side rails and horizontal rungs. Rougly, each rung represents a set of logical conditions and an output operation. For the programmers amongst you, each rung is an if statement; it it's simplest form, an if statement with a single thing in the "then" clause. The ladder program is executed in a continuous loop, testing input conditions and setting output conditions with each rung.
Over several years, I've sporadically worked on a PLC emulator. Written in Java, it's been a useful project for learning a lot of things. I've experimented with various design patterns, as well as Java language features. Things that I can't do so much in my day job, since we're under perpetual insane deadlines. I've seen too much code in my life where someone tried to use a design pattern that they read about, but never experienced implementing. There's a learning curve to this stuff and production code isn't the place to do that learning.
Other things I've learned about/played with: JAXB for parsing and generating XML and the Eclipse plug-in development kit. Eclipse GMF graphic modeling. Subversion source control. I'm sure that there are others.
I've become somewhat bored with the project, though. Learning is wonderful, but the end result is something that does nothing useful but inconvenience a lot of electrons. Writing a ladder logic program and watching the emulator run it, changing an output from false to true has a limited entertainment value. Real PLCs can control real things, like model trains. So I started looking for devices that would act like PLC modules, but could be connected to my PC and driven by the emulator. While looking for those, I came across microcontrollers (MCUs).
MCUs are small computer chips that can be embedded in a lot of things. Your cell phone likely has an ARM chip. Your car certainly has a microcontroller or two in it. When I say "tiny," I really mean it. The ATtiny25 from Atmel is an 8-pin chip and has a whopping big 2K in program space, along with 128 bytes of RAM! They're also cheap. I found the ATtiny85 (8K program space) for $0.69 in large quantities. $1.18 individually.
There are whole communities of open hardware enthusiasts working with MCUs. There are many, many platforms that can be used to prototype things and to build one-off projects. I've got an Arduino Uno which uses an 8-bit MCU (two, really) from Atmel.
So, why not combine these two interests, PLCs and MCUs, into one project? Build an open source hardware PLC system based on microcontrolers. That would give me more cool things to learn without costing too much. That's what my new project is. It's going to involve hardware and software devlopment. Custom PC boards! Soldering surface mount devices! Wheeeeeee! Since everything in the world needs an acronym, I'll call this project BASPLC. The "BAS" comes from a family joke that I've used as a business alias over the years. It stands for "Blind Ape Software." The family joke is that whenever someone did a project that didn't come out quite right (as in most of the time), we said the project was put together by Blind Ape Inc, or some variation. There's a family movie floating around that was produced by Myopic Gibbon Productions.
Before we continue, yes, I know that there's an existing open PLC project out there. I glanced at their web site briefly and then backed away, since I don't want to inadvertently appropriate some of their intellectual property. I backed away very quickly once I realized that their software was licensed under the Gnu Public License (GPL.) I've got a strong philosophical dislike for the GPL.
Besides the aforementioned learning opportunities, this project will give me a chance to go back to my "roots," so to speak. On the electronics/hardware side, I've had a fascination with circuits and circuilt design (digital for the most part -- analog circutry drives me nuts.) I had a copy of Don Lancaster's RTL Cookbook (warning big PDF!) I loved the digital circuits lab that I had as a freshman at UCLA -- I think that if I hadn't gone into software, I would have been an EE. There are tons of resources out there for the hobbiest, including some that are great for more software-oriented people like me.
On the software side this project takes me much closer to the "iron" (hardware.) I started programming with programmable calculators with what amounts a very simplistic assembly language. I've written lots of code in S/360 assembly language (not to mention 6502 and 80186 processors.) These systems were very limited in resources; one of the first mainframe computers I ever used was an IBM S/360 model 25 with 64K of memory. I think you can buy a refrigerator with a bigger processor in it. But that 360/25 was sufficient to run the business office of a major university. In today's world of nearly unlimited computing resources, I miss the challenge of trying to fit something useful into a small system.
I'm hoping that I can sustain the project and blogging about it. I don't have much confidence, I'm afraid. I have this problem with starting things and never finishing them. My sons were chiding me that I have a shorter attention span than a young child! Sadly, they're right. So, no promises, just a hope that this will continue. One motivation: I've been paying for this blog all along and it's become nothing but a dumping ground for SPAM. I deleted nearly 500 SPAM messages this morning!