That rare case has come when the need for mathematics and even physics appeared in the work of a microcontroller programmer. I had an interesting task at work on the topic of developing a heavy (70kg) PTZ camera. There was a problem in physics from the kinematics section. True, in terms of difficulty, it can be attributed to the school curriculum of the 6th grade.
Stepper motors are used in CNC machines, 2D / 3D printers, scanners, plotters, PTZ cameras, radar antennas, turrets, linear actuators, pointer devices (analogue clocks) and maybe somewhere else.
Stepper motors have one problem. Due to high load inertia, stepper motors can lose steps and fail to complete commands. To minimize this, the stepper motor shaft must be untwisted smoothly. The easiest way is to use trapezoidal motion profiles.
Formulation of the problem
The angle by which the stepper motor shaft must be rotated
Maximum possible angular frequency
Maximum angular acceleration
Given the angle, PhiSet, by which the stepper motor shaft should be rotated. The engine operates in three modes: acceleration ACCELwork at constant cruising speed RUNdeceleration DECEL. This results in a trapezoidal velocity profile.
Or acceleration ACCEL and slowdown DECEL. This results in a triangular speed profile (in case the OmegaMax cruising speed is very high and the angular path set to be traveled is very small).
Only acceleration is given as motion parameters. BettaMax [rad/s^2] and cruising speed OmegaMax [rad/s] in mode RUN. At zero time t0, the shaft starts moving and starts to pick up the angular velocity Omega with constant acceleration BettaMax. Calculate the time t1 at which the acceleration ACCEL should stop and the rotation should start at a constant speed OmegaMax (RUN phase), and calculate the time t2 at which the movement should stop at a constant speed OmegaMax RUN and start decelerating DECEL.
The times t1 and t2 can coincideif BettaMax very high and OmegaMax few. For symmetry and simplicity, we assume that the acceleration during acceleration and acceleration during deceleration are modulo BettaMaxbut opposite in sign.
The profile is a plot of angular velocity versus time Omega
function [ t1 t2 tf wlim] = calcTimesF( phi_set, w_max, B_max )
if(phi_set < S1)
%without RUN t1= t2
wlim = B_max*t1;
%with RUN t1 < t2
wlim = w_max;
In reality, this problem must be solved for discrete movement, since in reality we are dealing with a stepper motor. There, the solution becomes much more complicated. In changing the stage of movement (ACCEL, RUN, DECEL) you have to navigate not by time, as in a continuous setting, but by the distance traveled (the number of steps taken by the stepper motor). There is a publication about this Asynchronous Control System for Stepper Motor With an Incremental Encoder Feedback.
As you can see, ordinary school mathematics is quite enough to solve real evaluation problems from the sale of machine tools.
When calculating, always check the dimension in the formulas at each step.
If you are programming microcontrollers and you had to resort to mathematics, then write it in the comments.
computer numerical control