{"id":1586,"date":"2024-11-26T15:22:57","date_gmt":"2024-11-26T15:22:57","guid":{"rendered":"https:\/\/mitechservices.ca\/MITS\/?p=1586"},"modified":"2024-11-26T15:22:58","modified_gmt":"2024-11-26T15:22:58","slug":"numeric-data-types-in-plc-programming","status":"publish","type":"post","link":"https:\/\/mitechservices.ca\/MITS\/2024\/11\/26\/numeric-data-types-in-plc-programming\/","title":{"rendered":"Numeric Data Types in PLC Programming"},"content":{"rendered":"\n<p class=\"has-text-align-center\"><strong>See The Video Here<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"PLC Basics   Numeric Data Types Part 1 Boolean and Integers\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/kKZuzrizRd8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>When working with programmable logic controllers (PLCs), understanding numeric data types is essential. PLCs rely on various data types to handle information effectively, from simple Boolean states to complex floating-point calculations. This blog explores the building blocks of data units, the key numeric data types, and their practical applications in PLC programming.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-large-font-size\"><strong>Sizing of Data Units<\/strong><\/p>\n\n\n\n<p>At its core, digital information in a PLC is made up of <strong>bits<\/strong>. These bits can be grouped into larger units depending on their function. Here&#8217;s an overview:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Bit<\/strong>: The smallest unit, representing either 1 (on) or 0 (off).<\/li>\n\n\n\n<li><strong>Nibble<\/strong>: A group of 4 bits.<\/li>\n\n\n\n<li><strong>Byte<\/strong>: Composed of 8 bits.<\/li>\n\n\n\n<li><strong>Word<\/strong>: Composed of 16 bits.<\/li>\n\n\n\n<li><strong>Double Word<\/strong>: Composed of 32 bits.<\/li>\n<\/ul>\n\n\n\n<p>These units form the foundation for all data types used in PLC programming.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"980\" height=\"283\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/different-sizesdata-units.jpg\" alt=\"\" class=\"wp-image-195\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/different-sizesdata-units.jpg 980w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/different-sizesdata-units-300x87.jpg 300w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/different-sizesdata-units-768x222.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-large-font-size\"><strong>Basic Data Types<\/strong><\/p>\n\n\n\n<p>The <strong>basic (or atomic) data types<\/strong> represent fundamental pieces of information. They include:<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>1. Boolean<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Size<\/strong>: 1 bit.<\/li>\n\n\n\n<li><strong>Purpose<\/strong>: Represents two states, 1 (true\/on) or 0 (false\/off).<\/li>\n\n\n\n<li><strong>Example Use<\/strong>: Detecting whether a sensor is activated.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"215\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2024\/11\/Bool-Data.jpg\" alt=\"\" class=\"wp-image-1610\"\/><\/figure>\n<\/div>\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-medium-font-size\"><strong>2. Unsigned Integers<\/strong><\/p>\n\n\n\n<p>Unsigned integers represent positive whole numbers.<\/p>\n\n\n\n<p><strong>8-Bit Unsigned Integer<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Size: 1 byte (8 bits).<\/li>\n\n\n\n<li>Range: 0 to 255.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"183\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-8bit-unsigned.jpg\" alt=\"\" class=\"wp-image-198\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-8bit-unsigned.jpg 505w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-8bit-unsigned-300x109.jpg 300w\" sizes=\"auto, (max-width: 505px) 85vw, 505px\" \/><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>16-Bit Unsigned Integer<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Size: 1 word (16 bits).\n<ul class=\"wp-block-list\">\n<li>Range: 0 to 65,535.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"799\" height=\"177\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-16bit-unsigned.jpg\" alt=\"\" class=\"wp-image-197\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-16bit-unsigned.jpg 799w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-16bit-unsigned-300x66.jpg 300w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-16bit-unsigned-768x170.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-medium-font-size\"><strong>3. Signed Integers<\/strong><\/p>\n\n\n\n<p>Signed integers handle both positive and negative whole numbers. When converting signed integers from binary, there is a special arrangement to handle negative as well as positive values. The bit that is most to the left is considered the most significant bit (MSB). The signed integer data type uses the MSB for a special purpose. The MSB is assigned a negative value if that particular bit is set to 1. This gives the format the capability to express negative numbers.<\/p>\n\n\n\n<p><strong>8-Bit Signed Integer<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Size: 1 byte (8 bits).<\/li>\n\n\n\n<li>Range: -128 to 127.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"659\" height=\"400\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-8bit-signed.jpg\" alt=\"\" class=\"wp-image-202\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-8bit-signed.jpg 659w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-8bit-signed-300x182.jpg 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n<\/div>\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>16-Bit Signed Integer<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Size: 1 word (16 bits).\n<ul class=\"wp-block-list\">\n<li>Range: -32,768 to 32,767.<\/li>\n\n\n\n<li>The <strong>most significant bit (MSB)<\/strong> determines the sign. If the MSB is 1, the number is negative.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"871\" height=\"377\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-16bit-signed-1.jpg\" alt=\"\" class=\"wp-image-200\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-16bit-signed-1.jpg 871w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-16bit-signed-1-300x130.jpg 300w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-16bit-signed-1-768x332.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n<\/div>\n\n\n<p><strong>32-Bit Signed Integer<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Size: 1 double word (32 bits).<\/li>\n\n\n\n<li>Range: -2,147,483,648 to 2,147,483,647.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"987\" height=\"316\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-32bit-signed.jpg\" alt=\"\" class=\"wp-image-203\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-32bit-signed.jpg 987w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-32bit-signed-300x96.jpg 300w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/int-32bit-signed-768x246.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n<\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-large-font-size\"><strong>Floating Point<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong>See The Video Here<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"PLC Basics   Numeric Data Types Part 1 Boolean and Integers\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/kKZuzrizRd8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Floating-point data types store numbers with decimal places. Consider the Single Precision Floating Point as an example. It occupies a Double Word (32 bits). The way that data is encoded within the 32 bits is very different then what we see with integers.  To manage a wide range of numbers with decimal places, the 32 bit structure is divided into 3 subgroups. The subgroups hold different attributes that encode a value. The following is a brief description of the structure of the data type. <\/p>\n\n\n\n<p><strong>1 bit<\/strong> will represent the sign of the number, 0 if positive and 1 if negative.<\/p>\n\n\n\n<p><strong>8 bits<\/strong> are assigned to the purpose of storing an exponent value. An exponent is a component of a number when it is expressed in scientific notation. In this case it is a form of scientific notation that is at Base 2 .<\/p>\n\n\n\n<p><strong>23 bits<\/strong> are assigned to hold compressed details of the number that is known as the Mantissa. The Mantissa is also a component of a number when it is expressed in this Base 2 version of  scientific notation. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"366\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2024\/11\/Base2-Scientific-Notation-1024x366.jpg\" alt=\"\" class=\"wp-image-1619\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2024\/11\/Base2-Scientific-Notation-1024x366.jpg 1024w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2024\/11\/Base2-Scientific-Notation-300x107.jpg 300w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2024\/11\/Base2-Scientific-Notation-768x274.jpg 768w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2024\/11\/Base2-Scientific-Notation.jpg 1114w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n<\/div>\n\n\n<p><strong>Single Precision Floating Point<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Size<\/strong> 1 double word ( 32 bits ).\n<ul class=\"wp-block-list\">\n<li>1 bit: Sign (0 = positive, 1 = negative).<\/li>\n\n\n\n<li>8 bits: Exponent.<\/li>\n\n\n\n<li>23 bits: Mantissa.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1003\" height=\"433\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/floating-point.jpg\" alt=\"\" class=\"wp-image-204\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/floating-point.jpg 1003w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/floating-point-300x130.jpg 300w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/floating-point-768x332.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Floating points are ideal for applications requiring precision, such as temperature or flow rate measurements.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-large-font-size\"><strong>Other Data Types<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Structured Data Types<\/strong><\/p>\n\n\n\n<p>Combinations of the basic, atomic, data types can be grouped together and they are called structures. PLCs utilize these <strong>structured data types<\/strong> to handle specific tasks. There are predefined structured data types for timers, counters and file control operations just to name a few.<\/p>\n\n\n\n<p>Consider a Timer Data Type for an Allen Bradley SLC 500 PLC. It is made up of three 16 bit words. Bits 13, 14 and 15 of Word 0 are boolean data type. The booleans are to express the on\/off state for the timer Enable, Timer-Timing and Done. Word 1 and Word 2 are signed 16 bit integers containing numeric data for the timer preset and accumulator.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"237\" src=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/timer-data-type-1.jpg\" alt=\"\" class=\"wp-image-207\" srcset=\"https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/timer-data-type-1.jpg 723w, https:\/\/mitechservices.ca\/MITS\/wp-content\/uploads\/2022\/04\/timer-data-type-1-300x98.jpg 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-medium-font-size\"><strong>User-Defined Data Types (UDTs)<\/strong><\/p>\n\n\n\n<p>Some PLCs allow custom structures, enabling programmers to define data types tailored to their application by combining existing ones.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>Numeric data types are the backbone of PLC programming, enabling the efficient handling of data for a wide range of applications. Whether you\u2019re toggling a simple boolean state or performing precise floating-point calculations, selecting the right data type ensures your system operates smoothly.<\/p>\n\n\n\n<p>Take time to understand your PLC\u2019s predefined options, and don\u2019t hesitate to explore user-defined types for custom applications. Proper data management is a cornerstone of robust PLC programming.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><strong>Coming Soon &#8211; More PLC Blogs<\/strong><\/strong><\/p>\n\n\n\n<div style=\"height:187px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>See The Video Here When working with programmable logic controllers (PLCs), understanding numeric data types is essential. PLCs rely on various data types to handle information effectively, from simple Boolean states to complex floating-point calculations. This blog explores the building blocks of data units, the key numeric data types, and their practical applications in PLC &hellip; <a href=\"https:\/\/mitechservices.ca\/MITS\/2024\/11\/26\/numeric-data-types-in-plc-programming\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Numeric Data Types in PLC Programming&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1586","post","type-post","status-publish","format-standard","hentry","category-plc-basics"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/posts\/1586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/comments?post=1586"}],"version-history":[{"count":20,"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/posts\/1586\/revisions"}],"predecessor-version":[{"id":1630,"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/posts\/1586\/revisions\/1630"}],"wp:attachment":[{"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/media?parent=1586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/categories?post=1586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitechservices.ca\/MITS\/wp-json\/wp\/v2\/tags?post=1586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}