您现在所在的是:

三菱Mitsubishi

回帖:14个,阅读:7632 [上一页] [1] [2] [下一页]
50
910719004
文章数:1
年度积分:50
历史总积分:50
注册时间:2021/8/12
发站内信
发表于:2021/8/12 10:21:42
#10楼
       如果用绝对位置,代码如下,主要是暂停的时候获取当前位置,如果还没达到目标位置,点击继续的时候重新执行移动到位置命令,相当于在线变位.本人专注工控上位机,运动控制以及机器视觉.代码是c#代码,电机函数换成自己的api即可.希望对你有帮助!
       static bool bPause = false;
       bool posCommandFinished = false;
       void StartMotosThreads()
       {

           Task task0 = Task.Factory.StartNew(()=> {
               while (true)
               {
                   if (!bPause)
                   {
                       if (!posCommandFinished)
                       {
                           posCommandFinished = false;
                           double targetPos = 5000000;
                           //-----------------------------------------------------------------
                           // Create a command value.
                           //-----------------------------------------------------------------
                           Motion.PosCommand posCommand = new Motion.PosCommand();
                           posCommand.Profile.Type = WMX3ApiCLR.ProfileType.SCurve;
                           posCommand.Axis = 0;
                           posCommand.Target = targetPos;
                           posCommand.Profile.Velocity = 100000;
                           posCommand.Profile.Acc = 1000000;
                           posCommand.Profile.Dec = 1000000;

                           //-----------------------------------------------------------------
                           // Execute command to move from current position to
                           // specified position.
                           //-----------------------------------------------------------------
                           //Wmx3Lib_cm.Motion.StartMov(posCommand);
                           Wmx3Lib_cm.Motion.StartPos(posCommand);

                           //-----------------------------------------------------------------
                           // Wait until the axis moves to the target position and stops.
                           //-----------------------------------------------------------------
                           Wmx3Lib_cm.Motion.Wait(0);

                           double currPos = 0;
                           Wmx3Lib_cm.AxisControl.GetPosFeedback(0, ref currPos);
                           if (currPos == targetPos)
                           {
                               posCommandFinished = true;
                           }
                           System.Threading.Thread.Sleep(2000);

                       }

                   }
               }

           });
}

private void button_PauseMotos_Click(object sender, EventArgs e)
       {
           if ("暂停" == button_PauseMotos.Text)
           {
               button_PauseMotos.Text = "恢复";
               bPause = true;
               Wmx3Lib_cm.Motion.Stop(0);
               Logger.Warning("电机暂停...");
           }
           else
           {
               button_PauseMotos.Text = "暂停";
               bPause = false;

               Logger.Warning("电机恢复...");
           }
       }
[此贴子已经被作者于2021/8/12 10:29:05编辑过]
11422
Tivian
文章数:2783
年度积分:904
历史总积分:11422
注册时间:2006/5/21
发站内信
发表于:2021/8/12 12:38:05
#11楼
永宏有暂停输出功能
此帖发自手机工控论坛
50
飞库
文章数:9
年度积分:50
历史总积分:50
注册时间:2020/8/15
发站内信
发表于:2021/10/6 15:08:28
#12楼
这样不就可以了
50
飞库
文章数:9
年度积分:50
历史总积分:50
注册时间:2020/8/15
发站内信
发表于:2021/10/6 15:09:32
#13楼
附件 1633504091(1).jpg
这样不就可以了
2737
黄昏放牛
文章数:202
年度积分:102
历史总积分:2737
注册时间:2011/6/23
发站内信
发表于:2021/10/7 21:14:38
#14楼
以下是引用飞库2021/10/6 15:09:32的发言:
附件 1633504091(1).jpg
这样不就可以了
如果是相对定位呢?

关于我们 | 联系我们 | 广告服务 | 本站动态 | 友情链接 | 法律声明 | 非法和不良信息举报

工控网客服热线:0755-86369299
版权所有 工控网 Copyright©2025 Gkong.com, All Rights Reserved

78.0005