LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

Absolute position NXT motor

Hello,

 

Is it possible to send the NXT motor to an absolute position? I want the motor to act as a servo so that i can use it to steer an rc car.

 

 

 

0 Kudos
Message 1 of 8
(14,856 Views)

Hello Birrel,

 

There is only relative position sensor on NXT motor. So, you have to first set a reference position if you want to use absolute positioning.

 

You have two possibilities to set the reference position:
- either you fix the reference position as the starting position (which is not the most convenient solution)
- or, if your motor can move within a given mechanical range with a min and a max position (as it is the case for steering purpose), you can find those limits at the begining of your program and then decide to fix a reference position somewhere in that range (probably in the middle in your case).
You can easily find the mechanical limits by running the motor and monitoring the position. If the position does not change in a (small) amount of time, you have reached a limit.

Cédric | NI Belgium
0 Kudos
Message 2 of 8
(14,843 Views)

Hello,

 

Thank you for your answer. I had figured out something like that, but have some troubles to program it. I am totally new in Labview and NXT and rely on existing programs. Do you know if there is an example somewhere. I have found the PI controller and do only have to program the limits.

 

Kind regards,

 

Frank.

0 Kudos
Message 3 of 8
(14,836 Views)

Hello Frank,

 

As I told you, you can easily find the limits by running the motor and checking when the position is not evolving anymore. Once that happens, it means that you have found one limit. Then you can do the same in reverse direction to find the other one.

 

Here is a simple example I quickly did to find one limit:

sr_1156910.jpg 

Disclaimer: The example Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense

 

 

From there, you should be able to find the other limit and compute the center.

 

Does this reply to your need? 

Cédric | NI Belgium
0 Kudos
Message 4 of 8
(14,826 Views)

Hello,

 

Thank you, this is what I was looking for. Can you also tell me a way (probably a shift register) to store the value cause I also have to do a move the other way to determine the middle of the steering unit. Can this also been done by using sequential programming (the filmstrip)? I am normally a plc programmer so Labview programming is totally new for me and I have to use examples.

 

Kind regards,

 

Frank.

0 Kudos
Message 5 of 8
(14,819 Views)

Hello Frank,

 

The limit is already stored in a shift register! You can simply copy the example above a second time and you will have two shift registers with your two limits (but don't forget to change the motor direction and to remove the second "Reset Rotation" node).

Cédric | NI Belgium
0 Kudos
Message 6 of 8
(14,816 Views)

Hello cedhoc and everyone,

 

Another noob question..

 

I understand your code but how make it run once in LabView ( Similar to setup loop in text programming). I want to reference the motor once, in the begining, and then just use absolute position.

 

Thanks in advance!

0 Kudos
Message 7 of 8
(10,724 Views)

There is a Fixed Distance VI in the Advanced Motors palette that will allow you to specify a relative or absolute value in encoder counts to move the motors.

0 Kudos
Message 8 of 8
(10,655 Views)