Variable Frequency Drive (VFD) Motor Control — Control Design
Shared by TSIMEREZIVO Team · 4 Oct 2026 · 39 views
# Generic Module: Variable Frequency Drive (VFD) Motor Control
**Version**: 1.0
**Complexity**: Medium-High
**Industries**: Manufacturing, Water, HVAC, Mining, Pulp & Paper
**PLC Languages**: ST, FBD, Ladder
**Protocols**: Modbus TCP, EtherNet/IP, Profibus
---
## 📋 Overview
Modulate AC motor speed via frequency control. Enables energy savings, process precision, and soft-start capability.
**Use When:**
- ✅ AC induction motor (3-phase typical)
- ✅ Variable flow/pressure demand (pump, fan, compressor)
- ✅ Energy efficiency critical (80%-100% energy savings vs valve throttling)
- ✅ Need ramp up/down (eliminate mechanical shock)
**Do NOT Use When:**
- ❌ DC motor (use DC drive instead)
- ❌ Constant speed only (wasted VFD cost)
- ❌ Motor must drop-start magnetic contactor
---
## 🎯 Control Philosophy
**Speed Ramp Control**
```
1. PLC sends Speed_Reference (0-100%) to VFD
2. VFD internally ramps frequency (0-60Hz typical)
3. Motor accelerates smoothly over Ramp_Time (5-30 sec)
4. Motor maintains speed ±1 Hz (typically)
5. Feedback via encoder/sensor validates actual RPM
```
**Benefits:**
- ✅ Soft-start eliminates electrical inrush (reduces 6× inrush to <2×)
- ✅ Reduced mechanical stress on bearings & seals
- ✅ Energy savings (pump/fan flow ∝ speed³)
- ✅ Precise speed control (±0.5 Hz achievable)
- ✅ Built-in diagnostics & fault codes
---
## 🏗️ Control Logic (Pseudocode)
```pascal
PROGRAM VFD_Motor_Control
VAR
(* Settings *)
Ramp_Up_Time_Sec : REAL := 10.0; (* Acceleration *)
Ramp_Down_Time_Sec : REAL := 5.0; (* Deceleration *)
Min_Speed_Hz : REAL := 20.0; (* Stall torque threshold *)
Max_Speed_Hz : REAL := 60.0; (* Motor nameplate max *)
Acc_Current_Limit_Amps : REAL := 1.5 * Nameplate_Current;
(* Command Interface *)
Start_Command : BOOL := FALSE;
Stop_Command : BOOL := FALSE;
Speed_Reference : REAL := 0.0; (* 0-100% *)
Remote_Mode : BOOL := TRUE; (* TRUE=PLC, FALSE=VFD keypad *)
(* Feedback from VFD (Modbus register read) *)
VFD_Running : BOOL;
VFD_Current_Feedback : REAL; (* Amps *)
VFD_Frequency_Actual : REAL; (* Hz *)
VFD_Output_Voltage : REAL; (* Volts *)
VFD_Alarm_Code : INT; (* 0=OK, >0=fault *)
(* Feedback from motor *)
Motor_Speed_Actual : REAL; (* RPM *)
Encoder_Feedback : REAL; (* 0-4095 pulses *)
(* Internal state *)
Target_Speed_Hz : REAL; (* Ramping target *)
Current_Speed_Hz : REAL := 0.0; (* Actual output freq *)
Ramp_Step_Hz : REAL;
Speed_Error : REAL;
Ramp_Direction : INT := 0; (* -1=down, 0=stopped, +1=up *)
(* Status *)
Motor_Running : BOOL := FALSE;
Ready_For_Start : BOOL := TRUE;
Motor_Fault : BOOL := FALSE;
Thermal_Warning : BOOL := FALSE;
(* Diagnostics *)
Overspeed_Count : INT := 0;
Underspeed_Count : INT := 0;
Last_Fault_Code : INT := 0;
END_VAR
(* ─────────────────────────────────────────────────────── *)
(* 1. RAMP GENERATION (Smooth acceleration) *)
(* ─────────────────────────────────────────────────────── *)
(* Calculate target frequency from speed reference *)
Target_Speed_Hz := (Speed_Reference / 100.0) * Max_Speed_Hz;
(* Limit to min/max *)
Target_Speed_Hz := MAX(Min_Speed_Hz, MIN(Max_Speed_Hz, Target_Speed_Hz));
(* Determine ramp direction *)
IF Target_Speed_Hz > Current_Speed_Hz THEN
Ramp_Direction := 1; (* Accelerating *)
Ramp_Step_Hz := (Max_Speed_Hz / Ramp_Up_Time_Sec) * SCAN_TIME_SEC;
ELSIF Target_Speed_Hz < Current_Speed_Hz THEN
Ramp_Direction := -1; (* Decelerating *)
Ramp_Step_Hz := (Max_Speed_Hz / Ramp_Down_Time_Sec) * SCAN_TIME_SEC;
ELSE
Ramp_Direction := 0; (* At target *)
Ramp_Step_Hz := 0.0;
END_IF;
(* Apply ramp *)
IF Ramp_Direction = 1 THEN
Current_Speed_Hz := MIN(Current_Speed_Hz + Ramp_Step_Hz, Target_Speed_Hz);
ELSIF Ramp_Direction = -1 THEN
Current_Speed_Hz := MAX(Current_Speed_Hz - Ramp_Step_Hz, Target_Speed_Hz);
END_IF;
(* ─────────────────────────────────────────────────────── *)
(* 2. VFD COMMAND (Write to Modbus registers) *)
(* ─────────────────────────────────────────────────────── *)
(* Register 0 = Run Control (0x0002 = run) *)
IF (Start_Command OR Speed_Reference > 0) AND Ready_For_Start THEN
MODBUS_WRITE(VFD_IP, Reg:0, Value:0x0002); (* Run *)
Motor_Running := TRUE;
ELSIF Stop_Command OR Speed_Reference = 0 THEN
MODBUS_WRITE(VFD_IP, Reg:0, Value:0x0001); (* Stop *)
Motor_Running := FALSE;
END_IF;
(* Register 1 = Speed Reference (0-1000 = 0-60Hz) *)
(* Formula: Register = (Current_Speed_Hz / 60.0) * 1000 *)
Speed_Register : INT := INT((Current_Speed_Hz / 60.0) * 1000.0);
MODBUS_WRITE(VFD_IP, Reg:1, Value:Speed_Register);
(* ─────────────────────────────────────────────────────── *)
(* 3. FEEDBACK MONITORING (Read Modbus registers) *)
(* ─────────────────────────────────────────────────────── *)
(* Register 10 = Actual Frequency Feedback *)
VFD_Frequency_Actual := (MODBUS_READ(VFD_IP, Reg:10) / 1000.0) * 60.0;
(* Register 11 = Output Current *)
VFD_Current_Feedback := MODBUS_READ(VFD_IP, Reg:11) / 10.0; (* 0.1A resolution *)
(* Register 12 = Alarm Code *)
VFD_Alarm_Code := MODBUS_READ(VFD_IP, Reg:12);
(* Optional: Encoder feedback (validate motor actually turning) *)
Motor_Speed_Actual := Encoder_Feedback * ENCODER_SCALE_FACTOR;
(* ─────────────────────────────────────────────────────── *)
(* 4. FAULT DETECTION & DIAGNOSTICS *)
(* ─────────────────────────────────────────────────────── *)
(* Alarm codes (generic VFD):
1 = Overspeed
2 = Overcurrent
3 = Overvoltage
4 = Undervoltage
5 = Overtemp
6 = PTC Thermal
7 = Fan failure
*)
Motor_Fault := (VFD_Alarm_Code > 0);
IF Motor_Fault THEN
Last_Fault_Code := VFD_Alarm_Code;
Current_Speed_Hz := 0.0; (* Clear output *)
Ready_For_Start := FALSE; (* Require manual reset *)
Motor_Running := FALSE;
END_IF;
(* Thermal warning (70% of max current) *)
Thermal_Warning := (VFD_Current_Feedback > (Nameplate_Current * 0.7));
(* Speed error detection *)
Speed_Error := ABS(VFD_Frequency_Actual - Current_Speed_Hz);
IF Speed_Error > 3.0 THEN (* 3Hz deviation *)
Underspeed_Count := Underspeed_Count + 1;
IF Underspeed_Count > 5 THEN (* Persist for 5 scans *)
Motor_Fault := TRUE; (* Log and alarm *)
END_IF;
ELSE
Underspeed_Count := 0;
END_IF;
(* ─────────────────────────────────────────────────────── *)
(* 5. ENERGY CALCULATION (Optional) *)
(* ─────────────────────────────────────────────────────── *)
(* Power consumed = VFD_Current * Supply_Voltage * Power_Factor *)
Power_Consumed : REAL := VFD_Current_Feedback * 480.0 * 0.95; (* Watts *)
(* Energy over time *)
Total_Energy := Total_Energy + (Power_Consumed / 3600000.0); (* kWh *)
(* ─────────────────────────────────────────────────────── *)
(* 6. OUTPUTS *)
(* ─────────────────────────────────────────────────────── *)
HMI_Speed_Reference := Current_Speed_Hz;
HMI_Speed_Actual := VFD_Frequency_Actual;
HMI_Current := VFD_Current_Feedback;
HMI_Motor_Running := Motor_Running;
HMI_Fault_Code := Last_Fault_Code;
HMI_Thermal_Warning := Thermal_Warning;
END_PROGRAM
```
---
## 🏷️ Tag List
| Tag | Type | I/O | Range | Description |
|-----|------|-----|-------|-------------|
| `VFD_01_SPEED_REF` | REAL | Param | 0-100 % | Speed command setpoint |
| `VFD_01_START` | BOOL | Cmd | - | Start motor |
| `VFD_01_STOP` | BOOL | Cmd | - | Stop motor |
| `VFD_01_RESET_FAULT` | BOOL | Cmd | - | Reset fault code |
| `VFD_01_RUNNING` | BOOL | Status | - | Motor running state |
| `VFD_01_FREQ_CMD` | REAL | Status | 0-60 Hz | Output frequency (ramped) |
| `VFD_01_FREQ_ACTUAL` | REAL | Feedback | 0-60 Hz | VFD actual output frequency |
| `VFD_01_CURRENT` | REAL | Feedback | 0-50 A | Motor current draw |
| `VFD_01_VOLTAGE_OUT` | REAL | Feedback | 0-600 V | VFD output voltage |
| `VFD_01_ALARM_CODE` | INT | Alarm | 0-63 | VFD fault code |
| `VFD_01_SPEED_ACTUAL` | REAL | Feedback | 0-4000 RPM | Motor speed (from encoder) |
| `VFD_01_POWER_CONSUMED` | REAL | Status | 0-100 kW | Real-time power |
| `VFD_01_ENERGY_TOTAL` | REAL | Status | 0-999999 kWh | Cumulative energy |
| `VFD_01_THERMAL_WARN` | BOOL | Alarm | - | Temperature warning (>70% rated current) |
| `VFD_01_RAMP_UP_SEC` | REAL | Param | 1-300 | Acceleration time |
| `VFD_01_RAMP_DOWN_SEC` | REAL | Param | 1-300 | Deceleration time |
| `VFD_01_MIN_FREQ_HZ` | REAL | Param | 5-30 | Minimum frequency (stall avoidance) |
| `VFD_01_MAX_FREQ_HZ` | REAL | Param | 30-120 | Maximum frequency |
---
## 🚨 Alarm & Trip Matrix
| Alarm | Condition | Severity | Auto-Reset |
|-------|-----------|----------|-----------|
| **Overspeed** | Frequency > Max × 1.1 | Critical | Manual |
| **Overcurrent** | Current > Nameplate × 1.5 | Critical | Manual |
| **Overvoltage** | Output voltage > 600V | Critical | Manual |
| **Undervoltage** | Supply < 380V | Critical | Manual |
| **Overtemperature** | Heatsink > 80°C | Critical | Manual |
| **PTC Thermal Trip** | RTD sensor > setpoint | Critical | Auto (after cool-down) |
| **Fan Failure** | VFD cooling fan stalled | Warning | Manual |
| **Ground Fault** | Leakage > 10mA | Critical | Manual |
| **Underspeed** | Actual < Command - 3Hz | Warning | Auto |
| **Thermal Warning** | Current > 70% rated | Warning | Auto |
| **Communication Loss** | No Modbus ping 2 sec | Warning | Auto |
| **Ready for Start** | Fault cleared, power OK | Info | Manual reset command |
---
## 📺 HMI Layout
```
┌──────────────────────────────────────────┐
│ VFD MOTOR CONTROL - PUMP DRIVER │
├──────────────────────────────────────────┤
│ Speed Reference: 45% ⚙️ [████░░░░] │
│ ↑ (drag to adjust) │
│ │
│ Status: [RAMPING UP] 🟡 │
│ Frequency: 27 Hz → 27 Hz │
│ Current: 18.5A [Healthy green] │
│ Power: 8.2 kW │
│ │
│ Performance: │
│ Motor Speed: 1620 RPM │
│ Time to Speed: 8.2 sec / 10 sec │
│ Efficiency: 94% vs Full Speed │
│ │
│ ┌─────────────────────────────────┐ │
│ │ Ramp Settings │ │
│ │ Up: 10s Down: 5s Min: 20Hz │ │
│ │ [Advanced...] │ │
│ └─────────────────────────────────┘ │
│ │
│ Actions: [Start] [Stop] [Reset Fault] │
│ │
│ Last Fault: None (48 hours operation) │
│ Total Energy: 127.3 kWh (this month) │
│ │
└──────────────────────────────────────────┘
```
**Mobile View** (simplified):
```
Speed: 45% [████░░░░]
Status: RAMPING [●●●]
Current: 18.5A OK
Motor: 1620 RPM
[START] [STOP]
```
---
## 🔧 Configuration Parameters
```json
{
"nameplate_current_amps": 25.0,
"nameplate_voltage_volts": 480.0,
"nameplate_power_kw": 18.5,
"nameplate_speed_rpm": 1800,
"ramp_up_time_seconds": 10.0,
"ramp_down_time_seconds": 5.0,
"min_frequency_hz": 20.0,
"max_frequency_hz": 60.0,
"acceleration_current_limit_percent": 150,
"thermal_warning_threshold_percent": 70,
"speed_error_tolerance_hz": 3.0,
"encoder_pulses_per_revolution": 1024,
"motor_poles": 4,
"vfd_protocol": "modbus_tcp",
"vfd_ip_address": "192.168.1.50",
"vfd_port": 502,
"modbus_slave_id": 1
}
```
---
## 📝 Implementation Checklist
### Before Deployment
- [ ] **VFD commissioned by electrician** (parameter setup, ramp times configured)
- [ ] **Motor nameplate verified** (horsepower, voltage, current, RPM)
- [ ] **Encoder mounted** (if speed feedback required, validated 0-4095 pulses)
- [ ] **Network cable verified** (Ethernet for Modbus TCP, shielded & twisted pair)
- [ ] **VFD accessible in PLC code** (Modbus read/write library loaded)
- [ ] **Supply voltage stable** (480V ±10% typical 3-phase)
### During Commissioning
1. **No-load test**:
- Speed reference 0% → 25% → verify smooth ramp
- ~5 seconds to reach 25% (15Hz)
- No error messages
2. **Full-load test**:
- Speed reference 50% (30Hz)
- Monitor current ramp (should reach steady ~12A over 10s)
- No thermal warning
- Run for 15 minutes steady-state
3. **Fault injection**:
- Simulate power loss → VFD should halt & set alarm code
- Simulate over-current → thermal warning should trigger
- Verify alarm is displayed in HMI
4. **Energy logging**:
- Baseline: Record kWh at 100% speed (full open bypass valve)
- VFD mode: Record kWh at 50% speed
- Expect 50-80% energy reduction (non-linear pump laws)
---
## 📊 Expected Performance
- **Ramp smoothness**: <1 Hz step size (smooth acceleration, no mechanical shock)
- **Speed hold accuracy**: ±1 Hz (excellent regulation)
- **Current inrush**: 2× nameplate (vs 6× without VFD soft-start)
- **Energy savings**: 40-85% vs throttle valve (pump flow ∝ speed³)
- **Fault detection**: <2 seconds (current/voltage monitoring)
- **Mean time between failures**: >40,000 hours (MTBF typical)
---
## 🔄 Advanced Variations
### PID Closed-Loop Speed Control
Replace manual speed reference with PID loop controlling pump discharge pressure or flow rate.
### Energy Optimizer
Modulate speed based on demand—if downstream valve opening < 50%, reduce VFD speed to save energy.
### Multi-Motor Coordinated Control
Sequence multiple VFDs (e.g., dual pump duty/standby): start P1 at 25%, if pressure low add P2 at 25%.
### Daylight-Activated Control
In water treatment: reduce VFD speed during night (lower demand), ramp back up morning.
---
**Ready for production deployment in pump, fan, and compressor applications.**