Average of Analog Input

Saturday, 2 May 2009
Posted by Joe

Description :

This Siemens 200 PLCs's file is going to create a rolling average for the last 100 scans worth of an analog input.

File Details :

File Type: .zip

File Size:2.27 Kb

Download Now

More Info :

Please  Visit  http://plc2u.com/index.php/plc-code/s7200/average-of-analog-input

Label:

Daylight Savings Time for S7-200

Posted by Joe

Description :

This is a sample program how to demonstrate making the PLC adjust the clock for daylight savings time automatically. It is done with an S7-200, but the logic sould be similar for any PLC from any vendor.

It's written with Step 7-MicroWIN/32

File Details :

File Type: .zip

File Size 7.84 Kb

Download Now

More Info:

Please Visit http://plc2u.com/index.php/plc-code/s7200/daylight-savings-time-for-s7-200

Label:

Remanent On-delay Timer for Siemens S7 300/400

Posted by Joe

Remanent On-delay Timer for Siemens S7 300/400

-The attached FC makes standard PLC timers remanent.

-The timers are started, stopped and reset via digital inputs.

-The the remaining time can be monitored in the program.

File Details :

File Type: .zip

File Size 222.35 Kb

Download Now

Please visit us at http://plc2u.com/index.php/plc-code/s7300400/remanent-on-delay-timer-for-siemens-s7-300400

Label:

S7-200 Tips & Tricks Complete 8/2003

Posted by Joe

PLC Sample Code

Description:

Complete archive of Tips and Tricks for S7-200

File details:

File Type: .zip

File Size 25.63 Mb

Download Now

Please visit us at http://plc2u.com/index.php/plc-code/s7200/s7-200-tips-a-tricks-complete

Label:

PLCs Versus Other Types of Controls

Saturday, 25 April 2009
Posted by Joe

A PLC is not the alone best for authoritative a process. Sticking with alone basal relays may be of a account depending aloft your application. Yet, on the added hand, a computer ability be the way to go. The PLC vs. PC agitation has been activity on for a continued time. More generally admitting it doesn't appear bottomward to an "either or" bearings but involves a mix of technologies.

PLC vs Relay

Relay small

When I first started programming PLCs it was still ambiguous if a PLC was all-important over aloof broadcast control. With PLC prices activity down, admeasurement shrinking, and achievement of PLCs convalescent over the years this has become beneath of a battle. Yet the designer has to ask themselves if a PLC is absolutely abstract for their application. Some questions should be asked.

  • Is there a need for flexibility in control logic changes? Will there be frequent control logic changes? Will there be a need for rapid modification? A lot companies believe they will never change a design but more often then not ideas and goals do change and modifications will need to be made. Do you want to do that in hardware (relays) or software (PLC)?
  • Must similar control logic be used on different machines? It's so much easier to download a program then build another panel.
  • Is downtime a concern? Any change or troubleshooting on a relay system means the system might have to go offline. Changes in a PLC can often be made online with no downtime.
  • Are space requirements important? Based on the number of relays a PLC can be a real space saver.
  • Are increased capability and output required? PLCs can be faster then their mechanical counterparts.
  • Are there data collection and communications required? Only possible with a PLC or computer.
  • What are the overall costs? There's a certain price point comparison but in these days it's very low in favor of a PLC.
  • Is there a need for flexibility in control logic changes? Will there be frequent control logic changes? Will there be a need for rapid modification? A lot companies believe they will never change a design but more often then not ideas and goals do change and modifications will need to be made. Do you want to do that in hardware (relays) or software (PLC)?
  • Must similar control logic be used on different machines? It's so much easier to download a program then build another panel.
  • Is there a need for future growth? A PLC can easily accept a new module in a slot or get an expansion base.
  • Is there a need for high reliability? PLCs are seen as more robust over individual components.
  • Is downtime a concern? Any change or troubleshooting on a relay system means the system might have to go offline. Changes in a PLC can often be made online with no downtime.
  • Are space requirements important? Based on the number of relays a PLC can be a real space saver.
  • Are increased capability and output required? PLCs can be faster then their mechanical counterparts.
  • Are there data collection and communications required? Only possible with a PLC or computer.
  • What are the overall costs? There's a certain price point comparison but in these days it's very low in favor of a PLC.

PLC vs. Dedicated Controller

Controller dedicated

A dedicated controller is a single instrument that is dedicated to controlling one parameter such as a title="Acronym for Proportional, Integral, Derivative. Control algorithm that is used to closely control processes such as temperature, mixture, position, and velocity. The proportional portion takes care of the magnitude of the error. The derivative compensates for the rate of error change. The integral takes care of small errors over time.">PID controller measuring a temperature for heating control. They have the advantages of an all in one package, typically with display and buttons. This can be a very good thing to use in simple applications. A PLC these days can compete price wise and functionally with these controllers especially if you more then one controller is needed. PLCs offer a greater degree of flexibility too because the can be programmed to handle all sorts of different scenarios.

PLC vs. PC (Personal Computers)

Computer small

The PLC vs. PC debate has been going on for years and I'm not going to attempt to give the definitive answer. They both have their pros and cons. What often happens is that the two are used for their strengths in different parts of the factory.

 

 PLCPC
Environment The PLC was specifically designed for harsh conditions with electrical noise, magnetic fields, vibration, extreme temperatures or humidity.Common PCs are not designed for harsh environments. Industrial PCs are available but cost more.
Ease of Use By design PLCs are friendlier to technicians since they are in ladder logic and have easy connections. Operating systems like Windows are common. Connecting I/O to the PC is not always as easy.
Flexibility PLCs in rack form are easy to exchange and add parts. They are designed for modularity and expansion.Typical PCs are limited by the number of cards they can accommodate and are not easily expandable.
Speed PLCs execute a single program in sequential order. The have better ability to handle events in real time.PCs, by design, are meant to handle simultaneous tasks. They have difficulty handling real time events.
Reliability A PLC never crashes over long periods of time. ("Never" may not be the right word but its close enough to be true.) A PC locking up and crashing is frequent.
Programming languages Languages are typically fixed to ladder logic, function block or structured text.A PC is very flexible and powerful in what to use for programming.
Data management Memory is limited in its ability to store a lot of data. This is where the PC excels because of it's hard drive. Any long term data storage, history and trending is best done on a PC.
CostJust too hard to compare pricing with so many variables like I/O counts, hardware needed, programming software, etc.

 

Hybrids of PLC/PCs are common now (e.g. WinPLC). This type of hardware tries to mix the two platforms using the strengths of both. So the CPU might be able to run Windows CE or Linux in a rack that can accept common I/O modules.

Off the Shelf vs. Build Your Own

PLC custom board

For some manufacturers the choice these days is coming down to buy a PLC or make your own. The benefits of PLCs have become so widely known that manufacturers looking to cut cost can engineer their own solutions and build them more cost effectively. An example of this is the Divelbiss "PLC on a Chip" with the accompanying EZ LADDER programming software.

Please visit us a http://plc2u.com/index.php/plc-article/plc/plc-vs-other-type-of-control

Label:

Repair PLC

Posted by Joe

PLC Repair Bad Card

It’s inevitable. Left on your board is an old PLC agenda with a chicken post-it agenda on it that artlessly says, “Bad Card”. So you assay it out and abiding abundant article is mysteriously amiss with the cyberbanking audacity of this big-ticket little device. Your aggregation may accept some action for abortion assay and backup parts, but, added generally than not, there’s a chiffonier or drawer about with a lot of bad parts, bashed with cryptic adhesive notes, that you don’t accept the affection to bandy out. As those genitalia get added numerous, adored and cher it makes faculty to analysis into companies that specialize in PLC repair.

Please visit us at  http://plc2u.com/index.php/plc-article/plc/repair-plc

PLC Repair Companies

There are absolutely a few companies whose capital business focus is electronics adjustment including PLC boards. Some of them are alike absolutely PLC accouterments accompanying but best additionally account drives, DCS accessories and added ascendancy devices. Not alone will they adjustment PLC genitalia but they additionally accept a ample accumulation of surplus (new in box) and refurbished genitalia for replacement. This abnormally becomes important in earlier bequest systems. Alike admitting genitalia can be upwards of thirty years old they still abutment aliment on the brand of Allen Bradley PLC-2/PLC-3, Modicon 484/584, Siemens S5/S7 and Texas Instruments 500/505. PLC adjustment companies action the experience, assets and the abstruse libraries of schematics and manuals that would contrarily be adamantine to appear by.

Am I a Candidate?

Basically any aggregation complex in PLCs can account from PLC repair. Mid-size to ample factories are archetypal candidates but arrangement integrators and resellers additionally apprehend the advantages. The charge for bound controls, minimum blow and acid costs accomplish PLC adjustment needful for all sorts of industries from packaging, aliment processing, pharmaceutical, automotive and so on.

If you assignment in an earlier bulb you apperceive how able-bodied a PLC can be alive year afterwards year. You additionally apperceive as a artisan that your accessories will eventually fail. It’s not a amount of “if” but “when” and that’s back you’ll charge adjustment services. One of the problems is that the amount of advance is aloof not account it back it comes to factoring in removing the old system, programming the fresh one, installing hardware, alive out the bugs and acquirements how to use the fresh system. Having a reliable adjustment account ensures that you can accumulate the arrangement active at basal cost.

How Much Can I Save?

First of all, it doesn’t amount annihilation to acquisition out how abundant the accident will be in dollars. The majority of the PLC adjustment companies do not allegation annihilation for ciphering a adjustment cost. You would alone be out the amount of shipping.

Second of all, there are no accuse for time and materials. A archetypal adjustment account has a database of genitalia and their costs. These companies accept been about for awhile and accept accumulated the ability of archetypal genitalia that go bad and accordingly accept a abject amount for repairs.

The basal band is that it should amount you no added the 50% of the amount of new. Greg Carter of Radwell International says, “We alarm an account ‘Beyond Economical Repair’ aback the amount of genitalia and activity beat 45% of affairs new. We try to accomplish adjustment a actual adorable advantage --- 73% of items are angry about in 5 canicule or less.” Aback I asked Willy Williamson of Electrical South about a aphorism of deride he said, “Repairs should about not amount added again 50% of the amount of a fresh archetype of the aforementioned allotment number. If you run into instances area you apperceive a fresh one can be bought for beneath than the quoted adjustment price, allocution to your sales representative.”

If a allotment is accounted as un-repairable, as a aback up, these companies action refurbished or surplus genitalia at cogent savings. Bill Zalot, President of TEK Supply says, “In best cases if a assemblage is un-repairable for any reason, we are able to accommodate a backup for the chump at a amount alone hardly added than adjustment cost.” These surplus or repaired genitalia are additionally acceptable avenues to accomplish abiding you accept a aback up on your shelf for emergency situations.

What about Quality?

Of advance acclimation a allotment may not be as reliable as affairs a cast fresh one. The added acceptable adjustment companies admitting booty a abundant accord of pride in their assignment and ensure a affection repair. A acceptable adjustment aggregation will action a assurance on the allotment or alike the accomplished PLC. It seems the about assurance runs for one year but they can differ. It’s important to pay absorption to the assurance and analyze it to what others are offering. It’s additionally account allurement about their testing and analysis procedures. Make abiding they accept the adeptness to put the allotment in a arbor to absolutely exercise it afore sending it aback to you. How important is this? “We go to abundant lengths to absolutely exercise the PLCs we repair. We use analysis programs to absolutely exercise the memories and functions of the PLC. We absolutely don’t appetite to see it appear aback as a warranty. We additionally adopt to accumulate our barter advancing aback to us with added repairs, and acceptable affection is a above contributor to abiding relationships”, said Willy Williamson of Electrical South.

Label:

User Defined Data Types (UDTs) and OOP

Posted by Joe

For years now, Object Oriented Programming archetype (or OOP) has been a frequently acclimated programming practice, and has of advance begin its way into automated automation as well.

In the beggarly time, best PLC manufacturers accept begin agency to accomplish the programmers activity easier by introducing User Defined Types or UDTs. The name says it all; it is a ‘type’ that you, the programmer, can ascertain all by yourself. This agency that your programming ambiance will not alone accept the approved integers (INT) and Booleans (BOOL), but could additionally accept a ‘VALVE’ blazon or a ‘MOTOR’ type.

I can’t allege for added brands of PLC’s, but the Allen Bradley ControlLogix alternation of PLC’s, calm with RSLogix 5000 programming software, makes it actual accessible to assignment with these UDTs, and back the addition of RSLogix adaptation 17 beforehand this year, it is now alike accessible to adapt your UDTs while online with a active system.

The Controller Organizer has a binder alleged Data Types > User-Defined with all the UDTs in the project.

programmable logic controllers,plc,plc control,scada systems,hmi automation,modbus io,ethernet rs485,rs232 ethernet,industrial automation,as511,siemens,allen-bradley

I am of the assessment that every PLC affairs should await heavily on UDTs to advance readability, and if you are an OOP adept, it can be a abundant advice to adapt your classes.

Let’s go over the fundamentals of OOP for a little bit:

  • Classes: Classes define the abstract characteristics and behavior of an object. For example, a simple ‘VALVE’ class would have the characteristics (or attributes) that it can be open or closed (the things it can be), and as far as behavior goes, it could have the methods ‘to open’ and ‘to close’ (the things it can do)
  • Objects: An object is an instance (occurrence) of a class. In our example, there could be a Valve_001 and a Valve_002, which are both instances of the class ‘VALVE’, with the same attributes and methods.

Of course the definition of OOP goes a lot further than this. There is a very understandable explanation here: http://en.wikipedia.org/wiki/Object-oriented_programming#Fundamental_concepts for those who would like to read more. For now, let’s leave it at this, and see how we can apply this to an industrial environment.

If you look at a valve as an object in a typical industrial automation environment, you should note the following:

  • It has inputs and outputs that are specific for the object (proximity switches and solenoids).
  • It can be either ‘open’ or ‘closed’
  • You can tell it to go ‘open’ or ‘close’.
  • It could have an alarm timer, that would tell us if the valve did not open or close in a given time period after a command.
  • It might have interlocks, which allow the valve to open or close under certain conditions.

A UDT for this class, would fit all these backdrop and methods in one simple type. But, as always, we can apprehend added complications of the chic ‘VALVE’ during the ability of a project. To be as adjustable as possible, I awful acclaim the convenance of nesting UDT’s, which will become bright forth the way.

Let’s alpha with defining our class, and accumulate in apperception that it will accept to be calmly attainable for aliment bodies or added programmers.

If we alpha at the I/O end, the best adjustment is to actualize sub-classes alleged VALVE_IN and VALVE_OUT, which will accommodate our I/O.

The afterward archetype uses RSLogix5000 V16. First, actualize the sub-classes. From the File card baddest New Component > Tag. The afterward chat box appears to actualize and adapt the associates of the UDT.

programmable logic controllers,plc,plc control,scada systems,hmi automation,modbus io,ethernet rs485,rs232 ethernet,industrial automation,as511,siemens,allen-bradley

As you see, I am accustomed to booty the types I aloof created as the abstracts blazon in this UDT. The absolute advantage of this affection will become bright if you actualize a article alleged Valve001 of the blazon VALVE, and attending at the article in the ‘monitor tags’ window:

programmable logic controllers,plc,plc control,scada systems,hmi automation,modbus io,ethernet rs485,rs232 ethernet,industrial automation,as511,siemens,allen-bradley

Wow! Just by creating a new tag of the type VALVE, it gets all these I/O points right away, and referenced in the program:

programmable logic controllers,plc,plc control,scada systems,hmi automation,modbus io,ethernet rs485,rs232 ethernet,industrial automation,as511,siemens,allen-bradley

Of course, going further with this concept, everything for a valve can be included in one object. Allow me to skip some steps, and show you a possible final result:

The ‘VALVE’ class is now contained in a UDT called VALVE, which looks like this:

programmable logic controllers,plc,plc control,scada systems,hmi automation,modbus io,ethernet rs485,rs232 ethernet,industrial automation,as511,siemens,allen-bradley

As you see, the class VALVE now consists of the sub-classes VALVE_IN, VALVE_OUT, VALVE_TIMER, VALVE_STATUS, etc.

And an instance of this class, the object Valve001, would look like this:

programmable logic controllers,plc,plc control,scada systems,hmi automation,modbus io,ethernet rs485,rs232 ethernet,industrial automation,as511,siemens,allen-bradley

While adding stuff to my class, I did not have to re-create the object Valve001. RSLogix updated it for me, so all the properties and methods are available in my program.

Now, let’s say you’re working on this project with a couple hundred valves, and the customer decides to go with a different type of valve, that also has an analog input, that tells us the exact position of the valve. All we have to do is modify our VALVE_IN sub-class to add this to every instance of the type VALVE:

programmable logic controllers,plc,plc control,scada systems,hmi automation,modbus io,ethernet rs485,rs232 ethernet,industrial automation,as511,siemens,allen-bradley

Of course, you would still have to write code to tell your program what to do with that information, but that is also the reason why PLC programmers still have a job.

For somebody that is not familiar with your program, it might be confusing to look at all your UDT’s. We just made eight UDT’s for one simple valve class! But remember, you only have to do this during the design phase. Once you have a solid design for all your classes (and made sure their names are self-explanatory), you will never have to look at your UDT folder again, and creating a new instance will be a breeze.

Please visit us at  http://plc2u.com/index.php/plc-article/plc/user-defined-data-types-udts-and-oop

Label:

How to Symbol Program with Allen Bradley RS Logix 500- Part III

Sunday, 5 April 2009
Posted by Joe

NFPA 79 2002 Edition reference

Table E.1 Device and Component Designations ABE Alarm or Annunciator Bell ABU Alarm or Annunciator Buzzer AH Alarm or Annunciator Horn AM Ammeter AT Autotransformer CAP Capacitor CB Circuit Breaker CI Circuit Interrupter CNC Computerized Numerical Controller CON Contractor COs Cable-Operated (Emergency) Switch CPU Central Processing Unit CR Control Relay CRA Control Relay, Automatic CRH Control Relay, Manual CRL Control Relay, Latch CRM Control Relay, Master CRT Cathode Ray Tube, Monitor or Video Display Unit CRU Control Relay, Unlatch CS Cam Switch CT Current Transformer CTR Counter D Diode DISC Disconnect Switch DISP Display DR Drive EMO Emergency (Machine) Off Device END Encoder ESTOP Emergency Stop FLD Field FLS Flow Switch FS Float Switch FTS Foot Switch FU Fuse GEN Generator GRD, GND Ground GUI Graphical User Interface HM Hour Meter HTR Heating Element IC Integrated Circuit INST Instrument IOL Instantaneous Overload I/O Input/Output Device L Inductor LED Light Emitting Diode LS Limit Switch LT Pilot Light LVDT Linear Variable Differential Transformer M Motor Starter MD Motion Detector MF Motor Starter - Forward MG Motor Generator MR Motor Starter - Reverse MTR Motor OIT Operator Interface Terminal OL Overload Relay PB Pushbutton PBL Pushbutton, Illuminated PC Personal Computer PCB Printed Circuit Board PEC Photoelectric Device PL Plug PLC Programmable Logic Controller POT Potentiometer PRS Proximity Switch PS Pressure Switch PWS Power Supply Q Transistor QTM Thermistor REC Rectifier RECP Receptacle RES Resistor RH Rheostat S Switch SCR Silicon Controlled Rectifier SOL Solenoid SNSR Sensor SS Selector Switch SSL Selector Switch, Illuminated SSR Solid State Relay ST Saturable Transformer SUP Suppressor SYN Synchro or Resolver T Transformer TACH Tachometer Generator TAS Temperature-Actuated Switch TB Terminal Block T/C Thermocouple TR Timer Relay TSDR Transducer TWS Thumbwheel Switch V Electronic Tube VAR Varistor VM Voltmeter VR Voltage Regulator VS Vacuum Switch WLT Worklight WM Wattmeter X Reactor ZSS Zero Speed Switch

Please visit us at  http://plc2u.com/index.php/plc-article/plc/how-to-symbol-program-with-allen-bradley-rs-logix-500

Label:

How to Symbol Program with Allen Bradley RS Logix 500-Part II

Posted by Joe

Your symbols will start to pop up in a quick pick list. Arrow down to find your proximity switch if you can't remember it, or better yet keep typing it all out and press enter when done. Viola! You've just typed your first symbol program.

programmable logic control,plc,plcs,plc control,automation,scada,hmi,modbus,4-20 mA,ABB,Siemens

Other symbols programming tips I can offer is a grouping of symbol names such as STATION 1 could mean S1. If you are state logic programming, you might remember a station more so by its function. Let's say you have a station on some automation that presses a part assembly together. I would call all the internal bits by "PRESS" to indicate all these bits that begin with PRESS have the same functionally with my press station.

programmable logic control,plc,plcs,plc control,automation,scada,hmi,modbus,4-20 mA,ABB,Siemens

The fun doesn't stop there. Can't remember which control relay enables the fast speed index? Just type CR to bring up the list of all your control relays.

programmable logic control,plc,plcs,plc control,automation,scada,hmi,modbus,4-20 mA,ABB,Siemens

How about when you are creating bits that transfer information from your Panel View to your PLC? You could also group all those symbol names together with a PV.

programmable logic control,plc,plcs,plc control,automation,scada,hmi,modbus,4-20 mA,ABB,Siemens I hope you can see based on the samples shown that trying to memorize your program by the address names is pretty tough. Giving each of your symbols a name and you should be able to program faster than before. Group your symbols names to speed up symbol searches. Come up with your own "short hand" that you can remember easily or use the NPFA chart for some ideas.

Label:

How to Symbol Program with Allen Bradley RS Logix 500 - Part I

Posted by Joe

Symbols are used in RS Logix to identify a bit or memory area of a PLC by a name that you can more easily remember. See if you can see the symbols in this screen shot:

programmable logic control,plc,plcs,plc control,automation,scada,hmi,modbus,4-20 mA,ABB,Siemens

If you haven't found them by now, they are the descriptions in GREEN.

AUTO_MODE, RUNNING, POWER_ON, ALL_HOME, INDEX_ON_STAT, etc...

RS Logix makes it extremely easy to use symbols in your program. When you enter a new instruction with a question prompt, you can start typing your symbol name and a pop out window will start narrowing your search down to the symbol you have already created in the database. Notice I said "already created". That means it would be a good idea if you made up all your symbols ahead of time using the spread sheet template downloadable here

programmable logic control,plc,plcs,plc control,automation,scada,hmi,modbus,4-20 mA,ABB,Siemens

That's ok that you can't do them all before you start. Just keep creating them on the fly with terms or "short hand" that you can remember. Here are some tips for common short hand naming that I use myself.

When I am programming a hardware device such as a proximity switch or a photoeye input, I use the NFPA's Table E.1 Device and Component Designations as guidance to name all my hardware I/O. Below is a list of codes at the end of this article. This bascially means if I have a proximity switch connected to I:1.0/14 I could give it the symbol name

PRS_TRANSFER_EXT

programmable logic control,plc,plcs,plc control,automation,scada,hmi,modbus,4-20 mA,ABB,Siemens

PRS comes from the NFPA table which means "Proximity Switch TRANSFER means that this prox is connected to a transfer device of some sort EXT means that the direction the prox is detecting is You aren't required to use the NFPA's component designation, but this will give you some bases to start if you need ideas. More recently I have tried to trim my own symbols to the first two letters so I can drill down my symbol list very quickly in RS Logix. I've changed my own personal preference to PX for Proximity Switch. So if I enter an instruction in a rung, I can just type two letters "PX" at the question mark and low an behold EVERY SINGLE proximity switch on my automation system will come up in my list to choose from.

Label:

In View 2706-P42C w/Ethernet IP ASCII Example Code

Posted by Joe

File Information
Name:InView 2706-P42C w/Ethernet IP ASCII Example Code
Author:chakorules
Submitted By:chakorules
Submitted:Wed, Mar 18 2009 10:40 am
Views:218
Downloads:60

Download File

Label:

Serial UART

Thursday, 26 March 2009
Posted by Joe

Serial UART, an introduction

An UART, universal asynchronous receiver / transmitter is responsible for performing the main task in serial communications with computers. The device changes incomming parallel information to serial data which can be sent on a communication line. A second UART can be used to receive the information. The UART performs all the tasks, timing, parity checking, etc. needed for the communication. The only extra devices attached are line driver chips capable of transforming the TTL level signals to line voltages and vice versa.

To use the UART in different environments, registers are accessible to set or review the communication parameters. Setable parameters are for example the communication speed, the type of parity check, and the way incomming information is signalled to the running software.

Serial UART types

Serial communication on PC compatibles started with the 8250 UART in the IBM XT. In the years after, new family members were introduced like the 8250A and 8250B revisions and the 16450. The last one was first implemented in the AT. The higher bus speed in this computer could not be reached by the 8250 series. The differences between these first UART series were rather minor. The most important property changed with each new release was the maximum allowed speed at the processor bus side.

The 16450 was capable of handling a communication speed of 38.4 kbs without problems. The demand for higher speeds led to the development of newer series which would be able to release the main processor from some of its tasks. The main problem with the original series was the need to perform a software action for each single byte to transmit or receive. To overcome this problem, the 16550 was released which contained two on-board FIFO buffers, each capable of storing 16 bytes. One buffer for incomming, and one buffer for outgoing bytes.

A marvellous idea, but it didn't work out that way. The 16550 chip contained a firmware bug which made it impossible to use the buffers. The 16550A which appeared soon after was the first UART which was able to use its FIFO buffers. This made it possible to increase maximum reliable communication speeds to 115.2 kbs. This speed was necessary to use effectively modems with on-board compression. A further enhancment introduced with the 16550 was the ablity to use DMA, direct memory access for the data transfer. Two pins were redefined for this purpose. DMA transfer is not used with most applications. Only special serial I/O boards with a high number of ports contain sometimes the necessary extra circuitry to make this feature work.

The 16550A is the most common UART at this moment. Newer versions are under development, including the 16650 which contains two 32 byte FIFO's and on board support for software flow control. Texas Instruments is developing the 16750 which contains 64 byte FIFO's.

Registers

Eight I/O bytes are used for each UART to access its registers. The following table shows, where each register can be found. The base address used in the table is the lowest I/O port number assigned. The switch bit DLAB can be found in the line control register LCR as bit 7 at I/O address base + 3.

UART register to port conversion table
 DLAB = 0DLAB = 1
I/O portReadWriteReadWrite
baseRBR receiver bufferTHR transmitter holdingDLL divisor latch LSB
base + 1IER interrupt enableIER interrupt enableDLM divisor latch MSB
base + 2IIR interrupt identificationFCR FIFO controlIIR interrupt identificationFCR FIFO control
base + 3LCR line control
base + 4MCR modem control
base + 5LSR line status– factory testLSR line status– factory test
base + 6MSR modem status– not usedMSR modem status– not used
base + 7SCR scratch

Available registers
RBR, receiver buffer register
THR, transmitter holding register
IER, interrupt enable register
IIR, interrupt identification register
FCR, FIFO control register
LCR, line control register
MCR, modem control register
LSR, line status register
MSR, modem status register
SCR, scratch register
DLL, divisor latch LSB
DLM, divisor latch MSB

The communication between the processor and the UART is completely controlled by twelve registers. These registers can be read or written to check and change the behaviour of the communication device. Each register is eight bits wide. On a PC compatible, the registers are accessible in the I/O address area. The function of each register will be discussed here in detail.

RBR : Receiver buffer register (RO)

The RBR, receiver buffer register contains the byte received if no FIFO is used, or the oldest unread byte with FIFO's. If FIFO buffering is used, each new read action of the register will return the next byte, until no more bytes are present. Bit 0 in the LSR line status register can be used to check if all received bytes have been read. This bit wil change to zero if no more bytes are present.

THR : Transmitter holding register (WO)

The THR, transmitter holding register is used to buffer outgoing characters. If no FIFO buffering is used, only one character can be stored. Otherwise the amount of characters depends on the type of UART. Bit 5 in the LSR, line status register can be used to check if new information must be written to THR. The value 1 indicates that the register is empty. If FIFO buffering is used, more than one character can be written to the transmitter holding register when the bit signals an empty state. There is no indication of the amount of bytes currently present in the transmitter FIFO.

The transmitter holding register is not used to transfer the data directly. The byte is first transferred to a shift register where the information is broken in single bits which are sent one by one.

IER : Interrupt enable register (R/W)

The smartest way to perform serial communications on a PC is using interrupt driven routines. In that configuration, it is not necessary to poll the registers of the UART periodically for state changes. The UART will signal each change by generating a processor interrupt. A software routine must be present to handle the interrupt and to check what state change was responsible for it.

Interrupts are not generated, unless the UART is told to do so. This is done by setting bits in the IER, interrupt enable register. A bit value 1 indicates, that an interrupt may take place.

IER : Interrupt enable register
BitDescription
0Received data available
1Transmitter holding register empty
2Receiver line status register change
3Modem status register change
4Sleep mode (16750 only)
5Low power mode (16750 only)
6reserved
7reserved

IIR : Interrupt identification register (RO)

An UART is capable of generating a processor interrupt when a state change on the communication device occurs. One interrupt signal is used to call attention. This means, that additional information is needed for the software before the necessary actions can be performed. The IIR, interrupt identification register is helpful in this situation. Its bits show the current state of the UART and which state change caused the interrupt to occur.

IIR : Interrupt identification register
BitValueDescriptionReset by
00Interrupt pending
1No interrupt pending
1,2,3Bit 3Bit 2Bit 1  
000Modem status changeMSR read
001Transmitter holding register emptyIIR read or THR write
010Received data availableRBR read
011Line status changeLSR read
110Character timeout (16550)RBR read
40Reserved
50Reserved (8250, 16450, 16550)
164 byte FIFO enabled (16750)
6,7Bit 7Bit 6  
00No FIFO
10Unusable FIFO (16550 only)
11FIFO enabled

FCR : FIFO control register (WO)

FCR : FIFO control register
BitValueDescription
00Disable FIFO's
1Enable FIFO's
10
1Clear receive FIFO
20
1Clear transmit FIFO
30Select DMA mode 0
1Select DMA mode 1
40Reserved
50Reserved (8250, 16450, 16550)
1Enable 64 byte FIFO (16750)
6,7Bit 7Bit 6Receive FIFO interrupt trigger level
001 byte
014 bytes
108 bytes
1114 bytes

The FCR, FIFO control register is present starting with the 16550 series. This register controls the behaviour of the FIFO's in the UART. If a logical value 1 is written to bits 1 or 2, the function attached is triggered. The other bits are used to select a specific FIFO mode.

LCR : Line control register (R/W)

LCR : line control register
BitValueDescription
0,1Bit 1Bit 0Data word length
005 bits
016 bits
107 bits
118 bits
201 stop bit
11.5 stop bits (5 bits word) 2 stop bits (6, 7 or 8 bits word)
3,4,5Bit 5Bit 4Bit 3 
xx0No parity
001Odd parity
011Even parity
101High parity (stick)
111Low parity (stick)
60Break signal disabled
1Break signal enabled
70DLAB : RBR, THR and IER accessible
1DLAB : DLL and DLM accessible

The LCR, line control register is used at initialisation to set the communication parameters. Parity and number of data bits can be changed for example. The register also controls the accessibility of the DLL and DLM registers. These registers are mapped to the same I/O port as the RBR, THR and IER registers. Because they are only accessed at initialisation when no communication occurs this register swapping has no influence on performance. Some remarks about parity:

The UART is capable of generating a trailing bit at the end of each dataword which can be used to check some data distortion. Because only one bit is used, the parity system is capable of detecting only an odd number of false bits. If an even number of bits has been flipped, the error will not be seen.

When even parity is selected, the UART assures that the number of high bit values in the sent or received data is always even. Odd parity setting does the opposite. Using stick parity has very little use. It sets the parity bit to always 1, or always 0.

Common settings are:

  • 8 data bits, one stop bit, no parity
  • 7 data bits, one stop bit, even parity

MCR : Modem control register (R/W)

The MCR, modem control register is used to perform handshaking actions with the attached device. In the original UART series including the 16550, setting and resetting of the control signals must be done by software. The new 16750 is capable of handling flow control automatically, thereby reducing the load on the processor.

MCR : Modem control register
BitDescription
0Data terminal ready
1Request to send
2Auxiliary output 1
3Auxiliary output 2
4Loopback mode
5Autoflow control (16750 only)
6Reserved
7Reserved

The two auxiliary outputs are user definable. Output 2 is sometimes used in circuitry which controls the interrupt process on a PC. Output 1 is normally not used, however on some I/O cards, it controls the selection of a second oscillator working at 4 MHz. This is mainly for MIDI purposes.

LSR : Line status register (RO)

The LSR, line status register shows the current state of communication. Errors are reflected in this register. The state of the receive and transmit buffers is also available.

LSR : Line status register
BitDescription
0Data available
1Overrun error
2Parity error
3Framing error
4Break signal received
5THR is empty
6THR is empty, and line is idle
7Errornous data in FIFO

Bit 5 and 6 both show the state of the transmitting cycle. The difference is, that bit 5 turns high as soon as the transmitter holding register is empty whereas bit 6 indicates that also the shift register which outputs the bits on the line is empty.

MSR : Modem status register (RO)

The MSR, modem status register contains information about the four incomming modem control lines on the device. The information is split in two nibbles. The four most siginificant bits contain information about the current state of the inputs where the least significant bits are used to indicate state changes. The four LSB's are reset, each time the register is read.

MSR : Modem status register
BitDescription
0change in Clear to send
1change in Data set ready
2trailing edge Ring indicator
3change in Carrier detect
4Clear to send
5Data set ready
6Ring indicator
7Carrier detect

SCR : Scratch register (R/W)

The SCR, scratch register was not present on the 8250 and 8250B UART. It can be used to store one byte of information. In practice, it has only limited use. The only real use I know of is checking if the UART is a 8250/8250B, or a 8250A/16450 series. Because the 8250 series are only found in XT's even this use of the register is not commonly seen anymore.

DLL and DLM : Divisor latch registers (R/W)

For generating its timing information, each UART uses an oscillator generating a frequency of about 1.8432 MHz. This frequency is divided by 16 to generate the time base for communucation. Because of this division, the maximum allowed communication speed is 115200 bps. Modern UARTS like the 16550 are capable of handling higher input frequencies up to 24 MHz which makes it possible to communicate with a maximum speed of 1.5 Mbps. On PC's higher frequencies than the 1.8432 MHz are rarely seen because this would be software incompatible with the original XT configuration.

This 115200 bps communication speed is not suitable for all applications. To change the communication speed, the frequency can be further decreased by dividing it by a programmable value. For very slow communications, this value can go beyond 255. Therefore, the divisor is stored in two seperate bytes, the divisor latch registers DLL and DLM which contain the least, and most significant byte.

For error free communication, it is necessary that both the transmitting and receiving UART use the same time base. Default values have been defined which are commonly used. The table shows the most common values with the appropriate settings of the divisor latch bytes. Note that these values only hold for a PC compatible system where a clock frequency of 1.8432 MHz is used.

DLL and DLM : Divisor latch registers
Speed (bps)DivisorDLLDLM
502,3040x000x09
3003840x800x01
1,200960x600x00
2,400480x300x00
4,800240x180x00
9,600120x0C0x00
19,20060x060x00
38,40030x030x00
57,60020x020x00
115,20010x010x00

Label:

Software for RS232

Posted by Joe

Software downloads, read this first!

The software on this page is believed to function as described in the document present in each archive file. All archive files are in ZIP format.

Use this software at your own risk. Lammert Bies can not be held responsible for any damage, financial loss or injuries resulting from using the software found here. If such problems are encountered using this software, please send me a mail message describing the problem and the software will either be updated, or removed from this website.

Software for RS232 communications

The files listed below are free downloads.

Programs
File Size Release Language OS Description
prg_chk.zip 7,613 bytes 1999-02-21 V 1.01 Microsoft C/C++ DOS UART detector which checks default COM ports or user specified addresses for the existence and type of UART's.
Libraries
File Size Release Language OS Description
lib_crc.zip 29,330 bytes 2008-04-20V 1.16 ANSI C/C++ all CRC library with routines to check for errors in the data transfer. Support in the Error Detection and Correction forum
Please visit us at  http://plc2u.com/index.php/plc-article/interfacing/software-for-rs232-communications

Label:

Introduction to RS422

Monday, 9 March 2009
Posted by Joe

Introduction to RS422

Serial communication methods to transfer information between equipment have been defined by standards for nearly half a century. The oldest and best known standard is RS232, a standard which defines the communication between DTE, data terminal equipment, and DCE, data communication equipment. The relatively short distances and low speed the RS232 serial interface can handle demanded for newer standards like RS422, RS423 and RS485. In this document, I will focus on the RS422 interface for serial balanced differential communications.

Differential balanced signals with RS422

Serial, balanced and differential are the keywords for the RS422 interface standard. Serial means, that the information is sent bit by bit on a single transmission line, just like with RS232. Balanced differential is what makes RS422 different from RS232. On RS232 interfaces, the signals are send on lines which share a common zero. With RS422, each signal line consists of two wires, preferably twisted to reduce noise. The voltage-difference between the two lines is an indication of the signal value, rather than the voltage-level. Looking at voltage differences with RS422 rather than levels eliminates a lot of noice induced by external sources and allows for higher data rates and cable lengths compated to RS232. You can see the differences in speed and cable length between RS422 and other commonly used serial interface standards like RS232, RS423 and RS485 in the interface comparison table.

Twisting the lines helps to reduce the noise. The noise currents induced by an external source are reversed in every twist. Instead of amplifying each other as in a straight line, the reversed noice currents reduce each others influence. The figure explains this in more detail.

RS422

Network topology with RS422

There are more differences between RS422 and RS232 than the maximum data speed and cable length. RS232 was specifically defined as an interface between computers, printers and terminals with modems. The modem would translate the communication signals to protocol usable for long distance communication, where long distance could also mean a device on the other side of the control room or building. RS422 allows the direct connection of intelligent devices, without the need of modems. Furthermore, where the RS232 linedriver is only designed to serve one receiver, a RS422 linedriver can serve upto ten receivers in parallel. This allows one central control unit to send commands in parallel to upto ten slave devices. Unfortunately, those slave devices cannot send information back over a shared interface line. RS422 allows a multi-drop network topology, rather than a multi-point network where all nodes are considered equal and every node has send and receive capabilities over the same line. If you need to build a multi-point communication network rather than multi-drop, RS485 is the right choice with a maximum of 32 parallel send and 32 receive units parallel on one communication channel.

Please visit us at  http://plc2u.com/index.php/plc-article/interfacing/introduction-to-rs422

Label:

PLC programming cables for several brands

Posted by Joe

Most PLC's can be programmed from a PC via a serial cable. Unfortunately, many of these cables have a non standard layout. De cables shown here can be bought from the regular sales channels, but it is often much cheaper to solder them yourself.

Siemens PLC's

Most programming of Siemens S5 PLC's is done using a special RS232 to TTY converter. The S7 series are programmed using a RS232 to MPI bus converter. The easiest thing to do is buy these special cables from your local Siemens supplier. The operator terminals however can be programmed using a normal serial cable. The following cable can be used to program the OP series of operator displays.

programmable logic control,plc

Idec / Izumi PLC's

Idec / Izumi PLC series FA2, FA2J and FA3J all require a special communication adaptor for programming. This communication link adaptor (CLA) is a small box that converts the RS232 electrical signals into a compatible level for the PLC. The cable to connect the PC to a CLA uses a DB25 connector at the PLC side. The layout for a cable with a DB9 connector at the PC side is shown here.

programmable logic control,olc

Z-World microcontrollers

Z-World is an American company specialized in developing microcontroller boards based on the Z180 and Rabbit series micro controllers. Where PLC's are often used in single piece environments, micro controllers are mainly present in the OEM world where multiple controllers are needed. The main difference in programming a PLC is that most microcontrollers, including those from Z-World, are programmed in C. The Z-World programming package runs on a normal PC and the connection with the controller is made using a serial cable. This cable needs a DB9 connector at one and, and a RJ14 plug at the other. The pin out of a programming cable is shown here.

Please visit us at  http://plc2u.com/index.php/plc-article/interfacing/plc-programming-cables-for-several-brands

Label: ,

Mitsubishi PLC cable layouts

Friday, 6 March 2009
Posted by Joe

Melsec PLC's from Mitsubishi can be connected to PC's running Medoc programming software using various cables. Each different I/O module uses a different pin assignment. The signal levels of the A series CPU units are not RS232 compatible and must be converted with a SC-02N or SC-05 converter

The serial cable layout to connect this converter to a PC is shown in this diagram.

plc mitsubishi

If more than one serial port is necessary on an A series melsec PLC, the AJ71C24 or AJ71C21 serial communication modules can be plugged into the system. These modules provide RS232 compatible serial ports, so no signal conversion is necessary to connect these modules with a PC. Both modules are equipped with a DB25 connector.

The cable layout for these two modules is shown below.

plc mitsubishi

The A1SJ71C24-R2 can also be used to connect computers and devices to a melsec series A PLC. This plug-in module contains two serial ports, each with a DB9 connector. The wiring layout is in fact identical to the RS232 null modem cable with loopback handshaking.

Label: ,

Mitsubishi FX2N PLC Communication Cable

Posted by Joe

Here is a configuration of communication cable between Mitsubishi FX2 PLC HMI with a PC.

Here for Mitsubishi FX2N PLC:

Label: ,

Mini PLC with Microcontroller

Posted by Joe

Programmable Logic Controllers (PLC) have been extensively used in industry for the past five-six decades. PLC manufacturers offer different PLCs in terms of functions, program memories, and the number of inputs/outputs (I/O), ranging from a few to thousands of I/Os. The design and implementation of PLCs have long been a secret of the PLC manufacturers. As a microprocessor based technology, the functionality of a PLC is well-known from the end-user (programmer) point of view, but by now no serious work has been reported to describe a microprocessor/microcontroller based implementation of a PLC.

Here's the link : http://host.nigde.edu.tr/muzam/UZAM_PLC_with_PIC16F648A.htm

Download (PDF) :

  • PLC With PIC 16F648A Microcontroller (Part 1)
  • PLC With PIC 16F648A Microcontroller (Part 2)
  • PLC With PIC 16F648A Microcontroller (Part 3)
  • PLC With PIC 16F648A Microcontroller (Part 4)
  • Label:

    The difference between PLC and microcontrollers

    Posted by Joe

    A PLC is a special microcontroller designed for industrial use, that is for controlling machinery or processes. Usually a PLC is programmed using Ladder diagrams and specialized control software. A microcontroller is a microprocessor that can be used for any type of application, but there some for special applications, like a PLC. Here's a link.

    http://en.wikipedia.org/wiki/Microcontroller http://en.wikipedia.org/wiki/Programmable_logic_controller

    Label: