# Configuration file for mb2hal to communicate with Vevor D100 VFD
# via Modbus RTU (RS485)
#
# Load component using:
# loadusr -W mb2hal config=vfd_d100.ini

[MB2HAL_INIT]

# Debug level: 0 = silent, 1 = errors, 2 = OK messages, 3 = debugging, 4 = max debug
INIT_DEBUG=3

# Set to 1.1 to enable float/int pin options and specific features
VERSION=1.1

# HAL module (component) name. Pins will be prefixed with this name.
HAL_MODULE_NAME=vfd

# Delay between transactions in seconds (use 0.0 for normal speed)
SLOWDOWN=0.0

# Number of transactions defined below
TOTAL_TRANSACTIONS=4


# =====================================================================
# TRANSACTION 00: Write Main Control Register (0200H / 512 dec)
# =====================================================================
[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=1
# Delay after transmission in ms (helps with VFD response processing and EMI)
SERIAL_DELAY_MS=50
MB_SLAVE_ID=1

MB_TX_CODE=fnct_06_write_single_register
FIRST_ELEMENT=512
NELEMENTS=1
HAL_TX_NAME=control
MAX_UPDATE_RATE=10.0
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
DEBUG=1


# =====================================================================
# TRANSACTION 01: Write Given Frequency (0201H / 513 dec)
# =====================================================================
[TRANSACTION_01]
# Link settings (PORT, BAUD, etc.) are inherited from TRANSACTION_00
MB_TX_CODE=fnct_06_write_single_register
FIRST_ELEMENT=513
NELEMENTS=1
HAL_TX_NAME=speed
MAX_UPDATE_RATE=10.0
DEBUG=1


# =====================================================================
# TRANSACTION 02: Read Main Control Status (0210H / 528 dec)
# =====================================================================
[TRANSACTION_02]
MB_TX_CODE=fnct_03_read_holding_registers
FIRST_ELEMENT=528
NELEMENTS=1
HAL_TX_NAME=status
MAX_UPDATE_RATE=10.0
DEBUG=1


# =====================================================================
# TRANSACTION 03: Read Operating Parameters (0220H - 0223H / 544 - 547 dec)
# =====================================================================
[TRANSACTION_03]
MB_TX_CODE=fnct_03_read_holding_registers
FIRST_ELEMENT=544
# Receptors:
# 544 (0220H) = Output Frequency (Hz * 10)
# 545 (0221H) = Set Frequency (Hz * 10)
# 546 (0222H) = Output Current (A * 10)
# 547 (0223H) = Output Speed (RPM)
PIN_NAMES=freq_out,freq_set,current,rpm
HAL_TX_NAME=metrics
MAX_UPDATE_RATE=5.0
DEBUG=1
