Quote:
Originally Posted by martinrand
I had originally thought of using the equations you suggested but a discrete method (such as the one I used in my code) would be more appropriate for the MCU I'll be using. It also seems to bet the preferred way of performing the calculations.
|
If you're going to stick with constant acceleration, the closed form solution suggested above is easier to use. If you just want samples on regular intervals but don't mind using closed form for calculations, I would suggest something like:
1) calculate time and distance to accelerate from stop to Max_Vel
2) calculate time and distance to accelerate from Max_Vel to stop (same, if max_accel is the same)
3) verify that the sum of these distances is less than Demand; adjust times and distances if too large.
4) Calculate time to begin deceleration
5) Start a loop over time
Within the loop, do a case or if/then/elseif structure based on whether time is within the acceleration phase, cruise phase, or deceleration phase.