Sign in to follow this  
Followers 0
CJH

Any other compiler besides ladder?

17 posts in this topic

Hi all I'm not sure what kind of response to expect from this post - either shot down in flames, or told to take my problems elsewhere, but I feel it's a valid question, and I'm interested to know what others think... Why are we forced to program PLCs (in my case Micrologix) in clunky, obsolete ladder logic? We have an OEM product that uses a Micrologix at its core. It's not the best unit for the job, but we settled on it because of familiarity with the product, and proven reliability (you won't believe where some of these units get shipped!) However, ladder logic is FAR from ideal for this type of application - basically a fairly complicated flow diagram with lots of flow control (if, then, for, next etc). My understanding is that a PLC is just a microcontroller with industrial I/O attached. Why can't we do free form programming with them? Surely it's just a matter of tweaking the firmware. I find it hard to believe that the structure of the processor is such that it wouldn't be able to understand compiled machine code? So, in short, I'm just wondering why we're stuck programming in ladder, and why there aren't other options available (BASIC, C etc)? (From 'brand name' manufacturers, that is) Edited by CJH

Share this post


Link to post
Share on other sites
You can't just look at a MicroLogix and make general statements about all plc's. TI had structured text programming in the 80's, PLC-5's in the 90's. Now the newer top shelf PLC's support multiple progamming interfaces. As for small platforms, take a look at this one: http://www.lt-automation.com/PLCs(e).htm it has BASIC. And how about this one: http://www.lt-automation.com/Winceplcs(e).htm

Share this post


Link to post
Share on other sites
I appreciate my statement was a tad generalised, but my point is that it's ridiculous that we are stll limited to just ladder in big name brands like AB. I'm surprised no third parties have made a commercial compiler for common PLCs, because I'm sure there would be a huge market for it. Am I to understand the hardware architecture of the CPUs are built to hanldle only 'ladder-like' instructions? Surely not. Thanks for the links, but I've already looked at those, and they don't fit the picture of a known brand that you can pick up in any country in the world if you have hardware failures (which are unlikely in any event). We've been burned in the past going the 'cheap and nasty' route and then the manufacturers go belly-up. PS: let me just clarify that the scope of my question is in the 'micro' plc niche, ie AB Micrologix, Mitsubishi FX etc. I do realise that there are alternative programming methods on higher end PLCs!! Edited by CJH

Share this post


Link to post
Share on other sites
Perhaps is a mater of you get what you pay for. If you company would change to AB PLC's that run on RS5000 software you would have options like this or flow diagram etc.This is in CLX.

Share this post


Link to post
Share on other sites
You are limited because you did not do your home work. You are talking about bottomline PLC (Micrologix or Mitsu FX). Look at the Logix product line and you will find all languages commonly used in industry: Function Blocks, Structured Text, SFC and Ladder. Programming PLCs in C? why not. But keep in mind that programming is just a beginning. Maintenance and troubleshooting is more important. And believe me in most of places you will not find an electrician who can debug "C" program, but they all understand ladder. So please avoid making statements like this... Edited by Contr_Conn

Share this post


Link to post
Share on other sites
I think this comes down to you get what you pay for. You order a low end PLC you will have less capablities than a high end PLC.

Share this post


Link to post
Share on other sites
While I am only slightly sympathetic to your cause because I prefer having other languages available and choose the language that best fits the application, before you pick on ladder lets discuss a simple example of what it does. It is not so lowly of a language as you at first suppose. Are you a C programmer? Program the instructon "XIC I:0/0" in C. Go ahead. Try and to it in less than 9 keystrokes. Extract a single bit from a 16 bit word in BASIC in 9 keystrokes. Have at it. When the LL compiler encounters the three letter instruction XIC it generates all of the If-THEN-ELSE machine code and the bit mask to extract a single bit from the 16 bit word for you. So despite the simplicity of the language, it is no slouch compiler. There are some tasks which LL excells at and other languges cannot even come close. I choose the best language for the task at hand and most of my apps use a mix of languages. Incidentally, ladder logic does in fact support For/Next loops. Do a search on the forum to find several ways to do For/Next and While loops. I myself came into the automation world as a C programmer. I insisted upon doing one of my first machines with an embedded controller in C. The software development time was nearly a month for something that could have been written in two days in ladder. I was young, fresh out of shcool, and dumb. Your case seems to me to be more of a problem of a poorly chosen PLC than of a PLC language problem. Perhaps you should have chosen the CompactLogix family instead of the MicroLogix family. The CompactLogix gives you plain text variable naming and aliasing, user defined data types, and four IEC-61131 programming languages, including a text language called ST that is sort of C-like but is uniquely adapted to industrial control (and you don't have to implicitly write a master scan loop). May I suggest you open a Word or Notepad document, and attempt to write your application (remember that you are working with bits in a language that uses it in 16 or 32 bit chunks so you have to mask everything) - I think that afterwards, you will have a new appreciation for simple, lowly, ladder for what it can do as opposed to conetempt for what it doesn't, and was never designed, to do. EDIT: Compare this: XIC I:0/1 OTE O:0/0. To this: #define do_forever for(;;) #define IN1MASK 2 #define OUT0MASK 1 do_forever { If (Input & IN1_MASK) { Output = Output & OUT0MASK; } Else { Output = Output & NOT OUT0MASK; } } Each will generate roughly equivalent machine code. Ouch! the C looks a little clunky while the "clunky" (your word) ladder is simple with the compiler doing all of the work. Now if I was doing a lot of math then ladder would not be my first choice, it was not designed for that, but then neither would a micro-logix PLC. Edited by Alaric

Share this post


Link to post
Share on other sites
First off, this is hardly a new question, most of us have had this discussion many times. The question usually comes from someone who is used to programming in the PC world and has minimal experience with PLCs. Your question contains some misconceptions, I'll address them each: Just a couple reasons why BASIC or C hasn't taken over for ladder logic: They are compiled languages and do not lend themselves easily to on-line monitoring of the code running in the processor. They are even less suited to making incremental on-line changes while the processor is running. These are important considerations to many industrial users. If neither of these considerations seem important to you as an OEM, then embedded controllers may be just what you are looking for. Since they run native machine code, you can generate your code with whatever tools you like. Keep in mind though, that all the services that the PLC firmware provided are your responsibility. Good luck, Edited by mellis

Share this post


Link to post
Share on other sites
Try monitoring a program in online mode with any language other than ladder logic. Your head would pop off from all of the nodding and back and forth shaking. When working with folks that programmed their Siemens PLCs in any of the languages than ladder, I always laugh because online run mode debugging in the run mode is virtually impossible. Talk about slow. Edited by jstolaruk

Share this post


Link to post
Share on other sites
And let me add one more thing. Suppose that Cycle Stop is I:1/0 and Immediate Stop is I:1/1 and you used Immediate in a routine where you want cycle. Make the change and see how long it takes to make it. And oh yeah, the machine cannot be stopped until Saturday and this is Monday. In LL with online edit you'll be done in seconds, in another compiled language your weekend is shot re-compiling. I know I spent 3 months on a non PLC job in Memphis, with PLC we'd have been done in 3 days. Edited by BobLfoot

Share this post


Link to post
Share on other sites
I agree with everything that's been said so far, but want to add one little point. In the beginning, before solid-state electronics, there were switches and relays. How were they documented? As a ladder diagram. This is a universally-accepted "language" that can be found everywhere from your household furnace to the largest machines in any industrial facility. Generation after generation of electricians in every industry were taught to speak this language fluently. Most of which, by the way, will never know (or need to know) about PLCs. So after many decades of this established tradition, the PLCs began to be introduced. Did the PLC designers choose to impose a new language upon their customer base? Of course not, that would be insane. They (rightfully) made the new technology as familiar and comfortable to their prospective customers as they could. To this day, some electricians use PLCs, but most don't. But, they ALL still "speak" ladder logic. That's the established norm, and like it or not it ain't going away anytime soon.

Share this post


Link to post
Share on other sites
This could be the best argument for not using ladder.... :)

Share this post


Link to post
Share on other sites
I hadn't thought about this one. Very good point. Can the other languages of RsLogix 5000 be edited online?

Share this post


Link to post
Share on other sites
As far as I am concerned Ladder is a superb RISC language. For normal use you need to know a few instructions that can be built quickly and easily into a program for controlling a complex machine or process. The structured text and basic modules have their place, but for the actual control the PLCs are made to do ladder is by far the most robust, safe, programming launguage you could find. As far as engineering staff are concerned:- Our electricians need to at least be able to see why a process has failed, ladder with good comments make it simple for even the oldest technophobe to see the fault in a familiar language. Fault finding by MONITORING the PLC code is much quicker than the traditional electrical test methods.

Share this post


Link to post
Share on other sites
This is THE question and in my mind separates PLC from embedded microcontrollers and PCs. 1. The OP selected the ML with his eyes open. Why bother to complain? 2. AD has stage programming that should be considered as an option. 3. All of your applications are mostly written in C or C++ and you wouldn't have ladder logic without it. Think about it. You are writing less the 1% of the code in your applications. 4. Any language can be designed to edit on line but why? This would ruin the efficiency of C or C++ 5. XIC I:0/1 OTE O:0/0. So what? Why not?: OutputBit = OTE(XIC(InputBit)); // In C OutputBit=InputBit; // OK I cheated. You need C++ to do this. I like this myself. QX0:=IX0; // in ST, this works for me too. This thread has wondered off topic. The OP really wants a language that makes it easy to write a state machine. Unfortunately a ML1500 can't implement one efficiently whereas a S7 300 can but this needs to be written in STL. I think the PLC OEMS have decided not to ruin ladder and keep is simple. Ladder, a simple language for simple tasks. Use SFC and ST for high end applications. The OP really should look into Automation Direct's stage programming.

Share this post


Link to post
Share on other sites
Ladder, Function Block, Structured Text - yes Sequential Function Chart - yes, but be very careful!

Share this post


Link to post
Share on other sites
Thanks for the tip. I'm getting ready to get the add on.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0