LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

How to NOT reset motor position everytime it loads

Solved!
Go to 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 Kudos
Message 1 of 5
(7,816 Views)

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 of 5
(7,796 Views)

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 Kudos
Message 3 of 5
(7,794 Views)
Solution
Accepted by topic author 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 Kudos
Message 4 of 5
(7,783 Views)

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

0 Kudos
Message 5 of 5
(7,777 Views)