Maths headache

I need to solve this problem but I’m really not much good at algebra.

I want to move a motor a set distance d.
It needs to ramp up to speed in a set amount of time tr
then cruise along for a set amount of time tc
then ramp down again (for now I am leaving both ramp up/down times the same).

I need to figure out the top speed it should reach, and the distance moved during each of the different phases (so I can tell it to accelerate for x amount of distance travelled), and the amount of acceleration to apply so it goes the right distance.

I am pretty sure there is always only one unique solution for this but things don’t seem to cancel out as I’d hoped. My head hurts. Can anyone help me figure this out ?

these should be correct as starting equations:
tr = v/a (time spent accelerating from zero is equal to speed over acceleration)
v = dc/tc (speed is distance over time)

Ok took me a while but I think I cracked it

As I understand this your total distance travelled, d, and acceleration time, t_r, and cruise time, t_c, are specified, and you thus wish to solve for the “cruising speed”, v.

d = d_c + 2d_r

d_r = ½vt_r

d_c = vt_c

So,

d = v(t_r + t_c)

thus the required “cruising speed” is

v = d/(t_r + t_c)

The required constant acceleration/deceleration is then

a = v/t_r

I think this model might be a bit too simple to translate into an actual physical system, however.

I actually need to work out the speed and acceleration as they are unknown

I managed it this way, the motors seem to be behaving correctly so I think it works ok

physics equations for speed, distance and acceleration are:
d_r=1/2at_r^2
v=a
t_r
v=t_c*d_c

so starting with
d=2d_r+d_c

d=at_r^2 + vt_c

d=at_r^2 + at_r*t_c

d=a(t_r^2+t_r*t_c)

a=d/(t_r^2+t_r*t_c)

with t as total move time (t_r+t_c) we can simplify that to
a=d/(t_r*t)

so top speed is
v=a*t_r

I misread looks like you got the same thing actually but just sovled for speed first !
thanks for the help I will double check with that method but it seems to work out

edit: oops t=2t_r+t_c I’ll have to check the end bit again

a=d/(t_r*(t-t_r))

was close but not bang on, seems to work beautifully with this equation

1 Like

Well, yes, that is correct.

If you put

v = d/(t_r + t_c)

into

a = v/t_r,

you get

a = d/(t_r*(t_r + t_c)).

The total time

t = 2*t_r + t_c,

so

t_r + t_c = t - t_r.

You may therefore re-write the equation for the acceleration as

a = d/(t_r(t - t_r)).

2 Likes

Works great now. Thanks for the help I’m really useless at this stuff

Depending on what you are doing it might not be that simple, sorry

Its good enough for what I’m doing (getting several motors to move different distances across the same period of time).

I’ve got two motors to try it with and it works great

1 Like

If it is open loop it will be fine :slight_smile:

But closing the loop might get a bit more of a headache. Especially if you want it to move fast

PS @Barnaby_Coote
I have put in a lot of work into the space , the fact that you are building real stuff and bumping into real engineering problems makes it all make sense . :slight_smile:

2 Likes

yes open loop it is

Thanks Joe, I think everyone can appreciate the longs hours you’ve put in.
Hopefully loads more head bashing to come

1 Like

A potential problem I can see with this is that you will have a performance envelope of movement commands that your system will be able to satisfy, depending on the values of the variables and the maximum acceleration you can provide via your motors. Another problem is that there is no such thing as a constant acceleration in reality.

The library I’m using uses a close approximation that appears to be near enough and should have about the same amount of error for each motor. Its minute anyway. I can feed it acceleration and max speed values and it does the ramping which is why I needed those values. Both motors are starting and stopping at exactly the same time which is just what i want !

accelstepper library, or are you driving motor-motors, for want of a better term?