LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 

How to NOT reset motor position everytime it loads

Résolu !
Accéder à la solution

I am trying to every time I run the NXT program always go to a very specific position.  Problem is, everytime I run the program it automatically resets the position.  Is there a way to turn off reset of position?  Newer to programming with NXT and LabView so looking for basic solution.  I even tried using the PI position example provided by NI, and took at the RESET sub.VI and it STILL always resets the motor position read.  Anyone have a sample program to build off of.  Cannot figure this one out as it makes no sense it resets without having the RESET sub.vi.  Thanks,

Jason

0 Compliments
Message 1 sur 5
8 249 Visites

Hi Jason,

 

I'm a little unclear about what exactly you're trying to accomplish. What position is being reset every time? Are you're telling the robot to go forward for 2 seconds at 100%, but it doesn't remember that command at run-time?

 

If you're manually running a second VI, you may need to incorporate that code into the first VI in order to maintain position state.

 

All the best,

Fred Visser -- SystemLink R&D -- National Instruments
Message 2 sur 5
8 229 Visites

Fred,

 

Sorry I wasn't clear.  I am using the motor for rotation.  When I read position, regardless of where the motor stopped, the next time the program runs, it sets the position read to zero (resets the memory).  What I'm trying to do is, everytime the program runs, to go always to the exact same spot.  For example, I always want to go to position 180 at the start - the motor happens to be at 110 when the prior routine finished, so I want to move it to the "original" 180 the next time I run it......what happens is, instead of telling me the motor is now at 110, it resets to zero (when I run the program again) and then moves 180 off of that new resetted zero (versus the 70 it needed to move).  Basically I want to read raw position codes and not have the motor/NXT position memory reset.  Hope this helped clarify.

 

Thanks,

Jason

0 Compliments
Message 3 sur 5
8 227 Visites
Solution
Accepté par l'auteur du sujet JasonC1017

Hi Jason,

 

The NXT uses a relative encoder (as opposed to absolute), so when you run the program again, it has no memory of the previous value. If you need to maintain the position state, you'll need to record that information to flash memory using the File I/O VIs. The other option is to modify your program so that instead of calling your program manually twice, you put your code into a while loop, and wait for a button press before running the second iteration of your code.

The position value will still be in memory, and you can increment that value on the second iteration.

 

Hope this helps,

Fred Visser -- SystemLink R&D -- National Instruments
0 Compliments
Message 4 sur 5
8 216 Visites

Thank you!  That advise helped and I got it working!!!!!!!

0 Compliments
Message 5 sur 5
8 210 Visites