2
$\begingroup$

I want a very basic simulation of a linear axis that can be given a position demand, and it will move to that position at a constant speed. At this point, I do not care about acceleration, but if I can modify the TF to incorporate it that will be a bonus.

  • I will program this simulation using scipy
  • This is a discrete-time system
  • The position the axis moves to is exactly the demand (no steady-state error, gain 1)
  • The speed is constant. Ideally, I would like this to be configurable. But for the sake of this example, lets say it is 0.2m/s.
  • There is no overshoot
  • It is the same for both positive and negative steps, i.e increasing or decreasing the position demand
  • I do not care about the delay between the demand change and when it starts to respond. Ideally, it would be 0 or 1 time steps, but this is a really simple simulation so I do not care that much.
  • If it is given an impulse input then it will either move slightly or not at all, but I am not that interested in simulating this
  • If it is given a ramp input, then it will behave similarly to the step input if the slope of the ramp is steeper than the velocity of the axis, and will still move at the constant velocity even if the demand ramp is less steep (hence it will stop and start to track the demand). But again, I do not really care about simulating this, and would rather have a simplified solution.
  • A very rough approximation is fine, I do not need to identify the system to a realistic level.

So basically, the transfer function that represents the system is one that turns a step input into a ramp that goes between the start and end values of the step. If we also include acceleration, then it will turn a step input into a sigmoid looking signal.

What is this transfer function?

I could also represent this as ZerosPolesGain, or StateSpace within scipy, so either of those will also suffice as an answer.

Thanks

$\endgroup$
2
  • $\begingroup$ It's hard to understand what you exactly want to do, but to turn a step function into a ramp, you simply need an integrator: $y[n]] = x[n]+y[n-1]$, which would make sense since position is the integral of the velocity. $\endgroup$
    – Hilmar
    Dec 17 '20 at 13:57
  • $\begingroup$ @himar The problem is that an integrator would increase beyond the max value of the step. So I guess I need a saturated integrator? If that's a thing. After doing some reading I have come to the conclusion that a transfer function may not be the best way to do this, and instead, I have programmed up a slew rate limiter which does the job for me. $\endgroup$
    – Blue7
    Dec 18 '20 at 10:48
0
$\begingroup$

A simple moving average with a rectangular window will turn a step into a ramp, but no linear filter can give you a constant slope, because linearity implies that scaling the input (step) will scale the output (slope). Instead, what you want is a non-linear slew-rate limiter that steps towards the target at constant rate (eg. take the minimum of the "distance to target" and your allowable rate, then accumulate).

If you never want to move "too slowly" then you likely need a state-machine. If you are in steady-state and the target has moved "far enough" from your current value, then transition to moving state immediately. When you reach the target, transition back to steady-state. If you are in steady-state but the target only moved slightly, then transition into a timer-state where you still check if the target is far enough to start moving immediately, but also start moving when the timer expires. The downside is that small steps (or shallow ramps) will cause you to wait for the timer, but this is unavoidable unless you want to constantly (in the worst case every time-step) switch between moving and not moving (at which point you are basically doing PWM).

If you want to smooth the acceleration, then this can be done by taking the output of the slew-rate limiter and filtering it further. One (or two if you also want to avoid jerk) passes of moving average with short rectangular window often works well for this and will give you symmetric acceleration vs. deceleration and will still reach the target in finite time. Exponential moving averages (aka. one-pole low-pass filters) can also be used, but in that case you will only reach your target asymptotically.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.