A PLC Tag is not a Description; nor is it a Variable Name
Weâ€™ve had tag based control systems for years now but some programmers just arenâ€™t getting it.
The other day I was working on this machine that makes hand made quilts.Â Itâ€™s quite an ingenious machine, actually.Â The whole secret to this thing was this â€œHand-O-Maticâ€ stitcher unit that randomly inserts longer or shorter stitches to simulate making the quilt by hand.Â That was the problem, though â€“ the production manager said once in a while it just wouldnâ€™t produce short or long stitches so the machine produces these perfectly stitched quilts that wonâ€™t even fetch a tenth of the price at the big box retailer.Â The quality department kept rejecting them.
The drawings showed it was pretty simple.Â The PLC has two outputs to the stitcher: one tells it to do a long stitch, the other tells it to do a short stitch.Â Mike from the maintenance department had already determined that when the machine was acting up, those outputs werenâ€™t working.
Weâ€™ve Got Tags, Letâ€™s Use Them
I went online with the PLC and did a quick search for the output name shown in the drawings â€“ nothing.Â Thatâ€™s odd.Â Then I bring up the tag list and look for any tags with Stitcher in the name â€“ nothing.Â Finally I go to the hardware tag address for the outputs themselves and trace those back through the logic, and find they are being driven by some linear feedback shift registers.Â Guess what the tag names for the outputs of the shift registers wereâ€¦Â â€œbits(3).5â€ and â€œbits(4).5â€.Â Well Thatâ€™s Intuitive!
Thatâ€™s an example of the first mistake I keep seeing: programmers who donâ€™t even take advantage of tag based addresses.Â This isnâ€™t 1990 anymore; itâ€™s time to move on.
Tags are not Variables
The second mistake is usually made by guys like me who programmed computers in school before they started programming PLCs.Â The first time I saw tags I thought, â€œGreat!Â Variables!â€Â In languages like C, BASIC, and Pascal, the programmer has to use variable names that function as both a name and description.Â Youâ€™ll frequently see variable names like â€œmiFileLineLoopCountâ€ â€“ meaning, of course, that itâ€™s a module scoped integer that counts up once every time you read another line from the file.Â The only thing that keeps things sane is that they use lots of locally scoped variables that only have meaning within a single block of code, so you only have to worry about 20 or so variables at once.Â In the PLC world, weâ€™re largely stuck with tags scoped at the global or program level (though thatâ€™s changing).
So guys like me started creating PLC tags like â€œInbound_Conveyor_Zone_1_Blockedâ€.Â But the tag names are so long that when you try to view a decent sized rung of logic with 15 or so contacts, the programming software either wraps the rung in on itself or makes you scroll to the right 5 screenfuls.Â It becomes unreadable.Â Tags are not variables â€“ letâ€™s keep the descriptions separate.
Using Structured Tag Names
Every PLC program needs a structured tag naming convention.Â When the machine was designed it was already broken down into zones, areas, stations, components â€“ whatever.Â Tag names should reflect this.Â Have the tags make use of device IDs used in the drawings too.Â Itâ€™s also important to make tag names short.Â Consider this structured tag name: â€œS110_Deliv_PPâ€.Â The description of that tag might be â€œStation 110, Delivery Conveyor, Part Present Latch [E1522PRX]â€.Â The beauty of ladder logic is that the description will be displayed over the contact or coil in the editor.Â You donâ€™t have to spell out â€œStation110â€¦â€ in the tag name because anyone familiar with the system will recognize â€œS110â€¦â€ means the same thing.
The advantage of this scheme is that the tag database can be displayed in alphabetical order, so all tags for station 110 will be grouped together, and all tags for the station 110 delivery conveyor will also be grouped together.Â Do you need to add an identical delivery conveyor to station 120?Â Just select all the â€œS110_Deliv_*â€ tags and copy and rename them to â€œS120_Deliv_*â€ and you know youâ€™ve got them all.Â Do you want to delete station 110?Â Just select all the â€œS110_*â€ tags and delete them.Â Before tag based systems this meant we had to hunt down all the addresses used for that conveyor and delete the descriptions for each one (or we could leave the descriptions in there just to confuse the next programmer who has to look at it).
So, letâ€™s use tags with a purpose.Â Come up with a structured tag naming convention and stick to it.
Oh… and if anyoneâ€™s interested in buying some authentic hand made quilts, let me know â€“ I can get you a great deal!