|
@@ -249,6 +249,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
//页面初始化
|
|
|
label_BuildTime.Text= "编译时间:"+ System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString();
|
|
|
+ label_Computername.Text = "用户名:" + System.Environment.UserName;
|
|
|
|
|
|
//下拉控件初始值设定
|
|
|
comboBox_WorkMode.SelectedIndex = 0;
|
|
@@ -844,6 +845,8 @@ namespace Welling_Motor_Debug_Tool
|
|
|
richTextBox_AssistParam.Clear();
|
|
|
int index_1 = myParams.AssistParam.IndexOf("转矩曲线.a");
|
|
|
int index_2 = myParams.AssistParam.IndexOf("踏频曲线.d");
|
|
|
+ int index_3 = myParams.AssistParam.IndexOf("踏频助力加速限制");
|
|
|
+ int index_4 = myParams.AssistParam.IndexOf("踏频助力电流步进");
|
|
|
for (int i = 0; i < myParams.AssistParam.Count; i++)
|
|
|
{
|
|
|
if (i < index_1) //数据占用2bytes
|
|
@@ -854,7 +857,15 @@ namespace Welling_Motor_Debug_Tool
|
|
|
{
|
|
|
richTextBox_AssistParam.AppendText(myParams.AssistParam[i] + "=" + Convert.ToString((long)((Data[4 * i - 5] << 24) + (Data[4 * i - 6] << 16) + (Data[4 * i - 7] << 8) + Data[4 * i - 8])) + ", ");
|
|
|
}
|
|
|
- else //数据占用2bytes
|
|
|
+ else if (i < index_3) //数据占用2bytes,无符号
|
|
|
+ {
|
|
|
+ richTextBox_AssistParam.AppendText(myParams.AssistParam[i] + "=" + Convert.ToString((ushort)(Data[2 * i + 17] * 256 + Data[2 * i + 16])) + ", ");
|
|
|
+ }
|
|
|
+ else if (i <= index_4) //数据占用2bytes,有符号
|
|
|
+ {
|
|
|
+ richTextBox_AssistParam.AppendText(myParams.AssistParam[i] + "=" + Convert.ToString((short)(Data[2 * i + 17] * 256 + Data[2 * i + 16])) + ", ");
|
|
|
+ }
|
|
|
+ else //数据占用2bytes,无符号
|
|
|
{
|
|
|
richTextBox_AssistParam.AppendText(myParams.AssistParam[i] + "=" + Convert.ToString((ushort)(Data[2 * i + 17] * 256 + Data[2 * i + 16])) + ", ");
|
|
|
}
|
|
@@ -1751,7 +1762,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
/// </summary>
|
|
|
private void MC_RunInfo_Clear()
|
|
|
{
|
|
|
- foreach (Control c in groupBox2.Controls)
|
|
|
+ foreach (Control c in tabPage_RunInfo.Controls)
|
|
|
{
|
|
|
if ((c is TextBox))
|
|
|
{
|
|
@@ -1759,6 +1770,14 @@ namespace Welling_Motor_Debug_Tool
|
|
|
c.Text = "---";
|
|
|
}
|
|
|
}
|
|
|
+ foreach (Control c in tabPage_DebugInfo.Controls)
|
|
|
+ {
|
|
|
+ if ((c is TextBox))
|
|
|
+ {
|
|
|
+ if (c.Name != textBox_ErrorCode.ToString())
|
|
|
+ c.Text = "---";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -2677,7 +2696,14 @@ namespace Welling_Motor_Debug_Tool
|
|
|
return;
|
|
|
}
|
|
|
string SaveData = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff").Replace(" ", "_") + " --> ";
|
|
|
- foreach (Control c in groupBox2.Controls)
|
|
|
+ foreach (Control c in tabPage_RunInfo.Controls)
|
|
|
+ {
|
|
|
+ if (c is TextBox)
|
|
|
+ {
|
|
|
+ SaveData += c.Text + " , ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (Control c in tabPage_DebugInfo.Controls)
|
|
|
{
|
|
|
if (c is TextBox)
|
|
|
{
|
|
@@ -3044,9 +3070,11 @@ namespace Welling_Motor_Debug_Tool
|
|
|
var RunMode = new byte[1];
|
|
|
if (comboBox_WorkMode.Text == "配置模式")
|
|
|
RunMode[0] = 0x01;
|
|
|
+ else if (comboBox_WorkMode.Text == "调试模式")
|
|
|
+ RunMode[0] = 0x02;
|
|
|
else
|
|
|
RunMode[0] = 0x00;
|
|
|
- mySerialProcess.SendCmd((ushort)0x751, (byte)0x16, (ushort)0x1901, RunMode);
|
|
|
+ mySerialProcess.SendCmdWithoutNotice((ushort)0x751, (byte)0x16, (ushort)0x1901, RunMode);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -3370,8 +3398,30 @@ namespace Welling_Motor_Debug_Tool
|
|
|
bool MotorRunStatus = false;
|
|
|
private void button_FacModeMotorRun_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- string DebugDefaultInfo = "整体运行模式=4, 位置获取模式=1, 采样模式=2, 旋转方向=1, 定位电流=1000, 拖拽电压=18, 拖拽电流=1000, 拖拽频率=20, 加速斜率=500, 减速斜率=100, 转速环控制器带宽=15, 转速环控制器m=4, 电流环控制器带宽=300, 电流环控制器m=1, 磁链观测器带宽=10, 磁链观测器m=10, 锁相环带宽=150, 锁相环m=2, 惯量=300, PWM 最大占空比=900, PWM七段式切五段式阈值=700, 功率限幅值=6500, 功率Error=500, 功率限幅Kp=20, 功率限幅Ki=3000";
|
|
|
+ string DebugDefaultInfo = "";
|
|
|
+
|
|
|
+ //获取调试信息
|
|
|
+ if (richTextBox_DebugParam.Text == string.Empty)
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("请先读取调试信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DebugDefaultInfo = richTextBox_DebugParam.Text;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取参数
|
|
|
string[] strDataTemp = DebugDefaultInfo.Split(new string[] { ", " }, StringSplitOptions.None);
|
|
|
+ if (strDataTemp.Length != 25)
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("数据格式不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
var ConfigParam = new byte[60];
|
|
|
for (int i = 0; i < 60; i++)
|
|
@@ -3381,18 +3431,10 @@ namespace Welling_Motor_Debug_Tool
|
|
|
|
|
|
if (!MotorRunStatus) //停止状态
|
|
|
{
|
|
|
- //设置电机系列
|
|
|
- if (radioButton_FacModeDriverCity.Checked == true)
|
|
|
+ //设置速度环
|
|
|
+ if (radioButton_FacModeDriverCity.Checked | radioButton_FacModeDriverMtb.Checked | radioButton_FacModeDriverLG.Checked == true)
|
|
|
{
|
|
|
strDataTemp[0] = "整体运行模式=3";
|
|
|
- strDataTemp[3] = "旋转方向=1";
|
|
|
- strDataTemp[18] = "惯量=300";
|
|
|
- }
|
|
|
- else if (radioButton_FacModeDriverMtb.Checked == true)
|
|
|
- {
|
|
|
- strDataTemp[0] = "整体运行模式=3";
|
|
|
- strDataTemp[3] = "旋转方向=0";
|
|
|
- strDataTemp[18] = "惯量=500";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -3408,7 +3450,7 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
else if (label_Load.Text == "带载")
|
|
|
{
|
|
|
- strDataTemp[10] = "转速环控制器带宽=10";
|
|
|
+ strDataTemp[10] = "转速环控制器带宽=5";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -3420,7 +3462,17 @@ namespace Welling_Motor_Debug_Tool
|
|
|
//选择位置模式
|
|
|
if (label_MotorSensor.Text == "有感")
|
|
|
{
|
|
|
- strDataTemp[1] = "位置获取模式=1";
|
|
|
+ if (radioButton_FacModeDriverCity.Checked | radioButton_FacModeDriverMtb.Checked == true)
|
|
|
+ strDataTemp[1] = "位置获取模式=1";
|
|
|
+ else if (radioButton_FacModeDriverLG.Checked == true)
|
|
|
+ strDataTemp[1] = "位置获取模式=2";
|
|
|
+ else
|
|
|
+ {
|
|
|
+ timer_1s.Enabled = false;
|
|
|
+ MessageBox.Show("请选择电机类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ timer_1s.Enabled = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
else if (label_MotorSensor.Text == "无感")
|
|
|
{
|
|
@@ -3466,22 +3518,24 @@ namespace Welling_Motor_Debug_Tool
|
|
|
}
|
|
|
else //运转状态
|
|
|
{
|
|
|
- //设置电机调试参数
|
|
|
+ //还原为原始值
|
|
|
if (radioButton_FacModeDriverCity.Checked == true)
|
|
|
{
|
|
|
strDataTemp[0] = "整体运行模式=4";
|
|
|
strDataTemp[1] = "位置获取模式=1";
|
|
|
- strDataTemp[3] = "旋转方向=1";
|
|
|
- strDataTemp[10] = "转速环控制器带宽=15";
|
|
|
- strDataTemp[18] = "惯量=300";
|
|
|
+ strDataTemp[10] = "转速环控制器带宽=5";
|
|
|
}
|
|
|
else if (radioButton_FacModeDriverMtb.Checked == true)
|
|
|
{
|
|
|
strDataTemp[0] = "整体运行模式=5";
|
|
|
strDataTemp[1] = "位置获取模式=1";
|
|
|
- strDataTemp[3] = "旋转方向=0";
|
|
|
- strDataTemp[10] = "转速环控制器带宽=15";
|
|
|
- strDataTemp[18] = "惯量=500";
|
|
|
+ strDataTemp[10] = "转速环控制器带宽=5";
|
|
|
+ }
|
|
|
+ else if (radioButton_FacModeDriverLG.Checked == true)
|
|
|
+ {
|
|
|
+ strDataTemp[0] = "整体运行模式=6";
|
|
|
+ strDataTemp[1] = "位置获取模式=2";
|
|
|
+ strDataTemp[10] = "转速环控制器带宽=5";
|
|
|
}
|
|
|
else
|
|
|
{
|