pass variable to MVP command

pass variable to MVP command

Postby shorton » 18 Mar 2008, 00:50

I have some code that does a one time find and store for a target positional value in a user variable (bank 2 eeprom). Once set, it does nto change or get rewritten, so no harm to the eeprom.

When my regular code runs I need to be able to read this value and execute a move to it.

I can't find a way to get an accumulator value into a MVP or coordinate move command, only constants.

I need a:
MVP ACU, 0
command (Move to accumulator value). Or equivilant.

Is there a way to read a value from memory and them move to that absolute position, using the same motion profile the MVP would generate/obey?

I tried setting "target position" access param, but that didn't work out. Perhaps there is a complete solution using that method, but I don't see it. Or an alternate method??

Help!

Thanks,
Scott
shorton
Power User
Power User
 
Posts: 79
Joined: 10 Oct 2006, 18:20

Postby shorton » 18 Mar 2008, 01:18

It appears this will work. Is there another (better) way?

Code: Select all
CSUB SAVE_POSITION          // save actual motor position

GGP  11, 2      // lookup move distance from var 11, put in accum

AAP 1, 0                // temporarily set actual position register to accu
CCO 0, 0                // set coordinate 0 (RAM only) tricked into thinking motor is somewhere else.

CSUB RESTORE_POSITION        // fix register back with actual location

MVP COORD, 4, 0         // move to the variable value, now stored as coordinate 0


//*************************************************************************************
SAVE_POSITION:
//store actual position in user variable 15
GAP 1, 0     // actual motor position
AGP 15, 2    // store in var 15
RSUB

//*************************************************************************************
RESTORE_POSITION:
//restore actual position back to AP 1 register
GGP 15, 2
AAP 1, 0

RSUB

shorton
Power User
Power User
 
Posts: 79
Joined: 10 Oct 2006, 18:20

Postby Olav Kahlbaum (TRINAMIC) » 18 Mar 2008, 09:06

Yes, setting the "target position" is the right way. Before doing that, do a MVP REL 0, 0 command to ensure that the motor is in positioning mode and not in velocity mode:

Code: Select all
MVP REL, 0, 0  //ensure that motor is in positioning mode
GGP 11, 2      //Take position from variable
AAP 0, 0       //Copy it to the target position
User avatar
Olav Kahlbaum (TRINAMIC)
Site Admin
 
Posts: 3416
Joined: 11 Aug 2006, 08:02

Postby shorton » 18 Mar 2008, 13:37

Got it, thanks Olav. Much appreciated.
shorton
Power User
Power User
 
Posts: 79
Joined: 10 Oct 2006, 18:20


Return to Trinamic Motion Control Language (TMCL)

Who is online

Users browsing this forum: No registered users and 1 guest