As a PLC programmer or troubleshooter, you’re already be aware of certain things such as data types.
Sometimes they may be referred to differently depending on the platform, such as in one platform a floating point data type may be refereed to as a REAL, whereas in another it may be refereed to as a FLOAT.
Regardless of how they are referred to, you’ll want to understand the basic construct of the various commonly used types in the PLCs you use, and in this article I’ll cover several of the data types, access types, and ranges that can be set in a Mitsubishi PLC and GX Works3 project.
For this article I’ll start by starting a new project, but you can also start with a previous project and change the processor type under the Project drop-down menu.
In my example I’ll be working with one of the newer processors available, FX5U (part of the iQ-F series). How you choose to continue, of course, is optional.
You can start by adding tags (“label names”) before doing any programming. You can also add them as you progress through the chosen programming structure type you have chosen (Ladder, Structured Text, Function Block Diagram, etc.)
This is where you can choose to do straight symbol names or add addresses (“Device/Label”) such as a D100 or M52.
What designation of the data type you choose to use in the device will also limit what data type you can use.
The D designation is typically used for numeric values like Integers or Floats. If you use one for a Bit, it will look something like D100.0. The M device designation mentioned previously will be used for Boolean instances only.
Giving the device a label name is just good programming practice. This would fall under the commenting part of a program and is helpful not only to yourself as you proceed but later when you’re recalling this program or being reviewed by another programmer, and possibly any maintenance personnel that is looking at your code that needs to get a manufacturing line back up and running again as quickly as possible.
The data types available can make quite a long list as these can also include any number of SDT (structured data types) supplied by an OEM with a hardware import or generally custom defined by you as needed for the application.
As shown above, this is a simple SDT used to group standard built-in addresses in the FX5U processor. These SDTs can be quite involved. You can also have labels defined with nested data types.
The flexibility with Mitsubishi is definite here, you can make it as complex or as simple as you choose.
Here you can declare something like a “PLC_Status” label with the data type of the previously declared SDT FX5U_Status. When you pull up the label, in the Global label set (or other custom label sets), you will see the “Detailed Setting” under the Assign (Device/Label) column. When you click on this, you can then manually or automatically assign the device for each item in the structured label.
So, of course, you have the standard Boolean (Bit) data type. Used for normally open, normally closed, and pulse bits throughout the program. These can be defined as internal, local, global, and I/O bits (inputs, outputs, and HMI interface bits).
Then you have the Word (16-bit) and Double Word (32-bit) data types. These can be declared the same (local, global), but you will need to be sure if you are using a 16-bit value (-32,768 to 32,767) or the 32-bit (-65,536 to 65,535). Now, these are the signed integer ranges. If you are using the unsigned integers, your values can be 0 to 65,535 for the 16-bit and 32-bit value can go from 0 to 4,294,967,296. If declaring a Timer, for instance, you can select a Long Timer and it will be able to use a range up to the 32-bit unsigned value as a preset.
The next items in the list to look at and is standard among most PLCs are the Float (Real) and String data types. A float can be a range from -2128 to -2-126, 0, and 2-126 to 2128 for single precision and -21024 up to 21024 if using the LREAL or Double Precision Float data type.
The string data type is set up with 255 one-byte characters as a maximum. Just as most other popular PLCs, when selecting any of these data types, you can also select if the declaration is to be an array and how many elements will be set up.
Just as preferences differ from programmer to programmer and even from project to project, so do the ways to use, isolate, and manipulate data and the registers defined.
Beyond being familiar with the data types, you should be somewhat familiar with the way the system is built to fully understand how the numbers work and can be converted if needed.
As with some other PLC manufacturers, the Hex numbering system is the base and can have an impact on the flexibility of certain data types and program types (i.e., simple ladder, FBD, and structured text).
Keep that in mind, organize, and comment your program so that you are not the only one being called at 3 a.m. to get it running again. I will say again, it can be as simple or as complicated as you make it.
You’re the programmer so understand the system and the data types and the rest is just “ones and zeroes” as a shop foreman once jokingly said to me.
Written by Paul Hunt
Senior Automation Engineer and Freelance Writer
Have a question? Join our community of pros to take part in the discussion! You'll also find all of our automation courses at TheAutomationSchool.com.
Sponsor and Advertise: Get your product or service in front of our 75K followers while also supporting independent automation journalism by sponsoring or advertising with us! Learn more in our Media Guide here, or contact us using this form.
- Mitsubishi PLCs: Brief History and Hardware Overview - August 2, 2022
- Mitsubishi PLCs: FX5 vs iQ-R - February 10, 2022
- How To Register and Use a Device Profile in GX Works3 - November 9, 2021
Discover more from The Automation Blog
Subscribe to get the latest posts sent to your email.