C#移动伺服电机问题 [英] c# moving servo motors problem

查看:149
本文介绍了C#移动伺服电机问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..
我正在尝试移动平移和倾斜系统,并使用VS2008c#这样做,当我的程序找到一个目标并使其刷新并将新的当前点发送到要移动的电动机时..但是它结结巴巴,运行平稳! !
此外,当我将on_click事件设置为移动到我单击的事件时,也会遇到相同的问题.

关于如何解决此问题的任何想法?
我应该在电机运动中使用新的螺纹吗?


谢谢

Dutchbear

Hey all..
I’m trying to move a pan and tilt system and using VS2008c# to do so, when my program find a target and it enabled it refresh and sends the new current point to the motors to move.. but it stutterer and run smoothly!!
moreover on_click Event when i set it to move to what i click it dose the same problem.

any idea on how to overcome this problem?
should i use a new thread for the motor movement?


thanks

Dutchbear

推荐答案

实际上,我曾经使用过它,即在.NET紧凑框架中控制数码相机中镜头聚焦的步进电机.

我想您可以启动一个新线程来处理电机,但是我对使用托管代码来操纵现实世界的对象非常持怀疑态度.您永远不知道该垃圾收集器何时启动并且您的应用程序冻结.我不知道您在用它做什么,但是如果您正在为玩具机器人编写马达控件,那么这种口吃行为可能还可以.如果您要控制武器系统的车辆或目标平台,这是个坏主意(但是无论如何您都不会在.NET中做到这一点).

您可能不想听这句话,但是我的建议是用c ++编写一个访问马达的.dll,然后通过p/invoke调用该c ++ DLL.

瑞安(Ryan)
I actually have worked with that before, namely in controlling the stepper motors for lens focus in a digital camera, although it was in the .NET compact framework.

I suppose you could start a new thread to take care of the motor, but I am very leery about using managed code to manipulate real-world objects. You never know when that garbage collector is going to kick in and your application freezes. I don''t know what you are using this for, but if you are writing a motor control for a toy robot, this stuttering behavior is probably okay. If you are controlling a vehicle or targeting platform for a weapons system, this is a bad idea (but you wouldn''t be doing it in .NET anyway).

You probably don''t want to hear this, but my suggestion would be to write a .dll in c++ that accesses the motor, and then call that c++ DLL through p/invoke.

Ryan


liorogi写道:
liorogi wrote:

我应该为电机运动使用新的螺纹吗?

should i use a new thread for the motor movement?



您的意思是您实际上还没有尝试过吗?我们大多数人都没有使用这种控制器的经验,因此我们无法发表评论.



You mean you haven''t actually tried that yet? Most of us have no experience with this kind of controller stuff, so we can''t comment.


这篇关于C#移动伺服电机问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆