Trinamic Discussion Groups Forum Index Trinamic Discussion Groups
For quick support, please browse or search the forum!
 
 FAQFAQ    Impressum   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

can I change speeds "on the fly" with absolute tar
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Trinamic Discussion Groups Forum Index -> Trinamic Motion Control Language (TMCL)
Print this topic :: View previous topic :: View next topic  
Author Message
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Sun Dec 17, 2006 6:15 pm    Post subject: can I change speeds "on the fly" with absolute tar Reply with quote

TMCM-110-42

Is there a way I can change speeds "on the fly" without stopping the motor, but still end up at a target position accurately and not have insatnd (max) acceleration?

It appears that with the MVP command I have to issue a MST before it will read a change in speed axis parameter.

If I use velocity mode, I don't seem to have control over how many steps I want at a particular speed.

So example I have to travel a distance of 30000. I would like to move at speed 100 for 0-2000, speed 500 for 2001-28000, and speed 100 for the last 28001-30000. Without stopping the motor, and with smooth accelleration ramps.

Can it be done in TMCL?

THanks, Scott
Back to top
View user's profile Send private message
Andrew
Master
Master


Joined: 06 Nov 2006
Posts: 258
Location: Europe

PostPosted: Sun Dec 17, 2006 9:44 pm    Post subject: Mix MVP and ROL commands, change speed on the fly Reply with quote

You can mix MVP and ROL/ROR commands as much as you like. You change the speed or target position via axis parameters.
After doing so, you can still give more MVP, or ROL/ROR, or set the target position via an axis parameter.

You can switch from position mode to speed mode on the fly too. You are perfectly able to change speed, and still have an accurate destination. Even if you miss destination, the module will go back to it.
You can also change the speed in position mode on the fly.

... Just try everything...

Position count (parameter #1) remains valid in any mode. So you are not lost.

In position mode speed is set by parameter #4 "maximum positioning speed".
It can be set on the fly. Speed ramp will apply, as set by #5 "maximum acceleration".

In speed mode speed is set by parameter #2 "target (next) speed". The ramp still applies, as set by #5 "maximum acceleration". Speed limit also applies as set by #4 "maximum positioning speed".
If you set target speed greater than the limit in parameter #4, only the limit will be reached. Target speed will remain only a target. So, when you increase the limit on-the-fly, the speed would go up automatically. But not past the target speed.

All these parameters can be changed on the fly.

See also:
http://www.trinamic.com/ttdg/viewtopic.php?t=53
It has more discussion about mixing commands in direct mode and standalone mode.
_________________
Distributor of Trinamic
Our TMCM-DLL is here (not free): http://www.trinamic.com/ttdg/viewtopic.php?t=30 | Power supplies: http://www.trinamic.com/ttdg/viewtopic.php?t=394
On request: System integration services, custom programming, mechanics,etc


Last edited by Andrew on Sat Nov 03, 2007 4:16 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Sun Dec 17, 2006 11:35 pm    Post subject: Reply with quote

I tried MVP ABS, 0, 100
then changed max pos speed, then
MVP ABS, 2000

But there is no speed change.

I cannot physically overshoot my destination.

Can you give me an example of how to move as in my example"

Code:
I would like to move at speed 100 for 0-2000, speed 500 for 2001-28000, and speed 100 for the last 28001-30000. Without stopping the motor, and with smooth accelleration ramps.


I couldn't get it to work.
Back to top
View user's profile Send private message
Andrew
Master
Master


Joined: 06 Nov 2006
Posts: 258
Location: Europe

PostPosted: Mon Dec 18, 2006 12:29 pm    Post subject: Speed must change on the fly, otherwise something is wrong Reply with quote

Speed must change on the fly, otherwise something is wrong.
Sometimes speed does not increase because acceleration is zero (you did not allow acceleration).

Speed also won't change while acceleration or deceleration already takes place. You would need to change the target speed for that in speed mode.

The case where you need not just alter the speeds, but to alter them at certain points is a more complicated.
MVP stops after any move.
But you wish not to stop.
As I wrote on the other theme to you, TMCM are very poor at setting the bottom speed. Perhaps this still could be done with builtin functionality, but I need to think more. I will report later.

Without using built in functionality, this could be done obviously by standalone programming in TMCL.

For example you may do polling. Once you arrive at destination, you change the speed.
But the precision of the moment of "speed change" depends on precision of polling.
Below I submit a sample program. It is based on a function WAIT. Internally in TMCM it still does polling, though at high resolution. I don't know what is the resolution of WAIT. Perhaps Trinamic should comment.

An interesting discussion on speed is here:
http://www.trinamic.com/ttdg/viewtopic.php?t=263

A discusssion more closely related to this topic is here:
http://www.trinamic.com/ttdg/viewtopic.php?t=106
It discusses the advantages of TMC chips (also of the modules based on the chips).
It describes the options for contiguous ramps without stop.
It is a bit technical, but it reveals the internals of TMC modules - the working of chips TMC428 and TMC246/249.
It displays an example of a ramp the sample program below might be used to produce. At each waypoint there would be a pause. The duration of a pause is a product of duration of a command (about 0.38ms) and the number of sommands that change speed on-the-fly.

Here is the sample program to change speed on the fly on arrival to target points without stopping.
It users target points as variables in bank #2. So that you can change them without changing the standalone program.
Keeping target points variable imposes a penalty of time to retrieve them from the bank. Extra commands - extra time.
You might save some time by sending the variables in direct mode, but then there's a delay of communication over the RS232, or other port.
Another way would be to store values for waypoints directly in TMCL program in EEPROM. But then every time you change them you would need to write to EEPROM, which would wear it out. Read here on the durability of EEPROM:
http://www.trinamic.com/ttdg/viewtopic.php?t=117
It also describes some details of using a Coorrdinates Array.
One more explanation there, is that command MVP in TMCM610 does not yet approximate for all axes to arrive at a waypoint simultaneously. It will be fixed in the future. In other modules MVP does arrive approximately simultaneously.

But the sample code below is for 1 axis anyway.

Speed of communication (for direct mode) and duration of a command is also discussed here:
http://www.trinamic.com/ttdg/viewtopic.php?t=53
It also contains some intricacies of mixing commands in direct mode and standalone mode... Should you mix this program with standalone operation.

GGP 12 2 0 //Get variable for Speed
AAP 4 0 0 //Put it in "v_max"
GAP 4 0 0 //See what controller has actually assumed for "v_max"
AAP 130 0 0 //Put it in also in "v_min", so deceleration won't occur
MVP 2 0 0 //Move to coordinate 0 (must be stored previously)
WAIT 1 0 0 //Wait for arrival

/*Motor has stopped temporarily and abruptly
Now we have to change the next target position and speed
Then we have to restart motion
If we are quick, nobody notices the pause*/

SAP 138 0 2 //Set ramp to Velocity Mode
GAP 1 0 0 //Get position
AGP 53 2 0 //Back it up at user bank #2 in variable #53
GGP 0 2 0 //Get the next target position from user bank #2
AAP 1 0 0 //Overwrite the current position (parameter #1)
CCO 0 0 0 /*Store it in coordinates array. We can put a variable to coordinates array only through axis parameter #1. Otherwise we could use UF1 to ask computer to upload a coordinade via SCO.
See UF1 (Active Communication) here:
http://www.trinamic.com/ttdg/viewtopic.php?t=480*/
GGP 53 2 0 //Get the backed current position
AAP 1 0 0 //Restore it
GAP 4 0 0 //Take the current v_max
AAP 3 0 0 //Put the v_max to actual speed. Motion restarts without a target, because we are still in velocity mode

/*The pause betwen stop and start: 0.38ms*10commands=3.8ms.
Motion now has restarted without any acceleration.
No deceleration either, because we are still in velocity mode
To avoid resetting "p" (see the BUG below) you can change the speed in position mode, without using "SAP 138 0 2" above. But then deceleration would ensue immediately*/

MVP 2 0 0 //Begin moving to a target a few lines above stored in CCO 0. Automatically switches to "position mode"

/*BUG: When switching from another mode to position mode, MVP recalculates variable "p" (pmul, and pdiv). This overwrites your custom values. Make sure you restore them before deceleration occurs.
If changing does not occur (e.g. not previously changed to speed mode), then these parameters remain unaltered.
Changing "p" during deceleration (on-the-fly) affects deceleration immediately. Perhaps TMC428 recalculates "p" at every step of deceleration, not just at the beginning of deceleration.*/

SAP 130 0 1 //This is the finish. Be quick to set v_min back to default 1. This command should be placed before MVP (and before AAP 3). But then the pause between motions is even greater
GGP 13 2 0 //Get next variabe for Speed
AAP 4 0 0 //Put it in v_max
STOP 0 0 0


Last edited by Andrew on Mon May 14, 2007 1:52 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Thu Feb 22, 2007 5:42 pm    Post subject: Reply with quote

Andrew:

I'm getting back to this and trying to follow some of your posts. You have a habit of referring to other threads (themes)> Then int eh other thread you refer back to several other threads including the one that you came from. This leads those of use trying to follow in circles <smile>. I understand you touch on the similar situations in the other threads, but they are not always 100% on topic to the particular question. At the least it's hard to follow when jumping in circles. I'm trying to tie some of them down.

Can you assist me in getting a handle on your post above, in this thread alone woudl be great Shocked Very Happy Very Happy .

Some of your last statements in the previous reply in this thread are confusing becasue they say they have to come before the other commands, but they do not. I'm sure I'm misunderstanding some point, but there it is.

Please, let's take my original example literally and work to do exactly that.
First, let assume this will be a static, standalone program, running in standalone
mode.

Edit: snipped original part of this post after this point. For clarity, see next post for replacement text and issues:


Last edited by shorton on Thu Feb 22, 2007 10:35 pm; edited 2 times in total
Back to top
View user's profile Send private message
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Thu Feb 22, 2007 10:28 pm    Post subject: Reply with quote

Andrew:

I'm continuing to try to disect your suggestion.

As I recall the original problem was that a pair of MVPs reguire a MST or the second will not work.

i.e.
Code:
SAP 4 0 500
MVP 0 0 100
SAP 4 0 500
MVP 0 0 2000

Did not result in a speed change

Your code works out to this simplified flow as I see it:

Code:
v_max= speed1
v_min= speed1 // this to prevent it from decellerating, apparently
move to coord 0
wait for arrival

/ code segment results in:
set velocity mode
coord 0 = next position
act_speed = v_max // starts move

move to coord 0
Stopping right here. There was no change in speed up to this point, thus the confusion. The second MVP which goes into position mode still uses v_max which has not changed from the first time it was set. No speed change, yet.

Also the TMCL reference says to never overwrite the actual speed <- whenever a manual say not to do something I worry about the consequenses.

But, assuming that's OK, trying to deal with your last code paragraph about putting the code in somewhere before MVP...

For a complere, three speed move, did you mean this flow:

Code:

For the example, Speed 1 2 and 3 are preset
position 1,2,3 preset

// first part of move at speed1---------------------
coord0 = position1
v_max= speed1
v_min= speed1 // this to prevent it from decellerating, apparently
move to coord 0
wait for arrival

// second part of move:------------------------

/ Andrews code segment results in:
set velocity mode
coord 0 = position2

v_max= speed2
act_speed = v_max // starts move
move to coord 2
wait for arrival


// third part of move--------------------

set velocity mode
coord 0 = position3

// put this here on the last speed change before stop
v_min = 1 / to allow reaching target properly

v_max= speed3
act_speed = v_max // starts move
move to coord 0
wait for arrival

stop



This difference as I see it is the setting of act_speed which they said not to do. For 3 fixed points and speeds using this logic it appears one could more simply do:

Code:
SAP 4 0 500      // v_max=500
SAP 130 0 500   // v_min=500
MVP 0 0 100      // move to 100
wait 1 0 0         // wait for arrival

sap 4 0 1000    // v_max= 1000
sap 130 0 500  // v_min =1000
sap 138 0 2      // set velocity mode
sap 3 0 1000    // set actual speed 1000
MVP 0 0 2000   // move to 2000

sap 4 0 100    // v_max= 100
sap 130 0 1  // v_min =1
sap 138 0 2      // set velocity mode
sap 3 0 1000    // set actual speed 1000
MVP 0 0 3000   // move to 3000

stop

Whether or not the manual override of actual speed is good or not I'm not sure. The manual clearly says it is read only. You propose to overwrite it implying that it is not read only.

Is actual speed Read only or not?

What are the consequenses of overriding if it is writable? May be asking for trouble.
Back to top
View user's profile Send private message
Andrew
Master
Master


Joined: 06 Nov 2006
Posts: 258
Location: Europe

PostPosted: Sat Feb 24, 2007 7:15 pm    Post subject: Changing speed on the fly. Analysis of code. Try speed mode Reply with quote

Well done Shorton!
Your last code is almost correct.
I am glad my lessons start bearing fruits.

As for the circular references. This is part of the learning process. I try to keep answers both general and specific. This requires lots of links. Obviously many problems may have the same solution. Or several solutions combined. I cannot afford repeating each solution separately.
Shorton wrote:
As I recall the original problem was that a pair of MVPs reguire a MST or the second will not work.

I am not sure what you mean.
The original problem was how to set the next speed after arrival at a waypoint. And how to avoid motor stop at the same time.
And how to ensure that speed change occurs exactly at a waypoint, without involving any complex polling by software.

I gave you a sample code. You need to examine it. Ask yourself questions why I do one or another thing. Make sure you understand it, and then change the order of some commands, or modify the code. - Improvise.

Changing the speed on the fly in "position mode".

Shorton wrote:
SAP 4 0 500
MVP 0 0 100
SAP 4 0 500
MVP 0 0 2000

Did not result in a speed change

Both speeds SAP 4 are the same. Hence no speed change.
Also note, that you did not wait for arrival. You set the next speed immediately after starting the first motion. The first motion had not yet time to complete. So effectively you assume the second speed for the first motion, instead of the second motion.

Shorton wrote:
wait for arrival

/ code segment results in:
set velocity mode
coord 0 = next position
act_speed = v_max // starts move

Not "starts move". I would say: v_max continues the previous move. It restores the previous speed, which has abruptly dropped to zero on arrival.
This goes slightly past the first target (waypoint). But as long as you issue the next MVP quickly enough, and as long as the next target is far enough, you are safe.
And even if you miss the target, the controller will return.
Shorton wrote:
move to coord 0
Stopping right here. There was no change in speed up to this point

That's the desired effect. Because I wanted to keep the previous speed to avoid abrupt acceleration.
Note in my code the commands coming after the second MVP. One of them sets the next v_max. That's when the speed starts to change towards the second speed.
You can put that command before MVP. But then the pause between motor stop and restart would be longer. Though, for a simplified code, which has less commands, it might be OK.
Shorton wrote:
the TMCL reference says to never overwrite the actual speed

In private conversations I already wrote you that TMC chips, TMC modules, and TMC manuals are designed formalistically in some respects.
In this case the designer simply saw no need for the user to change the actual speed. He deemed it nonsense.
Imagine you see a bicycle, and try to assert that its speed is 100km/h, instead of 30km/h. The bicycle continues to go at 30km/h regardless. That's why they wrote never to overwrite.

But the design of the chip TMC428 inside your module is such, that it easily assumes any arbitrary speed written to its registers by TMCL. Obviously the designers are torn between contradictions. On one hand they uphold your supposed "sanity". On the other hand they design the device in the only logical way possible.

This time we were lucky, and the designer did not put artificial restrictions on our ability to set the actual speed. Perhaps because it would cause the code to look less beautiful.
At other times they failed to provide the freedom.
Shorton wrote:
Is actual speed Read only or not?

In short: You can overwrite the actual speed safely. The TMC428 chip does this routinely internally.

The alternative is to use commands ROL and ROR. They switch to speed mode automatically. But they do not set the speed abruptly. Acceleration will still occur. Unless you turn it off, as in picture 1 in this article:
http://www.trinamic.com/ttdg/viewtopic.php?p=854#854
Shorton wrote:
putting the code in somewhere before MVP...

Yes - improvise.

Shorton wrote:
// second part of move:
[...]
v_max= speed2
act_speed = v_max // starts move
[...]

Here is an error. You need to set the actual speed to the previous v_max, or to whatever it was at the finish. ... Not to the next v_max.
I mentioned this above.
The same error in the third section of your algorithm.
The rest is correct.

Below I mark what needs to be changed in your actual code.
Shorton wrote:
For 3 fixed points and speeds [...]:

Code:
SAP 4 0 500 // v_max=500
SAP 130 0 500 // v_min=500
MVP 0 0 100 // move to 100
wait 1 0 0 // wait for arrival

sap 4 0 1000 // v_max= 1000
sap 130 0 500 // v_min =1000
sap 138 0 2 // set velocity mode
sap 3 0 500 // restore actual speed 500
MVP 0 0 2000 // move to 2000

sap 4 0 100 // v_max= 100
sap 130 0 1 // v_min =1
sap 138 0 2 // set velocity mode
sap 3 0 1000 // set actual speed 1000
MVP 0 0 3000 // move to 3000

stop

Note the underlined commands. Both times you intended to make an error. You intended to set the actual speed to the next v_max, instead of the previous. So I corrected the first instance for you. On the second instance you simply copied the code, but forgot to change the speed to 100, which produced actually a correct code. So no need for my intervention.

One thing to consider is that you may want to restore the actual speed as soon as you arrive at a waypoint. So put the command SAP 3 immediately after WAIT.
The effect of this is that the motor would rotate without a target longer.
See what is better for your application: longer pause, or longer targetless motion.

You may see some speed profiles in pictures 5 and 6 in this article:
http://www.trinamic.com/ttdg/viewtopic.php?p=854#854
Note the initial dip in speed. It occurs, when setting v_actual abruptly in position mode. When setting it in speed mode the dip does not occur, because there's no target, and hence no need to decelerate.

One more option.
You might set v_min to the next required v_max. A kind of inverse deceleration. This way, the new speed sould occur before the waypoint. Not after.

Keep in mind, that either with normal or inverse deceleration you might need to adjust a variable p, so that the final part of deceleration is not flat. See pictures 5 and 6 in this article:
http://www.trinamic.com/ttdg/viewtopic.php?p=854#854

Note: In one axis motion, you may prefer to use axis parameter #0 target position to the command MVP.
You can easily load any value from any bank to an axis parameter. While MVP deals with a coordinates array, which you cannot easily load in direct mode. There are commands SCO (load a fixed value), and CCO (capture current position - from axis parameter #1). But no command exists to load a coordinates array from accumulator or any axis parameter or data bank.
You can also use #0 target position instead of MVP in 3 axis motion (or other multiple axis motion), if you do not care about simultaneous arrival of all axes. MVP usually approximates ramps for target to be reached simultaneously.

Changing the speed on the fly in "velocity mode".

This is an alternative to position mode.
In speed mode there's no pause in motion. Motor always rotates, and follows the change in Value field of the command.
Commands ROR and ROL ignore v_max - miaximum speed, and respect a_max - maximum acceleration.

The Value can be both negative and positive. So the following two commands are equivalent:
ROR 0, 0, Value
ROL 0, 0, -Value

The shortcoming: you need to constantly poll the current position. This involves certain precision in time and space.
On the other hand. The WAIT command in position mode (discussed above) also performs polling. Though with a greater resolution.

A simple one axis motion would be like this:
ROR 0, 0, 500 // Set first speed. Move endlessly

GGP 0, 2, 0 // Get the target position from variable #0 in user data bank #2 into accumulator
CALCX 9, 0, 0 // load the target from accumulator to X-register

Watch for arrival:
GAP 1, 0, 0 // Get current position into accumulator
CALCX 1, 0, 0 // Subtract target from current position. X from accumulator.
COMP 0, 0, 0 // Compare the result with zero
JC 6, 0, Watch for arrival // If less than target, go to watch again

ROR 0, 0, 1000 // Set second speed. Move endlessly

GGP 1, 2, 0 // Get the target position from variable #1 in user data bank #2 into accumulator
CALCX 9, 0, 0 // load the target from accumulator to X-register

Watch for second arrival:
GAP 1, 0, 0 // Get current position into accumulator
CALCX 1, 0, 0 // Subtract target from current position. X from accumulator.
COMP 0, 0, 0 // Compare the result with zero (you can compare only with fixed values)
JC 6, 0, Watch for second arrival // If less than target, go to watch again

MVP 0, 0, Last position //Make the last move in position mode.

Note that MVP respects v_max - maximum speed. So you may want to set v_max to the last desired speed before the program starts.
ROR will ignore v_max. MVP will respect v_max.
One more difference of position mode from velocity mode: MVP command automatically tries to calculate ramps so that all motors arrive at the target simultaneously. In velocity mode you need to do this yourself, or forget about it. This of course is not a concern in single axis systems.

The "Watch for arrival" loop lasts 4 commands. Each command - about 0.38ms. In total - 1.52ms. This is the precision of detection.

The "Watch for arrival" loop can be implemented as a subroutine with CSUB and RSUB. But it costs about 0.38ms per command. This means extra 0.76ms. Total duration: 2.28ms.

Take into account 2 more commands, which preceed the loop. These are GGP and CALCX. They add a delay of 0.76ms to the detection.

You can shorten the "watch loop". By resetting the current position to the negative value of the target. Then the arrival will be indicated by a value of zero. This way you can compare the position to zero directly. You eliminate one command CALCX from the loop. This increases precision.
But you increase the delay, because you calculate the negative. And you lose the absolute position count... Especially that as the motor continues to rotate, the exact moment when you actually reset the position is unknown.

Note: The command WAIT POS still works in velocity mode. It detects positions at speeds up to about 977steps/second. This is a period of about 1ms. The sensitivity does not depend on global parameter #78 "poll interval".
You can use this command to replace the "watch loop".


Last edited by Andrew on Sat Mar 03, 2007 2:48 pm; edited 5 times in total
Back to top
View user's profile Send private message Visit poster's website
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Sun Feb 25, 2007 9:51 pm    Post subject: Reply with quote

Andrew: OK, thanks. Yes I didn't understand the point about restoring the previous speed due to the stop caused by positioning mode. Thanks for straightening me out on that, I understand now.

So now I have a 3 part move working. There were some waits missing above, here is a complete, functional, 3 part move, then a 3 part move back the other way:

Code:
SAP 1, 0, 0                 // reset home position to 0

                            //motion:
speed1=150
speed2=300
speed3=150

// positions:
//    start     1                   2      end
//      0     2000                10000   12000

start=0
waypoint1=2000
waypoint2=10000
end=12000

SAP 4,      0, speed1       // v_max = speed1
SAP 130,    0, speed1       // v_min = speed1
MVP 0,      0, waypoint1    // move to position1
WAIT POS,   0, 0            // WAIT for arrival

SAP 4,      0, speed2       // v_max = speed2 for next move
SAP 130,    0, speed2       // v_min = speed2 for next move
SAP 138,    0, 2            // set velocity mode
SAP 3,      0, speed1       // restore actual speed to speed1 because MVP above made it 0
MVP 0,      0, waypoint2    // move to position2
WAIT POS,   0, 0            // WAIT for arrival

SAP 4,      0, speed3       // v_max = speed3
SAP 130,    0, 1            // v_min = 1 / to allow decelleration
SAP 138,    0, 2            // set velocity mode
SAP 3,      0, speed2       // set actual speed to speed2 (from last move)
MVP 0,      0, end          // move to position3
WAIT POS,   0, 0            // WAIT for arrival

WAIT TICKS, 0, 200          // pause before move back
                            // now, back the other way:

SAP 4,      0, speed1       // v_max = speed1
SAP 130,    0, speed1       // v_min = speed1
MVP 0,      0, waypoint2    // move to position2
WAIT POS,   0, 0            // WAIT for arrival

SAP 4,      0, speed2       // v_max = speed2 for next move
SAP 130,    0, speed2       // v_min = speed2 for next move
SAP 138,    0, 2            // set velocity mode
SAP 3,      0, -speed1      // restore actual speed to speed1 becasue MVP made it 0
MVP 0,      0, waypoint1    // move to position1
WAIT POS,   0, 0            // WAIT for arrival

SAP 4,      0, speed3       // v_max= speed3
SAP 130,    0, 1            // v_min =1
SAP 138,    0, 2            // set velocity mode
SAP 3,      0, -speed2      // set actual speed to speed2 (since last mvp made it 0)
MVP 0,      0, start        // move to position0
WAIT POS,   0, 0            // WAIT for arrival

STOP


This first part where I move in one directions works fine. But when I tried to move back the other way, I figured out I had to set the "actual speed" to negative values. So it works in both directions now.

The next thing is to try turning off acceleration completely, then trying a sequential set of the above with several steps. I'm looking at trying to make a stepped acceleration curve where I can skip any resonant speeds entirely.
Back to top
View user's profile Send private message
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Mon Feb 26, 2007 1:02 am    Post subject: Reply with quote

Well, in implementing this I've found good and bad.

Good: I can set a minimum start speed. I've set it to some low value e.g:
10 of max 260 and I get a decent, quieter start with no/reduced growl, and no apparent accel curve.

Bad: If I try to use it for a full motion as in the example above, I get a very solid "bump" when it changes speeds. The transition from 0 back to the previous speed isn't happenign fast enought to prevent the bump. The "bump" can be felt and heard. That bump wont' be acceptable in my app. It isn't noticible at teh very low speed on ramp up, but it's clearly evident at a faster speed, even at low current Sad.


Last edited by shorton on Mon Feb 26, 2007 2:25 am; edited 1 time in total
Back to top
View user's profile Send private message
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Mon Feb 26, 2007 1:38 am    Post subject: Reply with quote

This is the code that produces a hard bump in them middle of teh motion:

Code:

SAP 140, 0, 4 //Microstep (requires resetting #153, #4, #5)
SAP 153, 0, 8 //"ramp_div" Remains as in your original setting
SAP 154, 0, 2 //"pulse_div" Shifts the reachable range of physical speeds
SAP 4, 0, 260 //Maximum speed matches your physical speed
SAP 5, 0, 170 //"a_max" matches your physical acceleration
SAP 5, 0, 500 //"a_max" matches your physical acceleration
//SAP 136,0,2 //default=2   accel threshold
//SAP 144,0,0 // default 0  max low current (0-8)
SAP 137, 0, 10 //Correct the "pdiv" manually
SAP 146, 0, 42 //Correct "pmul". "p" now matches your previous "p"

SAP 6, 0, 800 //Reduce the max current
SAP 203, 0, -1 //Relieve resonance further by permanent mixed decay

SAP 1, 0, 0           // reset home position

// tried this on and off
SAP 211, 0, 1       // fullstep at all speeds

LOOP1:

minspeed=130
speed1=10
speed2=260
speed3=200

start=0
end=25600
waypoint1=50
waypoint2=end-50
waypoint3=12000

SAP 4,      0, speed1       // v_max = speed1
SAP 130,    0, speed1       // v_min = speed1
MVP 0,      0, waypoint1    // move to position1
WAIT POS,   0, 0            // WAIT for arrival

SAP 3,      0, speed1       // restore actual speed to prev speed because MVP above made it 0
SAP 4,      0, speed2       // v_max = speed for next move
SAP 130,    0, speed2       // v_min = speed for next move
SAP 138,    0, 2            // set velocity mode
MVP 0,      0, waypoint3    // move to position at new speed
WAIT POS,   0, 0            // WAIT for arrival

//bumps here

// moved sap 3 to here to see if it would help, didn't make any difference
SAP 3,      0, speed2       // restore actual speed
SAP 4,      0, speed3       // v_max  for next move
SAP 130,    0, minspeed     // v_min  for next move
SAP 138,    0, 2            // set velocity mode
MVP 0,      0, end
WAIT POS,   0, 0            // WAIT for arrival

WAIT TICKS, 0, 100

SAP 4,      0, speed1       // v_max = speed1
SAP 130,    0, speed1       // v_min = speed1
MVP 0,      0, waypoint2    // move to position1
WAIT POS,   0, 0            // WAIT for arrival

SAP 4,      0, speed2       // v_max = speed2 for next move
SAP 130,    0, minspeed     // v_min = speed2 for next move
SAP 138,    0, 2            // set velocity mode
SAP 3,      0, -speed1      // restore actual speed to speed1 because MVP above made it 0
MVP 0,      0, start        // move to position2 at speed2
WAIT POS,   0, 0            // WAIT for arrival

WAIT TICKS, 0, 200

JA LOOP1

STOP


Se anything I'm doing wrong there to casue the "bump"?
Back to top
View user's profile Send private message
Olav Kahlbaum (TRINAMIC)
TRINAMIC master
TRINAMIC master


Joined: 11 Aug 2006
Posts: 950

PostPosted: Mon Feb 26, 2007 9:44 am    Post subject: Reply with quote

I see that you are setting the minimum speed (SAP 130) to the same value as the maximum speed (SAP 4). This causes something like a hard stop when the motor has reached the target position.
In your first move, your speed is low (speed1=10), but in your second move you are using a higher speed (speed2=260, so 26 times higher than speed1). I think that this causes the bump. Please try setting the minimum speed to a lower value in your second move.
Back to top
View user's profile Send private message
Andrew
Master
Master


Joined: 06 Nov 2006
Posts: 258
Location: Europe

PostPosted: Mon Feb 26, 2007 2:18 pm    Post subject: The finishing speed does not reach the top speed Reply with quote

There's no sense in setting a speed mode just before the position mode MVP. You need to move that command anywhere closer to the preceeding WAIT. It would eliminate the initial dip of speed, after setting the current speed abruptly.

This of course does not cure the particular bump you have.

I suspect the bump occurs not just after the second move. But after each move. Beause all moves are too short, all of them never reach v_max=260 and v_min=260, or even speed 10. Just you do not notice the bump after the first move.
You correctly set the first v_max and v_min to a lower value of 10. But even this speed might not be achieved on a short move of 50 steps. So it still might cause a bump. Just you do not notice, because the speed is slow.

Just as I noted to you in our previous discussions, including in other threads. The distance you are trying to move does not allow you to accelerate to the v_max. So you are wrong to assume that the finishing speed was v_max or v_min. There's no point in restoring that speed.
You need to learn what actual speed to restore.

If all distances are fixed, I suggest you simply detect the speed at which the finish occurs, and try to restore that fixed speed.

Instead of trying to determine the finishing speed by reading it in an experiment, you may simply try and set different speeds on the bumped move, and see when the bump disappears.

Also you could calculate, what speed the controller has time to accelerate to, by using the formula for theoretical S.
(See the description of TMC428 about variable p, or the other thread:
http://www.trinamic.com/ttdg/viewtopic.php?t=263)
But as I noted there, the formula is not correct. Still you could try to use it for approximation.

If you have variable distances, then you cannot easily detect the actual finishing speed on the fly. Then I would recommend to implement my suggestion for speed mode. Speed would change around each waypoint with a certain precision, but at least with an invariable repeatability.

Note that in my suggestion for speed mode you can insert any code into the detection loop. For example insert the earlier mentioned UF1 function to report the arrival to the computer. TMCL-IDE will not be able to deal with that report. But a custom software, like my DLL, would.
Back to top
View user's profile Send private message Visit poster's website
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Mon Feb 26, 2007 5:57 pm    Post subject: Reply with quote

Olav Kahlbaum (TRINAMIC) wrote:
I see that you are setting the minimum speed (SAP 130) to the same value as the maximum speed (SAP 4). This causes something like a hard stop when the motor has reached the target position.
In your first move, your speed is low (speed1=10), but in your second move you are using a higher speed (speed2=260, so 26 times higher than speed1). I think that this causes the bump. Please try setting the minimum speed to a lower value in your second move.
Thanks Olav. I was just trying to emulate Andrew's suggestion. THat's the way he had it, with both equal. For what it's worth, the bump is "visible" It's not from the speed shift up. I experimented with the same sequence but the same speeds. In that test, the bump is still there. It's coming from a partial stop. You can see it try to stop before continuing.
Back to top
View user's profile Send private message
shorton
Power User
Power User


Joined: 10 Oct 2006
Posts: 74

PostPosted: Mon Feb 26, 2007 6:23 pm    Post subject: Re: The finishing speed does not reach the top speed Reply with quote

Andrew:
Andrew wrote:
There's no sense in setting a speed mode just before the position mode MVP. You need to move that command anywhere closer to the preceeding WAIT. It would eliminate the initial dip of speed, after setting the current speed abruptly.

Thanks. That is where I origianlly had the statement. I meant to elaborate that point in the code comments. In the code above I had just moved it closer to the command that I presumed causes the premature stop, as a test. It bumps regardless of the location of that code line.

TO be sure we are talking about the same thing: Cut/pasted from above I have:

Code:
// moved sap 3 to here to see if it would help, didn't make any difference
SAP 3,      0, speed2       // restore actual speed
SAP 4,      0, speed3       // v_max  for next move
SAP 130,    0, minspeed     // v_min  for next move
SAP 138,    0, 2            // set velocity mode
MVP 0,      0, end
WAIT POS,   0, 0            // WAIT for arrival


What I aslo tried, from your original suggestion was:

Code:
SAP 4,      0, speed3       // v_max  for next move
SAP 130,    0, minspeed     // v_min  for next move
SAP 138,    0, 2            // set velocity mode
SAP 3,      0, speed2       // restore actual speed
MVP 0,      0, end
WAIT POS,   0, 0            // WAIT for arrival


And I tried:

Code:
SAP 4,      0, speed3       // v_max  for next move
SAP 130,    0, speed3     // v_min  for next move
SAP 138,    0, 2            // set velocity mode
SAP 3,      0, speed2       // restore actual speed
MVP 0,      0, end
WAIT POS,   0, 0            // WAIT for arrival




Quote:
I suspect the bump occurs not just after the second move. But after each move. Beause all moves are too short, all of them never reach v_max=260 and v_min=260, or even speed 10. Just you do not notice the bump after the first move.
You correctly set the first v_max and v_min to a lower value of 10. But even this speed might not be achieved on a short move of 50 steps. So it still might cause a bump. Just you do not notice, because the speed is slow.

Yes, I agree it might not reach the velocity on the very short initial move. But on my long moves it is definately reaching it's v_max. It gets to it very quickly if not instantly. And remains there through the move distance. As I mentioned to Olav above, I did experimente with the code sequence and no speed change between the 2 waypoints. Say speed 150 throughout for example. The bump still occurs. The bump is clearly coming from the motor trying to stop, then continuing. Easy to feel it do it.

Quote:
Just as I noted to you in our previous discussions, including in other threads. The distance you are trying to move does not allow you to accelerate to the v_max. So you are wrong to assume that the finishing speed was v_max or v_min. There's no point in restoring that speed.
I disagree. The short start move I listed above aside, for the long. main move I'm making, I am indeed reaching the v_max specified. There is no continuos acceleration, I have a constant, flat velocity.

Quote:
You need to learn what actual speed to restore.
If the speed is constant, then by your code, I need to restore the speed to what it was before the MVP put it back in to position mode and tried to stop it at the end of the wait for position. Unless I misunderstood, but I didnt' think I did.

Quote:
If all distances are fixed, I suggest you simply detect the speed at which the finish occurs, and try to restore that fixed speed.
Again, first move aside, it's the one in the "middle" of the long move that casues the bump.

Quote:
If you have variable distances, then you cannot easily detect the actual finishing speed on the fly. Then I would recommend to implement my suggestion for speed mode. Speed would change around each waypoint with a certain precision, but at least with an invariable repeatability.
My distances are fixed. Always the same.

Quote:
Note that in my suggestion for speed mode you can insert any code into the detection loop. For example insert the earlier mentioned UF1 function to report the arrival to the computer. TMCL-IDE will not be able to deal with that report. But a custom software, like my DLL, would.
There is no computer in my application. Have to do whatever I do in standalone mode.




.
Back to top
View user's profile Send private message
Andrew
Master
Master


Joined: 06 Nov 2006
Posts: 258
Location: Europe

PostPosted: Thu Mar 01, 2007 9:39 pm    Post subject: Speed is too fast to detect position. Try the speed mode Reply with quote

Shorton wrote:
That is where I origianlly had the statement.

I suggest you keep the command for velocity mode - SAP 138 - before restoring the speed, or at least immediately after.

The latests samples, which you provided make no sense. Hence no result.
Shorton wrote:
But on my long moves it is definately reaching it's v_max.

Then try long moves... Maybe 100000 steps, or more.

Before anything, I also would suggest that you try just 2 moves with acceleration completely off.
As in picture 1 in this article:
http://www.trinamic.com/ttdg/viewtopic.php?p=854#854

No changing speeds... No acceleration... Simply concatenate two moves.
And see if bumps occurs.
Just ensure that you stay above the lower bad speeds.
Shorton wrote:
I did experimente with the code sequence and no speed change between the 2 waypoints. Say speed 150 throughout for example. The bump still occurs.

Good. But have you tried with acceleration/deceleration off?
Shorton wrote:
It gets to it very quickly if not instantly.

Not very much so. Calculations show that speed 260 in your conditions should be achieved in about 600-9000 steps (formulas have flaws).
Shorton wrote:
I disagree. [...] for the long. main move [...] I am indeed reaching the v_max specified. There is no continuos acceleration, I have a constant, flat velocity.

To disagree you need to have something to judge by.
You did not even check what speed is achieved.
But I agree. It seems that on 12000 steps speed 260 should indeed be achieved.

At pulse_div=2, the speed number 260 produces a step rate of 15869.14s/s. The period of a step is 0.063ms. The period of one TMCL command is about 0.38ms. It is equivalent to 2631.59s/s.
Aren't you simply trying to move too fast?

I guess the speed 2631.59s/s is still above bad speeds. I also guess that the motor easily transits from 2631.59s/s to 15869.14s/s. So the bump does not produce missing steps. Does it?

If that's what's causing the bump, then at this speed you cannot insert any commands between moves.
You need to use speed mode, as I suggested in my last meaningful article above.
Note that I have added a comment there: The command WAIT POS still works in velocity mode. It detects positions at speeds up to about 977steps/second. That is a period of about 1ms.

Please note that when you change a_max, you need to check if p is still correct. For example in you case you set a_max twice: first to 170, then to 500. But you do not adjust p.
For a_max=500 p should be 0.061. This can be achieved with:
#146 "deceleration multiplier" (pmul)=122
#137 "deceleration divisor" (pdiv)=9


This decelerates to speed 1 precisely. To decelerate to greater speeds (like custom v_min) you need to decrease S, that is - increase p respectively.
You find the discussion on p in the another theme:
http://www.trinamic.com/ttdg/viewtopic.php?t=263&highlight=pmul+pdiv+p#787
If you are looking just for the formula, and not for the whole discussion, you quickly find the method how to set p, if you look for the word "Theoretical".
Use the function Find in your browser.


In your case p does not influence deceleration between moves, because speed v_max is achieved, and v_max=v_min. That's of course if v_max is achieved indeed.
_________________
Distributor of Trinamic
Our TMCM-DLL is here (not free): http://www.trinamic.com/ttdg/viewtopic.php?t=30 | Power supplies: http://www.trinamic.com/ttdg/viewtopic.php?t=394
On request: System integration services, custom programming, mechanics,etc


Last edited by Andrew on Sat Nov 03, 2007 4:20 pm; edited 7 times in total
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Trinamic Discussion Groups Forum Index -> Trinamic Motion Control Language (TMCL) All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group