When you design a PLC logic, you have to take care of the names that you provide to tags. It should be easily understood and interpreted by any programmer. It should neither be too long nor too short.
The naming convention is important because improper tagging can cause troubleshooting issues for programmers. Also, giving lengthy names will consume the memory of PLC. So, every programmer has to follow proper naming conventions before writing a PLC program. In this post, we will see the concept of PLC tag naming conventions.
PLC Naming Conventions
First of all, let us understand how tag naming convention plays a great role in PLC programming. You have a motor with its run command and run feedback as PLC IO’s.
The motor is located in the blower room and it is used as an air compressor. The motor tag name in the P&ID is M-101. Now, for a PLC programmer, identifying a tag location is important. So, there are two types of mindsets that normally define a PLC programmer.
The first will try to give as much information as possible in a tag name; so he can name the motor run command as M101_Compressor_Run_Command. The second one will try to give the name as Q_M101_Comp.
The second mindset looks very clear, as he is giving short names and keeping the length as minimal as possible. This is the reason why naming a PLC tag is important, as it relieves the programmer from reading such lengthy tags in situations where urgent troubleshooting has arrived. (It is to be noted that PLC tag naming does not accept any special character apart from underscore (_) ).
A PLC tag name should contain information that can help the programmer relate to the meaning of it. This generally implies the following information –
- data type (eg. boolean, integer),
- data flow (eg. input, output),
- scope (eg. local, global),
- instrument or device type (eg. motor, valve, sensor),
- process parameter (eg. pressure, flow, temperature) and
- location of the device.
Tag Name Styles
There are various styles according to IEC standards that must be followed for proper naming.
Let us have a look at some of the most generally used:
- Camel Style,
- Pascal Style,
- Snake Style,
- Prefix with Data Type Style
Camel Style
In this style, there is no underscore in between. A full name is given to the whole word, but each word in it starts with a capital letter. For example, take the above-discussed example.
M101_Compressor_Run_Command will be written as m101CompressorRunCommand. You can identify each word by a capital letter.
The first letter will be a compulsory small letter. This style looks good if the word is small. It prevents the use of underscore and this makes memory consumption smaller.
Pascal Style
It is similar to the camel style; the only difference is that the first letter will be a compulsory capital letter.
For example, our tag will be written as M101CompressorRunCommand.
Snake Style
The example that we discussed before is the snake style. Here, each word will be separated by an underscore.
Prefix with Data Type Style
Here, the tag will be prefixed by the data type of the tag name. In our case, the tag type was boolean. According to IEC standards, a boolean tag is usually given a prefix of ‘x’.
So, our style will be written as xM101CompressorRunCommand. This helps the programmer to identify what type of data is used for that particular tag.
Tips For Tag Naming in PLC Programming
The first and foremost rule is that the length of a tag should be short, but not so short that no one can understand it. As discussed, the length should contain appropriate information in a proper length. Lengthy names should be strictly avoided.
Follow the general tag naming styles that were discussed. These are according to IEC standards and make the logic look neat and clean.
To reduce bugs during tag creation, use Excel files. Excel reduces workload in a very vast way as duplication and copying becomes very easy. Errors are hardly produced in Excel files.
It is not always necessary to use a full name for a word. For example, the valve can be written as vlv and temperature can be written as temp.
Avoid making the tag fully capitals. It looks cumbersome and inappropriate to read.
If you liked this article, then please subscribe to our YouTube Channel for Instrumentation, Electrical, PLC, and SCADA video tutorials.
You can also follow us on Facebook and Twitter to receive daily updates.
Read Next:
- Pop-up in FactoryTalk View Studio
- How to use PLC with SQL Database?
- What is a PLC Retrofitting Project?
- Transferring Data Across PLC Systems
- What is Thin Client in SCADA?