Posted on Leave a comment

My Saga With PLCs – Part1

I didn’t learn PLCs in school.  My gig was Engineering Physics and if the homework didn’t use Calculus to think about the atomic level, I didn’t learn it.  Granted, I didn’t learn to use Calculus to think about the atomic level, either, but that’s another rant.  So, I’m learning PLCs.  Here are some thoughts for others entering this domain.

  1. There must be no money in PLCs anymore. (joke)  Allen and Bradley made some truly cutting edge software at the tail end of the Reagan administration and then halted all progress.  This, in and of itself, ain’t a big deal.  The big deal is that 3 decades of progress have radically reduced the time wasted on clunky software.  If you use a modern IDE to program anything, you’ll be frustrated by RSLogix.  If you use Notepad to program anything, you’ll still be frustrated by RSLogix.
  2. The story goes that Ladder Logic was designed to be simple enough for non-programmers to use it.  I’m not a “programmer”, but I’ve done a fair chunk of it.  The need for visualization adds an extra layer to the mix.  Instead of remembering the XIC is “examine if closed”, we also have to remember what the schematic symbol looks like and where we can find it and how to get it into our schematic.  It would have just been much more efficient to type “XIC”.   A GUI needs to hit a critical mass of usefulness in order to displace text-based tools.  The GUI in Notepad++ is pretty straight-forward.  We all know how to manipulate text.  Finding the menu with XOR in it is not so clear.  Hopefully, getting adapted to RSLogix won’t be so bad after I force myself through the blatant inefficiency.
  3. I started down the PLC thing months ago.  It’s taken me months of working here and there to get a working hardware setup.  (4 switches, 4 lights, and connected to the PC.)  I spent nearly a week working on the ethernet connection.  I found an authority online who said, “Absolutely do not use Ethernet! on a MicroLogix PL1100”.  I bit the bullet and bought the $25 Serial cable. It worked immediately.  It’s my understanding that the ethernet on the MicroLogix1100 is of the primitive variety….whatever that means.  If a person has to use ethernet, the recommendation seems to be to use a “crossover cable” ($6 on Ebay) to allow plugging it straight into a computer somehow.
  4. The $25 Serial cable was a total waste of money.  It works, but I have $2 FTDI chips all over the place.  (FTDI converts USB to serial and vice versa for use as COM ports in Windows or equivalent.)  I only needed power and 2 wires.   The MicroLogix PL1100 uses a fairly goofy connector that I don’t have.  So, I basically paid $25 for a connector.  Oh well.
  5. The $25 Serial cable was actually a knockoff from Amazon.  The Allen and Bradley cable is a whopping $50.  To me, this is a $2 board from Ebay.   You see ridiculous pricing all over the place in PLC land.  The most notable example is the PLC Trainer.  They often come with 4 switches and 4 lights and cost $150+.  Since no one with sense is driving 100kW systems while TRAINING, there’s no point for these to be high-power, industrial powerhouses.  Switches rated for 125V on Digikey start at $1 a pop.  The lighting is even more grotesque.  Industrial-grade indicator lights are expensive because they are built like tanks.  As cool as tanks are, you don’t want a tank in your basement.  An LED and a resistor, believe it or not, is capable of acting as a perfectly viable indicator-via-photon tool.  This does lead to opportunity, but I have to admit I get nervous when prices are obscenely inflated and no one seems to question it.  I’m sure questioning it.  Look for an Electron Injection PLC trainer soon.
  6. It seems obvious to me to use an LED and resistor for indicator lights.  They’ve been the absolute standard since they were invented.  The LED is the default tool to use for such a job.  I can’t see how any engineer or technician learning PLCs wouldn’t immediately think to grab a 680 ohm resistor and a red LED out of the cabinet.  A person has to go through a minefield of rationalizations to arrive at the hyper-expensive alternative for the same reason you don’t book a flight in a B2 bomber to go Cancun.
  7. The worst part about learning PLCs this far is the lack of projects.  It’s well understood that the best way to learn Arduino (or anything in life) is to have a big problem you plan to solve with it and jump in.  Let’s say we want a robot that can plant seeds.  When you finish such a project, you end up with a seed planter.  Cool!  The problem with PLCs is they cost about 100x what microcontrollers generally cost.  (Give or take.)  It doesn’t make sense to jump into such “hobbyist” projects with industrial tools.  So what are you supposed to do?  Start your own beer factory in your basement?  (Don’t tempt me!)  Even then, it’s not exactly clear why I’d use a PLC when I could just program a $5 microcontroller.  Maybe that will be revealed down the road.
  8. I learned pretty quickly that the emulator for the Allen and Bradley PLCs was omitting quite a bit of the “PLC Experience”.   Here’s a metaphor.  Your can emulate changing the oil in your car, but it will never drip oil in your face.  There’s some nastiness that needs to be addressed with the real thing that gets lost in the emulators even though I REALLY wanted the emulator to work out.
  9. Get ready for some work.  I decided that I hated the user interface.  Again, this is common when doing anything new.  I was hoping for a shortcut by jumping straight into the code.  WRONG!  Here’s the code for my tiny little “program”.

     BST XIC I:0.0/0 NXB XIC I:0.0/1 BND BST XIC I:0.0/2 NXB XIC I:0.0/3 BND OTE O:0.0/1 

    Look at the end first.  We have an OTE to energize the output at 0.0/1 whenever the rest is true.

    As for the rest, I’ll show you the C version.

    if (   (BIT0  OR BIT1)  AND  (BIT2 OR BIT3)  ) {

           Output  = 1;

    }

    I’m reminded of how lucky I am to have the C language.  This is only an illustration to show that if a person had some hardcore coding to do on a PLC, the GUI is where it’s at.  The code behind PLCs reminds me a bit of Assembly and no one wants to go there. 

Conclusion

My earliest days with PLCs have been less than ideal.  It’s not PLCs fault that I can’t economically use them for stupid, little projects.  That takes most of the fun away.  However, I’ve made myself a list of assignments…..easy stuff like “Push a momentary switch and turn an LED on for 8 seconds”.  By stacking up enough of these little hurdles, I think I can begin to get a feel for this thing.

PLCs are a radically different culture than I’ve experienced with programming microcontrollers or playing with Python or even HTML.  The terminology is different.   They often make things much more complicated than they need to be.  The above C vs PLC code above is a great illustration of that.    They will often say things that are either incorrect or could easily be made to be incorrect.  For example, the whole idea of XIC is “examine if closed”.  In real life, they are asking if an input is at a HIGH level and is so, do something else.    Well, I can create either HIGH or LOW levels with either a closed or open switch using pullup resistors on a microcontroller.   Why do they assume the switch is closed?  It’s okay that they have, but it would have been nice to have this explained to me.  In my mind, reacting to HIGH and LOW conditions is just as simple and not so presumptuous.  There are REALLY good reasons why you may want to utilize active HIGH or active LOW (see the NC vs NO debate with CNC machines limit switches, for example).  This is just one example.  Maybe I’m making it too complicated…..

Making these simple generally makes them more complicated.  PLCs seem to fall into this category over and over for me.  Again, when I finally adapt to Ronald Reagan’s RSLogix, I suspect things will get easier.  The quirks are all over the place.  With that said, if a person was diving into bare metal C on a microcontroller, they would probably see even more quirks.  Too bad.  I’m generally used to those so they don’t count.  (smilie)

Leave a Reply

Your email address will not be published.