firmware-base/docs/SAKO_VFD.md

134 lines
3.8 KiB
Markdown

---
title: SAKO VFD Component
description: Documentation for the SAKO Variable Frequency Drive component interface
keywords: [VFD, SAKO, RS485, Modbus, frequency, motor control]
---
# SAKO VFD
**Path**: [`src/components/SAKO_VFD.cpp`](../src/components/SAKO_VFD.cpp)
**Revision History**: Initial documentation
The SAKO_VFD component provides an interface for controlling and monitoring SAKO Variable Frequency Drives over RS485 using Modbus RTU protocol. It enables setting frequency, controlling motor direction, reading operational status, and retrieving fault information.
## REQUIREMENTS
### Hardware
- ESP32 or compatible microcontroller
- RS485 transceiver hardware
- SAKO VFD connected to RS485 bus
### Software
- ENABLE_RS485 flag must be defined in config.h
- ModbusRTU library for communication
## FEATURES
- Control motor speed by setting frequency in 0.01 Hz units
- Start and stop motor operation
- Change motor direction (forward/reverse)
- Monitor operational parameters:
- Current frequency
- Set frequency
- Output current
- Output power (kW)
- Output torque percentage
- Read VFD status and fault codes
- Automatic retract operation with state machine
- Integration with Modbus TCP for remote control
## DEPENDENCIES
- [Component](../src/Component.h) - Base component functionality
- [ModbusRTU](../src/modbus/ModbusRTU.h) - RS485 Modbus communication
- [ModbusTypes](../src/modbus/ModbusTypes.h) - Modbus data type definitions
- [xstatistics](../src/xstatistics.h) - Statistics collection for VFD parameters
```mermaid
graph TD
SAKOVFD[SAKO_VFD] --> RTUBase[RTU_Base]
RTUBase --> Component[Component]
SAKOVFD --> ModbusRTU[ModbusRTU]
SAKOVFD --> Statistics[xstatistics]
```
## BEHAVIOUR
```mermaid
stateDiagram-v2
[*] --> Stopped
Stopped --> Accelerating: run()
Accelerating --> Running
Running --> Decelerating: stop()
Decelerating --> Stopped
Running --> Reversing: reverse()
Reversing --> Running
Error --> Stopped: resetFault()
Stopped --> Retract: retract()
Retract --> Braking
Braking --> ReverseStopped
ReverseStopped --> Reversing
Reversing --> BrakeReversing
BrakeReversing --> Retracted
Retracted --> [*]
state Error {
[*] --> FaultCode
}
```
## TODOS
### PERFORMANCE
- Consider implementing a more efficient polling mechanism for less critical parameters
- Add caching of VFD parameters with configurable refresh rates
- Implement rate limiting for write operations to prevent overloading the RS485 bus
### SECURITY
- Add validation for input values before sending to the VFD
- Implement error handling for unexpected responses from the VFD
- Consider adding authentication for control operations
### COMPLIANCE
- Ensure compliance with industrial standards for VFD control
- Add proper error handling and recovery mechanisms
- Implement data logging for compliance with maintenance requirements
### RECOMMENDATIONS
- Set appropriate read intervals based on system requirements
- Implement proper error handling for Modbus communication failures
- Consider adding more advanced control features like PID control for motor speed
- Use statistics tracking to monitor performance and detect potential issues
## EXAMPLE
This example shows how to initialize and mount a SAKO_VFD component in a system:
```cpp
#ifdef ENABLE_SAKO_VFD
sakoVFD = new SAKO_VFD(
MB_SAKO_VFD_SLAVE_ID, // Modbus slave ID of the VFD
MB_SAKO_VFD_READ_INTERVAL // Polling interval in milliseconds
);
if (sakoVFD)
{
components.push_back(sakoVFD);
Log.infoln(F("SAKO VFD initialized. SlaveID:%d, ReadInterval:%d ms"),
MB_SAKO_VFD_SLAVE_ID, MB_SAKO_VFD_READ_INTERVAL);
}
else
{
Log.errorln(F("SAKO VFD initialization failed."));
}
#endif
```
### References
- SAKO VFD User Manual (refer to manufacturer documentation)
- Modbus RTU specification for register definitions