Skip to Content
ModbusHow to read a 64-bit register in Niagara 4

How to read a 64-bit register in Niagara 4

Reading 64-bit values from Modbus devices requires reading multiple 16-bit Modbus registers and combining them. This guide provides detailed instructions for reading 64-bit registers in Niagara 4 Modbus drivers.

Overview

Modbus registers are 16-bit, so 64-bit values require:

  • Multiple Registers: Reading 4 consecutive 16-bit registers
  • Data Combination: Combining registers into 64-bit value
  • Byte Order: Handling byte order (endianness)
  • Data Type: Specifying correct data type
  • Point Configuration: Proper point configuration

Understanding 64-Bit Register Reading

Register Layout

64-Bit Value Storage:

A 64-bit value occupies 4 Modbus registers:

  • Register 0: Bits 0-15 (least significant)
  • Register 1: Bits 16-31
  • Register 2: Bits 32-47
  • Register 3: Bits 48-63 (most significant)

Byte Order Considerations:

  • Little Endian: Lower bytes first (common)
  • Big Endian: Higher bytes first
  • Register Order: Register order may vary by device
  • Byte Swapping: May require byte swapping

Data Types

64-Bit Data Types:

  • Long Long (int64): Signed 64-bit integer
  • Unsigned Long Long (uint64): Unsigned 64-bit integer
  • Double: 64-bit floating point (IEEE 754)
  • Custom: Custom data types

Step-by-Step Configuration

Step 1: Identify Register Information

Gather Required Information:

  1. Starting Register: Identify starting Modbus register address
  2. Register Count: Determine number of registers (4 for 64-bit)
  3. Data Type: Determine data type (integer, float, etc.)
  4. Byte Order: Determine byte order (little/big endian)
  5. Register Type: Determine register type (Holding/Input)

Example:

  • Starting Register: 40001 (Holding Register 1)
  • Register Count: 4 registers
  • Data Type: Signed 64-bit integer (int64)
  • Byte Order: Little endian
  • Register Type: Holding Registers

Step 2: Access Modbus Driver Configuration

Via Workbench:

  1. Open Workbench: Launch Niagara Workbench
  2. Connect to Station: Connect to Station containing Modbus driver
  3. Navigate to Driver: Navigate to Modbus driver in Station tree
  4. Driver Properties: Right-click driver and select Properties

Via Web Interface:

  1. Access Web Interface: Open JACE web interface
  2. Navigate to Drivers: Navigate to Drivers section
  3. Select Modbus Driver: Select Modbus driver
  4. Driver Configuration: Access driver configuration

Step 3: Create or Configure Device

Add Modbus Device:

  1. Add Device: Add Modbus device to driver
  2. Device Address: Configure device slave address
  3. Device Properties: Configure device properties
  4. Save Device: Save device configuration

Step 4: Create Point for 64-Bit Register

Create New Point:

  1. Add Point: Add new point to Modbus device
  2. Point Name: Enter descriptive point name
  3. Point Type: Select appropriate point type
  4. Register Configuration: Configure register settings

Step 5: Configure Register Settings

Register Configuration:

  1. Register Type: Select register type:

    • Holding Register: Read/Write registers (4xxxx)
    • Input Register: Read-only registers (3xxxx)
  2. Starting Address: Enter starting register address:

    • Modbus Address: Enter Modbus address (e.g., 1)
    • Address Format: May be 0-based or 1-based
  3. Register Count: Set register count to 4 (for 64-bit)

  4. Data Type: Select data type:

    • Long Long: Signed 64-bit integer
    • Unsigned Long Long: Unsigned 64-bit integer
    • Double: 64-bit floating point
    • Custom: Custom data type if available

Step 6: Configure Byte Order

Byte Order Settings:

  1. Byte Order: Configure byte order:

    • Little Endian: Lower bytes first (common)
    • Big Endian: Higher bytes first
    • Auto: Auto-detect if supported
  2. Register Order: Configure register order:

    • Normal: Registers in normal order
    • Swapped: Registers swapped if needed
  3. Word Order: Configure word order if applicable:

    • Normal: Normal word order
    • Swapped: Word order swapped

Common Configurations:

  • Little Endian, Normal Order: Most common
  • Big Endian, Normal Order: Some devices
  • Little Endian, Swapped: Some devices require swapping

Step 7: Configure Point Properties

Point Properties:

  1. Point Name: Descriptive name for the point
  2. Units: Configure units if applicable
  3. Scaling: Configure scaling if needed
  4. Alarms: Configure alarms if needed
  5. History: Configure history if needed

Step 8: Save and Test Configuration

Save Configuration:

  1. Save Point: Save point configuration
  2. Save Device: Save device configuration
  3. Save Driver: Save driver configuration
  4. Apply Changes: Apply changes to driver

Test Reading:

  1. Enable Point: Ensure point is enabled
  2. Force Poll: Force poll of the point
  3. Check Value: Verify value is read correctly
  4. Verify Data: Verify data matches expected value

Configuration Examples

Example 1: Reading Signed 64-Bit Integer

Configuration:

Point Name: Total Energy (64-bit)
Register Type: Holding Register
Starting Address: 40001
Register Count: 4
Data Type: Long Long (int64)
Byte Order: Little Endian
Register Order: Normal

Expected Result:

  • Reads registers 40001-40004
  • Combines into signed 64-bit integer
  • Displays as single 64-bit value

Example 2: Reading 64-Bit Floating Point

Configuration:

Point Name: High Precision Temperature
Register Type: Input Register
Starting Address: 30001
Register Count: 4
Data Type: Double (64-bit float)
Byte Order: Little Endian
Register Order: Normal

Expected Result:

  • Reads registers 30001-30004
  • Combines into 64-bit floating point
  • Displays as double precision float

Example 3: Reading with Byte Swapping

Configuration:

Point Name: Device Serial Number
Register Type: Holding Register
Starting Address: 40100
Register Count: 4
Data Type: Unsigned Long Long (uint64)
Byte Order: Big Endian
Register Order: Swapped

Expected Result:

  • Reads registers 40100-40103
  • Applies byte and register swapping
  • Combines into unsigned 64-bit integer

Advanced Configuration

Custom Data Types

If Standard Types Don't Work:

  1. Custom Type: Use custom data type if available
  2. Bit Manipulation: Manually combine registers if needed
  3. Scripting: Use scripts for complex data handling
  4. Driver Extensions: Use driver extensions if available

Scaling and Conversion

Apply Scaling:

  1. Raw Value: Read raw 64-bit value
  2. Scaling Factor: Apply scaling factor
  3. Offset: Apply offset if needed
  4. Units: Convert to appropriate units

Example Scaling:

Raw Value: 1234567890123456
Scaling Factor: 0.001
Scaled Value: 1234567890123.456
Units: kWh

Error Handling

Handle Read Errors:

  1. Timeout Configuration: Configure appropriate timeouts
  2. Retry Logic: Configure retry logic
  3. Error Handling: Configure error handling
  4. Fallback Values: Configure fallback values

Troubleshooting

Incorrect Values

If values are incorrect:

  1. Register Address: Verify starting register address
  2. Register Count: Verify register count is 4
  3. Data Type: Verify data type matches device
  4. Byte Order: Try different byte order settings
  5. Register Order: Try swapping register order

Reading Failures

If reading fails:

  1. Register Type: Verify register type (Holding vs Input)
  2. Device Address: Verify device slave address
  3. Network Connectivity: Check network connectivity
  4. Device Support: Verify device supports 64-bit reads
  5. Driver Logs: Check driver logs for errors

Byte Order Issues

If byte order is wrong:

  1. Try Little Endian: Try little endian first
  2. Try Big Endian: Try big endian if little doesn't work
  3. Register Swapping: Try register order swapping
  4. Word Swapping: Try word order swapping
  5. Device Documentation: Check device documentation

Performance Issues

If performance is poor:

  1. Poll Interval: Adjust poll interval
  2. Priority: Set appropriate priority
  3. Register Grouping: Group related registers
  4. Optimisation: Optimise polling configuration

Best Practices

Configuration

  • Document Settings: Document register configuration
  • Test Thoroughly: Test with known values
  • Verify Byte Order: Verify byte order with device documentation
  • Error Handling: Configure appropriate error handling

Data Validation

  • Range Checking: Implement range checking
  • Value Validation: Validate values are reasonable
  • Error Detection: Detect and handle errors
  • Logging: Log errors for troubleshooting

Performance

  • Efficient Polling: Configure efficient polling
  • Priority Management: Set appropriate priorities
  • Optimisation: Optimise register reads
  • Monitoring: Monitor performance

Additional Resources

  • Modbus Protocol Specification
  • Niagara 4 Modbus Driver Documentation
  • Data Type Conversion Guide
  • Modbus Register Mapping Guide