# Pre-Commissioning Process for CHINT Meters

## Document Information
- **Version**: 1.0
- **Last Updated**: 2026-04-04
- **Target Audience**: Field Operations Team, Development Team, Remote Commissioning Team

---

## Table of Contents
1. [Introduction](#introduction)
2. [Team Roles and Responsibilities](#team-roles-and-responsibilities)
3. [Equipment and Software Requirements](#equipment-and-software-requirements)
4. [Pre-Commissioning Workflow](#pre-commissioning-workflow)
5. [Converter Tool Guide](#converter-tool-guide)
6. [Troubleshooting Guide](#troubleshooting-guide)
7. [Safety and Best Practices](#safety-and-best-practices)
8. [Inventory Management](#inventory-management)
9. [Future Enhancements](#future-enhancements)

---

## Introduction

### Purpose of Pre-Commissioning

Pre-commissioning is the process of converting CHINT DDSU666/DTSU666 meters from their native **DL/T645 protocol** to **Modbus RTU protocol** and assigning unique Modbus addresses **before** the meters are installed at customer sites.

### Why Pre-Commissioning Matters

**Problem**: Fresh CHINT meters operate on the Chinese DL/T645 protocol and default to Modbus address `1` after conversion. If meters are converted on-site:
- **Address collisions** occur when multiple meters default to address 1
- **Production disruption** happens when using the production USB-RS485 adapter for conversion (interrupts live meters)
- **Field complexity** increases with protocol conversion and addressing at customer locations

**Solution**: Pre-commission all meters in a controlled lab environment before field deployment.

### Benefits

✅ **Zero Downtime**: Field installation becomes plug-and-play (physical connection only)
✅ **No Address Conflicts**: Each meter arrives with unique, pre-assigned Modbus address
✅ **Quality Control**: Test meter communication before shipping
✅ **Simplified Installation**: Field team doesn't need protocol conversion tools
✅ **Audit Trail**: Complete inventory tracking from procurement to commissioning

---

## Team Roles and Responsibilities

### Development Team
**Responsibilities**:
- Assign Modbus addresses based on site requirements and numbering scheme
- Maintain master meter inventory spreadsheet
- Build and distribute converter.exe updates
- Provide escalation support for complex technical issues
- Plan and design system upgrades

**Tools Used**:
- Master Inventory Spreadsheet (Nextcloud Sheets)
- PyInstaller (for building Windows executable)

---

### Field Operations Team
**Responsibilities**:
- Execute lab conversion of meters from DL/T645 → Modbus RTU
- Assign Modbus addresses per Development Team's mapping
- Test meter responses after conversion
- Update inventory status (Assigned → Converted → Shipped)
- Label meters physically with assigned Modbus address
- Package and ship pre-configured meters to sites

**Tools Used**:
- converter.exe (Windows GUI application)
- USB-RS485 adapter (dedicated lab adapter, NOT production)
- Meter Inventory Spreadsheet (Nextcloud Sheets)
- Physical label maker/stickers

**Training Required**:
- Converter tool operation (see [Converter Tool Guide](#converter-tool-guide))
- Inventory management workflow
- Basic RS485 wiring (A+/B- terminals)

---

### Field Installation Team
**Responsibilities**:
- Mount meter at customer location
- Wire power connections (L1/L2/L3/N)
- Wire current transformers (if three-phase meter)
- Connect to existing Modbus RS485 bus (A+/B- terminals)
- Verify meter powers up and displays readings
- Notify Remote Commissioning Team when installation complete

**Tools Used**:
- Standard electrical installation tools
- Multimeter for continuity checks

**Training Required**:
- Meter mounting procedures
- RS485 bus connection (parallel wiring to existing meters)
- Safety protocols for live electrical work

---

### Remote Commissioning Team
**Responsibilities**:
- Connect to Raspberry Pi remotely via ZeroTier + SSH
- Add meter entry to production config file (config.prod.yaml)
- Deploy configuration changes using automated script
- Monitor service restart and verify meter logging
- Update inventory status (Installed → Commissioned)
- Notify stakeholders when meter is live

**Tools Used**:
- ZeroTier VPN client
- SSH client (Terminal, PuTTY, etc.)
- Text editor (nano, vim)
- add_meter.sh CLI helper script (recommended)

**Training Required**:
- SSH basics and remote access
- YAML syntax for meter configuration
- Deployment script usage
- Log monitoring with systemctl/journalctl

---

## Equipment and Software Requirements

### Hardware (Field Operations Team)

| Item | Specification | Purpose | Notes |
|------|--------------|---------|-------|
| **USB-RS485 Adapter** | CH340, FTDI, or PL2303 chipset | Connect Windows PC to meter | **CRITICAL**: Use dedicated lab adapter, NOT production adapter |
| **Windows PC/Laptop** | Windows 7/10/11 | Run converter.exe GUI | Must have USB port |
| **Power Supply** | 230V AC (single-phase) or 3-phase | Power meter during conversion | Match meter type |
| **RS485 Wiring** | 2-wire twisted pair | Connect adapter to meter A+/B- terminals | Keep wiring short (<2 meters) |
| **Label Maker** | Any type | Create Modbus address labels | Physical labels prevent confusion |

### Software (Field Operations Team)

| Item | Location | Version | Purpose |
|------|----------|---------|---------|
| **converter.exe** | Nextcloud: `/Field_Operations/Tools/converter_v1.0.exe` | v1.0 | Protocol conversion and address assignment |
| **USB Driver** | Manufacturer website | Latest | CH340/FTDI/PL2303 driver for Windows |
| **Meter Inventory** | Nextcloud Sheets (shared link) + Excel backup on Nextcloud | Current | Track meter status |

**Download Links**:
- CH340 Driver: [http://www.wch.cn/downloads/CH341SER_EXE.html](http://www.wch.cn/downloads/CH341SER_EXE.html)
- FTDI Driver: [https://ftdichip.com/drivers/vcp-drivers/](https://ftdichip.com/drivers/vcp-drivers/)
- PL2303 Driver: [http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=225](http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=225)

---

## Pre-Commissioning Workflow

### Overview: 5-Phase Process

```
Phase 1: Address Assignment (Development Team)
   ↓
Phase 2: Lab Conversion (Field Operations Team)
   ↓
Phase 3: Pre-Dispatch Testing (Field Operations Team)
   ↓
Phase 4: Field Installation (Field Installation Team)
   ↓
Phase 5: Remote Commissioning (Remote Commissioning Team)
```

---

### Phase 1: Address Assignment (Development Team)

**Duration**: 15-30 minutes per batch

**Steps**:

1. **Receive Procurement List**
   - New meters arrive from supplier
   - Record 12-digit serial numbers from meter labels
   - Note meter types (DDSU666 single-phase or DTSU666 three-phase)

2. **Assign Modbus Addresses**
   - Follow numbering scheme:
     - **Single-phase (DDSU666)**: IDs `02` to `99` (90 meters max per site)
     - **Three-phase (DTSU666)**: IDs `100` and above (unlimited)
   - **CRITICAL RULE**: Never use address `1` (factory default, causes conflicts)

   **Example Assignment**:
   ```
   Site: Office Building A
   - Meter Serial 200322016690 → Address 02 (Floor 1 Reception)
   - Meter Serial 200322016691 → Address 03 (Floor 1 Office)
   - Meter Serial 200322016692 → Address 04 (Floor 2 Office)
   - Meter Serial 200415023456 → Address 100 (Main 3-Phase Supply)
   ```

3. **Update Master Inventory Spreadsheet**
   - Open Nextcloud Sheets inventory (link in team resources)
   - Add new rows for each meter:
     - Meter Serial Number (12 digits)
     - Meter Type (DDSU666 or DTSU666)
     - Site Name
     - Building/Customer Name
     - Assigned Modbus Address
     - Status: **"Assigned"**
     - Date Assigned: Today's date
     - Assigned By: Your name

4. **Send Assignment List to Field Operations Team**
   - Export assignment list as PDF or share Nextcloud Sheets link
   - Include any special instructions (e.g., priority meters, site notes)

---

### Phase 2: Lab Conversion (Field Operations Team)

**Duration**: 5-10 minutes per meter
**Location**: Lab/Office environment
**Tools**: Windows PC, converter.exe, USB-RS485 adapter

**Steps**:

#### 2.1 Physical Setup

1. **Connect Meter to Power**
   - Single-phase: Connect L (live) and N (neutral)
   - Three-phase: Connect L1, L2, L3, and N
   - Verify meter LCD powers on and displays readings

2. **Connect USB-RS485 Adapter**
   - Locate meter's RS485 terminals (usually labeled A+/B- or 485A/485B)
   - Connect adapter's A+ wire to meter's A+ terminal
   - Connect adapter's B- wire to meter's B- terminal
   - **Polarity matters!** Incorrect wiring causes "No response" errors

3. **Connect Adapter to Windows PC**
   - Plug USB end into PC USB port
   - Windows should detect and install driver automatically
   - If not, install driver manually (see Equipment section)

#### 2.2 Launch Converter Tool

1. **Run converter.exe**
   - Double-click converter_v1.0.exe from Nextcloud download
   - GUI window opens with title "DLT645 to Modbus Converter"
   - Initial status shows red "● Disconnected"

#### 2.3 Configure Connection

1. **Detect Serial Port**
   - Click "⟳ Refresh" button
   - Dropdown populates with available ports (e.g., `COM3`, `COM4`)
   - If no ports appear:
     - Check USB cable connection
     - Verify driver installed (Windows Device Manager → Ports)
     - Try different USB port

2. **Select Port and Baud Rate**
   - Select detected port from dropdown (e.g., `COM3`)
   - Baud rate: Keep default `2400` (DLT645 standard)

3. **Connect to Port**
   - Click "Connect" button
   - Status changes to green "● Connected"
   - All action buttons become enabled
   - Log shows: `[HH:MM:SS] Connected → COM3 @ 2400 baud`

#### 2.4 Enter Meter Details

1. **DLT645 Station Address** (12 digits)
   - Find on meter label or LCD display
   - Example: `200322016690`
   - Must be exactly 12 digits (tool validates)

2. **Target Modbus Address** (from assignment list)
   - Refer to Master Inventory for assigned address
   - Example: Address `02` for first single-phase meter
   - Valid range: 1-247 (but avoid address 1)

3. **Reverse Address Bytes** (checkbox)
   - Keep checked by default
   - Tool will auto-retry with this toggled if conversion fails

#### 2.5 Execute Conversion (Recommended: Use "Full Process")

**Option A: Full Process (Recommended for Field Operations)**

1. Click "▶ Full Process" button
2. Tool automatically performs:
   - **Step 1/2**: Convert protocol (DLT645 → Modbus RTU)
   - **Step 2/2**: Change Modbus address to target value
3. Watch log panel for progress:
   ```
   [14:23:15] ═══ Full Process Started ═══
   [14:23:15] [1/2] Converting protocol — station=200322016690
   [14:23:15] TX: FE FE FE FE 68 02 03 20 01 66 90...
   [14:23:27] ✓ Protocol conversion done.
   [14:23:27] [2/2] Changing Modbus address: 1 → 10
   [14:23:30] ✓ Address set to 10.
   [14:23:30] ═══ Full Process Complete ═══
   ```
4. **Success indicators**:
   - ✓ checkmarks for both steps
   - No ✗ errors in log
   - "Full Process Complete" message

**Option B: Manual Step-by-Step** (for troubleshooting)

If Full Process fails, try manual steps:

1. **Convert Protocol First**
   - Click "Convert Protocol" button
   - Tool sends DLT645 protocol-switch command
   - Wait 2-5 minutes for meter to respond
   - Log shows: `✓ Protocol conversion done.`

2. **Scan for Current Address** (optional)
   - Click "🔍 Scan" button
   - Tool tests all 247 Modbus addresses (takes ~90 seconds)
   - Log shows: `✓ Meter found at Modbus address 1`
   - "Current Modbus Address" field auto-updates

3. **Change Address**
   - Ensure "Current Modbus Address" is correct (usually 1 after conversion)
   - Enter "Target Modbus Address" (from assignment list)
   - Click "Change Modbus Addr" button
   - Log shows: `✓ Address changed to 10.`

#### 2.6 Update Inventory

1. **Open Nextcloud Sheets Inventory**
2. **Find meter row** (search by serial number)
3. **Update fields**:
   - Status: Change "Assigned" → **"Converted"**
   - Date Converted: Today's date
   - Converted By: Your name
   - Notes: Add any issues encountered (e.g., "Required reverse byte toggle")

#### 2.7 Label Meter Physically

1. **Create Label** (using label maker or sticker)
   - Text: `Modbus Address: 02` (use actual assigned address)
   - Include site name if space permits
2. **Affix Label to Meter**
   - Place on front panel or top cover
   - Ensure visible after installation
   - Prevents confusion during field installation

#### 2.8 Disconnect and Repeat

1. **Disconnect from Meter**
   - Click "Disconnect" button in converter tool
   - Status returns to red "● Disconnected"
   - Unplug USB-RS485 adapter from PC
   - Disconnect adapter from meter terminals
   - Power off meter

2. **Repeat for Next Meter**
   - Proceed to next meter in batch
   - Follow steps 2.1-2.7 for each meter

---

### Phase 3: Pre-Dispatch Testing (Field Operations Team)

**Duration**: 5 minutes per meter
**Purpose**: Verify meter responds at assigned Modbus address before shipping

**Steps**:

1. **Setup Test Bus**
   - Connect 2-3 converted meters to same RS485 bus
   - Use twisted pair wiring (parallel connection)
   - Ensure meters have different addresses (e.g., 10, 11, 12)

2. **Test Communication** (Manual Method)
   - Connect USB-RS485 adapter to test bus
   - Open converter tool
   - Change baud rate to `9600` (Modbus standard)
   - Use "Scan" function to detect meters
   - Verify each meter responds at its assigned address

3. **Alternative: Use NFE Test Script**
   - If Raspberry Pi available for testing
   - Copy test_modbus_read.py script to test Pi
   - Edit script to test specific meter ID
   - Run: `python3 test_modbus_read.py`
   - Verify readings returned (voltage, current, power)

4. **Record Test Results**
   - Update inventory spreadsheet:
     - Add checkmark or "Tested OK" in Notes column
     - If test fails, mark as "Retest Required" and escalate to Development Team

5. **Package for Shipping**
   - Power off meter
   - Ensure address label is visible
   - Package securely with protective materials
   - Include shipping label with site name

---

### Phase 4: Field Installation (Field Installation Team)

**Duration**: 30-60 minutes per meter (excluding electrical prep)
**Location**: Customer site
**Safety**: Follow all electrical safety protocols

**Steps**:

#### 4.1 Pre-Installation Checks

1. **Verify Meter Received**
   - Confirm meter serial number matches work order
   - Verify Modbus address label matches site plan
   - Inspect for shipping damage

2. **Review Site Plan**
   - Identify installation location
   - Locate existing Modbus RS485 bus terminals
   - Note power source (single-phase or three-phase)

#### 4.2 Physical Installation

1. **Mount Meter** (per manufacturer instructions)
   - Use DIN rail mounting or wall mount bracket
   - Ensure meter is accessible for reading and maintenance
   - Keep away from excessive heat and moisture

2. **Wire Power Connections**

   **Single-Phase (DDSU666)**:
   - Connect Line (L) from customer's circuit breaker
   - Connect Neutral (N) from customer's neutral bar
   - Verify polarity with multimeter

   **Three-Phase (DTSU666)**:
   - Connect L1, L2, L3 from customer's supply
   - Connect Neutral (N) from neutral bar
   - If using current transformers (CTs):
     - Install CTs on each phase conductor
     - Connect CT secondaries to meter CT terminals (K1/L1, K2/L2, K3/L3)
     - Ensure CT orientation matches current flow direction

3. **Wire Modbus RS485 Bus**
   - **CRITICAL**: This step must NOT interrupt existing meters
   - Locate existing RS485 bus terminals (A+/B- or 485A/485B)
   - Connect new meter's A+ terminal to bus A+ (parallel)
   - Connect new meter's B- terminal to bus B- (parallel)
   - Use twisted pair cable (CAT5 or dedicated RS485 cable)
   - Keep total bus length under 1200 meters
   - Use 120Ω termination resistor if meter is at end of bus

#### 4.3 Power-Up and Verify

1. **Energize Meter**
   - Turn on customer circuit breaker
   - Meter LCD should illuminate and display readings
   - Verify voltage readings match expected values (230V ±10% single-phase, 400V ±10% three-phase)

2. **Quick Communication Test** (Optional)
   - If laptop with converter tool available:
     - Connect USB-RS485 adapter to bus (parallel, don't disconnect existing)
     - Set baud rate to 9600
     - Use "Scan" to verify meter responds at assigned address
     - Disconnect adapter when done
   - If no laptop: Skip this step (Remote Commissioning Team will verify)

3. **Notify Remote Commissioning Team**
   - Send message: "Meter [Serial Number] installed at [Site Name], ready for commissioning"
   - Include photo of meter with label visible (for audit trail)
   - Update inventory:
     - Status: "Converted" → **"Installed"**
     - Date Installed: Today's date
     - Installed By: Your name

---

### Phase 5: Remote Commissioning (Remote Commissioning Team)

**Duration**: 10-15 minutes per meter
**Location**: Remote (via ZeroTier VPN + SSH)

**Prerequisites**:
- Receive notification from Field Installation Team
- ZeroTier VPN client installed and connected to network ID: `2873fd00f2d70904`
- SSH access to production Raspberry Pi: `nfetestpi2@10.135.127.86`

**Steps**:

#### 5.1 Connect to Raspberry Pi

1. **Start ZeroTier VPN**
   - Ensure ZeroTier client is running
   - Verify connected to "my-first-network" (ID: 2873fd00f2d70904)
   - Check ZeroTier shows "ONLINE" status

2. **SSH to Production Pi**
   ```bash
   ssh nfetestpi2@10.135.127.86
   ```
   - Enter password when prompted
   - Or use SSH key if configured (passwordless)

#### 5.2 Add Meter to Configuration (Option A: Manual Edit)

**For users comfortable with YAML editing**:

1. **Edit Staging Config**
   ```bash
   nano ~/nfe-modbus-energy-logger/config/config.prod.yaml
   ```

2. **Add Meter Entry**

   Scroll to the `meters:` section and add new entry:

   **Single-Phase Meter Example**:
   ```yaml
   meters:
     # ... existing meters ...

     - id: 2                      # Assigned Modbus address
       name: "floor1_reception"    # Descriptive name (lowercase, underscores)
       type: "1phase"              # Meter type
       enabled: true               # Enable logging
   ```

   **Three-Phase Meter Example**:
   ```yaml
   meters:
     # ... existing meters ...

     - id: 100                     # Assigned Modbus address
       name: "main_supply"         # Descriptive name
       type: "3phase"              # Meter type
       enabled: true               # Enable logging
   ```

   **Naming Conventions**:
   - Use lowercase letters
   - Use underscores instead of spaces
   - Make names descriptive but concise
   - Examples: `floor2_office`, `hvac_panel`, `server_room`

3. **Save and Exit**
   - Press `Ctrl+O` to save
   - Press `Enter` to confirm filename
   - Press `Ctrl+X` to exit nano

#### 5.2 Add Meter to Configuration (Option B: CLI Helper Script - RECOMMENDED)

**For automated validation and safety**:

1. **Run Helper Script**
   ```bash
   ~/nfe-modbus-energy-logger-prod/scripts/add_meter.sh
   ```

2. **Answer Interactive Prompts**
   ```
   Enter Meter ID (2-247): 2
   Enter Meter Name: floor1_reception
   Enter Meter Type (1phase/3phase): 1phase
   Enable meter? (yes/no): yes

   About to add:
     ID: 2
     Name: floor1_reception
     Type: 1phase
     Enabled: true

   Proceed? (yes/no): yes
   ```

3. **Script Automatically**:
   - Validates input (address range, type, duplicate ID check)
   - Backs up current config
   - Appends meter to YAML
   - Runs deployment script
   - Monitors service restart
   - Verifies meter logging
   - Reports success or failure

4. **Review Output**
   ```
   ✅ Meter 2 (floor1_reception) successfully added and logging
   📁 Data directory: ~/nfe-modbus-energy-logger-prod/data/meter_010/
   📊 CSV file: meter_010_2026-04-04.csv
   ```

#### 5.3 Deploy to Production (Manual Method Only)

**Skip this if you used add_meter.sh script (already done)**

1. **Run Deployment Script**
   ```bash
   ~/nfe-modbus-energy-logger/scripts/deploy.sh
   ```

2. **Script Actions**:
   - Backs up production directory
   - Syncs staging code to production
   - Runs pre-flight test (30-second dry run)
   - Restarts meter.service
   - Verifies service started successfully
   - Auto-rollback if service fails

3. **Monitor Deployment**
   - Watch for "Deployment complete" message
   - Check for any error messages
   - If errors occur, script auto-rolls back

#### 5.4 Monitor Service Restart

1. **Watch Service Logs**
   ```bash
   sudo journalctl -u meter.service -f
   ```

2. **Look for Meter Initialization**
   ```
   [timestamp] ✅ Initialized meter 10 (floor1_reception, 1phase)
   [timestamp] 🚀 Starting multi-meter logger
   [timestamp]    Poll interval: 10s
   [timestamp]    Log interval: 900s (15 minutes)
   [timestamp]    Active meters: 3
   ```

3. **Press `Ctrl+C` to stop watching logs**

#### 5.5 Verify Meter Logging

1. **Check Data Directory Created**
   ```bash
   ls -lh ~/nfe-modbus-energy-logger-prod/data/
   ```
   - Should show new directory: `meter_010/` (or corresponding ID)

2. **Check CSV File Started**
   ```bash
   ls -lh ~/nfe-modbus-energy-logger-prod/data/meter_010/
   ```
   - Should show CSV file: `meter_010_2026-04-04.csv` (today's date)

3. **View Recent Log Entries**
   ```bash
   tail -20 ~/nfe-modbus-energy-logger-prod/data/meter_010/meter_010_2026-04-04.csv
   ```
   - Should show recent readings with timestamps
   - Verify data fields populated (not all zeros or empty)

4. **Sample Output**:
   ```
   timestamp,meter_id,V_L1_V,I_L1_A,P_total_kW,E_total_kWh,...
   2026-04-04 15:15:00,10,234.5,2.1,0.49,12345.6,...
   2026-04-04 15:30:00,10,235.1,2.3,0.53,12345.8,...
   ```

#### 5.6 Update Inventory and Notify

1. **Update Inventory Spreadsheet**
   - Status: "Installed" → **"Commissioned"**
   - Date Commissioned: Today's date
   - Commissioned By: Your name
   - Notes: Add any observations (e.g., "All readings nominal")

2. **Verify Backup Enabled** (if configured)
   - Check backup service runs successfully:
     ```bash
     sudo journalctl -u backup.service -n 50
     ```
   - Verify meter CSV files being backed up to Nextcloud

3. **Notify Stakeholders**
   - Send confirmation message: "Meter [Serial Number] commissioned at [Site Name] - logging active"
   - Include link to meter data directory or dashboard (if available)

---

## Converter Tool Guide

### GUI Overview

```
┌─────────────────────────────────────────────────────────┐
│  DLT645 to Modbus Converter                             │
├─────────────────────────────────────────────────────────┤
│  Serial Port: [COM3         ▼] [⟳ Refresh]  [Connect]  │
│  Baud Rate:   [2400         ▼]                          │
│  Status: ● Connected                                     │
├─────────────────────────────────────────────────────────┤
│  DLT645 Station Address (12 digits):                    │
│  [200322016690                                       ]  │
│                                                           │
│  Current Modbus Address: [1   ]  [🔍 Scan]              │
│  Target Modbus Address:  [10  ]                         │
│                                                           │
│  ☑ Reverse address bytes                                │
├─────────────────────────────────────────────────────────┤
│  [Convert Protocol] [Change Modbus Addr] [▶ Full Process]│
├─────────────────────────────────────────────────────────┤
│  Log Panel (scrollable):                                │
│  [14:23:15] Connected → COM3 @ 2400 baud                │
│  [14:23:25] Converting protocol — station=200322016690  │
│  [14:23:27] ✓ Protocol conversion done.                 │
│  [14:23:30] ✓ Address changed to 10.                    │
│                                                           │
└─────────────────────────────────────────────────────────┘
```

### Input Field Descriptions

| Field | Description | Valid Values | Example |
|-------|-------------|--------------|---------|
| **Serial Port** | USB-RS485 adapter COM port | Auto-detected ports | COM3 |
| **Baud Rate** | Communication speed | 1200, 2400, 4800, 9600, 19200 | 2400 (DLT645 default) |
| **DLT645 Station Address** | Meter's 12-digit serial number | 000000000000 - 999999999999 | 200322016690 |
| **Current Modbus Address** | Address meter currently responds to | 1-247 | 1 (factory default) |
| **Target Modbus Address** | New address to assign | 1-247 | 10 (from assignment list) |
| **Reverse Address Bytes** | Toggle byte order for firmware compatibility | Checked/Unchecked | ☑ Checked (recommended) |

### Button Functions

| Button | Function | When to Use | Duration |
|--------|----------|-------------|----------|
| **⟳ Refresh** | Re-scan for serial ports | USB adapter just connected | Instant |
| **Connect** | Open selected serial port | Before any conversion operations | Instant |
| **Disconnect** | Close serial port | After conversion complete | Instant |
| **Convert Protocol** | Send DLT645 protocol-switch command | Standalone protocol conversion | 2-5 minutes |
| **🔍 Scan** | Search all 247 Modbus addresses | Find current meter address | ~90 seconds |
| **Change Modbus Addr** | Write new address to meter | After protocol conversion | 5-10 seconds |
| **▶ Full Process** | Automated conversion + address change | **RECOMMENDED for Field Operations** | 5-10 minutes |

### Success Indicators

**Look for these in the log panel**:

✅ **Protocol Conversion Success**:
```
[14:23:27] ✓ Protocol conversion done.
```

✅ **Address Change Success**:
```
[14:23:30] ✓ Address set to 10.
```

✅ **Full Process Success**:
```
[14:23:30] ═══ Full Process Complete ═══
```

✅ **Meter Discovery Success**:
```
[14:23:45] ✓ Meter found at Modbus address 1. 'Current Modbus Address' updated.
```

### Error Indicators

❌ **Communication Errors**:
```
[14:23:27] ✗ No response — check wiring / address / baud rate.
```

❌ **Validation Errors**:
```
Validation Error: Station address must be exactly 12 digits.
Validation Error: Modbus address must be an integer 1–247.
```

❌ **Port Errors**:
```
Error: No port selected. Click ⟳ Refresh first.
Connection Error: [SerialException message]
```

---

## Troubleshooting Guide

### Problem: No Serial Ports Detected

**Symptoms**:
- Dropdown shows "No ports found" or is empty
- "⟳ Refresh" button doesn't populate ports

**Causes and Solutions**:

1. **USB Adapter Not Connected**
   - ✅ **Solution**: Plug USB adapter into PC USB port
   - Click "⟳ Refresh" again

2. **Driver Not Installed**
   - ✅ **Solution**: Install USB-RS485 driver for your adapter chipset
   - Check Windows Device Manager → Ports (COM & LPT)
   - If device shows yellow warning icon, driver missing
   - Download and install correct driver (see Equipment section)
   - Restart PC if required
   - Click "⟳ Refresh" after driver installed

3. **Faulty USB Cable or Adapter**
   - ✅ **Solution**: Try different USB port
   - Try different USB cable
   - Test adapter on another PC
   - Replace adapter if confirmed faulty

4. **Windows Security Blocking**
   - ✅ **Solution**: Run converter.exe as Administrator
   - Right-click → "Run as administrator"

---

### Problem: "No Response" During Protocol Conversion

**Symptoms**:
- Log shows: `[HH:MM:SS] ✗ No response.`
- Tool retries with reverse byte toggle automatically

**Causes and Solutions**:

1. **Incorrect Station Address**
   - ✅ **Solution**: Double-check 12-digit serial number on meter label
   - Ensure no typos (easy to confuse 0/O, 1/I, 6/8)
   - Verify number matches meter (not packaging)

2. **Wiring Problem (Most Common)**
   - ✅ **Solution**: Check RS485 connections
   - Verify A+ to A+, B- to B- (not swapped)
   - Tighten terminal screws (loose connections cause intermittent failures)
   - Use twisted pair cable (not individual wires)
   - Keep wiring short (<2 meters)

3. **Incorrect Baud Rate**
   - ✅ **Solution**: Confirm baud rate is 2400 for DLT645 meters
   - Some meters may use different rates (try 1200, 4800)

4. **Meter Not Powered**
   - ✅ **Solution**: Verify meter LCD is illuminated
   - Check power connections (L/N for single-phase, L1/L2/L3/N for three-phase)
   - Use multimeter to verify voltage at terminals

5. **RS485 Bus Termination Issue**
   - ✅ **Solution**: If multiple meters on same bus, add 120Ω termination resistor across A+/B- at each end

6. **Reverse Byte Order Required**
   - ✅ **Solution**: Tool auto-retries with reverse toggle
   - Manually toggle "Reverse address bytes" checkbox and retry

7. **Meter Already in Modbus Mode**
   - ✅ **Solution**: Meter may already be converted (from previous attempt)
   - Change baud rate to 9600
   - Use "Scan" function to find current address
   - Skip to "Change Modbus Addr" step if needed

---

### Problem: Scan Finds No Modbus Address

**Symptoms**:
- After protocol conversion, scan completes but finds no meter
- Log shows: `⚠ No meter responded on Modbus addresses 1-247.`

**Causes and Solutions**:

1. **Protocol Conversion Failed**
   - ✅ **Solution**: Meter still in DLT645 mode
   - Return to "Convert Protocol" step
   - Try manual conversion with longer timeout
   - Power cycle meter (turn off, wait 10 seconds, turn on)
   - Retry conversion

2. **Incorrect Baud Rate for Modbus**
   - ✅ **Solution**: After conversion, meter uses 9600 baud for Modbus
   - Change baud rate dropdown to 9600
   - Retry scan

3. **Meter Needs Time to Restart**
   - ✅ **Solution**: Wait 5 minutes after protocol conversion
   - Power cycle meter
   - Retry scan

---

### Problem: Address Change Fails

**Symptoms**:
- Log shows: `✗ Address change failed.`
- Meter doesn't respond at new address

**Causes and Solutions**:

1. **Wrong Register Address for Meter Type**
   - ✅ **Solution**:
   - DDSU666 (single-phase) uses register 0x0006
   - DTSU666 (three-phase) uses register 0x002E
   - Converter GUI currently supports single-phase only
   - For three-phase, use CLI version:
     ```bash
     python3 converter_cli.py change --port COM3 --current 1 --target 10 --type 3phase
     ```

2. **Meter Not in Modbus Mode**
   - ✅ **Solution**: Ensure protocol conversion succeeded first
   - Use "Scan" to verify meter responds in Modbus mode

3. **Current Address Incorrect**
   - ✅ **Solution**: Use "Scan" function to discover actual current address
   - Update "Current Modbus Address" field with scanned value
   - Retry address change

---

### Problem: Meter Doesn't Respond After Conversion

**Symptoms**:
- Conversion appears successful in log
- But meter doesn't respond in Modbus mode later

**Causes and Solutions**:

1. **Conversion Incomplete (False Positive)**
   - ✅ **Solution**: Some meters acknowledge command but don't actually switch
   - Power cycle meter (off for 30 seconds, then on)
   - Wait 5 minutes after power-on
   - Retry scan

2. **Firmware Requires Extended Timing**
   - ✅ **Solution**: Use CLI version with extended timeout:
     ```bash
     python3 converter_cli.py convert --port COM3 --station 200322016690 --reverse --extended
     ```

3. **Meter Reverted to DLT645 Mode**
   - ✅ **Solution**: Some meters revert to factory default after power loss
   - This is rare but possible
   - Repeat full conversion process
   - Test immediately after conversion before power cycling

---

### Escalation: When to Contact Development Team

Contact Development Team if:
- Meter doesn't respond after 3 conversion attempts
- Error messages not covered in this guide
- Physical damage suspected (meter LCD dead, RS485 terminals broken)
- Firmware version incompatibility suspected
- Need CLI script for three-phase meter address change
- converter.exe crashes or freezes

**Escalation Information to Provide**:
- Meter serial number
- Meter type (DDSU666 or DTSU666)
- Complete log output from converter tool (screenshot)
- Steps already attempted
- Observations (LCD displays, unusual behavior)

---

## Safety and Best Practices

### General Safety

⚠️ **Electrical Safety**:
- Only qualified electricians perform power wiring (Phase 4)
- De-energize circuits before connecting meter to live power
- Use lockout/tagout (LOTO) procedures
- Verify voltage with multimeter before assuming power is off
- Wear appropriate personal protective equipment (PPE)

⚠️ **RS485 Bus Safety**:
- Never connect/disconnect RS485 wiring with power applied (can damage meter)
- Use ESD (electrostatic discharge) precautions when handling meter electronics
- Keep RS485 bus wiring away from high-voltage conductors (>50V)

### Conversion Best Practices

✅ **One Meter at a Time**:
- Convert meters individually (don't connect multiple unconverted meters to same bus)
- This prevents address conflicts during conversion

✅ **Document Before Converting**:
- Update inventory BEFORE starting conversion
- Record meter serial number, type, and assigned address
- This prevents confusion if interrupted mid-process

✅ **Test Before Shipping**:
- Always perform Phase 3 Pre-Dispatch Testing
- Catch issues in lab, not at customer site
- Reduces field failures and rework

✅ **Never Reuse Addresses on Same Site**:
- Each meter must have unique address
- Keep site-specific address map
- Even if meter replaced, don't reuse old address immediately (wait until removed from config)

✅ **Physical Labeling is Mandatory**:
- Label prevents installation errors
- Field Installation Team relies on label (may not have inventory access)
- Use durable labels (water-resistant, doesn't fade)

✅ **Keep Conversion Logs**:
- Take screenshot of successful conversion log
- Store in Nextcloud or local folder
- Useful for audit trail and troubleshooting
- Include meter serial number in filename (e.g., `conversion_200322016690_success.png`)

---

## Inventory Management

### Master Inventory Spreadsheet

**Primary Location**: Nextcloud Sheets (shared link - request from Development Team)
**Backup Location**: Nextcloud `/Field_Operations/Templates/METER_INVENTORY_TEMPLATE.xlsx`

### Required Columns

| Column Name | Data Type | Purpose | Example |
|-------------|-----------|---------|---------|
| **Meter Serial Number** | Text (12 digits) | Unique meter identifier | 200322016690 |
| **Meter Type** | Text | Single or three-phase | DDSU666 or DTSU666 |
| **Site Name** | Text | Customer site | Office Building A |
| **Building/Customer** | Text | Specific location or customer name | Floor 1 Reception |
| **Assigned Modbus Address** | Number (1-247) | Pre-assigned unique address | 10 |
| **Status** | Dropdown | Current workflow stage | Assigned, Converted, Shipped, Installed, Commissioned |
| **Date Assigned** | Date | When address assigned | 2026-04-01 |
| **Date Converted** | Date | When protocol conversion completed | 2026-04-02 |
| **Date Installed** | Date | When physically installed at site | 2026-04-03 |
| **Date Commissioned** | Date | When added to NFE config and logging | 2026-04-04 |
| **Converted By** | Text | Field Ops team member name | Jane Doe |
| **Installed By** | Text | Field Installation team member | John Smith |
| **Commissioned By** | Text | Remote Commissioning team member | Alice Johnson |
| **Notes** | Text | Issues, observations, special instructions | Required reverse byte toggle |

### Status Workflow

```
Unassigned → Assigned → Converted → Shipped → Installed → Commissioned
     ↓          ↓           ↓           ↓          ↓            ↓
   (New)   (Dev Team)  (Field Ops) (Field Ops) (Field Inst) (Remote Comm)
```

**Status Definitions**:

- **Unassigned**: New meter received from supplier, no address assigned yet
- **Assigned**: Development Team assigned Modbus address, ready for conversion
- **Converted**: Field Operations Team completed protocol conversion and address assignment
- **Shipped**: Meter packaged and sent to customer site
- **Installed**: Field Installation Team physically installed meter and wired to bus
- **Commissioned**: Remote Commissioning Team added to NFE config and verified logging

### Conditional Formatting (Nextcloud Sheets)

**Setup in Nextcloud Sheets**:

1. **Status Column Color Coding**:
   - Unassigned: Gray background
   - Assigned: Yellow background (action required by Field Ops)
   - Converted: Light blue (ready to ship)
   - Shipped: Blue (in transit)
   - Installed: Orange (action required by Remote Comm)
   - Commissioned: Green (complete)

2. **Overdue Highlighting**:
   - If "Status = Assigned" and "Date Assigned" > 7 days ago → Red text (conversion overdue)
   - If "Status = Installed" and "Date Installed" > 2 days ago → Red text (commissioning overdue)

3. **Address Range Validation**:
   - If "Meter Type = DDSU666" and "Assigned Modbus Address" < 10 or > 99 → Red background (invalid)
   - If "Meter Type = DTSU666" and "Assigned Modbus Address" < 100 → Red background (invalid)

### Data Validation (Nextcloud Sheets)

**Setup in Nextcloud Sheets**:

1. **Status Dropdown**:
   - Column: Status
   - Criteria: List from a range: `Unassigned, Assigned, Converted, Shipped, Installed, Commissioned`
   - Reject invalid input

2. **Meter Type Dropdown**:
   - Column: Meter Type
   - Criteria: List from a range: `DDSU666, DTSU666`
   - Reject invalid input

3. **Address Range Validation**:
   - Column: Assigned Modbus Address
   - Criteria: Number between 1 and 247
   - Warning on invalid input (not rejection, to allow temporary placeholders)

### Audit Trail Requirements

**What to Track**:
- Every status change must include date and operator name
- Notes column should capture any deviations from standard process
- Conversion logs (screenshots) stored in Nextcloud with meter serial in filename

**Retention**:
- Keep inventory records for lifetime of deployment
- Archive old entries when meters decommissioned
- Export monthly backup to Excel and store in Nextcloud

---

## Future Enhancements

**Planned for Phase 2**:

1. **Web-Based Commissioning Portal**
   - Browser-based UI for adding meters to NFE config
   - No SSH required for Remote Commissioning Team
   - Authentication and audit logging
   - Real-time dashboard showing meter status

2. **Automated Meter Discovery on Modbus Bus**
   - Raspberry Pi scans bus for new meters automatically
   - Suggests config entries for detected meters
   - Reduces manual configuration errors

3. **Inventory Management Database**
   - Centralized database replacing Nextcloud Sheets
   - API integration between converter tool and inventory
   - Auto-update status on successful conversions
   - Real-time sync across all teams

4. **Converter Tool Enhancements**:
   - Batch operations (convert multiple meters in sequence)
   - Save/load meter assignment lists
   - Auto-populate from inventory database
   - Persistent configuration (remember last settings)
   - Auto-generated conversion reports (PDF)

5. **Mobile App for Field Installation**
   - Scan meter barcode/QR code
   - Verify address label matches inventory
   - Guided installation checklist
   - Photo documentation for audit trail

6. **Automated Alerting**:
   - Notify Remote Commissioning when meter installed
   - Alert if meter stops logging after commissioning
   - Daily summary of meters pending action

7. **Fleet Management Dashboard**:
   - Web dashboard showing all meters across all sites
   - Real-time status (online/offline)
   - Energy consumption graphs
   - Maintenance scheduling

**How to Request Features**:
- Contact Development Team (CTO)
- Describe use case and priority
- Features prioritized based on team feedback and ROI

---

## Appendix

### Glossary

- **DL/T645**: Chinese national standard for electrical meter communication protocol
- **Modbus RTU**: Industry-standard serial communication protocol for industrial devices
- **RS485**: Differential serial communication standard (A+/B- or Data+/Data-)
- **Station Address**: 12-digit unique identifier for DL/T645 meters (meter serial number)
- **Modbus Slave Address**: 1-byte address (1-247) for Modbus devices on same bus
- **USB-RS485 Adapter**: Device converting USB to RS485 differential signals
- **Baud Rate**: Communication speed in bits per second (bps)
- **Protocol Conversion**: One-time operation switching meter from DL/T645 to Modbus mode
- **ZeroTier**: Virtual private network (VPN) software for secure remote access
- **SSH**: Secure Shell protocol for remote command-line access

### Quick Reference Card

**Converter Tool Quick Steps**:
1. Connect meter power and USB-RS485 adapter
2. Run converter.exe → Refresh → Select port → Connect
3. Enter 12-digit station address (from meter label)
4. Enter target Modbus address (from inventory)
5. Click "▶ Full Process"
6. Wait for "✓ Full Process Complete"
7. Update inventory status to "Converted"
8. Label meter with address sticker

**Common Mistakes to Avoid**:
- ❌ Using address 1 (always use 10+ for single-phase, 100+ for three-phase)
- ❌ Swapping A+/B- wiring (causes "No response" errors)
- ❌ Forgetting to change baud rate to 9600 after conversion (for Modbus scan)
- ❌ Skipping physical label (causes installation errors)
- ❌ Not updating inventory (breaks audit trail)
---

**Document Version History**:
- v1.0 (2026-04-04): Initial release - Complete pre-commissioning workflow

**Document Owner**: Development Team
**Review Cycle**: Quarterly or as needed for process updates