IMDHMIControls LibraryShop main store

Troubleshooting

Why Citect Modbus ULONG needs LongDataType on the IOServer

SCADA and data logging Published 8 min read

Short answer

A ULONG tag that fails while INT, UINT and LONG tags read correctly is a 32-bit register-assembly fault, not a transport fault. Set [MODBUS] LongDataType = 3 (65,536 × high register + low register) on the IOServer, and only with the I/O Device protocol set to MODBUS, because MODBUS20 and MODBUS30 hardcode mode 3 and ignore the parameter. Confirm the register pair against an independent Modbus poll before and after the change.

On this page
  1. Why can Citect read LONG and UINT tags but not the ULONG tag?
  2. Is the 40001 offset or base-1 addressing at fault?
  3. What does the [MODBUS] LongDataType parameter control?
  4. Why does LongDataType have no effect on MODBUS20 or MODBUS30?
  5. How do you confirm the register order before touching Citect?
  6. How do you set LongDataType = 3 on the IOServer?
  7. What do you check when the ULONG tag still fails after the change?
  8. Questions asked

A ULONG tag that misreads while INT, UINT and LONG tags on the same device read correctly is not a wiring, gateway or offset fault: the Citect Modbus driver is assembling that value's two 16-bit registers the wrong way. The documented fix is LongDataType = 3 in the [MODBUS] section of the IOServer's driver parameters, applied on the machine that actually runs the IOServer, with the I/O Device protocol on MODBUS rather than a numbered variant, because MODBUS20 and MODBUS30 hardcode mode 3 and ignore the parameter. Prove the register order with an independent Modbus poll first, make the change, reload the IOServer, and compare the tag against the same poll. The sections below run the checks in the order they pay off, with the arithmetic shown so you can substitute your own raw words.

Why can Citect read LONG and UINT tags but not the ULONG tag? #

The ULONG tag fails because the driver assembles every 32-bit value through the [MODBUS] LongDataType mode, and a ULONG declaration still lands in whatever mode the IOServer is running, whose documented default range cannot hold a full-range unsigned measurement. Modbus carries 16-bit registers and nothing else: function code 03 returns holding-register words, function code 04 returns input-register words, and there is no 32-bit type anywhere on the wire.

A ULONG value is two consecutive registers, and which word counts as high, what each word is multiplied by and how large the result may be are all decided by the driver, not by the device's declaration. The declaration changes only the range your tag expects, not the assembly, which is why the same pair misreads in Citect even with the tag declared LONG while the neighbors succeed: their values happen to survive the mode your IOServer is in, and the big unsigned measurement does not.

Is the 40001 offset or base-1 addressing at fault? #

No — a wrong 40001-style offset or a base-1 mismatch breaks every tag on the device at once, and your INT, UINT and LONG tags already read correctly, so the channel, slave ID, function code and addressing convention are all proven by those working tags. The 40001-style prefix is an entry convention layered over one-based PLC addressing, and the way the two combine has its own classic failure — the one behind why Modbus error 8189 needs 400001 added to the register address — but an offset fault takes down every tag, not one data type.

What an offset can still do is aim the ULONG tag one register away from the pair, so rule it out explicitly: poll the two words, note the first register of the pair, and confirm the Citect tag resolves to that same register once the project's addressing convention is applied. A wrong address returns a stable wrong value that no LongDataType mode will repair, which is exactly what makes the poll comparison decisive.

What does the [MODBUS] LongDataType parameter control? #

[MODBUS] LongDataType selects how the driver joins two 16-bit registers into one 32-bit LONG value: mode 0, the documented default, computes 10,000 × low + high into a shortened 0 to 99,999,999 range, and modes 1 and 3 join the words by 65,536 across the full signed range. Allowable values are 0 to 3, and the four modes differ in both arithmetic and reachable range:

Mode Assembly the driver applies Documented range
0 (documented default) 10,000 × low register + high register 0 to 99,999,999
1 65,536 × low register + high register -2,147,483,648 to +2,147,483,647
2 10,000 × high register + low register Same as mode 0, with the register order swapped
3 65,536 × high register + low register Same as mode 1, with the register order swapped

Mode 0 is a simplified packing with a shortened range, which is why a fresh project reads small values correctly and then trips over the first measurement whose words do not fit. Modes 1 and 3 span the full signed LONG range and differ only in which register the driver treats as the high word, so for a high-word-first unsigned device value, mode 3 is the setting that reproduces it.

Why does LongDataType have no effect on MODBUS20 or MODBUS30? #

No — the driver help marks LongDataType as not applicable under the MODBUS20 and MODBUS30 protocol variants, because those drivers hardcode the value to 3, so an INI edit is silently ignored while those selections are active. Citect ships a family of Modbus protocol configurations, and in the numbered variants the major parameters are compiled into the driver, leaving nothing for an INI edit to move.

The plain MODBUS selection is the one that reads the [MODBUS] section of the driver parameters, which is why every LongDataType change pairs with a protocol check on the I/O Device. Confirm which selection the project uses before editing anything — the device's protocol and address entries are project-level settings, the same ones covered in setting the Modbus slave ID for a Citect I/O device. The hardcoded mode on a numbered variant is 3, so if your poll shows the device sends the low word first, moving the I/O Device to plain MODBUS and setting the proven mode is the only configuration path that works.

How do you confirm the register order before touching Citect? #

Poll the same register pair with an independent Modbus master tool, write down both raw 16-bit words, and calculate what each of the four LongDataType modes would return; the mode that reproduces the device's documented value is the mode to set. Worked example with illustrative numbers: the device documents a 32-bit measurement of 123,456, and a poll of the pair returns the first register as 0x0001 and the next as 0xE240 (57,920 as an unsigned decimal).

  • Mode 3: 65,536 × 1 + 57,920 = 65,536 + 57,920 = 123,456 — matches the documented value, so the pair is high word first.
  • Mode 1: 65,536 × 57,920 + 1 = 3,795,845,121, which is past the signed LONG maximum, so the driver wraps it to -499,122,175 — a negative number for a positive measurement.
  • Mode 2: 10,000 × 1 + 57,920 = 67,920 — positive, plausible and simply wrong, with no error raised anywhere.
  • Mode 0: 10,000 × 57,920 + 1 = 579,200,001 — outside the mode-0 range altogether.

Read the words as raw unsigned values rather than trusting the tool's own LONG display, and if you pull a wider block around the pair, keep the block inside the device's implemented map, because a read across an unimplemented span returns exception 02 — the mechanics are in Modbus exception 02 when a read crosses a register map gap. The mode whose arithmetic lands on the documented value is the mode to set, and a negative Citect reading afterwards points at a wrapped full-range mode, not at noise. Use the assembled number for indication and logging only; the relay's own protection elements keep making the trip decisions no matter what the SCADA tag shows.

How do you set LongDataType = 3 on the IOServer? #

Open the Setup Editor on the machine that runs the IOServer, set LongDataType = 3 in the [MODBUS] section of the MODBUS driver parameters, and restart or reload the IOServer so the running process picks the change up. Work through it in this order:

  1. Confirm the I/O Device's protocol is MODBUS and not a numbered variant; on MODBUS20 or MODBUS30 the edit below does nothing.
  2. On the machine that runs the IOServer, open the Setup Editor and find the [MODBUS] section of the MODBUS driver parameters. An edit made in a project copy on a workstation that is not the running IOServer changes nothing in the runtime.
  3. Set LongDataType to the mode your poll proved — 3 if your words match the worked example — so the section contains, at minimum, the lines below.
  4. Restart or reload the IOServer so the running process re-reads its initialization.
  5. Read the ULONG tag again and compare it with the poll value you recorded before the change; the two must agree digit for digit.

The [MODBUS] section needs, at minimum:

[MODBUS]
LongDataType = 3

Other settings such as InitType or MaxBits may sit in the same section; they are separate parameters with their own purposes, so leave them untouched unless their own documentation directs a change.

What do you check when the ULONG tag still fails after the change? #

When both raw words and the mode-3 arithmetic match the device value but the ULONG tag still misreads on protocol MODBUS with LongDataType = 3 on the IOServer, the fault is the driver's ULONG type mapping, so read the pair as two UINTs and combine them. Before you conclude that, run these five checks:

  • Protocol variant: if the I/O Device is on MODBUS20 or MODBUS30, the driver runs hardcoded mode 3 no matter what the INI says, so move the selection to plain MODBUS to take control of the mode.
  • Runtime location: confirm the edit sits in the [MODBUS] section on the machine whose IOServer actually serves the project, and that the IOServer restarted after the edit.
  • Tag address: resolve the tag to its register and compare with the first register of your poll pair; a one-register offset gives a stable wrong value that no mode repairs.
  • Magnitude: a device value above 2,147,483,647 cannot be held by a LONG tag in any mode, so no parameter change will ever read it correctly, and that case belongs to the unsigned workaround below.
  • Escalation: if all four pass and the ULONG tag still disagrees with the poll, the remaining difference is the driver's handling of the declared ULONG type in your build — log the case with the SCADA vendor's support, handing over the raw words, the mode and the software version, and bridge the gap by reading the two registers as UINT tags and combining them exactly as mode 3 assembles them, in a Cicode expression or a derived tag.

That decision tree separates transport, addressing, register order and type interpretation, and it ends in one of two places: a correct ULONG tag on the IOServer, or a proven two-UINT bridge while the vendor confirms the type mapping for your build.

Questions asked

Which Citect versions publish the LongDataType parameter?

The parameter and its four modes are documented in the Modbus driver help of the 7.3 generation of Citect SCADA, and the same MODBUS driver parameters are still published in the current AVEVA Plant SCADA documentation. Defaults and behavior are driver-specific, so confirm the help file that ships with your installed build before trusting any default beyond the documented mode table.

Can a LONG tag read any unsigned device value?

No. Modes 1 and 3 span the signed LONG range of -2,147,483,648 to +2,147,483,647, so an unsigned device value above the positive limit wraps to a negative number no matter which mode is set. Read the pair as two UINT tags and combine them arithmetically instead, which also keeps the tag's range honest.

What does the shortened mode 0 range actually exclude?

Mode 0 and mode 2 build the value as decimal digits, four per register, so the documented range tops out at 99,999,999. A device word carrying a binary value above 9,999 cannot be represented in that packing, and the tag returns a wrong number without raising any error, which is what makes unproven mode choices so expensive to debug.

Does register order matter differently over Modbus TCP than over serial?

No. The device puts the same two 16-bit words on the wire either way, and the gateway or TCP link forwards them unchanged; the assembly into a 32-bit value happens inside the Citect driver after the words arrive. A transport change cannot fix a word-order fault, which is why a clean poll through the same path is the checkpoint before any parameter edit.

Keep reading

  • Troubleshooting

    Fixing junk Modbus TCP REAL writes from Citect SCADA

    The junk is the two 16-bit halves of your 32-bit REAL, assembled in the wrong order. Give each REAL two consecutive holding registers and set the [MODNET]FloatMode parameter - values 0 to 3, default 0, byte order 1 0 3 2 - until the PLC reads back the entered value. The address is usually right; ModScan already matched the PLC arrangement.

    SCADA and data logging

  • Explainer

    Modbus register bit addressing in a SCADA item reference

    A bit inside a holding register such as 40041 is not a Modbus protocol address: the standard moves the register as one 16-bit word. Use the driver's documented bit-reference syntax only when it states the format and the numbering; otherwise read the full register and derive each Boolean with an AND mask.

    SCADA and data logging

  • How-to

    Connecting Citect SCADA to a Modbus RTU gateway over MODNET

    Yes — MODNET is Citect's driver for Modbus over TCP/IP, and a true RTU-to-TCP converter presents standard Modbus TCP on its Ethernet side, so the combination works. Success then rides on two things: the gateway's operating mode, and carrying the RTU slave address and register offsets into Citect correctly, proved by reading one register whose value you can see at the device.

    SCADA and data logging