为什么该程序在针对计算机而不是 NXT 时可以在 LabView 中运行?

发布于 2024-12-19 23:29:01 字数 579 浏览 1 评论 0原文

我有一个用 Labview 为我的 LEGO Mindstorms NXT 2.0 编写的程序。当目标设置为计算机时,程序运行得很好。但是,当我将目标设置为 NXT 时,程序的运行方式与设置为计算机时的运行方式不同。

该程序使机器人前进,直到距离物体 30 厘米,NXT 的超声波传感器检测到该物体。然后机器人就会停下来。如果物体移动并且NXT超声波传感器30厘米范围内没有物体,机器人将再次前进,直到再次距离物体30厘米。然后,它就会停止。

当目标在 Labview 中设置为计算机时,此功能有效,但在设置为 NXT 时则无效。当设置为NXT时,一旦检测到第一个物体,它将停止。但是,如果物体被移除并且超声波传感器的30厘米范围内不再有任何物体,机器人将保持静止并且不会向前移动。

这是框图的屏幕截图: 框图

这里是该程序源代码的链接。

任何帮助将不胜感激。

I have a program written in Labview for my LEGO Mindstorms NXT 2.0. When the target is set to the computer, the program works just fine. However, when I set the target to the NXT, the program doesn't work the same as when targeted to the computer.

The program makes the robot go forward until it is 30 centimetres away from an object, which is detected by the NXT's ultrasonic sensor. Then the robot will stop. If the object is moved and there is no object within 30 centimeters of the NXT's ultrasonic sensor, the robot will go forward again until it is 30 centimeters away from an object again. Then, it will stop.

This works when the target is set to computer in Labview, but not when set to NXT. When set to NXT, once the first object is detected, it will stop. But, if the object is removed and there is no longer any object within 30 centimetres of the ultrasonic sensor, the robot will remain stationary and not move forward.

Here is a screenshot of the block diagram:
block diagram

Here is a link to the source code for the program.

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

追风人 2024-12-26 23:29:02

我对NXT的经验非常有限,但我建议您使用字符串VI在NXT的屏幕上显示一些调试数据(例如i,距离等)。这将使您能够确定程序所在的位置,并可能帮助您找到问题。

顺便说一句,在 LV 中,通常不建议使用没有控制其执行速率的循环。对于在 NXT 上运行的代码来说,这可能有所不同,但我仍然建议在循环中添加一个简单的等待。

My experience with NXT is very limited, but I would suggest that you use the string VIs to display some debug data on the NXT's screen (such as i, the distance, etc.). This will allow you to determine where the program is and might help you find the problem.

As a side point, in LV it is generally not recommended to have a loop which doesn't have something controlling its rate of execution. This might be different for code running on the NXT, but I would still suggest adding a simple wait to the loop.

揽月 2024-12-26 23:29:02

我在您的代码中没有看到错误,但是在部署到 NXT 目标时我会做的是使循环无限(将 Stop 替换为 False 常量)并删除波形图。 NXT 不需要它们。

I don't see a mistake in your code, but what I would do when deploying to NXT target is I would make the loop infinite ( replace Stop with a False constant) and delete the waveform chart. You don't need them at NXT.

半城柳色半声笛 2024-12-26 23:29:02

我通过添加 200 毫秒的等待块来减慢 NXT 的速度来修复此问题。这很有效,看起来砖头有点超前了。

I fixed this by adding a 200ms wait block to slow the NXT down. This worked, it seemed that the brick was getting ahead of itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文