firmware-base/docs-c/components/Sako-Registers.md
2025-06-04 13:45:12 +02:00

3.5 KiB

title description keywords
Sako Modbus Register Enums Comprehensive documentation for the Sako drive Modbus register enumeration mappings
Sako
VFD
Modbus
registers
ESP32
industrial-automation

Sako Modbus Register Enums

Path: ./src/devices/sako/sako_modbus_registers.h

Revision History: Initial documentation

This component defines enumeration values for Sako VFD drive parameters accessible via Modbus. It provides a comprehensive mapping of control and configuration registers for Sako frequency inverters with descriptive comments on parameter functions and values.

REQUIREMENTS

  • Modbus RTU communication capability
  • RS485 interface connected to Sako VFD
  • Properly configured Modbus client implementation

FEATURES

  • Complete parameter mapping for Sako VFD registers
  • Human-readable enumeration names that describe register purposes
  • Detailed comments for parameter options and value ranges
  • Hexadecimal address values with logical grouping by parameter sections
  • Support for all major drive control and configuration functions

DEPENDENCIES

graph TD
    Application --> SakoModbusRegisters
    SakoModbusRegisters --> ModbusClient
    ModbusClient --> RS485Hardware

BEHAVIOUR

The component provides enumeration constants that map to specific Modbus registers in the Sako VFD. It doesn't implement any behavior itself but provides the addressing information needed for the application to communicate with the device.

sequenceDiagram
    Application->>ModbusClient: Use Register Address from E_SAKO_PARAM
    ModbusClient->>SakoVFD: Send Modbus Request
    SakoVFD->>ModbusClient: Send Register Data
    ModbusClient->>Application: Return Result

TODOS

PERFORMANCE

  • Consider organizing registers into separate enum classes for different parameter groups
  • Evaluate if a more structured approach like a map or class with methods would improve usability

SECURITY

  • Add validation ranges for each parameter to prevent sending invalid values
  • Consider adding read/write permissions to prevent accidental modification of critical parameters

COMPLIANCE

  • Verify all register addresses and descriptions against the latest Sako VFD documentation
  • Ensure compatibility with different Sako VFD series and firmware versions

RECOMMENDATIONS

  • Use constants from this enumeration rather than hardcoded values in application code
  • When sending values to the VFD, always check the allowed range from the parameter description
  • Consider implementing a higher-level interface that uses these enum values but provides type safety and validation

EXAMPLE

// Example of using the Sako register enums with a Modbus client
ModbusClient* modbusClient = new ModbusClient(
    &Serial2,
    PIN_RS485_DE_RE,
    MODBUS_BAUD_RATE
);

// Read motor control mode
uint16_t controlMode;
if (modbusClient->readHoldingRegister(
    SAKO_MODBUS_ADDRESS,
    static_cast<uint16_t>(E_SAKO_PARAM::E_SAKO_PARAM_P00_01_MOTOR_CONTROL_MODE),
    controlMode
)) {
    Serial.printf("Motor control mode: %d\n", controlMode);
}

// Set motor frequency to 50Hz (value needs to be scaled according to parameter specification)
uint16_t frequencyValue = 5000; // 50.00Hz, assuming two decimal places
modbusClient->writeHoldingRegister(
    SAKO_MODBUS_ADDRESS,
    static_cast<uint16_t>(E_SAKO_PARAM::E_SAKO_PARAM_P00_08_PRESET_FREQUENCY),
    frequencyValue
);

References