向项目中添加独立的电机

一旦你设置好了控制车轮的驱动器,您可能需要添加一个额外的电动机来控制独立于车轮的部件,例如机械臂。由于此马达不会成为坦克,拱形轮或麦克纳姆轮发动机的一部分,因此您绝对希望对其进行独立控制。

这些VI片段展示了如何在可能已经包含多个电机的项目中设置单个电机。如果看到HAND> ARROW> LABVIEW符号,只需将图像拖到框图中,瞧,代码!好的,操作方法如下。

FIRST, create a motor reference in the Begin.vi, using the Motor Control Open VI and Motor Control Refnum Registry Set VI. These can be found by right-clicking in the block diagram and going to WPI Robotics Library>>RobotDrive>>Motor Control. Choose your PWM line and name your motor. I named mine “Lift Motor” and connected it to PWM 7. (I also included and enabled the Motor Control Safety Config VI, which automatically turns off the motor if it loses connection.)

../../../../_images/1.png

现在,使用“Motor Control Refnum Registry Get” VI在Teleop.vi中引用您的电机(名称必须准确),并告诉它用Motor Control Set Output VI做什么。它们与上述VI位于同一位置。

../../../../_images/2.png

例如,如果按下操纵杆0上的按钮4,则下一个代码片段指示提升马达向前移动,否则保持不动。对我而言,按钮4是Xbox样式控制器(“游戏杆0”)上的左bumper。有关更深入的操纵杆按钮选项的信息,请查看 如何使用操纵杆按钮控制电机或电磁阀.

../../../../_images/3.png

最后,我们需要使用“Motor Control Refnum Registry Get” VI和“Motor Control Close” VI关闭Finish.vi中的引用(就像对驱动器和操纵杆一样)。该图在一个平面序列结构内单独显示了Close VI,但我们确实希望所有Close VI都在同一帧中。您可以将这两个VI放置在其他Get VI和Close VI下方(用于操纵杆和驱动器)。

../../../../_images/4.png

希望这可以帮助您编写最好的机器程序!祝你好运!