Introduction

Many people know that PLCs are capable of working with numbers and mathematical calculations but the instruction set and rules can be confusing when trying to implement them in GX IEC Developer.

Design Considerations

Most Mitsubishi PLCs include 3 different mathematical instruction sets. There is a set of instructions for 16-bit signed integers, another set for 32-bit signed integers and a third set for floating point variables. This in itself is manageable but it starts to get tricky when, for example, the result of a 16-bit multiply gives a 32-bit answer which can then not be used with any other 16-bit instructions without conversion back to 16-bit.

The best way to simplify the maths challenge is to use the IEC instruction set and not the Mitsubishi instruction set which, after all, is what you should be using if you are trying to write a pure IEC compliant application.

From the examples below you can see that when using the IEC instruction set, it does not matter if you are trying to do 16-bit, 32-bit or floating point maths, the instructions are the same.

Example 1 – 16-bit integer maths

NOTE: the 2 lines of code needed for the non-IEC version

Example 2 – floating point maths

NOTE: only 1 line of code for each version this time, but the IEC code is the same as example 1

It is even easier if you use structured text:

Further Information

For further information, please refer to the GX IEC Developer help files and the structured text manuals or contact our support desk (support@adroit.co.za).

You can download this Tip in PDF format here.

[et_pb_divi_related_posts_module _builder_version="3.0.106" header_text="Related Posts" posts_count="5" posts_source="tags" /]