1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Maximum velocity for the motor movement

  1. Feb 7, 2017 #1

    Joan M

    User Avatar
    Gold Member

    Hello all,

    First of all let me say this is my first post here and I don't know if I'm placing it into the right forum/place. If I'm doing something wrong or similar, please let me know and I'll try to solve it asap.

    This is not homework, but it is for sure introductory level so I've thought it was right to write it here.

    Again, if it is not the right place just let me know.

    1. The problem statement, all variables and given/known data

    I'm creating a small program to move a motor. That movement will have to be performed using the trapezoid profile in order to keep it soft at the beginning and at the end.

    In my case I'm trying to create a trajectory from point x0 to x1 given a maximum acceleration and a speed (which is entered by the user and therefore it can be much higher than what is allowed by the system).

    The available data is:
    • vmax = desired maximum speed (it can be impossible to reach).
    • v0 = initial speed.
    • vf = final speed (usually it will be 0).
    • a = acceleration (to accelerate and brake, we will use the same).
    • x0 = initial position.
    • xf = destination position.

    2. Relevant equations
    See in the attempt at a solution where I've pasted a piece of code and all the comments to make it easier to follow.

    3. The attempt at a solution
    Code (Visual Basic):

      ta = Abs((vmax - v0) / a)   ' Acceleration time
     da = (v0 * ta) + (0.5 * a * ta * ta)    ' Distance while accelerating
     tf = Abs((vmax - vf) / a)  ' Braking time.
     df = (vf * tf) + (0.5 * a * tf * tf)  ' Distance while braking.
     If (da + df > dist) Then  ' If the acceleration and braking distances are bigger than the complete travel we have problems...
       If (v0 = vf) Then  ' If initial and final speeds are the same...
         taux = (Sqr((a * dist) + (v0 * v0)) - v0) / a   ' then I can calculate the time it will take to reach the real maximum speed
         vmax = v0 + a * taux   ' and at the end I can calculate the maximum speed
       Else  ' but... if both speeds are not coincident...
         DistTotal = xf - x0 - da - df  ' Here I'm getting the total distance that is traveled.
         RelAccDec = da / (da + df)  ' The relationship between the acceleration and deceleration stages.
         dist_corr_acc = DistTotal * RelAccDec  ' The correction factor for the acceleration stage.
         da = da + dist_corr_acc  ' The real distance traveled during acceleration.
         dist_corr_dec = DistTotal * (1 - RelAccDec) ' the correction factor for braking.
         df = df + dist_corr_dec  ' the real distance traveled during braking.

          taux = (Sqr((a * dist) + (v0 * v0)) - v0) / a  ' This should give me the time the acceleration stage takes.
         vmax = v0 + (a * taux)  ' and this the maximum speed reached during the acceleration (which will be the maximum speed used to move the motor).
       End If
      End If
     
    The solution works with two big flaws:

    1. We can not find the real vmax (just something close to it as we are drecreasing always by 1).
    2. It will take ages to calculate the vmax if the user enters a very big value for vmax initially.
    taux is not getting the right value... can someone here tell me which formula is the right one to get the desired result?

    I've been looking at formulas for two days and now I'm obfuscated and I've decided to search for help.
    I've seen this forum and I've thought to write this here and see what happens.

    Usually in the forums I participate I try to help and so, but I'm afraid here I won't be able to help a lot, but I'll try to snoop around and see if I can give something to the community.

    Well, thank you for your time and for helping.

    Joan.
     
    Last edited: Feb 7, 2017
  2. jcsd
  3. Feb 7, 2017 #2

    gneill

    User Avatar

    Staff: Mentor

    Hi Joan M, Welcome to Physics Forums.

    Are we to assume that the user doesn't choose initial or final speeds that exceed vmax? In other words, you take care of input error checking elsewhere?

    You should be able to solve algebraically for the acceleration and deceleration timings so you don't have to "hunt" for them in code. I'd suggest first assuming that vmax won't be reached and solving for the acceleration and deceleration times (so no coasting between acceleration and deceleration phases) and then checking to see if the vmax would be exceeded. If not, you're done. Otherwise choose a coasting speed (could be vmax) and then fit your trapezoid.

    Only the basic kinematic equations are required.
     
  4. Feb 7, 2017 #3

    Joan M

    User Avatar
    Gold Member

    Hi qneill,

    the user won't be able to introduce the initial or final speeds that exceed vmax as (in this case ) the final speed will always be 0 and the initial speed can be 0 or the speed the last movement was using at the moment the new one has been introduced so the maximum value will be vmax.

    I've updated my original post.

    Of course I agree what you say, it's much better using a straight formula to get the desired result than hunting it in the code... The problem with that is that I don't remember/know the right one.

    As you will see now in the code there is a good approach to the problem.

    The issue is that even I get the right distances (acceleration and braking) I can't get the right amount of time to accelerate and therefore the vmax.

    Could you take a look at it and tell me which formula is the one that would solve that?

    Thank you very much.
     
  5. Feb 7, 2017 #4

    gneill

    User Avatar

    Staff: Mentor

    That's something you could work on here if you were so inclined. Only basic kinematic equations are required (manipulated appropriately with a bit of algebra, of course).

    First, I notice at the start of your code:

    df = (vf * tf) + (0.5 * a * tf * tf) ' Distance while braking.

    you have the acceleration as a for braking. It should be -a, since it's decelerating (acceleration is negative while braking). Further, you have the velocity going into the braking maneuver as vf. That's the final speed, not the speed going into the braking maneuver. It should be vmax, since that's the speed you've assumed for calculating your times.

    I also notice that you take specific cases like vf = vo, which is not an ideal approach. You still need to handle the cases where vf ≠ vo, which is the general case and would include vf = vo.

    Your code doesn't say what happens for the case (da + df ≤ dist), you've closed off the IF statement that would detect this without proving the ELSE clause to handle it.

    It's not clear to me how you arrived at some of the equations that you're using. For example, how did you arrive at:

    taux = (Sqr((a * dist) + (v0 * v0)) - v0) / a

    for "the time it will take to reach the real maximum speed" ? Can you show us how you derived this? It seems to me that the units don't match in the terms.
     
  6. Feb 7, 2017 #5

    Joan M

    User Avatar
    Gold Member

    Hi again gneill (sorry for writing your name wrong before).

    I'm interested in the absolute value for the braking distance therefore is easier to have the acceleration positive, anyway I could put the acceleration negative (as it should be) and call abs to get the absolute value.
    I've calculated the time it will take to go from max to vf just before, and this gives me the time. so then I can calculate correctly the df.
    In the Excel file I'm using to test it, both da and df work well.

    Of course you are right, I have to handle the other cases, but as my solution to the other cases is that bad, this save computer cycles in that specific case (which is not a good approach at all but is still better than nothing).

    Have to disagree here... If there is no need to calculate the special case where the vmax can't be reached then the first four lines solve perfectly the issue without needing to continue processing the code inside the first IF clause.

    Neither to me... I've found this searching the Internet... tried it and it worked perfectly when the v0 is equal than vf, but it stops working when v0 is different than vf.

    It's not a matter of wanting to do it but knowing how to do it...

    Now it seems that if I could calculate correctly the time it will take to move from x0 to da starting at v0 then I could calculate easily the vmax using the last formula in my code: vmax = v0 + (a * taux)

    Can you spot the problem on this formula? taux = (Sqr((a * dist) + (v0 * v0)) - v0) / a

    Thank you very much for your patience.

    Joan.
     
  7. Feb 7, 2017 #6

    gneill

    User Avatar

    Staff: Mentor

    What about the case where vmax is reached and yet da + df < dist?

    To me it looks like it's missing a factor of two (the whole thing should be multiplied by two). The formula will only work when the initial and final speeds are the same (v0). You'll need to find a different formula for when the speeds are different. I'm not sure how your DistTotal, RelAccDec, Dist_corr_acc, and so on are functioning.
     
  8. Feb 7, 2017 #7

    Joan M

    User Avatar
    Gold Member

    Then the first four lines in the code are enough to get the right values. ta, da, tf and df will have the right values and we will get a trapezoid and not a triangle in the movement: we will reach the vmax and go a certain amount of time at vmax. I can promise you this works. :wink:

    In fact the original formula was
    Code (Text):
    taux = (Sqr((2 * a * da) + (v0 * v0)) - v0) / a
    but da was almost half of dist so I used dist at the beginning, now the code has the original formula.
    This is giving a close result for vmax, but still far away, at least it is always bigger than what I expect, but of course it's awful having to loop to search for something that should be calculated... :sorry:

    Thank you for your comments.
     
  9. Feb 9, 2017 #8

    Joan M

    User Avatar
    Gold Member

    I think I've understood why it is not working...

    See:
    Code (Visual Basic):

    ta = Abs((vmax - v0) / a)   ' Acceleration time
    da = (v0 * ta) + (0.5 * a * ta * ta)    ' Distance while accelerating
    tf = Abs((vmax - vf) / a)  ' Braking time.
    df = (vf * tf) + (0.5 * a * tf * tf)  ' Distance while braking.
    If (da + df > dist) Then  ' If the acceleration and braking distances are bigger than the complete travel we have problems...
     If (v0 = vf) Then  ' If initial and final speeds are the same...
       taux = (Sqr((a * dist) + (v0 * v0)) - v0) / a   ' then I can calculate the time it will take to reach the real maximum speed
       vmax = v0 + a * taux   ' and at the end I can calculate the maximum speed
     Else  ' but... if both speeds are not coincident...
       '******************************************************************
       '**** WRONG APPROACH STARTS HERE
       '******************************************************************
       DistTotal = xf - x0 - da - df  ' Here I'm getting the total distance that is traveled.
       RelAccDec = da / (da + df)  ' The relationship between the acceleration and deceleration stages.
       dist_corr_acc = DistTotal * RelAccDec  ' The correction factor for the acceleration stage.
       da = da + dist_corr_acc  ' The real distance traveled during acceleration.
       dist_corr_dec = DistTotal * (1 - RelAccDec) ' the correction factor for braking.
       df = df + dist_corr_dec  ' the real distance traveled during braking.
       taux = (Sqr((a * dist) + (v0 * v0)) - v0) / a  ' This should give me the time the acceleration stage takes.
       vmax = v0 + (a * taux)  ' and this the maximum speed reached during the acceleration (which will be the maximum speed used to move the motor).
       '******************************************************************
       '**** WRONG APPROACH ENDS HERE
       '******************************************************************
     End If
    End If
     
    When the da + df are bigger than the total distance and v0 and vf are not coincident I'm doing a proportional reduction which approximates the vmax to it's desired/needed value, but I can't simply do that...

    The problem here I think is that part: I don't have to make a proportional reduction, I do need to find the position in which the acceleration movement and the deceleration movement are coincident once I will have this position then I should check the speed any of the movements has in that position. And that one should be vmax.

    Now the issue is doing that.

    I've found several examples out there on how to find that in a constant velocity movement, but I've not found any for constant acceleration movement.

    Any help with that? A resource to learn how to do it, a sample, a formula...

    Thank you very much!
     
  10. Feb 9, 2017 #9

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Maybe a graphical approach will help. On a velocity-time graph, you have a simple polygonal shape. You know the area total and some ordinates and slopes. What equations can you write?
     
  11. Feb 10, 2017 #10

    Joan M

    User Avatar
    Gold Member

    _acc (means the acceleration stage data)
    Code (Text):
    a_acc should be the inclination of the line.
    x0_acc could be considered 0
    xf_acc is unknown.
    v0_acc should be the intersection of the accelerating line with the vertical axis (given we consider x0 = 0).
    vf_acc is the vmax I'm searching.
    t0_acc could be considered 0.
    tf_acc is the time it will take to accelerate to reach the desired vmax (not the reachable one).
    _dec (means the deceleration stage data)
    Code (Text):
    a_dec is the inclination of the line and it's the same than -a_acc.
    x0_dec is unknown.
    xf_dec is the distance I want to move the motor.
    v0_dec is the vmax I'm searching.
    vf_dec is 0 as we will stop at the end. t0_dec is 0.
    tf_dec is the time it will take to go from the unreachable vmax to the vf.
    But I don't know how to proceed with all this...

    Thank you for your post haruspex.
     
  12. Feb 10, 2017 #11

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Let a be the magnitude of the acceleration and deceleration.
    If it starts at speed v0 and accelerates for time t0, what speed is reached and how far does it go?
    If it then decelerates for time t1 down to speed v1, what second expression does that give you for the peak speed, and what total distance is covered?
     
  13. Feb 10, 2017 #12

    Joan M

    User Avatar
    Gold Member

    I don't know t0 neither t1... and both times are different if we start from a v0 that is different than vf...

    I'm sorry, but I can't see what you are suggesting...

    Thank you for posting!
     
  14. Feb 10, 2017 #13

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    I know that. That's the beauty of algebra, you can write down relationships between variables without knowing any values.
    The first two lines of code in your first post in the thread contain the two equations you need to answer my questions in post #11. The main difference is that there your vmax was a known quantity; now it will be the unknown speed reached.
     
  15. Feb 11, 2017 #14

    Joan M

    User Avatar
    Gold Member

    first of all, English is not my first language so, whatever can be understood in these next lines it's from respect.

    I know the equations, but simply I'm not understanding what you try to tell me...

    I've been struggling to get this for days, the practice I have with that is 0 after years of not doing it. So, even I don't pretend anyone here to solve the issue for me, a little example and a small guide on the right steps to do it would be great.

    Could you try to give a more detailed answer please?

    Thank you very much!
     
  16. Feb 11, 2017 #15

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    If it starts at speed v0 and accelerates at rate a for time t0 what speed is reached? I know you can answer this because it is represented in the first line of the code in post #1. Call this speed vp.

    If, having reached that speed, it decelerates (accelerates at -a) for time t1 it is to reach speed v1. We can run that backwards: if it is moving at speed v1 and accelerates at a for time t1 it will reach speed vp. So we have exactly the same equation as before, but now with t1 and v1 instead of t0 and v0.

    Post those two equations and I'll help with the next step.
     
  17. Feb 11, 2017 #16

    Joan M

    User Avatar
    Gold Member

    Ok,
    If I understood you well we do have this:

    Code (C):
    vp = v0 + (a * t0)  // Velocity at the intersection point (vp) equals the initial speed (v0) + the acceleration (now it is positive) multiplied by the run time (t0).
    vp = v1 - (a * t1)  // and Velocity at the intersection point (vp) equals the initial speed (v1) + the acceleration (now it is negative) multiplied by the run time (t1).
    Is that right?

    PS: Thank you again.
     
  18. Feb 11, 2017 #17

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Not quite. There should be no sign change.
    Now write expressions for the distances moved during the two phases.
     
  19. Feb 11, 2017 #18

    Joan M

    User Avatar
    Gold Member

    OK, so:

    Code (C):

    vp = v0 + (a * t0)  // Velocity at the intersection point (vp) equals the initial speed (v0) + the acceleration (now it is positive) multiplied by the run time (t0).
    vp = v1 + (a * t1)  // and Velocity at the intersection point (vp) equals the initial speed (v1) + the acceleration (now it is negative) multiplied by the run time (t1).

    d0 = x00 + (v00 * t0) + (0.5 * a0 * t0 * t0)    // Distance while accelerating = the initial space + the initial velocity at the current time + half of the acceleration * current time ^2
    d1 = x01 + (v01 * t1) + (0.5 * a1 * t1 * t1)    // Distance while braking = the initial space + the initial velocity at the current time + half of the acceleration * current time ^2
     
    Corrected the sign at the second equation and added both equations for the space/distance run.

    Everything OK?

    Thanks again.
     
  20. Feb 11, 2017 #19

    gneill

    User Avatar

    Staff: Mentor

    This is an excellent idea, and I can offer a suggestion to simplify writing equations from the geometry. If we choose units for velocity and distance such that the acceleration is unity, then all slopes in the velocity versus time plots will be 1 or -1, corresponding to 45 degree angles so that every triangle that appears will be a 45° equilateral triangle. That means the size of any velocity change is equal in magnitude to the time change it occurred over in this unit system.

    To convert the "real world" given values to these working units divide the velocities and distance values by the magnitude of the real world acceleration. For example, if the actual acceleration is 5 m/s2 then the given values:

    ##v_o = 10~m/s~~;~~v_f = 25~m/s~~;~~x_o = 30~m~~;~~x_f = 500~m##

    become our "unitless" working quantities:

    ##v_o = 2~~;~~v_f = 5~~;~~x_o = 6~~;~~x_f = 100##

    To convert values back to the real-world values, simply multiply by the same value (5 in this example). Since the time units are not scaled, times calculated in the converted unit system will reflect "real world" times, which is handy because you're looking for acceleration control times.

    Here's a sample of a plot that depicts a final velocity greater than the initial velocity and where the motor speed had to go negative (moving backwards) in order to achieve the desired total distance (perhaps the required distance of travel was too close to the start location in order to match both distance and velocity with a simple positive acceleration followed by a deceleration). Remember that that velocity and time measurements are interchangeable thanks to the acceleration being unity and all slopes being 1:

    upload_2017-2-11_9-21-0.png

    Areas under the curve (between the curve and the horizontal time axis) represent distance (Δx), and areas below the 0 velocity axis represent negative distances. The total change in position achieved is the sum of the all the areas "under" the curve. In the diagram, the green areas represent positive velocities and increasing distance, while the blue areas are negative velocities and decreasing distance. Summing the areas is made easy by the equal leg lengths of 45° right triangles:

    ##Δx = \frac{v_o^2}{2} + \frac{v_f^2}{2} - t_1^2##

    which is easy to solve for ##t_1##. We can also easily pick out that the maximum speed is equal to ##t_1##, and is a negative speed in this instance.

    If there's a speed limit to be enforced then finding the times where the curve hits the limit is simple, again thanks to the 45° triangles. The amount of coasting time to insert can be determined from the area of the triangle "clipped" by the maximum speed limit.
     
  21. Feb 11, 2017 #20

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    In your distance equations you are conflating two different forms. You can have either the displacement form:
    Δx=v0Δt+½aΔt2
    Or the position form:
    x=x0+v0Δt+½aΔt2
    Your d0, d1 are displacements, so you don't need the x00 and x01.

    You can eliminate vp between the first two equations to get an equation for t1 in terms of t0.
    You are given a total distance, d0+d1, so adding the two distance equations gives you another equation relating the two times.
    Two equations, two unknowns; solve.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Maximum velocity for the motor movement
  1. Velocity Maximum (Replies: 19)

  2. Maximum Velocity (Replies: 36)

Loading...