LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

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

hello,guys
 
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 Unlimited.vi in deep, I found that SendDirectCommand.vi 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
(17,724 Views)
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,
Brady
0 Kudos
Message 2 of 23
(17,707 Views)

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
(17,699 Views)

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

 

/Magnus

0 Kudos
Message 4 of 23
(17,492 Views)
Hi, Yes I did today..
 
Here it is..
 
Saludos
 
Gustavo
0 Kudos
Message 5 of 23
(17,492 Views)

Hi Thanks for your fast help.

 

/Magnus

0 Kudos
Message 6 of 23
(17,488 Views)
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?)

Thanks...

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

0 Kudos
Message 7 of 23
(17,309 Views)
I tried the distancia.vi 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 distancia.vi is not a solution to run the motor for a given number of roations or degrees. 
 
0 Kudos
Message 8 of 23
(17,158 Views)
Hi
 
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
(17,153 Views)

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
(17,144 Views)