programming controllers- c vs. relay ladder logic
DESCRIPTION
PLC Programming logic ladder diagram programming languageTRANSCRIPT
![Page 1: Programming Controllers- C vs. Relay Ladder Logic](https://reader036.vdocuments.mx/reader036/viewer/2022071709/563dbae5550346aa9aa8c9ea/html5/thumbnails/1.jpg)
WHITEp a p e r
PROGRAMMING CONTROLLERS: C VS. RELAY LADDER LOGICBy G. Young, Customer Support Manager
The World of program-mable controllers hasbecome more sophis-
ticated if not more complicated.No longer is it sufficient for amachine to endlessly perform thesame series of actions. Systemsnow, in addition to performingrepetitive tasks, must optimizeprocedures in order to maximizeproduction while keeping basicstatistics (a requirement of qualityassurance). Moreover, manysystems must interact with one ormore third-party devices withinterfaces that are alien to thecontrolling Programmable LogicController (PLC). Some systemsmust also interface with at leastone enterprise-wide network thatprovides management with up-to-the-minute information.
Relay Ladder Logic (RLL)was designed to provide moreflexible software simulation thatwould replace the relays, timers,and counters common to controlsystems of the 1960s and 1970s.
RLL has been successful in notonly achieving, but in surpassingits modest goals. RLL is a power-ful tool when applied to anapplication that performs specifictasks. However, RLL cannot meetthe multiple challenges of today�sPLCs even though some RLLshave been retrofitted with featuresto handle more complicatedapplication demands. At best,these enhancements are awkwardand slow and are either difficult ornearly impossible to use. RLL issimply not suited for today�s morecomplicated industrial problems.
C, on the other hand, wasdesigned to be a general purposeprogramming language. Not onlydoes C dominate the developmentof applications for personal andcorporate computing, it dominatesthe development of embeddedsystems. Therefore, C is used toprogram everything from wordprocessors and databases tomicrowaves and TVs. In essence,C is everywhere.
The reason for C�s popularityis its general-purpose nature.Because C makes no assumptionsabout its environment or whattypes of tasks it will perform,programs written in C use re-sources much more efficientlythan equivalent RLL systems.
Most PLCs provide the user witha fixed number of devices such asauxiliary relays, registers, andtimers. Eventually, every RLLprogrammer encounters a situa-tion where a fixed allocation ofassets is not acceptable for anapplication. For example, aparticular application may onlyrequire a few auxiliary relays andtimers, but requires more registersthan an RLL application can makeavailable.
The most aggravatingaspect of this scenario is that thePLC often has the neededmemory, but has allocated thatmemory to unneeded auxiliaryrelays and timers. When pro-gramming in C, allocatingmemory is not a problem becausethe programmer is in control ofhow resources are allocated. Aslong as a programmer does notattempt to allocate more resourcesthan available, C allows theprogrammer to decide how to useresources.
When programming in C, allocating memory is not a
problem because theprogrammer is in control
of how resources areallocated.
This paper examines two methodsof programming embeddedcontrollers and describes thebenefits of using C-Language inindustrial control applications.
Z-World White Paper No. 100 Part No. 022-0022 Rev. B
ELECTROMATEToll Free Phone (877) SERVO98
Toll Free Fax (877) SERV099www.electromate.com
Sold & Serviced By:
![Page 2: Programming Controllers- C vs. Relay Ladder Logic](https://reader036.vdocuments.mx/reader036/viewer/2022071709/563dbae5550346aa9aa8c9ea/html5/thumbnails/2.jpg)
C can solve mostprogramming problemsand is supported on all
major programmingplatforms.
Another important advantageof C is its execution focus. RLLwas written to simulatehardware�s inherently paralleloperation. Parallel operation isaccomplished by executing every�rung� of the RLL program oneach scan. While this achievesthe desired results, it has onemajor drawback: scan timesincrease as the size and complex-ity of the program increases.When attempting to use RLL toperform complex tasks, scantimes, which can increase tomore than 10 milliseconds, aregenerally too slow for mostapplications.
C, however, has a programcounter that starts at the function
main (the first function executedin any C program). The program-mer counter works its waythrough the code, directed by flowcontrol statements written by theprogrammer. A processor runninga C program is executing only onesequence of instructions at a time.
While one sequence of instruc-tions is executed, the rest of theprogram is idle, waiting to ex-ecute the next set of instructions.This single execution focus gives
the programmer incredible powerto decide which aspects of theapplication need the most intenseattention and which only need tobe checked periodically. Withoutthis control, handling high-speedevents (such as deployment of anairbag) would be impossible.
In today�s more sophisticatedrealm of programmable control-lers, it is well worth the timeinvested to become a proficient Cprogrammer. C can solve mostprogramming problems and issupported on all major program-ming platforms. Ultimately, agood C programmer can writeprograms that out perform thoseof an equally competent program-mer using RLL.
C and RLL Characteristics
C Programming Language
� Programming flexibility provides manymeans to solve a problem. So many, in fact,that a novice often gets overwhelmed by thepossibilities.
� Ability to focus execution on a small sectionof code. Important for applications wherecertain functions are not done often enough orare skipped entirely.
� Less intuitive for beginners and a little harderto learn than RLL.
� A useful set of basics can be learned quickly,but the more complicated aspects of thelanguage can be quite confusing even toprogrammers with moderate experience.
� Designed to perform a single task, andperforms that task well.
Relay Ladder Logic
� So restrictive that the simplest problems oftenseem to solve themselves.
� Executes every section with every scan. Thereis no chance of code not executing.
� Can be learned relatively quickly.
http://www.zworld.com
Z-World White Paper No. 100 Page 2 of 2
Part No. 022-0022 Rev. B
Z-World, Inc. � 2900 Spafford Street, Davis, California 95616 U.S.A. � 530.757.3737 Fax: 530.753.5141
ELECTROMATEToll Free Phone (877) SERVO98
Toll Free Fax (877) SERV099www.electromate.com
Sold & Serviced By: