Common Software-Only Method

One of the biggest challenges associated with CNC machines is ensuring smooth movement in two or more axes at a time. Consider an example where the machine has received a command to move from the start position 0,0 to end position 10,15 at a speed of 10 cm/s.

First, use the Pythagorean Theorem to calculate the total distance the actuator will travel, as shown in Equation 3-1.

Figure 1. Total Travel Distance TotalDistance=X2+Y2=102+152=18.03cm

Next, calculate the percent of total distance (and correspondingly, the percent of the total speed) of each axis, as shown in Equation 3-2.

Figure 2. Travel Percentages XPERCENT=XTotalDistance=1018.03=55.48%

YPERCENT=YTotalDistance=1518.03=83.21%

After calculating the percentage of the total distance for each axis, multiply by the desired overall speed to get the speed of each axis, as shown in Equation 3-3.

Figure 3. Travel Speeds XSPEED=DesiredSpeed×XPercent=10×55.48%=5.55cm/s YSPEED=DesiredSpeed×YPercent=10×83.21%=8.32cm/s

The controller must then calculate how often to advance each stepper motor to achieve the two desired speeds and then use a timer to advance the axis that often. This is more challenging if, rather than moving at a constant speed, the machine must ramp up to the desired speed or slow down to stop. Therefore, the speed in the two axes must constantly recalculate as acceleration is ongoing, placing further load on the controller.

To optimize this process, CIPs can be used to limit the number of calculations and the remaining calculations can be batch-processed in advance by a computer. An inexpensive 8-bit microcontroller can handle the remaining real-time demands of operating the CNC machine, as will be discussed in the following sections.