"Ramp up" phase for periodic function

122 Views Asked by At

I have a periodic function describing the angle of an impeller blade rotating around an axis (2 pi is a full rotation):

enter image description here

(R code:)

param.rps = 2     # rotations per second

getAngle <- function(t) { t %% param.rps / param.rps * pi * 2.0 }

x = seq(0, 10, 0.1)
y = getAngle(x)
plot(y ~ x, xlab="Time [seconds]", ylab="Angle", axes=F, ylim=c(0,2)*pi)
axis(side=1)
axis(side=2, at=pi*0:2,labels=c("0", "pi", "2*pi"),las=2)

Now I would like to add a "ramp up" phase where the impeller accelerates from 0 up to its final rps. I tried just adding a factor to the formula that linearly increases up to 1, and that does achieve the acceleration but has the unwanted side effect of making the impeller "jump" back halfway through its rotation:

param.rampup = 5  # how many seconds is the ramp up phase
getAngle <- function(t) { pmin(1.0, (t / param.rampup)) * t %% param.rps / param.rps * pi * 2.0 }

enter image description here

I assume the cycle points would have to be shifted to the right by the amount of the ramp up phase somehow but I've been playing around a bit and can't make it produce the behaviour I want. Does anybody have any hints?

1

There are 1 best solutions below

0
On BEST ANSWER

Here is a solution:

param.rps = 2     # rotations per second
param.rampup = 5  # how many seconds is the ramp up phase

getAngle <- function(t) {
  ifelse(t < param.rampup,
         ((1/(2*param.rampup*param.rps) * t^2)*2*pi) %% (2*pi),
         ((1/(2*param.rps) * param.rampup + (t-param.rampup) / param.rps)*2*pi) %% (2*pi)
         )
}
x = seq(0, 10, 0.05)
y = getAngle(x)
plot(y ~ x, xlab="Time [seconds]", ylab="Angle", axes=F, ylim=c(0,2)*pi)
axis(side=1)
axis(side=2, at=pi*0:2,labels=c("0", "pi", "2*pi"),las=2)

enter image description here