LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

Showing results for 
Search instead for 
Did you mean: 

How to control NXT motor's rotation by using LabView NXT Direct Commands?

I want to use labview NXT Direct Commands to control my NXT .
I connected PC and NXT through USB successfully, and also got the response form Sound Sensor.
The sound level is used to specify the rotational distance of NXT motor  in DEGREES, however I found that 'NXT Direct Commands >output>motor unlimited' can not accept a Degree input parameter.
I try to modify these subVIs, add Degree and Break(?) parameters. It seem that Degree parameter can be defind (also worked),but it worked in a incorrect way.
I read LabVIEW_for_NXT_Advanced_Programming_Guide, and try to add UpdataFlags for that VI. After analysis Motor in deep, I found that can't be open,it's locked! So I have no idea about the structure of "Output Port Info".
Can anybody help?
0 Kudos
Message 1 of 23
If you look inside the "Motor Unlimited" direct command VI (which it sounds like you have), you'll see the big cluster of constants that is the Output Port info. The TachoLimit parameter is the one that you'll want to change. It specifies how far, in degrees, the motor should turn. The motor will run forever if the TachoLimit is 0.
I suggest you copy the guts of the Motor Unlimited VI into a new VI and add the distance parameter. Note that this will VI will just send the command to start the motors and return. It will not wait for the distance to compelete (much like the Motor block with "Wait for Completion" unchecked in NXT-G).
Hope this helps,
0 Kudos
Message 2 of 23

Thanks Brady,

I used the same method like you suggested before I post this question.

The Degree parameter can affect the motor rotation,but it worked indefinitely. I mean,for example,I set the value of Degree to 360,but the motor sometimes rotated more than 360 ,sometime less than 360.

I also added Break/Coast parameters to figure out the rotation problems

When I read "LabVIEW_for_NXT_Advanced_Programming_Guide",I found that UpdataFlags parameter must be added, but you can not find this parameter in the Output Port info cluster. And it seems very difficult to modify this cluster.

0 Kudos
Message 3 of 23

Hi I´m trying to solve this problem also. Does anyone has the solution for "Motordistance"  in direct command?



0 Kudos
Message 4 of 23
Hi, Yes I did today..
Here it is..
0 Kudos
Message 5 of 23

Hi Thanks for your fast help.



0 Kudos
Message 6 of 23
I'm running your Distancia code in LabVIEW 7.1.  It does not count rotations.  Is 7.1 the problem?  (As opposed to 8.x?)


Message Edited by mtrigoboff on 03-07-2007 04:54 PM

0 Kudos
Message 7 of 23
I tried the using 7.1.1. The motor movement does not correspond to actual no. of rotations entered as 'y'. When I entered y=360 the motor axle turned one rotation. So it appears to be acting like turning in degrees. This is so even when I change the motor power from 100 to 50. But for larger numbers entered the rotation is inconsistent. So it is not like in NXT-G where 1 rotation means one rotation of the motor axle.
And if I change from RotationCount to TachoLimit which is suppose to turn the motor by degrees, the motor runs forever.
So the is not a solution to run the motor for a given number of roations or degrees. 
0 Kudos
Message 8 of 23
I have made a .vi with which one can control the rotation by degrees in direct mode. It is made with LabVIEW 8.20 so I include a picture of it so that you can build it by your self in LabVIEW version 7.1.1. You need to put the .vi inside a loop and then you stop the loop when the output (motorspeed) is zero. Depending on the application you migth need to change the controlvariables.
If you have a newer version of LabVIEW (8.0) I can send you the complete .vi.
Good luck.
0 Kudos
Message 9 of 23

Thanks! Interesting approach using PID control. Where did you find the PID vi?

But I'm puzzled that the set point is in degrees but the input is RotationCount. I thought it should be TachoLimit according to the Toolkit Programming Guide?



0 Kudos
Message 10 of 23