polarimeter_software/User/driver/sv630p/h06_speed_control.h

618 lines
21 KiB
C
Raw Normal View History

2025-09-30 02:37:23 +00:00
#ifndef __H06_SPEED_CONTROL_H__
#define __H06_SPEED_CONTROL_H__
#include "sv_common.h"
// H06.00 主速度指令A来源
#define REG_H06_00_MAIN_SPEED_CMD_A_SRC 0x0600 // Main Speed Command A Source
/**
* @enum SV630P_MainSpeedCmdASource
* @brief Main speed command A source enumeration
* Defines available sources for main speed command A
*/
typedef enum
{
DIGITAL_VALUE_SPECIFIED_CMD_A = 0,
} SV630P_MainSpeedCmdASource;
// Source of H06.01 Auxiliary Speed Command B
#define REG_H06_01_AUX_SPEED_CMD_B_SRC 0x0601 // Auxiliary Speed Command B Source
/**
* @enum SV630P_AuxSpeedCmdBSource
* @brief Auxiliary speed command B source enumeration
* Defines available sources for auxiliary speed command B
*/
typedef enum
{
DIGITAL_VALUE_SPECIFIED_CMD_B = 0,
MULTI_SEGMENT_SPEED_CMD_B = 1
} SV630P_AuxSpeedCmdBSource;
// H06.02 速度指令选择
#define REG_H06_02_SPEED_CMD_SELECT 0x0602 // Speed Command Selection
/**
* @enum SV630P_SpeedCmdSelect
* @brief Speed command selection enumeration
* Defines options for speed command selection
*/
typedef enum
{
SV630P_SPEED_CMD_MAIN_A = 0, /**< Main speed command A source: selected by H06.00 */
SV630P_SPEED_CMD_AUX_B = 1, /**< Auxiliary speed command B source: selected by H06.01 */
SV630P_SPEED_CMD_A_PLUS_B = 2, /**< Main A + Auxiliary B: combined effect of sources selected by H06.00 and H06.01 */
SV630P_SPEED_CMD_A_B_SWITCH = 3, /**< A/B source switch: controlled by DI function FunIN.4 (Cmd_SEL)
- FunIN.4 invalid: Main speed command A
- FunIN.4 valid: Auxiliary speed command B */
SV630P_SPEED_CMD_COMMUNICATION = 4 /**< Communication given: speed command input via H31.09 with 0.001rpm precision */
} SV630P_SpeedCmdSelect;
// H06.03 速度指令键盘设定值
#define REG_H06_03_SPEED_CMD_KEYBOARD 0x0603 // Speed Command Keyboard Setting
#define H06_03_SPEED_CMD_KEYBOARD_MIN -6000
#define H06_03_SPEED_CMD_KEYBOARD_MAX 6000
#define H06_03_SPEED_CMD_KEYBOARD_DEF 200
// H06.04 点动速度设定值
#define REG_H06_04_JOG_SPEED_SET 0x0604 // Jog Speed Setting
#define H06_04_JOG_SPEED_MIN 0
#define H06_04_JOG_SPEED_MAX 6000
#define H06_04_JOG_SPEED_DEF 1000
// H06.05 速度指令加速斜坡时间常数
#define REG_H06_05_ACCEL_RAMP_TIME 0x0605 // Speed Command Acceleration Ramp Time Constant
#define H06_05_ACCEL_RAMP_MIN 0
#define H06_05_ACCEL_RAMP_MAX 65535
#define H06_05_ACCEL_RAMP_DEF 0
// H06.06 速度指令减速斜坡时间常数
#define REG_H06_06_DECEL_RAMP_TIME 0x0606 // Speed Command Deceleration Ramp Time Constant
#define H06_06_DECEL_RAMP_MIN 0
#define H06_06_DECEL_RAMP_MAX 65535
#define H06_06_DECEL_RAMP_DEF 0
// H06.07 最大转速阈值
#define REG_H06_07_MAX_SPEED_THRESHOLD 0x0607 // Maximum Speed Threshold
#define H06_07_MAX_SPEED_THRESHOLD_MIN 0
#define H06_07_MAX_SPEED_THRESHOLD_MAX 6000
#define H06_07_MAX_SPEED_THRESHOLD_DEF 6000
// H06.08 正向速度阈值
#define REG_H06_08_FORWARD_SPEED_THRESHOLD 0x0608 // Forward Speed Threshold
#define H06_08_FORWARD_SPEED_MIN 0
#define H06_08_FORWARD_SPEED_MAX 6000
#define H06_08_FORWARD_SPEED_DEF 6000
// H06.09 反向速度阈值
#define REG_H06_09_REVERSE_SPEED_THRESHOLD 0x0609 // Reverse Speed Threshold
#define H06_09_REVERSE_SPEED_MIN 0
#define H06_09_REVERSE_SPEED_MAX 6000
#define H06_09_REVERSE_SPEED_DEF 6000
// H06.11 转矩前馈控制选择
#define REG_H06_11_TORQUE_FEEDFORWARD_SEL 0x0611 // Torque Feedforward Control Selection
/**
* @enum SV630P_TorqueFeedforwardSelect
* @brief Torque feedforward control selection enumeration
* Defines options for torque feedforward control
*/
typedef enum
{
SV630P_TORQUE_FEEDFORWARD_NONE = 0, /**< No torque feedforward */
SV630P_TORQUE_FEEDFORWARD_INTERNAL = 1 /**< Internal torque feedforward */
} SV630P_TorqueFeedforwardSelect;
// H06.13 速度平滑滤波时间
#define REG_H06_13_SPEED_SMOOTH_FILTER_TIME 0x0613 // Speed Smooth Filter Time
#define H06_13_FILTER_TIME_MIN 0
#define H06_13_FILTER_TIME_MAX 65535
#define H06_13_FILTER_TIME_DEF 0
// H06.15 零位固转速阈值
#define REG_H06_15_ZERO_POS_SPEED_THRESHOLD 0x0615 // Zero Position Fixed Speed Threshold
#define H06_15_ZERO_POS_THRESHOLD_MIN 0
#define H06_15_ZERO_POS_THRESHOLD_MAX 6000
#define H06_15_ZERO_POS_THRESHOLD_DEF 10
// H06.16 电机旋转速度阈值
#define REG_H06_16_MOTOR_ROTATE_THRESHOLD 0x0616 // Motor Rotation Speed Threshold
#define H06_16_ROTATE_THRESHOLD_MIN 0
#define H06_16_ROTATE_THRESHOLD_MAX 1000
#define H06_16_ROTATE_THRESHOLD_DEF 20
// H06.17 速度一致信号阈值
#define REG_H06_17_SPEED_CONSISTENT_THRESHOLD 0x0617 // Speed Consistent Signal Threshold
#define H06_17_CONSISTENT_THRESHOLD_MIN 0
#define H06_17_CONSISTENT_THRESHOLD_MAX 100
#define H06_17_CONSISTENT_THRESHOLD_DEF 10
// H06.18 速度到达信号阈值
#define REG_H06_18_SPEED_ARRIVE_THRESHOLD 0x0618 // Speed Arrive Signal Threshold
#define H06_18_ARRIVE_THRESHOLD_MIN 10
#define H06_18_ARRIVE_THRESHOLD_MAX 6000
#define H06_18_ARRIVE_THRESHOLD_DEF 1000
// H06.19 零速输出信号阈值
#define REG_H06_19_ZERO_SPEED_OUTPUT_THRESHOLD 0x0619 // Zero Speed Output Signal Threshold
#define H06_19_ZERO_SPEED_THRESHOLD_MIN 1
#define H06_19_ZERO_SPEED_THRESHOLD_MAX 6000
#define H06_19_ZERO_SPEED_THRESHOLD_DEF 10
// H06.28 齿槽力矩波动补偿使能
#define REG_H06_28_COGGING_COMP_ENABLE 0x0628 // Cogging Torque Ripple Compensation Enable
/**
* @enum SV630P_CoggingCompEnable
* @brief Cogging torque ripple compensation enable enumeration
* Defines options for cogging torque ripple compensation enable
*/
typedef enum
{
SV630P_COGGING_COMP_DISABLE = 0, // 禁用齿槽力矩波动补偿
SV630P_COGGING_COMP_ENABLE = 1, // 使能齿槽力矩波动补偿
// 其他枚举值根据实际文档定义补充
} SV630P_CoggingCompEnable;
// H06.31 正弦频率
#define REG_H06_31_SINE_FREQUENCY 0x0631 // Sine Frequency
#define H06_31_SINE_FREQ_MIN 0
#define H06_31_SINE_FREQ_MAX 16000
#define H06_31_SINE_FREQ_DEF 50
// H06.32 正弦幅值
#define REG_H06_32_SINE_AMPLITUDE 0x0632 // Sine Amplitude
#define H06_32_SINE_AMP_MIN 0
#define H06_32_SINE_AMP_MAX 30000
#define H06_32_SINE_AMP_DEF 30
// H06.33 正弦幅值与H06.32名称相同,需根据文档确认差异)
#define REG_H06_33_SINE_AMPLITUDE 0x0633 // Sine Amplitude
#define H06_33_SINE_AMP_MIN 0
#define H06_33_SINE_AMP_MAX 3
#define H06_33_SINE_AMP_DEF 0
// H06.35 正弦偏置
#define REG_H06_35_SINE_OFFSET 0x0635 // Sine Offset
#define H06_35_SINE_OFFSET_MIN -9900
#define H06_35_SINE_OFFSET_MAX 9900
#define H06_35_SINE_OFFSET_DEF 0
/**
* @brief Read main speed command A source
* @param dev Device handle
* @param src Output parameter for main speed command A source
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_00_read_main_speed_cmd_a_src(sv630p_handle_t *dev, SV630P_MainSpeedCmdASource *src);
/**
* @brief Write main speed command A source
* @param dev Device handle
* @param src Main speed command A source to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_00_write_main_speed_cmd_a_src(sv630p_handle_t *dev, SV630P_MainSpeedCmdASource src);
/**
* @brief Read auxiliary speed command B source
* @param dev Device handle
* @param src Output parameter for auxiliary speed command B source
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_01_read_aux_speed_cmd_b_src(sv630p_handle_t *dev, SV630P_AuxSpeedCmdBSource *src);
/**
* @brief Write auxiliary speed command B source
* @param dev Device handle
* @param src Auxiliary speed command B source to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_01_write_aux_speed_cmd_b_src(sv630p_handle_t *dev, SV630P_AuxSpeedCmdBSource src);
/**
* @brief Read speed command selection mode
* @param dev Device handle
* @param select Output parameter for speed command selection mode
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_02_read_speed_cmd_select(sv630p_handle_t *dev, SV630P_SpeedCmdSelect *select);
/**
* @brief Write speed command selection mode
* @param dev Device handle
* @param select Speed command selection mode to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_02_write_speed_cmd_select(sv630p_handle_t *dev, SV630P_SpeedCmdSelect select);
/**
* @brief Read keyboard setting value of speed command
* @param dev Device handle
* @param speed Output parameter for speed value (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_03_read_speed_cmd_keyboard(sv630p_handle_t *dev, int16_t *speed);
/**
* @brief Write keyboard setting value of speed command
* @param dev Device handle
* @param speed Speed value to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_03_write_speed_cmd_keyboard(sv630p_handle_t *dev, int16_t speed);
/**
* @brief Read jog speed setting value
* @param dev Device handle
* @param speed Output parameter for jog speed (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_04_read_jog_speed(sv630p_handle_t *dev, uint16_t *speed);
/**
* @brief Write jog speed setting value
* @param dev Device handle
* @param speed Jog speed to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_04_write_jog_speed(sv630p_handle_t *dev, uint16_t speed);
/**
* @brief Read acceleration ramp time constant
* @param dev Device handle
* @param time Output parameter for acceleration time (ms)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_05_read_accel_ramp_time(sv630p_handle_t *dev, uint16_t *time);
/**
* @brief Write acceleration ramp time constant
* @param dev Device handle
* @param time Acceleration time to set (ms)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_05_write_accel_ramp_time(sv630p_handle_t *dev, uint16_t time);
/**
* @brief Read deceleration ramp time constant
* @param dev Device handle
* @param time Output parameter for deceleration time (ms)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_06_read_decel_ramp_time(sv630p_handle_t *dev, uint16_t *time);
/**
* @brief Write deceleration ramp time constant
* @param dev Device handle
* @param time Deceleration time to set (ms)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_06_write_decel_ramp_time(sv630p_handle_t *dev, uint16_t time);
/**
* @brief Read maximum speed threshold
* @param dev Device handle
* @param threshold Output parameter for maximum speed threshold (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_07_read_max_speed_threshold(sv630p_handle_t *dev, uint16_t *threshold);
/**
* @brief Write maximum speed threshold
* @param dev Device handle
* @param threshold Maximum speed threshold to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_07_write_max_speed_threshold(sv630p_handle_t *dev, uint16_t threshold);
/**
* @brief Read forward speed threshold
* @param dev Device handle
* @param threshold Output parameter for forward speed threshold (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_08_read_forward_speed_threshold(sv630p_handle_t *dev, uint16_t *threshold);
/**
* @brief Write forward speed threshold
* @param dev Device handle
* @param threshold Forward speed threshold to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_08_write_forward_speed_threshold(sv630p_handle_t *dev, uint16_t threshold);
/**
* @brief Read reverse speed threshold
* @param dev Device handle
* @param threshold Output parameter for reverse speed threshold (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_09_read_reverse_speed_threshold(sv630p_handle_t *dev, uint16_t *threshold);
/**
* @brief Write reverse speed threshold
* @param dev Device handle
* @param threshold Reverse speed threshold to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_09_write_reverse_speed_threshold(sv630p_handle_t *dev, uint16_t threshold);
/**
* @brief Read torque feedforward control selection
* @param dev Device handle
* @param select Output parameter for torque feedforward control selection
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_11_read_torque_feedforward_sel(sv630p_handle_t *dev, SV630P_TorqueFeedforwardSelect *select);
/**
* @brief Write torque feedforward control selection
* @param dev Device handle
* @param select Torque feedforward control selection to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_11_write_torque_feedforward_sel(sv630p_handle_t *dev, SV630P_TorqueFeedforwardSelect select);
/**
* @brief Read speed smooth filter time
* @param dev Device handle
* @param time Output parameter for speed smooth filter time (μs)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_13_read_speed_smooth_filter_time(sv630p_handle_t *dev, uint16_t *time);
/**
* @brief Write speed smooth filter time
* @param dev Device handle
* @param time Speed smooth filter time to set (μs)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_13_write_speed_smooth_filter_time(sv630p_handle_t *dev, uint16_t time);
/**
* @brief Read zero position fixed speed threshold
* @param dev Device handle
* @param threshold Output parameter for zero position fixed speed threshold (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_15_read_zero_pos_speed_threshold(sv630p_handle_t *dev, uint16_t *threshold);
/**
* @brief Write zero position fixed speed threshold
* @param dev Device handle
* @param threshold Zero position fixed speed threshold to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_15_write_zero_pos_speed_threshold(sv630p_handle_t *dev, uint16_t threshold);
/**
* @brief Read motor rotation speed threshold
* @param dev Device handle
* @param threshold Output parameter for motor rotation speed threshold (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_16_read_motor_rotate_threshold(sv630p_handle_t *dev, uint16_t *threshold);
/**
* @brief Write motor rotation speed threshold
* @param dev Device handle
* @param threshold Motor rotation speed threshold to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_16_write_motor_rotate_threshold(sv630p_handle_t *dev, uint16_t threshold);
/**
* @brief Read speed consistent signal threshold
* @param dev Device handle
* @param threshold Output parameter for speed consistent signal threshold (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_17_read_speed_consistent_threshold(sv630p_handle_t *dev, uint16_t *threshold);
/**
* @brief Write speed consistent signal threshold
* @param dev Device handle
* @param threshold Speed consistent signal threshold to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_17_write_speed_consistent_threshold(sv630p_handle_t *dev, uint16_t threshold);
/**
* @brief Read speed arrive signal threshold
* @param dev Device handle
* @param threshold Output parameter for speed arrive signal threshold (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_18_read_speed_arrive_threshold(sv630p_handle_t *dev, uint16_t *threshold);
/**
* @brief Write speed arrive signal threshold
* @param dev Device handle
* @param threshold Speed arrive signal threshold to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_18_write_speed_arrive_threshold(sv630p_handle_t *dev, uint16_t threshold);
/**
* @brief Read zero speed output signal threshold
* @param dev Device handle
* @param threshold Output parameter for zero speed output signal threshold (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_19_read_zero_speed_output_threshold(sv630p_handle_t *dev, uint16_t *threshold);
/**
* @brief Write zero speed output signal threshold
* @param dev Device handle
* @param threshold Zero speed output signal threshold to set (rpm)
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_19_write_zero_speed_output_threshold(sv630p_handle_t *dev, uint16_t threshold);
/**
* @brief Read cogging torque ripple compensation enable status
* @param dev Device handle
* @param enable Output parameter for cogging compensation enable status
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_28_read_cogging_comp_enable(sv630p_handle_t *dev, SV630P_CoggingCompEnable *enable);
/**
* @brief Write cogging torque ripple compensation enable status
* @param dev Device handle
* @param enable Cogging compensation enable status to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_28_write_cogging_comp_enable(sv630p_handle_t *dev, SV630P_CoggingCompEnable enable);
/**
* @brief Read sine frequency setting
* @param dev Device handle
* @param freq Output parameter for sine frequency
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_31_read_sine_frequency(sv630p_handle_t *dev, uint16_t *freq);
/**
* @brief Write sine frequency setting
* @param dev Device handle
* @param freq Sine frequency to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_31_write_sine_frequency(sv630p_handle_t *dev, uint16_t freq);
/**
* @brief Read sine amplitude (H06.32)
* @param dev Device handle
* @param amp Output parameter for sine amplitude
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_32_read_sine_amplitude(sv630p_handle_t *dev, uint16_t *amp);
/**
* @brief Write sine amplitude (H06.32)
* @param dev Device handle
* @param amp Sine amplitude to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_32_write_sine_amplitude(sv630p_handle_t *dev, uint16_t amp);
/**
* @brief Read sine amplitude (H06.33)
* @param dev Device handle
* @param amp Output parameter for sine amplitude (H06.33)
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_33_read_sine_amplitude(sv630p_handle_t *dev, uint16_t *amp);
/**
* @brief Write sine amplitude (H06.33)
* @param dev Device handle
* @param amp Sine amplitude (H06.33) to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_33_write_sine_amplitude(sv630p_handle_t *dev, uint16_t amp);
/**
* @brief Read sine offset
* @param dev Device handle
* @param offset Output parameter for sine offset
* @return Operation result
* @retval SV630P_OK Success
* @retval SV630P_BUS_ERR Communication bus error
*/
int sv630p_h06_35_read_sine_offset(sv630p_handle_t *dev, int16_t *offset);
/**
* @brief Write sine offset
* @param dev Device handle
* @param offset Sine offset to set
* @return Operation result
* @retval SV630P_OK Success
* @retval Other values Failure
*/
int sv630p_h06_35_write_sine_offset(sv630p_handle_t *dev, int16_t offset);
#endif //__H06_SPEED_CONTROL_H__