Go to Post Remind me again why anyone, my team included, is stupid enough to keep going to week 1 events? - Madison [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-03-2015, 11:44
martinrand martinrand is offline
Registered User
no team
 
Join Date: Mar 2015
Location: London
Posts: 11
martinrand is an unknown quantity at this point
Trapezoidal Motion Profile Using Discrete Method

Hi,

I'm trying to program an arduino to generate a Trapezoidal Motion Profile to control a DC motor with a quadrature encoder.

Essentially, the user will input the desired Target Position, Max Velocity and Acceleration (decel = -accel) and the code will calculate the target position versus time which will then be compared with the actual position. The result will then be subject to a PID calculation

My initial assumption was that I could use basic Newtonian physics to determine position (i.e. PT = P0 + V0T + 1/2AT2, VT = V0 + AT). However, after reading through documentation for pre-existing motion controllers, I discovered that the prevalent method was to use a discrete time method, which is as follows:

VK = VK-1 + A (A = Acceleration)
PK = PK-1 + VK-1 + A/2

I'm having a hard time understanding quite how this equation would generate the target position versus time. In the case of Velocity, it seems to just add the acceleration to the current velocity. But what about everything in between?

Could anybody take a shot at explaining to me how this method is used? I've spent ages searching for answers online but have had no such luck.

Thanks,

Martin
  #2   Spotlight this post!  
Unread 09-03-2015, 13:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Trapezoidal Motion Profile Using Discrete Method


While you're waiting for answers, take a look at this paper. It's pretty straightforward.

  #3   Spotlight this post!  
Unread 09-03-2015, 13:48
martinrand martinrand is offline
Registered User
no team
 
Join Date: Mar 2015
Location: London
Posts: 11
martinrand is an unknown quantity at this point
Re: Trapezoidal Motion Profile Using Discrete Method

Thanks for your reply!

I'm trying to stay away from S-Curve profiles for the time being. I think I should probably understand the trapezoidal method before I start jumping into some more complicated.
  #4   Spotlight this post!  
Unread 09-03-2015, 16:29
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Trapezoidal Motion Profile Using Discrete Method

Quote:
Originally Posted by martinrand View Post
I'm trying to stay away from S-Curve profiles for the time being.
If you use a trapezoidal velocity profile, you will get an S-curve for x(t).


Quote:
I think I should probably understand the trapezoidal method before I start jumping into some more complicated.
Sinusoidal is actually less complicated in many ways. No need to break the functions into regions.

FWIW, I just updated the paper to revA to include a plot of accel vs velocity so you can check to make sure the profile does not run afoul of motor saturation.



Last edited by Ether : 09-03-2015 at 18:30.
  #5   Spotlight this post!  
Unread 09-03-2015, 16:38
martinrand martinrand is offline
Registered User
no team
 
Join Date: Mar 2015
Location: London
Posts: 11
martinrand is an unknown quantity at this point
Re: Trapezoidal Motion Profile Using Discrete Method

Thanks, I'll certainly take another look.
Potentially, I could generate an sigmoid function to represent position, using parameters from a trapezoidal profile.

I suppose calculating position at a given time would then be as simple as plugging t into the equation. This would then do away with the need to have 3 section for accel, max velocity and decel.

Does that sound feasible?
This was how I originally assumed things were done.
  #6   Spotlight this post!  
Unread 09-03-2015, 17:00
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Trapezoidal Motion Profile Using Discrete Method



The a(t), v(t), and x(t) functions in the paper are stand-alone.

If you are not going to use velocity or acceleration in your control algorithm, you don't need to compute a(t) or v(t). Just use x(t).


  #7   Spotlight this post!  
Unread 09-03-2015, 17:16
martinrand martinrand is offline
Registered User
no team
 
Join Date: Mar 2015
Location: London
Posts: 11
martinrand is an unknown quantity at this point
Re: Trapezoidal Motion Profile Using Discrete Method

Any idea how I would take 3 variables for a trapezoidal profile (Accel, Max Velocity and Target Position, *decel=-accel*) and convert that into x(t)?
  #8   Spotlight this post!  
Unread 09-03-2015, 17:24
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Trapezoidal Motion Profile Using Discrete Method

Quote:
Originally Posted by martinrand View Post
Any idea how I would take 3 variables for a trapezoidal profile (Accel, Max Velocity and Target Position, *decel=-accel*) and convert that into x(t)?
http://www.chiefdelphi.com/media/papers/download/4284

http://www.chiefdelphi.com/media/papers/download/4287

http://www.chiefdelphi.com/media/papers/download/4288

Knock yourself out.


  #9   Spotlight this post!  
Unread 09-03-2015, 17:38
martinrand martinrand is offline
Registered User
no team
 
Join Date: Mar 2015
Location: London
Posts: 11
martinrand is an unknown quantity at this point
Re: Trapezoidal Motion Profile Using Discrete Method

Thanks for that!

Afraid I can't open the .exe as I'm using a mac. Any chance you have a mac version or source code available?
Thanks
  #10   Spotlight this post!  
Unread 09-03-2015, 17:58
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Trapezoidal Motion Profile Using Discrete Method

Quote:
Originally Posted by martinrand View Post
Afraid I can't open the .exe as I'm using a mac. Any chance you have a mac version or source code available?
You have the equations. Just put them into a spreadsheet or LabVIEW. Or install Maxima on your Mac and run the script I gave you.


  #11   Spotlight this post!  
Unread 10-03-2015, 14:43
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Trapezoidal Motion Profile Using Discrete Method

Quote:
Originally Posted by martinrand View Post
Potentially, I could generate an sigmoid function to represent position
Which particular sigmoid function did you have in mind?

Assuming you meant the Logistic Function:
x(t) = L/(1+exp(-k*(t-tm))),

where:

tm = the t-value of the sigmoid's midpoint

L = the curve's maximum value

k = the steepness of the curve
...that would be a poor choice.

To see why, suppose you want to go from x=0 and v=0 and a=0 at t=0 to x=5ft and v=0 and a=0 at t=3seconds.

Then L and tm would be L=5 tm=3/2.

The only free parameter left is k; try k=2, k=3, k=4, k=5.

As can be seen from the graphs, there is no acceptable value for k.

k=2: a, v, and x are non-zero at beginning and end points, and x has not reached 5 at t=3.

k=3: better, but a and v are still nonzero at endpoints

k=4: a is still not quite zero at endpoints. max accel has grown to 7.7

k=5: endpoints look good, but max accel is now 12, and max jerk is 77

Compare those graphs to the Figure on page 1 of this paper, which uses a sinusoidal function for x(t), resulting in
x=0, v=0, and a=0 at t=0, and

x=5, v=0, a=0 at t=3, and

max accel=3.5, max speed=3.3, max jerk=7.3

Attached Files
File Type: pdf sigmoid.pdf (811.4 KB, 130 views)

Last edited by Ether : 10-03-2015 at 17:25.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi