//將軸參寫入M2X4 slave private void setMotion() { U16 hMode; //初始化給1 且限制在 1~3,這邊又把home mode變成12 or 9 if (axisPara.HomeMode == HomeMode.TwoPoint) { hMode = 12; } else { hMode = 9; } initErr = CCMNet.CS_mnet_m204_set_alm(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, Convert.ToUInt16(axisPara.LogicALM), 0); if (axisPara.MotorMode == MotorMode.Servo) { initErr = CCMNet.CS_mnet_m204_set_inp(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 1, Convert.ToUInt16(axisPara.LogicINP)); } else { initErr = CCMNet.CS_mnet_m204_set_inp(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 0, Convert.ToUInt16(axisPara.LogicINP)); } initErr = CCMNet.CS_mnet_m204_set_erc_on(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 0); initErr = CCMNet.CS_mnet_m204_set_erc(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, Convert.ToUInt16(axisPara.LogicERC), 0, 0); initErr = CCMNet.CS_mnet_m204_set_home_config(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, hMode, Convert.ToUInt16(axisPara.LogicORG), Convert.ToUInt16(axisPara.LogicZ), 0, 0); initErr = CCMNet.CS_mnet_m204_set_sd(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 0, Convert.ToInt16(axisPara.LogicSD), 0, 0); initErr = CCMNet.CS_mnet_m204_set_ltc_logic(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, Convert.ToUInt16(axisPara.LogicLTC)); initErr = CCMNet.CS_mnet_m204_set_pls_outmode(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, (U16)axisPara.PulseMode); initErr = CCMNet.CS_mnet_m204_set_pls_iptmode(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, (U16)axisPara.EncMode, (U16)axisPara.EncDir); if (axisPara.MotorMode == MotorMode.Servo) { //initErr = CCMNet.CS_mnet_m204_set_feedback_src(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 3); initErr = CCMNet.CS_mnet_m204_set_feedback_src(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 0); } else { initErr = CCMNet.CS_mnet_m204_set_feedback_src(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 2); } //0:External Feedback, Position Counter //1:Command Pulse, Position Counter //2:Command Pulse, Command Pulse //3:External Feedback, Command Pulse initErr = CCMNet.CS_mnet_m204_set_el(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 0, Convert.ToInt16(axisPara.LogicEL)); initErr = CCMNet.CS_mnet_m204_fix_speed_range(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, MmToPulse(axisPara.MaxVel)); }