In this paper, two optimization methods are used to adjust the gain values for the cascade PID controller. These algorithms are the butterfly optimization algorithm (BOA), which is a modern method based on tracking the movement of butterflies to the scent of a fragrance to reach the best position and the second method is particle swarm optimization (PSO). The PID controllers in this system are used to control the position, velocity, and current of a permanent magnet DC motor (PMDC) with an accurate tracking trajectory to reach the desired position. The simulation results using the MATLAB environment showed that the butterfly optimization algorithm is better than the particle swarming optimization (PSO) in terms of performance and overshoot or any deviation in tracking the path to reach the desired position. While an overshoot of 2.557% was observed when using the PSO algorithm, and a position deviation of 7.82 degrees was observed from the reference position.