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:
- Starting Register: Identify starting Modbus register address
- Register Count: Determine number of registers (4 for 64-bit)
- Data Type: Determine data type (integer, float, etc.)
- Byte Order: Determine byte order (little/big endian)
- 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:
- Open Workbench: Launch Niagara Workbench
- Connect to Station: Connect to Station containing Modbus driver
- Navigate to Driver: Navigate to Modbus driver in Station tree
- Driver Properties: Right-click driver and select Properties
Via Web Interface:
- Access Web Interface: Open JACE web interface
- Navigate to Drivers: Navigate to Drivers section
- Select Modbus Driver: Select Modbus driver
- Driver Configuration: Access driver configuration
Step 3: Create or Configure Device
Add Modbus Device:
- Add Device: Add Modbus device to driver
- Device Address: Configure device slave address
- Device Properties: Configure device properties
- Save Device: Save device configuration
Step 4: Create Point for 64-Bit Register
Create New Point:
- Add Point: Add new point to Modbus device
- Point Name: Enter descriptive point name
- Point Type: Select appropriate point type
- Register Configuration: Configure register settings
Step 5: Configure Register Settings
Register Configuration:
-
Register Type: Select register type:
- Holding Register: Read/Write registers (4xxxx)
- Input Register: Read-only registers (3xxxx)
-
Starting Address: Enter starting register address:
- Modbus Address: Enter Modbus address (e.g., 1)
- Address Format: May be 0-based or 1-based
-
Register Count: Set register count to 4 (for 64-bit)
-
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:
-
Byte Order: Configure byte order:
- Little Endian: Lower bytes first (common)
- Big Endian: Higher bytes first
- Auto: Auto-detect if supported
-
Register Order: Configure register order:
- Normal: Registers in normal order
- Swapped: Registers swapped if needed
-
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:
- Point Name: Descriptive name for the point
- Units: Configure units if applicable
- Scaling: Configure scaling if needed
- Alarms: Configure alarms if needed
- History: Configure history if needed
Step 8: Save and Test Configuration
Save Configuration:
- Save Point: Save point configuration
- Save Device: Save device configuration
- Save Driver: Save driver configuration
- Apply Changes: Apply changes to driver
Test Reading:
- Enable Point: Ensure point is enabled
- Force Poll: Force poll of the point
- Check Value: Verify value is read correctly
- 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:
- Custom Type: Use custom data type if available
- Bit Manipulation: Manually combine registers if needed
- Scripting: Use scripts for complex data handling
- Driver Extensions: Use driver extensions if available
Scaling and Conversion
Apply Scaling:
- Raw Value: Read raw 64-bit value
- Scaling Factor: Apply scaling factor
- Offset: Apply offset if needed
- 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:
- Timeout Configuration: Configure appropriate timeouts
- Retry Logic: Configure retry logic
- Error Handling: Configure error handling
- Fallback Values: Configure fallback values
Troubleshooting
Incorrect Values
If values are incorrect:
- Register Address: Verify starting register address
- Register Count: Verify register count is 4
- Data Type: Verify data type matches device
- Byte Order: Try different byte order settings
- Register Order: Try swapping register order
Reading Failures
If reading fails:
- Register Type: Verify register type (Holding vs Input)
- Device Address: Verify device slave address
- Network Connectivity: Check network connectivity
- Device Support: Verify device supports 64-bit reads
- Driver Logs: Check driver logs for errors
Byte Order Issues
If byte order is wrong:
- Try Little Endian: Try little endian first
- Try Big Endian: Try big endian if little doesn't work
- Register Swapping: Try register order swapping
- Word Swapping: Try word order swapping
- Device Documentation: Check device documentation
Performance Issues
If performance is poor:
- Poll Interval: Adjust poll interval
- Priority: Set appropriate priority
- Register Grouping: Group related registers
- 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
Related Topics
- How many Modbus networks can a JACE Support?
- How many Slave Devices can be supported on a Modbus Network
- How do the Niagara Point types translate to Modbus Register Types
Additional Resources
- Modbus Protocol Specification
- Niagara 4 Modbus Driver Documentation
- Data Type Conversion Guide
- Modbus Register Mapping Guide