The homebrew AVR-based PLC – the introduction

Few years ago when I was searching the net for similar projects to gather some stuff for my potential graduate thesis, there was just a plain void. On techie forums ocasionaly some excited novice popped up with greeny questions about what would take to make a PLC, etc., just to get a bunch of “smart” answers about how stupid one has to be for trying to make something that someone somewhere can eagerly sell him. Not much useful, indeed. Sure, people wrote about projects and “PLCs” they’ve made, but almost all of them were just a kind of a relay board with a MCU attached to it – far from being something like the real thing.

I’ve got some vague experience with Siemens Simatic S7 controllers when working for a customer back then and I kind of knew what I wanted. The only real thing I came about was an old article in Elektor Electronics, describing a simple PLC-like device using an 8052 chip. I was quite happy with what I read, bought some chips and wires and started playing with it.

Now, few years latter, designing homebrew PLCs seem to be a popular challenge for hobbyists with articles and projects popping-up everywhere on the net and magazines. And projects and goals of designers are improving and getting more and more complex. Though, last time I checked no one actually set himself to make a device that you could put side-by-side to, say, a Simatic and have them comparable. Not an easy task. Especially for a hobbyist. But without goals set too high, this shouldn’t be too hard. That’s what I thought. And that’s what I still think.

But, perhaps, before we go further with this adventure, I should try to finally answer what point does it really make to spend all that time and money reinventing the wheel everybody can – and most probably will continue to – buy from the “big names”. Because it’s fun creating things! You can’t beat that argument! And it isn’t even about reinventing the wheel. By basing it on platforms like Arduino and designing it in shields etc., any hobbyist would be able to assemble, build and extend his own customized real PLC controller (or part of it) and use it for whatever task he intended. Well, isn’t that a noble cause! And it’s something new indeed.

But, most of all, I need it to finish my thesis. At the time being, I have a working prototype consisting of an AVRUSB646 mini board, a module with the PLC logic and user interfacing, a RS232 module and a simple I/O module with direct interfacing (one MCU pin to one input/output – not the brightest solution, obviously, but it shouldn’t be hard to add a bus-controlled I/O board at latter time). On the firmware part, I have a working “control monitor” written in the Arduino language (C++), which (besides all the other necessary stuff) takes the control app written as a function and calls it every time the scan cycle comes across. The monitor (together with the control app) is compiled with AVR-GCC and uploaded to the controller over the ordinary USB cable using a simple make file.

Probably I will extend the I/O module to several inputs and relay outputs for the sake of the thesis presentation. But, apart from this, I will stop working on the hardware part for a while. My big task is now to figure out a way to adapt the MatIEC compiler of the Beremiz project to generate a valid C (or C++) code that it will be possible to fit into the control function (i.e., the control application) of the firmware.

Stay in touch and feel free to comment if you find it interesting in any way.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *