**Why does the second register of the two registers that make up a 32-bit energy always read zero?**

Most general-purpose data acquisition systems support the “long int” or “swapped long int” format of the WattNode 32-bit energy register pairs. That format is the easiest way to read the WattNode 32-bit integer energy registers. Configuring your data acquisition system to handle the Wattnode energy register pairs as a long integer (aka a 32-bit, 2-word or 4-byte integer) avoids having to worry about low-level details like binary number systems.

However, in cases where your data acquisition system only supports acquiring the raw 16-bit Modbus registers displayed as two separate 16-bit integers, then you may encounter some confusing results due to the nature of binary number systems that Modbus slaves and data acquisition systems use to transfer data.

For example, when an energy is displayed as two separate registers, the most significant register (or upper) register will read zero until the energies exceed 6.5 megawatt-hours (or 6,553 kilowatt-hours). Only after 6.5 MWH is exceeded will the least significant (or lower) register “roll over” and a non-zero value then be produced in the upper register.

Another unexpected result of viewing the raw register values separately as signed 16-bit integers is that the least significant register can appear to periodically alternate between negative and positive values e.g. when it reaches 32767 it will suddenly change to a negative value like -32768 and increment to -1 before “rolling over” to 1 and resume counting up to 32767 again. This is what happens when an “unsigned” binary integer is inadvertently displayed as a “signed” value and it is a consequence of “two’s complement” binary arithmetic. To avoid this, make sure your data acquisition system correctly interprets the registers as signed or unsigned and scales them appropriately as described below.

A value of zero or another invalid value can also result from improper scaling of a register. Most data acquisition (or SCADA) systems support combining different data sources into a single quantity with the desired engineering units (e.g. KWH) by applying “transfer equations” (or mathematical formulas that facilitate the computation of values derived from the raw Modbus registers which they typically refer to by the term “tags”, “points” or “sources”). If your software can’t handle “long int” paired Modbus register data format directly then in order to combine both registers into a single energy value you’ll need to use this equation (this example is for the WattNode’s EnergySum which is comprised of Modbus registers 1201 and 1202):

EnergySum in KWH = (Reg1201 + (Reg1202 * 65536)) / 10

The raw value of register 1202 must be multiplied by its binary weight, which is 65536 (i.e. 2 raised to an exponent of 16) since it is the most significant word of a 32-bit (i.e. “long”) integer. Note that the upper, most significant register (Reg1202) must be treated as a “signed” integer and the lower, least significant register must be treated as an “unsigned” integer. Note that this equation assumes that the computations are done with double-precision floating point numbers (aka IEEE-754 “doubles”), which is the case with virtually all state-of-the-art SCADA systems that run on PC platforms. However, to avoid overflow and loss of precision on some data loggers or PLCs that have limited processing resources, the raw 16-bit register values should be coerced into long integers before the computations are done.

The generalized formula to use is:

Energy in KWH = (LowerEnergyReg + (UpperEnergyReg * 65536)) / 10

where the LowerEnergyReg is “unsigned” and the UpperEnergyReg is “signed”. Note that dividing by 10 is necessary to convert to KWH since the units for the 32-bit integer energies are “0.1 KWH”. In other words, they are prescaled by a factor of 10 in order to provide higher resolution for limited resource systems such as PLCs. The IEEE doubles that are typically used for data processing on PC platforms have approximately 16 decimal digits of resolution compared to the 9 or so digits for long integers so for PC-hosted systems scaling isn’t needed after the energy data is acquired.