====== Number System (CUBLOC Ladder Logic) ====== The basic data processing units used in ladder logic are **Word (16-bit)** and **Double Word (32-bit)**. In the CUBLOC ladder environment, strict numerical ranges must be observed to prevent interference with system-reserved addresses. ===== 1. Memory Structure (D-Area) ===== * **D-Area (Data Register):** Basically composed of 16-bit (1 Word) units. * **Double Word Processing:** To handle 32-bit data, **two consecutive D-areas** are required (e.g., combining D0 and D1 to store a single 32-bit value). ===== 2. Data Types and Range Limits ===== This system operates on the principle of using **Unsigned Integers** to prevent data collisions with hardware control ports (P, WP, etc.). ^ Unit ^ Bit Count ^ Decimal Range ^ Hexadecimal Range ^ | Word | 16-bit | 0 ~ 65,535 | 0000H ~ FFFFH | | Double Word (D-Word) | 32-bit | 0 ~ 2,147,418,111 | 00000000H ~ **7FFEFFFFH** | > **Critical Notice:** Both Word and Double Word (D-Word) should be processed as **Unsigned (Positive)**. In particular, Double Words must be used within the upper limit of **0x7FFEFFFF** to avoid encroaching on the system-reserved address area (0x7FFF1000 and above). ===== 3. Upper Limit Restrictions ===== ==== Collision with System Reserved Addresses ==== * The area from **0x7FFF1000 to 0x7FFFFFFF** is reserved for **Memory-Mapped I/O** addresses to control hardware I/O ports (P0, WP0, etc.). * **Prohibition of Negative Numbers (2's Complement):** If the Most Significant Bit (MSB) is set to 1 to represent a negative number (e.g., 0x80000000 or higher), the system may misinterpret it as a system-reserved address rather than a number, causing calculation errors or hardware malfunctions. * **Recommendation:** If negative arithmetic is required, do not use signed values directly. Instead, manage a separate D-area as a sign flag (e.g., 0: Positive, 1: Negative) within your logic. ==== Operational Cautions ==== * If a calculation result exceeds **2,147,418,111 (0x7FFEFFFF)**, it overlaps with internal system addresses, resulting in data corruption. * You must implement logic to filter or cap values before they exceed this upper limit during input or arithmetic processes. ==== Usage Examples ==== Entering a value that exceeds the system limit into a Double Word (e.g., 0xEE6B4000) will result in an error or incorrect calculation results, as shown below: {{ :cubloc:ladder_number:dwerr.png?nolink |}} Always ensure you use positive values below the upper limit: {{ :cubloc:ladder_number:dwval.png?nolink |}} While it is technically possible to input negative numbers using DWMOV, this should be avoided as it can trigger unpredictable system errors: {{ :cubloc:ladder_number:dwval2.png?nolink |}} [[cubloc:index#Ladder_Logic:|Go CUBLOC Ladder Logic home]]