Saturday, July 2, 2011

An Introduction to PLC

PLC's (Programmable Logic Controllers), are often the unsung heroes of electronics. Though widely used in industries for automation and control, they are barely mentioned in the academic setup. I first heard of PLC's while interning in L&T IES, just after my second year. And when I heard that the software suite to program it cost lakhs, it definitely got me interested. I had to see what exactly this software could do.

So what are PLC's? According to Wikipedia, A programmable logic controller (PLC) or programmable controller is a digital computer used for automation of electromechanical processes, such as control of machinery on factory  amusement rides, or lighting fixtures. The first thing that came to my mind when I read this was "Why are we using such expensive solutions, when a simple cheap microcontroller will suffice?"

A PLC rack with the controller, I/O modules, communication modules and power.
 Turns out there's a lot PLC's can do. Microcontrollers are not built for the industrial environment. We don't just need a processor with I/O pins. A typical PLC will -
1) Have many hundreds of I/O's (depends on size). 
A typical manufacturing plant will be huge, with hundreds of control valves, pumps, motors, and  measuring instruments. All of these need to be controlled. For example, if the flowmeter reports a huge influx of the fluid in the pipe, the PLC directs the pump to take it easy.
2)Continue functioning in the event of emergencies like no power (with battery backup), or in case an I/O doesn't work.
You just can't take chances in industries. A PLC's code is stored in non-volatile memory. It can immediately switch to battery backup in case of a power outage.
3)Is very very safe and precise. Typical electronics like mobiles or laptops, sometimes malfunction. For a PLC, the chances to screw up are almost non-existent.
4) Is usually decentralized and modular. This way even if one module is mal-function, it doesn't affect the entire operation. The difference between PLC's and DCS (Distributed Control Systems) have almost dissappeared.
5)Has excellent communication support. Most PLC's are equipped with various protocols of communication like ethernet/IP (the industrial version of ethernet), devicenet, controlnet etc. This way a PLC can use devicenet to talk to the low-end devices, and ethernet/IP to connect to a computer.
6)Good software support. There are a few major players in this market like Siemens and Rockwell Automation. They have their own proprietary softwares, with excellent support, making it easy to program PLC's.
7)Reprogrammability. I shouldn't have left this for the last, since it's probably the most important feature. Suppose a perfume manufacturer typically bottles 50 perfumes per minute. The demand slows down, and he wants to reduce the supply to 40 bottles per minute. It's very easy to change the PLC program. He can simply reprogram it. If this needs to be done frequently,  PLC's are connected to a SCADA (supervisory control and data acquisition). That's just a complicated name for a computer that monitors everything. Using an HMI (Human Machine Interface), he can change the supply rate directly.

That being said, PLC's are awfully expensive, if intended for academic purposes. No wonder many colleges simply do away with it.

I was suggested to take up a project on "elevator logic" in order to get familiar with PLC's. It sounded quite easy to me initially, but turned out it to be way more complicated. PLC's typically use a very different method of programming than the traditional "C" or "Java". It uses ladder logic, with took me quite some time getting used to. Google it up; there are various tutorials on that. (For the lazy ones, here goes - Ladder logic mimics relays. It has inputs (contacts), and outputs (coils), which respond to the inputs.)

Luckily, RSLogix 5000 supported structured text, a style of programming PLC's which is very similar to C. I used structured text for algorithms I found notoriously complicated to mimic in ladder logic.

I'll be posting more details about my project soon.