Stepper motors can indeed drive axes directly, and they are usually connected to mechanical axes that need to be precisely controlled, either through couplings or directly to the position or speed.
Each stepper motor can control one axis in principle, but it can also indirectly control multiple axes through specific mechanical designs (such as gears, pulleys, etc.), but this is usually not direct control, but through mechanical linkage.
Inside the printer, if the print needle needs to move horizontally and vertically, then at least two stepper motors are indeed required to control these two directions respectively.
Each stepper motor is responsible for the movement of one dimension, that is, one axis. The control program that drives these stepper motors sends corresponding pulse signals and direction signals to each motor according to the distance and direction of the required movement.
For milling machines, the three axes X, Y, and Z usually correspond to the three basic movement directions of the workpiece: the X axis controls horizontal left and right movement, the Y axis controls horizontal forward and backward movement, and the Z axis controls up and down movement.
The stepper motors on these axes are controlled by drivers, which work according to the instructions of the CNC (computer numerical control) program or motion controller. In the program, the three variables X, Y, and Z represent the position or movement of these three axes, not the coils of the stepper motor.
Therefore, when you see the three variables X, Y, and Z in the program, they represent the three control axes of the milling machine, not the coils of the stepper motor. The stepper motor on each axis moves according to the values of these variables, thereby achieving precise processing of the workpiece.