运控控制(四)代码和接线
public partial class Form1 : Form { ushort NrStations = 1; ushort[] StationCode = { 0, 1, 2, 3, 4, 5, 6 ,7}; ushort[] StationType = { 2, 0, 0, 0, 0, 0, 0, 0 }; int Ret = -1; public Form1() { InitializeComponent(); } private void OpenCard_Click(object sender, EventArgs e) { Ret = CMCDLL_NET.MCF_Open_Net(NrStations, ref StationCode[0], ref StationType[0]); if (Ret == 0) MessageBox.Show("Open OK"); else MessageBox.Show("Open Failed"+Ret); } private void timer1_Tick(object sender, EventArgs e) { ushort logic = 0; CMCDLL_NET.MCF_Get_Input_Bit_Net(13, ref logic); if (logic == 0) this.IsOn.Checked = true; else this.IsOn.Checked = false; } private bool State = false; private void SetLight_Click(object sender, EventArgs e) { if(State==false) { CMCDLL_NET.MCF_Set_Output_Bit_Net(4, 0); State = true; }else { CMCDLL_NET.MCF_Set_Output_Bit_Net(4, 1); State = false; } } double Vel = 10000; double Acc = 100000; double Jerk = 1000000; private void AxisPositive_Click(object sender, EventArgs e) { CMCDLL_NET.MCF_JOG_Net(0, Vel, Jerk); } private void AxisNegative_Click(object sender, EventArgs e) { CMCDLL_NET.MCF_JOG_Net(0, -Vel, Jerk); } private void EmgStop_Click(object sender, EventArgs e) { CMCDLL_NET.MCF_Axis_Stop_Net(0, 0);//0,紧急 1缓慢停止 } private void StartHome_Click(object sender, EventArgs e) { CMCDLL_NET.MCF_Search_Home_Stop_Time_Net(0, 0); CMCDLL_NET.MCF_Search_Home_Set_Net(0, 30, 0, 0, 0, 10000, 3000, 0, 0); CMCDLL_NET.MCF_Search_Home_Start_Net(0); } private void MoveAbs_Click(object sender, EventArgs e) { CMCDLL_NET.MCF_Set_Axis_Profile_Net(0, 0, Vel, Acc, Jerk, Acc, 0); CMCDLL_NET.MCF_Uniaxial_Net(0, int.Parse(Dist.Text), 0);//0 绝对,1相对 } }
接线:
输入:这里是开关: DI点接开关一端,开关另外一端接地。
输出:DO点接灯的一端,灯的另外一端接24V。
三个传感器:棕色,蓝色接24V和地, 三根黑线分别接正负极限,原点。
控制卡上的5V,分别接到步进驱动器 脉冲和方向的正极,
脉冲和方向的负极接到控制卡 脉冲和方向的负极。
利用Z相回零
编码器的Z信号通常是一个单独的脉冲信号,它在每个编码器轴上的一周中只发生一次脉冲。Z信号的作用是标记轴的旋转周期,也称为“Z相位”或“零位信号”
参考
https://zhidao.baidu.com/question/379483236.html